https://git.reactos.org/?p=reactos.git;a=commitdiff;h=73ca084e968eb160a0c9d…
commit 73ca084e968eb160a0c9ddd9c73facb591f1425a
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Thu Jun 20 22:02:18 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Thu Jun 20 22:08:38 2019 +0200
[NETCFGX] Read a components bind value and implement the IsBoundTo method.
---
dll/win32/netcfgx/inetcfgcomp_iface.c | 30 +++++++++++++++++++++++++++-
dll/win32/netcfgx/netcfg_iface.c | 37 +++++++++++++++++++++++++++++++++++
dll/win32/netcfgx/precomp.h | 1 +
3 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/dll/win32/netcfgx/inetcfgcomp_iface.c
b/dll/win32/netcfgx/inetcfgcomp_iface.c
index 3f72f980a1..9e26208ea6 100644
--- a/dll/win32/netcfgx/inetcfgcomp_iface.c
+++ b/dll/win32/netcfgx/inetcfgcomp_iface.c
@@ -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
diff --git a/dll/win32/netcfgx/netcfg_iface.c b/dll/win32/netcfgx/netcfg_iface.c
index c26f026fd0..fe4e69d11e 100644
--- a/dll/win32/netcfgx/netcfg_iface.c
+++ b/dll/win32/netcfgx/netcfg_iface.c
@@ -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
diff --git a/dll/win32/netcfgx/precomp.h b/dll/win32/netcfgx/precomp.h
index 4230377bd8..77ba0e9696 100644
--- a/dll/win32/netcfgx/precomp.h
+++ b/dll/win32/netcfgx/precomp.h
@@ -47,6 +47,7 @@ typedef struct tagNetCfgComponentItem
DWORD dwCharacteristics; //Y
ULONG Status; //Y
BOOL bChanged; //Y
+ LPWSTR pszBinding;
struct tagNetCfgComponentItem * pNext;
INetCfgComponentControl * pNCCC;
}NetCfgComponentItem;