[NETCFGX] Read a components bind value and implement the IsBoundTo method.
authorEric Kohl <eric.kohl@reactos.org>
Thu, 20 Jun 2019 20:02:18 +0000 (22:02 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 20 Jun 2019 20:08:38 +0000 (22:08 +0200)
dll/win32/netcfgx/inetcfgcomp_iface.c
dll/win32/netcfgx/netcfg_iface.c
dll/win32/netcfgx/precomp.h

index 3f72f98..9e26208 100644 (file)
@@ -92,7 +92,35 @@ INetCfgComponentBindings_fnIsBoundTo(
     INetCfgComponentBindings *iface,
     INetCfgComponent *pnccItem)
 {
-    return E_NOTIMPL;
+    INetCfgComponentImpl *pComponent;
+    PWSTR pszBindName, ptr;
+    INT len;
+
+    pComponent = impl_from_INetCfgComponentBindings(iface);
+    if (pComponent == NULL ||
+        pComponent->pItem == NULL ||
+        pComponent->pItem->pszBinding == NULL)
+        return E_POINTER;
+
+    if (pnccItem == NULL ||
+        ((INetCfgComponentImpl*)pnccItem)->pItem == NULL ||
+        ((INetCfgComponentImpl*)pnccItem)->pItem->szBindName == NULL)
+        return E_POINTER;
+
+    pszBindName = ((INetCfgComponentImpl*)pnccItem)->pItem->szBindName;
+
+    ptr = pComponent->pItem->pszBinding;
+    while (*ptr != UNICODE_NULL)
+    {
+        len = wcslen(ptr);
+
+        if (len > 8 && _wcsicmp(&ptr[8], pszBindName) == 0)
+            return S_OK;
+
+        ptr = ptr + len + 1;
+    }
+
+    return S_FALSE;
 }
 
 HRESULT
index c26f026..fe4e69d 100644 (file)
@@ -226,6 +226,41 @@ static const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback =
  * INetCfg
  */
 
+HRESULT
+ReadBindingString(
+    NetCfgComponentItem *Item)
+{
+    WCHAR szBuffer[200];
+    HKEY hKey;
+    DWORD dwType, dwSize;
+
+    if (Item == NULL || Item->szBindName == NULL)
+        return S_OK;
+
+    wcscpy(szBuffer, L"SYSTEM\\CurrentControlSet\\Services\\");
+    wcscat(szBuffer, Item->szBindName);
+    wcscat(szBuffer, L"\\Linkage");
+
+    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+    {
+        dwSize = 0;
+        RegQueryValueExW(hKey, L"Bind", NULL, &dwType, NULL, &dwSize);
+
+        if (dwSize != 0)
+        {
+            Item->pszBinding = CoTaskMemAlloc(dwSize);
+            if (Item->pszBinding == NULL)
+                return E_OUTOFMEMORY;
+
+            RegQueryValueExW(hKey, L"Bind", NULL, &dwType, (LPBYTE)Item->pszBinding, &dwSize);
+        }
+
+        RegCloseKey(hKey);
+    }
+
+    return S_OK;
+}
+
 HRESULT
 EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem ** pHead)
 {
@@ -324,6 +359,8 @@ EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem **
                 }
                 RegCloseKey(hSubKey);
 
+                ReadBindingString(pCurrent);
+
                 if (!pLast)
                     *pHead = pCurrent;
                 else
index 4230377..77ba0e9 100644 (file)
@@ -47,6 +47,7 @@ typedef struct tagNetCfgComponentItem
     DWORD dwCharacteristics;    //Y
     ULONG Status;               //Y
     BOOL bChanged;              //Y
+    LPWSTR pszBinding;
     struct tagNetCfgComponentItem * pNext;
     INetCfgComponentControl * pNCCC;
 }NetCfgComponentItem;