ReactOS  0.4.14-dev-845-g8381e29
netcfg_iface.c File Reference
#include "precomp.h"
Include dependency graph for netcfg_iface.c:

Go to the source code of this file.

Classes

struct  INetCfgImpl
 

Typedefs

typedef struct INetCfgImplLPINetCfgImpl
 

Functions

static __inline LPINetCfgImpl impl_from_INetCfgLock (INetCfgLock *iface)
 
static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback (INetCfgPnpReconfigCallback *iface)
 
HRESULT WINAPI INetCfgLock_fnQueryInterface (INetCfgLock *iface, REFIID iid, LPVOID *ppvObj)
 
ULONG WINAPI INetCfgLock_fnAddRef (INetCfgLock *iface)
 
ULONG WINAPI INetCfgLock_fnRelease (INetCfgLock *iface)
 
HRESULT WINAPI INetCfgLock_fnAcquireWriteLock (INetCfgLock *iface, DWORD cmsTimeout, LPCWSTR pszwClientDescription, LPWSTR *ppszwClientDescription)
 
HRESULT WINAPI INetCfgLock_fnReleaseWriteLock (INetCfgLock *iface)
 
HRESULT WINAPI INetCfgLock_fnIsWriteLocked (INetCfgLock *iface, LPWSTR *ppszwClientDescription)
 
HRESULT WINAPI INetCfgPnpReconfigCallback_fnQueryInterface (INetCfgPnpReconfigCallback *iface, REFIID iid, LPVOID *ppvObj)
 
ULONG WINAPI INetCfgPnpReconfigCallback_fnAddRef (INetCfgPnpReconfigCallback *iface)
 
ULONG WINAPI INetCfgPnpReconfigCallback_fnRelease (INetCfgPnpReconfigCallback *iface)
 
HRESULT WINAPI INetCfgPnpReconfigCallback_fnSendPnpReconfig (INetCfgPnpReconfigCallback *iface, NCPNP_RECONFIG_LAYER Layer, LPCWSTR pszwUpper, LPCWSTR pszwLower, PVOID pvData, DWORD dwSizeOfData)
 
HRESULT ReadBindingString (NetCfgComponentItem *Item)
 
HRESULT EnumClientServiceProtocol (HKEY hKey, const GUID *pGuid, NetCfgComponentItem **pHead)
 
HRESULT EnumerateNetworkComponent (const GUID *pGuid, NetCfgComponentItem **pHead)
 
HRESULT EnumerateNetworkAdapter (NetCfgComponentItem **pHead)
 
HRESULT FindNetworkComponent (NetCfgComponentItem *pHead, LPCWSTR pszwComponentId, INetCfgComponent **pComponent, INetCfg *iface)
 
HRESULT WINAPI INetCfg_fnQueryInterface (INetCfg *iface, REFIID iid, LPVOID *ppvObj)
 
ULONG WINAPI INetCfg_fnAddRef (INetCfg *iface)
 
ULONG WINAPI INetCfg_fnRelease (INetCfg *iface)
 
HRESULT WINAPI INetCfg_fnInitialize (INetCfg *iface, PVOID pReserved)
 
VOID ApplyOrCancelChanges (NetCfgComponentItem *pHead, const CLSID *lpClassGUID, BOOL bApply)
 
VOID FreeComponentItem (NetCfgComponentItem *pItem)
 
HRESULT WINAPI INetCfg_fnUninitialize (INetCfg *iface)
 
HRESULT WINAPI INetCfg_fnApply (INetCfg *iface)
 
HRESULT WINAPI INetCfg_fnCancel (INetCfg *iface)
 
HRESULT WINAPI INetCfg_fnEnumComponents (INetCfg *iface, const GUID *pguidClass, IEnumNetCfgComponent **ppenumComponent)
 
HRESULT WINAPI INetCfg_fnFindComponent (INetCfg *iface, LPCWSTR pszwComponentId, INetCfgComponent **pComponent)
 
HRESULT WINAPI INetCfg_fnQueryNetCfgClass (INetCfg *iface, const GUID *pguidClass, REFIID riid, void **ppvObject)
 
HRESULT WINAPI INetCfg_Constructor (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
 

Variables

static const INetCfgLockVtbl vt_NetCfgLock
 
static const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback
 
static const INetCfgVtbl vt_NetCfg
 

Typedef Documentation

◆ LPINetCfgImpl

Function Documentation

◆ ApplyOrCancelChanges()

VOID ApplyOrCancelChanges ( NetCfgComponentItem pHead,
const CLSID lpClassGUID,
BOOL  bApply 
)

Definition at line 642 of file netcfg_iface.c.

646 {
647  HKEY hKey;
648  WCHAR szName[200];
649  LPOLESTR pszGuid;
650 
651  while(pHead)
652  {
653  if (pHead->bChanged)
654  {
655  if (IsEqualGUID(lpClassGUID, &GUID_DEVCLASS_NET))
656  {
657  if (bApply)
658  {
659  if (StringFromCLSID(&pHead->InstanceId, &pszGuid) == NOERROR)
660  {
661  swprintf(szName, L"SYSTEM\\CurrentControlSet\\Control\\Network\\%s", pszGuid);
662  CoTaskMemFree(pszGuid);
663 
665  {
666  RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pHead->szDisplayName, (wcslen(pHead->szDisplayName)+1) * sizeof(WCHAR));
667  RegCloseKey(hKey);
668  }
669  }
670  }
671  }
672  else if (pHead->pNCCC)
673  {
674  if (bApply)
675  {
677  //FIXME
678  // implement INetCfgPnpReconfigCallback and pass it to
679  //INetCfgComponentControl_ApplyPnpChanges(pHead->pNCCC, NULL);
680  }
681  else
682  {
684  }
685  }
686  }
687  pHead = pHead->pNext;
688  }
689 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NOERROR
Definition: winerror.h:2354
#define KEY_READ
Definition: nt_native.h:1023
static LPOLESTR
Definition: stg_prop.c:27
#define INetCfgComponentControl_CancelChanges(p)
Definition: netcfgn.h:54
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define INetCfgComponentControl_ApplyRegistryChanges(p)
Definition: netcfgn.h:52
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct tagNetCfgComponentItem * pNext
Definition: precomp.h:51
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static const WCHAR szName[]
Definition: msipriv.h:1194
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
INetCfgComponentControl * pNCCC
Definition: precomp.h:52
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
#define REG_SZ
Definition: layer.c:22

Referenced by INetCfg_fnApply(), and INetCfg_fnCancel().

◆ EnumClientServiceProtocol()

HRESULT EnumClientServiceProtocol ( HKEY  hKey,
const GUID pGuid,
NetCfgComponentItem **  pHead 
)

ReactOS tcpip guid is not yet generated

Definition at line 265 of file netcfg_iface.c.

266 {
267  DWORD dwIndex = 0;
268  DWORD dwSize;
269  DWORD dwType;
270  WCHAR szName[100];
271  WCHAR szText[100];
272  HKEY hSubKey, hNDIKey;
273  NetCfgComponentItem * pLast = NULL, *pCurrent;
274 
275  *pHead = NULL;
276  do
277  {
278  szText[0] = L'\0';
279 
280  dwSize = sizeof(szName)/sizeof(WCHAR);
281  if (RegEnumKeyExW(hKey, dwIndex++, szName, &dwSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
282  {
283  pCurrent = CoTaskMemAlloc(sizeof(NetCfgComponentItem));
284  if (!pCurrent)
285  return E_OUTOFMEMORY;
286 
287  ZeroMemory(pCurrent, sizeof(NetCfgComponentItem));
288  CopyMemory(&pCurrent->ClassGUID, pGuid, sizeof(GUID));
289 
290  if (FAILED(CLSIDFromString(szName, &pCurrent->InstanceId)))
291  {
293  //CoTaskMemFree(pCurrent);
294  //return E_FAIL;
295  }
296  if (RegOpenKeyExW(hKey, szName, 0, KEY_READ, &hSubKey) == ERROR_SUCCESS)
297  {
298  /* retrieve Characteristics */
299  dwSize = sizeof(DWORD);
300 
301  RegQueryValueExW(hSubKey, L"Characteristics", NULL, &dwType, (LPBYTE)&pCurrent->dwCharacteristics, &dwSize);
302  if (dwType != REG_DWORD)
303  pCurrent->dwCharacteristics = 0;
304 
305  /* retrieve ComponentId */
306  dwSize = sizeof(szText);
307  if (RegQueryValueExW(hSubKey, L"ComponentId", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
308  {
309  if (dwType == REG_SZ)
310  {
311  szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
312  pCurrent->szId = CoTaskMemAlloc((wcslen(szText)+1)* sizeof(WCHAR));
313  if (pCurrent->szId)
314  wcscpy(pCurrent->szId, szText);
315  }
316  }
317 
318  /* retrieve Description */
319  dwSize = sizeof(szText);
320  if (RegQueryValueExW(hSubKey, L"Description", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
321  {
322  if (dwType == REG_SZ)
323  {
324  szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
325  pCurrent->szDisplayName = CoTaskMemAlloc((wcslen(szText)+1)* sizeof(WCHAR));
326  if (pCurrent->szDisplayName)
327  wcscpy(pCurrent->szDisplayName, szText);
328  }
329  }
330 
331  if (RegOpenKeyExW(hSubKey, L"NDI", 0, KEY_READ, &hNDIKey) == ERROR_SUCCESS)
332  {
333  /* retrieve HelpText */
334  dwSize = sizeof(szText);
335  if (RegQueryValueExW(hNDIKey, L"HelpText", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
336  {
337  if (dwType == REG_SZ)
338  {
339  szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
340  pCurrent->szHelpText = CoTaskMemAlloc((wcslen(szText)+1)* sizeof(WCHAR));
341  if (pCurrent->szHelpText)
342  wcscpy(pCurrent->szHelpText, szText);
343  }
344  }
345 
346  /* retrieve Service */
347  dwSize = sizeof(szText);
348  if (RegQueryValueExW(hNDIKey, L"Service", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
349  {
350  if (dwType == REG_SZ)
351  {
352  szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
353  pCurrent->szBindName = CoTaskMemAlloc((wcslen(szText)+1)* sizeof(WCHAR));
354  if (pCurrent->szBindName)
355  wcscpy(pCurrent->szBindName, szText);
356  }
357  }
358  RegCloseKey(hNDIKey);
359  }
360  RegCloseKey(hSubKey);
361 
362  ReadBindingString(pCurrent);
363 
364  if (!pLast)
365  *pHead = pCurrent;
366  else
367  pLast->pNext = pCurrent;
368 
369  pLast = pCurrent;
370  }
371  }
372  else
373  break;
374 
375  }while(TRUE);
376  return S_OK;
377 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define ZeroMemory
Definition: winbase.h:1642
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const WCHAR szText[]
Definition: dialog.c:139
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct tagNetCfgComponentItem * pNext
Definition: precomp.h:51
#define CopyMemory
Definition: winbase.h:1640
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:59
static const WCHAR szName[]
Definition: msipriv.h:1194
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
HRESULT ReadBindingString(NetCfgComponentItem *Item)
Definition: netcfg_iface.c:230
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
#define REG_DWORD
Definition: sdbapi.c:596
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define REG_SZ
Definition: layer.c:22

Referenced by EnumerateNetworkComponent().

◆ EnumerateNetworkAdapter()

HRESULT EnumerateNetworkAdapter ( NetCfgComponentItem **  pHead)

Definition at line 405 of file netcfg_iface.c.

406 {
407  DWORD dwSize, dwIndex;
408  HDEVINFO hInfo;
409  SP_DEVINFO_DATA DevInfo;
410  HKEY hKey;
411  WCHAR szNetCfg[50];
412  WCHAR szAdapterNetCfg[MAX_DEVICE_ID_LEN];
413  WCHAR szDetail[200] = L"SYSTEM\\CurrentControlSet\\Control\\Class\\";
414  WCHAR szName[130] = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
415  NetCfgComponentItem * pLast = NULL, *pCurrent;
416 
417  hInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT );
418  if (!hInfo)
419  {
420  return E_FAIL;
421  }
422 
423  dwIndex = 0;
424  do
425  {
426  ZeroMemory(&DevInfo, sizeof(SP_DEVINFO_DATA));
427  DevInfo.cbSize = sizeof(DevInfo);
428 
429  /* get device info */
430  if (!SetupDiEnumDeviceInfo(hInfo, dwIndex++, &DevInfo))
431  break;
432 
433  /* get device software registry path */
434  if (!SetupDiGetDeviceRegistryPropertyW(hInfo, &DevInfo, SPDRP_DRIVER, NULL, (LPBYTE)&szDetail[39], sizeof(szDetail)/sizeof(WCHAR) - 40, &dwSize))
435  break;
436 
437  /* open device registry key */
438  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szDetail, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
439  break;
440 
441  /* query NetCfgInstanceId for current device */
442  dwSize = sizeof(szNetCfg);
443  if (RegQueryValueExW(hKey, L"NetCfgInstanceId", NULL, NULL, (LPBYTE)szNetCfg, &dwSize) != ERROR_SUCCESS)
444  {
445  RegCloseKey(hKey);
446  break;
447  }
448 
449  /* allocate new INetConnectionItem */
450  pCurrent = CoTaskMemAlloc(sizeof(NetCfgComponentItem));
451  if (!pCurrent)
452  break;
453 
454  ZeroMemory(pCurrent, sizeof(NetCfgComponentItem));
455  CopyMemory(&pCurrent->ClassGUID, &GUID_DEVCLASS_NET, sizeof(GUID));
456  CLSIDFromString(szNetCfg, &pCurrent->InstanceId); //FIXME
457 
458  /* set bind name */
459  pCurrent->szBindName = CoTaskMemAlloc((wcslen(szNetCfg)+1) *sizeof(WCHAR));
460  if (pCurrent->szBindName)
461  wcscpy(pCurrent->szBindName, szNetCfg);
462 
463  /* retrieve ComponentId */
464  dwSize = sizeof(szAdapterNetCfg);
465  if (RegQueryValueExW(hKey, L"ComponentId", NULL, NULL, (LPBYTE)szAdapterNetCfg, &dwSize) == ERROR_SUCCESS)
466  {
467  pCurrent->szId = CoTaskMemAlloc((wcslen(szAdapterNetCfg)+1) * sizeof(WCHAR));
468  if (pCurrent->szId)
469  wcscpy(pCurrent->szId, szAdapterNetCfg);
470  }
471  /* set INetCfgComponent::GetDisplayName */
472  dwSize = sizeof(szAdapterNetCfg);
473  if (RegQueryValueExW(hKey, L"DriverDesc", NULL, NULL, (LPBYTE)szAdapterNetCfg, &dwSize) == ERROR_SUCCESS)
474  {
475  pCurrent->szDisplayName = CoTaskMemAlloc((wcslen(szAdapterNetCfg)+1) * sizeof(WCHAR));
476  if (pCurrent->szDisplayName)
477  wcscpy(pCurrent->szDisplayName, szAdapterNetCfg);
478  }
479 
480  RegCloseKey(hKey);
481  /* open network connections details */
482  wcscpy(&szName[80], szNetCfg);
483  wcscpy(&szName[118], L"\\Connection");
484 
486  {
487  /* retrieve pnp instance id */
488  dwSize = sizeof(szAdapterNetCfg);
489  if (RegQueryValueExW(hKey, L"PnpInstanceID", NULL, NULL, (LPBYTE)szAdapterNetCfg, &dwSize) == ERROR_SUCCESS)
490  {
491  pCurrent->szNodeId = CoTaskMemAlloc((wcslen(szAdapterNetCfg)+1) * sizeof(WCHAR));
492  if (pCurrent->szNodeId)
493  wcscpy(pCurrent->szNodeId, szAdapterNetCfg);
494  }
495  RegCloseKey(hKey);
496  }
497 
498  if (SetupDiGetDeviceRegistryPropertyW(hInfo, &DevInfo, SPDRP_DEVICEDESC, NULL, (PBYTE)szNetCfg, sizeof(szNetCfg)/sizeof(WCHAR), &dwSize))
499  {
500  szNetCfg[(sizeof(szNetCfg)/sizeof(WCHAR))-1] = L'\0';
501  pCurrent->szDisplayName = CoTaskMemAlloc((wcslen(szNetCfg)+1) * sizeof(WCHAR));
502  if (pCurrent->szDisplayName)
503  wcscpy(pCurrent->szDisplayName, szNetCfg);
504  }
505 
506  if (pLast)
507  pLast->pNext = pCurrent;
508  else
509  *pHead = pCurrent;
510 
511  pLast = pCurrent;
512 
513  }while(TRUE);
514 
516  return NOERROR;
517 }
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1792
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NOERROR
Definition: winerror.h:2354
#define KEY_READ
Definition: nt_native.h:1023
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3229
#define ZeroMemory
Definition: winbase.h:1642
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct tagNetCfgComponentItem * pNext
Definition: precomp.h:51
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define CopyMemory
Definition: winbase.h:1640
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define SetupDiGetClassDevs
Definition: setupapi.h:2588
#define SPDRP_DEVICEDESC
Definition: setupapi.h:502
static const WCHAR szName[]
Definition: msipriv.h:1194
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
BYTE * PBYTE
Definition: pedump.c:66
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define DIGCF_PRESENT
Definition: setupapi.h:171
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define SPDRP_DRIVER
Definition: setupapi.h:511

Referenced by INetCfg_fnInitialize().

◆ EnumerateNetworkComponent()

HRESULT EnumerateNetworkComponent ( const GUID pGuid,
NetCfgComponentItem **  pHead 
)

Definition at line 382 of file netcfg_iface.c.

384 {
385  HKEY hKey;
386  LPOLESTR pszGuid;
387  HRESULT hr;
388  WCHAR szName[150];
389 
390  hr = StringFromCLSID(pGuid, &pszGuid);
391  if (SUCCEEDED(hr))
392  {
393  swprintf(szName, L"SYSTEM\\CurrentControlSet\\Control\\Network\\%s", pszGuid);
395  {
396  hr = EnumClientServiceProtocol(hKey, pGuid, pHead);
397  RegCloseKey(hKey);
398  }
399  CoTaskMemFree(pszGuid);
400  }
401  return hr;
402 }
HRESULT EnumClientServiceProtocol(HKEY hKey, const GUID *pGuid, NetCfgComponentItem **pHead)
Definition: netcfg_iface.c:265
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
static LPOLESTR
Definition: stg_prop.c:27
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR szName[]
Definition: msipriv.h:1194
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412

Referenced by INetCfg_fnInitialize().

◆ FindNetworkComponent()

HRESULT FindNetworkComponent ( NetCfgComponentItem pHead,
LPCWSTR  pszwComponentId,
INetCfgComponent **  pComponent,
INetCfg *  iface 
)

Definition at line 521 of file netcfg_iface.c.

526 {
527  while(pHead)
528  {
529  if (!_wcsicmp(pHead->szId, pszwComponentId))
530  {
531  return INetCfgComponent_Constructor(NULL, &IID_INetCfgComponent, (LPVOID*)pComponent, pHead, iface);
532  }
533  pHead = pHead->pNext;
534  }
535  return S_FALSE;
536 }
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
EXTERN_C const IID IID_INetCfgComponent
Definition: netcfgx.h:77
struct tagNetCfgComponentItem * pNext
Definition: precomp.h:51
HRESULT WINAPI INetCfgComponent_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv, NetCfgComponentItem *pItem, INetCfg *pNCfg)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by INetCfg_fnFindComponent().

◆ FreeComponentItem()

VOID FreeComponentItem ( NetCfgComponentItem pItem)

Definition at line 692 of file netcfg_iface.c.

693 {
695  CoTaskMemFree(pItem->szHelpText);
696  CoTaskMemFree(pItem->szId);
697  CoTaskMemFree(pItem->szBindName);
698  CoTaskMemFree(pItem->szNodeId);
699  CoTaskMemFree(pItem->pszBinding);
700  CoTaskMemFree(pItem);
701 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420

Referenced by INetCfg_fnUninitialize().

◆ impl_from_INetCfgLock()

static __inline LPINetCfgImpl impl_from_INetCfgLock ( INetCfgLock *  iface)
static

Definition at line 17 of file netcfg_iface.c.

18 {
19  return (INetCfgImpl*)((char *)iface - FIELD_OFFSET(INetCfgImpl, lpVtblLock));
20 }
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254

Referenced by INetCfgLock_fnAcquireWriteLock(), INetCfgLock_fnAddRef(), INetCfgLock_fnQueryInterface(), INetCfgLock_fnRelease(), and INetCfgLock_fnReleaseWriteLock().

◆ impl_from_INetCfgPnpReconfigCallback()

static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback ( INetCfgPnpReconfigCallback *  iface)
static

Definition at line 22 of file netcfg_iface.c.

23 {
24  return (INetCfgImpl*)((char *)iface - FIELD_OFFSET(INetCfgImpl, lpVtblPnpReconfigCallback));
25 }
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254

Referenced by INetCfgPnpReconfigCallback_fnAddRef(), INetCfgPnpReconfigCallback_fnQueryInterface(), and INetCfgPnpReconfigCallback_fnRelease().

◆ INetCfg_Constructor()

HRESULT WINAPI INetCfg_Constructor ( IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppv 
)

Definition at line 865 of file netcfg_iface.c.

866 {
867  INetCfgImpl *This;
868 
869  if (!ppv)
870  return E_POINTER;
871 
872  This = (INetCfgImpl *) CoTaskMemAlloc(sizeof (INetCfgImpl));
873  if (!This)
874  return E_OUTOFMEMORY;
875 
876  This->ref = 1;
877  This->lpVtbl = (const INetCfg*)&vt_NetCfg;
878  This->lpVtblLock = (const INetCfgLock*)&vt_NetCfgLock;
879  This->lpVtblPnpReconfigCallback = (const INetCfgPnpReconfigCallback*)&vt_NetCfgPnpReconfigCallback;
880  This->hMutex = NULL;
881  This->bInitialized = FALSE;
882  This->pNet = NULL;
883  This->pClient = NULL;
884  This->pService = NULL;
885  This->pProtocol = NULL;
886 
887  if (!SUCCEEDED (INetCfg_QueryInterface ((INetCfg*)This, riid, ppv)))
888  {
889  INetCfg_Release((INetCfg*)This);
890  return E_NOINTERFACE;
891  }
892 
893  INetCfg_Release((INetCfg*)This);
894  return S_OK;
895 }
#define INetCfg_QueryInterface(p, a, b)
Definition: netcfgx.h:287
static const INetCfgLockVtbl vt_NetCfgLock
Definition: netcfg_iface.c:158
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
static const INetCfgVtbl vt_NetCfg
Definition: netcfg_iface.c:851
#define INetCfg_Release(p)
Definition: netcfgx.h:289
static const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback
Definition: netcfg_iface.c:216
#define S_OK
Definition: intsafe.h:59
#define E_POINTER
Definition: winerror.h:2365
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ INetCfg_fnAddRef()

ULONG WINAPI INetCfg_fnAddRef ( INetCfg *  iface)

Definition at line 583 of file netcfg_iface.c.

585 {
586  INetCfgImpl * This = (INetCfgImpl*)iface;
587  ULONG refCount = InterlockedIncrement(&This->ref);
588 
589  return refCount;
590 }
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ INetCfg_fnApply()

HRESULT WINAPI INetCfg_fnApply ( INetCfg *  iface)

Definition at line 754 of file netcfg_iface.c.

756 {
757  INetCfgImpl *This = (INetCfgImpl *)iface;
758 
759  if (!This->bInitialized)
761 
762  ApplyOrCancelChanges(This->pNet, &GUID_DEVCLASS_NET, TRUE);
763  ApplyOrCancelChanges(This->pClient, &GUID_DEVCLASS_NETCLIENT, TRUE);
764  ApplyOrCancelChanges(This->pService, &GUID_DEVCLASS_NETSERVICE, TRUE);
765  ApplyOrCancelChanges(This->pProtocol, &GUID_DEVCLASS_NETTRANS, TRUE);
766 
767  return S_OK;
768 }
VOID ApplyOrCancelChanges(NetCfgComponentItem *pHead, const CLSID *lpClassGUID, BOOL bApply)
Definition: netcfg_iface.c:642
#define TRUE
Definition: types.h:120
#define NETCFG_E_NOT_INITIALIZED
Definition: netcfgx.h:303
#define S_OK
Definition: intsafe.h:59

◆ INetCfg_fnCancel()

HRESULT WINAPI INetCfg_fnCancel ( INetCfg *  iface)

Definition at line 772 of file netcfg_iface.c.

774 {
775  INetCfgImpl *This = (INetCfgImpl *)iface;
776 
777  if (!This->bInitialized)
779 
780  ApplyOrCancelChanges(This->pClient, &GUID_DEVCLASS_NETCLIENT, FALSE);
781  ApplyOrCancelChanges(This->pService, &GUID_DEVCLASS_NETSERVICE, FALSE);
782  ApplyOrCancelChanges(This->pProtocol, &GUID_DEVCLASS_NETTRANS, FALSE);
783 
784  return S_OK;
785 }
VOID ApplyOrCancelChanges(NetCfgComponentItem *pHead, const CLSID *lpClassGUID, BOOL bApply)
Definition: netcfg_iface.c:642
#define NETCFG_E_NOT_INITIALIZED
Definition: netcfgx.h:303
#define S_OK
Definition: intsafe.h:59

◆ INetCfg_fnEnumComponents()

HRESULT WINAPI INetCfg_fnEnumComponents ( INetCfg *  iface,
const GUID pguidClass,
IEnumNetCfgComponent **  ppenumComponent 
)

Definition at line 789 of file netcfg_iface.c.

793 {
794  INetCfgImpl *This = (INetCfgImpl *)iface;
795 
796  if (!This->bInitialized)
798 
799  if (IsEqualGUID(&GUID_DEVCLASS_NET, pguidClass))
800  return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pNet, iface);
801  else if (IsEqualGUID(&GUID_DEVCLASS_NETCLIENT, pguidClass))
802  return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pClient, iface);
803  else if (IsEqualGUID(&GUID_DEVCLASS_NETSERVICE, pguidClass))
804  return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pService, iface);
805  else if (IsEqualGUID(&GUID_DEVCLASS_NETTRANS, pguidClass))
806  return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, This->pProtocol, iface);
807  else
808  return E_NOINTERFACE;
809 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT WINAPI IEnumNetCfgComponent_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv, NetCfgComponentItem *pItem, INetCfg *pNCfg)
#define NETCFG_E_NOT_INITIALIZED
Definition: netcfgx.h:303
smooth NULL
Definition: ftsmooth.c:416
EXTERN_C const IID IID_IEnumNetCfgComponent
Definition: netcfgx.h:266
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ INetCfg_fnFindComponent()

HRESULT WINAPI INetCfg_fnFindComponent ( INetCfg *  iface,
LPCWSTR  pszwComponentId,
INetCfgComponent **  pComponent 
)

Definition at line 814 of file netcfg_iface.c.

818 {
819  HRESULT hr;
820  INetCfgImpl *This = (INetCfgImpl *)iface;
821 
822  if (!This->bInitialized)
824 
825  hr = FindNetworkComponent(This->pClient, pszwComponentId, pComponent, iface);
826  if (hr == S_OK)
827  return hr;
828 
829  hr = FindNetworkComponent(This->pService, pszwComponentId, pComponent, iface);
830  if (hr == S_OK)
831  return hr;
832 
833  hr = FindNetworkComponent(This->pProtocol, pszwComponentId, pComponent, iface);
834  if (hr == S_OK)
835  return hr;
836 
837  return S_FALSE;
838 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT FindNetworkComponent(NetCfgComponentItem *pHead, LPCWSTR pszwComponentId, INetCfgComponent **pComponent, INetCfg *iface)
Definition: netcfg_iface.c:521
#define NETCFG_E_NOT_INITIALIZED
Definition: netcfgx.h:303
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59

◆ INetCfg_fnInitialize()

HRESULT WINAPI INetCfg_fnInitialize ( INetCfg *  iface,
PVOID  pReserved 
)

Definition at line 609 of file netcfg_iface.c.

612 {
613  HRESULT hr;
614  INetCfgImpl *This = (INetCfgImpl *)iface;
615 
616  if (This->bInitialized)
618 
619  hr = EnumerateNetworkAdapter(&This->pNet);
620  if (FAILED(hr))
621  return hr;
622 
623 
624  hr = EnumerateNetworkComponent(&GUID_DEVCLASS_NETCLIENT, &This->pClient);
625  if (FAILED(hr))
626  return hr;
627 
628  hr = EnumerateNetworkComponent(&GUID_DEVCLASS_NETSERVICE, &This->pService);
629  if (FAILED(hr))
630  return hr;
631 
632 
633  hr = EnumerateNetworkComponent(&GUID_DEVCLASS_NETTRANS, &This->pProtocol);
634  if (FAILED(hr))
635  return hr;
636 
637  This->bInitialized = TRUE;
638  return S_OK;
639 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
HRESULT EnumerateNetworkAdapter(NetCfgComponentItem **pHead)
Definition: netcfg_iface.c:405
HRESULT EnumerateNetworkComponent(const GUID *pGuid, NetCfgComponentItem **pHead)
Definition: netcfg_iface.c:382
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define NETCFG_E_ALREADY_INITIALIZED
Definition: netcfgx.h:302

◆ INetCfg_fnQueryInterface()

HRESULT WINAPI INetCfg_fnQueryInterface ( INetCfg *  iface,
REFIID  iid,
LPVOID ppvObj 
)

Definition at line 542 of file netcfg_iface.c.

546 {
547  INetCfgImpl * This = (INetCfgImpl*)iface;
548  *ppvObj = NULL;
549 
550  if (IsEqualIID (iid, &IID_IUnknown) ||
551  IsEqualIID (iid, &IID_INetCfg))
552  {
553  *ppvObj = This;
554  INetCfg_AddRef(iface);
555  return S_OK;
556  }
557  else if (IsEqualIID (iid, &IID_INetCfgLock))
558  {
559  if (This->bInitialized)
561 
562  *ppvObj = (LPVOID)&This->lpVtblLock;
563  This->hMutex = CreateMutexW(NULL, FALSE, L"NetCfgLock");
564 
565  INetCfgLock_AddRef(iface);
566  return S_OK;
567  }
569  {
570  if (This->bInitialized)
572 
573  *ppvObj = (LPVOID)&This->lpVtblPnpReconfigCallback;
575  return S_OK;
576  }
577 
578  return E_NOINTERFACE;
579 }
#define E_NOINTERFACE
Definition: winerror.h:2364
EXTERN_C const IID IID_INetCfgLock
Definition: netcfgx.h:14
#define INetCfgPnpReconfigCallback_AddRef(p)
Definition: netcfgn.h:24
smooth NULL
Definition: ftsmooth.c:416
EXTERN_C const IID IID_INetCfg
Definition: netcfgx.h:300
#define INetCfgLock_AddRef(p)
Definition: netcfgx.h:22
const GUID IID_IUnknown
#define LPVOID
Definition: nt_native.h:45
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:59
#define INetCfg_AddRef(p)
Definition: netcfgx.h:288
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
EXTERN_C const IID IID_INetCfgPnpReconfigCallback
Definition: netcfgn.h:29
#define NETCFG_E_ALREADY_INITIALIZED
Definition: netcfgx.h:302
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ INetCfg_fnQueryNetCfgClass()

HRESULT WINAPI INetCfg_fnQueryNetCfgClass ( INetCfg *  iface,
const GUID pguidClass,
REFIID  riid,
void **  ppvObject 
)

Definition at line 842 of file netcfg_iface.c.

847 {
848  return E_FAIL;
849 }
#define E_FAIL
Definition: ddrawi.h:102

◆ INetCfg_fnRelease()

ULONG WINAPI INetCfg_fnRelease ( INetCfg *  iface)

Definition at line 594 of file netcfg_iface.c.

596 {
597  INetCfgImpl * This = (INetCfgImpl*)iface;
598  ULONG refCount = InterlockedDecrement(&This->ref);
599 
600  if (!refCount)
601  {
603  }
604  return refCount;
605 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1

◆ INetCfg_fnUninitialize()

HRESULT WINAPI INetCfg_fnUninitialize ( INetCfg *  iface)

Definition at line 705 of file netcfg_iface.c.

707 {
708  INetCfgImpl *This = (INetCfgImpl *)iface;
709  NetCfgComponentItem *pItem;
710 
711  if (!This->bInitialized)
713 
714  /* Free the services */
715  while (This->pService != NULL)
716  {
717  pItem = This->pService;
718  This->pService = pItem->pNext;
719  FreeComponentItem(pItem);
720  }
721 
722  /* Free the clients */
723  while (This->pClient != NULL)
724  {
725  pItem = This->pClient;
726  This->pClient = pItem->pNext;
727  FreeComponentItem(pItem);
728  }
729 
730  /* Free the protocols */
731  while (This->pProtocol != NULL)
732  {
733  pItem = This->pProtocol;
734  This->pProtocol = pItem->pNext;
735  FreeComponentItem(pItem);
736  }
737 
738  /* Free the adapters */
739  while (This->pNet != NULL)
740  {
741  pItem = This->pNet;
742  This->pNet = pItem->pNext;
743  FreeComponentItem(pItem);
744  }
745 
746  This->bInitialized = FALSE;
747 
748  return S_OK;
749 }
VOID FreeComponentItem(NetCfgComponentItem *pItem)
Definition: netcfg_iface.c:692
#define NETCFG_E_NOT_INITIALIZED
Definition: netcfgx.h:303
smooth NULL
Definition: ftsmooth.c:416
struct tagNetCfgComponentItem * pNext
Definition: precomp.h:51
#define S_OK
Definition: intsafe.h:59

◆ INetCfgLock_fnAcquireWriteLock()

HRESULT WINAPI INetCfgLock_fnAcquireWriteLock ( INetCfgLock *  iface,
DWORD  cmsTimeout,
LPCWSTR  pszwClientDescription,
LPWSTR ppszwClientDescription 
)

Definition at line 61 of file netcfg_iface.c.

66 {
67  DWORD dwResult;
68  HKEY hKey;
69  WCHAR szValue[100];
71 
72  if (This->bInitialized)
74 
75  dwResult = WaitForSingleObject(This->hMutex, cmsTimeout);
76  if (dwResult == WAIT_TIMEOUT)
77  {
78  if (ppszwClientDescription)
79  {
80  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Network\\NetCfgLockHolder", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
81  {
82  dwResult = sizeof(szValue);
83  if (RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)szValue, &dwResult) == ERROR_SUCCESS)
84  {
85  szValue[(sizeof(szValue)/sizeof(WCHAR))-1] = L'\0';
86  *ppszwClientDescription = CoTaskMemAlloc((wcslen(szValue)+1) * sizeof(WCHAR));
87  if (*ppszwClientDescription)
88  wcscpy(*ppszwClientDescription, szValue);
89  }
90  RegCloseKey(hKey);
91  }
92  }
93  return S_FALSE;
94  }
95  else if (dwResult == WAIT_OBJECT_0)
96  {
97  if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Network\\NetCfgLockHolder", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
98  {
99  RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pszwClientDescription, (wcslen(pszwClientDescription)+1) * sizeof(WCHAR));
100  RegCloseKey(hKey);
101  }
102  return S_OK;
103  }
104 
105  return E_FAIL;
106 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define WAIT_OBJECT_0
Definition: winbase.h:387
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_TIMEOUT
Definition: dderror.h:14
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:59
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define NETCFG_E_ALREADY_INITIALIZED
Definition: netcfgx.h:302
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
Definition: netcfg_iface.c:17
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

◆ INetCfgLock_fnAddRef()

ULONG WINAPI INetCfgLock_fnAddRef ( INetCfgLock *  iface)

Definition at line 42 of file netcfg_iface.c.

44 {
46 
47  return INetCfg_AddRef((INetCfg*)This);
48 }
#define INetCfg_AddRef(p)
Definition: netcfgx.h:288
static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
Definition: netcfg_iface.c:17

◆ INetCfgLock_fnIsWriteLocked()

HRESULT WINAPI INetCfgLock_fnIsWriteLocked ( INetCfgLock *  iface,
LPWSTR ppszwClientDescription 
)

Definition at line 127 of file netcfg_iface.c.

130 {
131  HKEY hKey;
132  WCHAR szValue[100];
133  DWORD dwSize, dwType;
134  HRESULT hr;
135 
136  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Network\\NetCfgLockHolder", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
137  return S_FALSE;
138 
139  dwSize = sizeof(szValue);
140  if (RegQueryValueExW(hKey, NULL, NULL, &dwType, (LPBYTE)szValue, &dwSize) == ERROR_SUCCESS && dwType == REG_SZ)
141  {
142  hr = S_OK;
143  szValue[(sizeof(szValue)/sizeof(WCHAR))-1] = L'\0';
144  *ppszwClientDescription = CoTaskMemAlloc((wcslen(szValue)+1) * sizeof(WCHAR));
145  if (*ppszwClientDescription)
146  wcscpy(*ppszwClientDescription, szValue);
147  else
148  hr = E_OUTOFMEMORY;
149  }
150  else
151  {
152  hr = E_FAIL;
153  }
154  RegCloseKey(hKey);
155  return hr;
156 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:59
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

◆ INetCfgLock_fnQueryInterface()

HRESULT WINAPI INetCfgLock_fnQueryInterface ( INetCfgLock *  iface,
REFIID  iid,
LPVOID ppvObj 
)

Definition at line 30 of file netcfg_iface.c.

34 {
36  return INetCfg_QueryInterface((INetCfg*)This, iid, ppvObj);
37 }
#define INetCfg_QueryInterface(p, a, b)
Definition: netcfgx.h:287
static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
Definition: netcfg_iface.c:17

◆ INetCfgLock_fnRelease()

ULONG WINAPI INetCfgLock_fnRelease ( INetCfgLock *  iface)

Definition at line 52 of file netcfg_iface.c.

54 {
56  return INetCfg_Release((INetCfg*)This);
57 }
#define INetCfg_Release(p)
Definition: netcfgx.h:289
static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
Definition: netcfg_iface.c:17

◆ INetCfgLock_fnReleaseWriteLock()

HRESULT WINAPI INetCfgLock_fnReleaseWriteLock ( INetCfgLock *  iface)

Definition at line 110 of file netcfg_iface.c.

112 {
114 
115  if (This->bInitialized)
117 
118 
119  if (ReleaseMutex(This->hMutex))
120  return S_OK;
121  else
122  return S_FALSE;
123 }
#define S_FALSE
Definition: winerror.h:2357
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define S_OK
Definition: intsafe.h:59
#define NETCFG_E_ALREADY_INITIALIZED
Definition: netcfgx.h:302
static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
Definition: netcfg_iface.c:17

◆ INetCfgPnpReconfigCallback_fnAddRef()

ULONG WINAPI INetCfgPnpReconfigCallback_fnAddRef ( INetCfgPnpReconfigCallback *  iface)

Definition at line 185 of file netcfg_iface.c.

187 {
189 
190  return INetCfg_AddRef((INetCfg*)This);
191 }
static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:22
#define INetCfg_AddRef(p)
Definition: netcfgx.h:288

◆ INetCfgPnpReconfigCallback_fnQueryInterface()

HRESULT WINAPI INetCfgPnpReconfigCallback_fnQueryInterface ( INetCfgPnpReconfigCallback *  iface,
REFIID  iid,
LPVOID ppvObj 
)

Definition at line 174 of file netcfg_iface.c.

178 {
180  return INetCfg_QueryInterface((INetCfg*)This, iid, ppvObj);
181 }
#define INetCfg_QueryInterface(p, a, b)
Definition: netcfgx.h:287
static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:22

◆ INetCfgPnpReconfigCallback_fnRelease()

ULONG WINAPI INetCfgPnpReconfigCallback_fnRelease ( INetCfgPnpReconfigCallback *  iface)

Definition at line 195 of file netcfg_iface.c.

197 {
199  return INetCfg_Release((INetCfg*)This);
200 }
static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:22
#define INetCfg_Release(p)
Definition: netcfgx.h:289

◆ INetCfgPnpReconfigCallback_fnSendPnpReconfig()

HRESULT WINAPI INetCfgPnpReconfigCallback_fnSendPnpReconfig ( INetCfgPnpReconfigCallback *  iface,
NCPNP_RECONFIG_LAYER  Layer,
LPCWSTR  pszwUpper,
LPCWSTR  pszwLower,
PVOID  pvData,
DWORD  dwSizeOfData 
)

Definition at line 204 of file netcfg_iface.c.

211 {
212  /* FIXME */
213  return E_NOTIMPL;
214 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ReadBindingString()

HRESULT ReadBindingString ( NetCfgComponentItem Item)

Definition at line 230 of file netcfg_iface.c.

232 {
233  WCHAR szBuffer[200];
234  HKEY hKey;
235  DWORD dwType, dwSize;
236 
237  if (Item == NULL || Item->szBindName == NULL)
238  return S_OK;
239 
240  wcscpy(szBuffer, L"SYSTEM\\CurrentControlSet\\Services\\");
241  wcscat(szBuffer, Item->szBindName);
242  wcscat(szBuffer, L"\\Linkage");
243 
244  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
245  {
246  dwSize = 0;
247  RegQueryValueExW(hKey, L"Bind", NULL, &dwType, NULL, &dwSize);
248 
249  if (dwSize != 0)
250  {
252  if (Item->pszBinding == NULL)
253  return E_OUTOFMEMORY;
254 
255  RegQueryValueExW(hKey, L"Bind", NULL, &dwType, (LPBYTE)Item->pszBinding, &dwSize);
256  }
257 
258  RegCloseKey(hKey);
259  }
260 
261  return S_OK;
262 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:59
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by EnumClientServiceProtocol().

Variable Documentation

◆ vt_NetCfg

const INetCfgVtbl vt_NetCfg
static
Initial value:
=
{
}
HRESULT WINAPI INetCfg_fnUninitialize(INetCfg *iface)
Definition: netcfg_iface.c:705
ULONG WINAPI INetCfg_fnRelease(INetCfg *iface)
Definition: netcfg_iface.c:594
HRESULT WINAPI INetCfg_fnQueryNetCfgClass(INetCfg *iface, const GUID *pguidClass, REFIID riid, void **ppvObject)
Definition: netcfg_iface.c:842
ULONG WINAPI INetCfg_fnAddRef(INetCfg *iface)
Definition: netcfg_iface.c:583
HRESULT WINAPI INetCfg_fnQueryInterface(INetCfg *iface, REFIID iid, LPVOID *ppvObj)
Definition: netcfg_iface.c:542
HRESULT WINAPI INetCfg_fnInitialize(INetCfg *iface, PVOID pReserved)
Definition: netcfg_iface.c:609
HRESULT WINAPI INetCfg_fnFindComponent(INetCfg *iface, LPCWSTR pszwComponentId, INetCfgComponent **pComponent)
Definition: netcfg_iface.c:814
HRESULT WINAPI INetCfg_fnApply(INetCfg *iface)
Definition: netcfg_iface.c:754
HRESULT WINAPI INetCfg_fnEnumComponents(INetCfg *iface, const GUID *pguidClass, IEnumNetCfgComponent **ppenumComponent)
Definition: netcfg_iface.c:789
HRESULT WINAPI INetCfg_fnCancel(INetCfg *iface)
Definition: netcfg_iface.c:772

Definition at line 851 of file netcfg_iface.c.

Referenced by INetCfg_Constructor().

◆ vt_NetCfgLock

const INetCfgLockVtbl vt_NetCfgLock
static
Initial value:
=
{
}
HRESULT WINAPI INetCfgLock_fnAcquireWriteLock(INetCfgLock *iface, DWORD cmsTimeout, LPCWSTR pszwClientDescription, LPWSTR *ppszwClientDescription)
Definition: netcfg_iface.c:61
HRESULT WINAPI INetCfgLock_fnReleaseWriteLock(INetCfgLock *iface)
Definition: netcfg_iface.c:110
HRESULT WINAPI INetCfgLock_fnQueryInterface(INetCfgLock *iface, REFIID iid, LPVOID *ppvObj)
Definition: netcfg_iface.c:30
ULONG WINAPI INetCfgLock_fnAddRef(INetCfgLock *iface)
Definition: netcfg_iface.c:42
HRESULT WINAPI INetCfgLock_fnIsWriteLocked(INetCfgLock *iface, LPWSTR *ppszwClientDescription)
Definition: netcfg_iface.c:127
ULONG WINAPI INetCfgLock_fnRelease(INetCfgLock *iface)
Definition: netcfg_iface.c:52

Definition at line 158 of file netcfg_iface.c.

Referenced by INetCfg_Constructor().

◆ vt_NetCfgPnpReconfigCallback

const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback
static
Initial value:
=
{
}
HRESULT WINAPI INetCfgPnpReconfigCallback_fnQueryInterface(INetCfgPnpReconfigCallback *iface, REFIID iid, LPVOID *ppvObj)
Definition: netcfg_iface.c:174
ULONG WINAPI INetCfgPnpReconfigCallback_fnRelease(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:195
HRESULT WINAPI INetCfgPnpReconfigCallback_fnSendPnpReconfig(INetCfgPnpReconfigCallback *iface, NCPNP_RECONFIG_LAYER Layer, LPCWSTR pszwUpper, LPCWSTR pszwLower, PVOID pvData, DWORD dwSizeOfData)
Definition: netcfg_iface.c:204
ULONG WINAPI INetCfgPnpReconfigCallback_fnAddRef(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:185

Definition at line 216 of file netcfg_iface.c.

Referenced by INetCfg_Constructor().