ReactOS 0.4.15-dev-7693-gd0e2924
netcfg_iface.c
Go to the documentation of this file.
1#include "precomp.h"
2
3typedef struct
4{
5 const INetCfg * lpVtbl;
6 const INetCfgLock * lpVtblLock;
7 const INetCfgPnpReconfigCallback *lpVtblPnpReconfigCallback;
16
17static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
18{
19 return (INetCfgImpl*)((char *)iface - FIELD_OFFSET(INetCfgImpl, lpVtblLock));
20}
21
22static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback *iface)
23{
24 return (INetCfgImpl*)((char *)iface - FIELD_OFFSET(INetCfgImpl, lpVtblPnpReconfigCallback));
25}
26
27
31 INetCfgLock * iface,
32 REFIID iid,
33 LPVOID * ppvObj)
34{
36 return INetCfg_QueryInterface((INetCfg*)This, iid, ppvObj);
37}
38
39
43 INetCfgLock * iface)
44{
46
47 return INetCfg_AddRef((INetCfg*)This);
48}
49
53 INetCfgLock * iface)
54{
56 return INetCfg_Release((INetCfg*)This);
57}
58
62 INetCfgLock * iface,
63 DWORD cmsTimeout,
64 LPCWSTR pszwClientDescription,
65 LPWSTR *ppszwClientDescription)
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 }
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));
101 }
102 return S_OK;
103 }
104
105 return E_FAIL;
106}
107
109WINAPI
111 INetCfgLock * iface)
112{
114
115 if (This->bInitialized)
117
118
119 if (ReleaseMutex(This->hMutex))
120 return S_OK;
121 else
122 return S_FALSE;
123}
124
126WINAPI
128 INetCfgLock * iface,
129 LPWSTR *ppszwClientDescription)
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
149 }
150 else
151 {
152 hr = E_FAIL;
153 }
155 return hr;
156}
157
158static const INetCfgLockVtbl vt_NetCfgLock =
159{
166};
167
168/***************************************************************
169 * INetCfgPnpReconfigCallback
170 */
171
173WINAPI
175 INetCfgPnpReconfigCallback * iface,
176 REFIID iid,
177 LPVOID * ppvObj)
178{
180 return INetCfg_QueryInterface((INetCfg*)This, iid, ppvObj);
181}
182
183ULONG
184WINAPI
186 INetCfgPnpReconfigCallback * iface)
187{
189
190 return INetCfg_AddRef((INetCfg*)This);
191}
192
193ULONG
194WINAPI
196 INetCfgPnpReconfigCallback * iface)
197{
199 return INetCfg_Release((INetCfg*)This);
200}
201
203WINAPI
205 INetCfgPnpReconfigCallback * iface,
207 LPCWSTR pszwUpper,
208 LPCWSTR pszwLower,
210 DWORD dwSizeOfData)
211{
212 /* FIXME */
213 return E_NOTIMPL;
214}
215
216static const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback =
217{
222};
223
224
225/***************************************************************
226 * INetCfg
227 */
228
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
245 {
246 dwSize = 0;
247 RegQueryValueExW(hKey, L"Bind", NULL, &dwType, NULL, &dwSize);
248
249 if (dwSize != 0)
250 {
251 Item->pszBinding = CoTaskMemAlloc(dwSize);
252 if (Item->pszBinding == NULL)
253 return E_OUTOFMEMORY;
254
255 RegQueryValueExW(hKey, L"Bind", NULL, &dwType, (LPBYTE)Item->pszBinding, &dwSize);
256 }
257
259 }
260
261 return S_OK;
262}
263
266{
267 DWORD dwIndex = 0;
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}
378
379
380
383 const GUID *pGuid, NetCfgComponentItem ** pHead)
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);
398 }
399 CoTaskMemFree(pszGuid);
400 }
401 return hr;
402}
403
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 */
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 {
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
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 }
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}
518
519
522 NetCfgComponentItem * pHead,
523 LPCWSTR pszwComponentId,
524 INetCfgComponent **pComponent,
525 INetCfg * iface)
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}
537
538
539
541WINAPI
543 INetCfg * iface,
544 REFIID iid,
545 LPVOID * ppvObj)
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}
580
581ULONG
582WINAPI
584 INetCfg * iface)
585{
586 INetCfgImpl * This = (INetCfgImpl*)iface;
587 ULONG refCount = InterlockedIncrement(&This->ref);
588
589 return refCount;
590}
591
592ULONG
593WINAPI
595 INetCfg * iface)
596{
597 INetCfgImpl * This = (INetCfgImpl*)iface;
598 ULONG refCount = InterlockedDecrement(&This->ref);
599
600 if (!refCount)
601 {
603 }
604 return refCount;
605}
606
608WINAPI
610 INetCfg * iface,
611 PVOID pReserved)
612{
613 HRESULT hr;
614 INetCfgImpl *This = (INetCfgImpl *)iface;
615
616 if (This->bInitialized)
618
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}
640
641VOID
643 NetCfgComponentItem *pHead,
644 const CLSID * lpClassGUID,
645 BOOL bApply)
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));
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}
690
691VOID
693{
696 CoTaskMemFree(pItem->szId);
698 CoTaskMemFree(pItem->szNodeId);
700 CoTaskMemFree(pItem);
701}
702
704WINAPI
706 INetCfg * iface)
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}
750
751
753WINAPI
755 INetCfg * iface)
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}
769
771WINAPI
773 INetCfg * iface)
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}
786
788WINAPI
790 INetCfg * iface,
791 const GUID *pguidClass,
792 IEnumNetCfgComponent **ppenumComponent)
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}
810
811
813WINAPI
815 INetCfg * iface,
816 LPCWSTR pszwComponentId,
817 INetCfgComponent **pComponent)
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}
839
841WINAPI
843 INetCfg * iface,
844 const GUID *pguidClass,
845 REFIID riid,
846 void **ppvObject)
847{
848 return E_FAIL;
849}
850
851static const INetCfgVtbl vt_NetCfg =
852{
863};
864
866{
868
869 if (!ppv)
870 return E_POINTER;
871
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 InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
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:2533
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:4911
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4132
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1787
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3224
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
#define swprintf
Definition: precomp.h:40
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT WINAPI INetCfgComponent_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv, NetCfgComponentItem *pItem, INetCfg *pNCfg)
HRESULT WINAPI IEnumNetCfgComponent_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv, NetCfgComponentItem *pItem, INetCfg *pNCfg)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPOLESTR
Definition: stg_prop.c:27
ULONG WINAPI INetCfgLock_fnAddRef(INetCfgLock *iface)
Definition: netcfg_iface.c:42
static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
Definition: netcfg_iface.c:17
HRESULT WINAPI INetCfgPnpReconfigCallback_fnSendPnpReconfig(INetCfgPnpReconfigCallback *iface, NCPNP_RECONFIG_LAYER Layer, LPCWSTR pszwUpper, LPCWSTR pszwLower, PVOID pvData, DWORD dwSizeOfData)
Definition: netcfg_iface.c:204
HRESULT WINAPI INetCfg_fnApply(INetCfg *iface)
Definition: netcfg_iface.c:754
HRESULT EnumerateNetworkAdapter(NetCfgComponentItem **pHead)
Definition: netcfg_iface.c:405
static const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback
Definition: netcfg_iface.c:216
HRESULT FindNetworkComponent(NetCfgComponentItem *pHead, LPCWSTR pszwComponentId, INetCfgComponent **pComponent, INetCfg *iface)
Definition: netcfg_iface.c:521
ULONG WINAPI INetCfgPnpReconfigCallback_fnAddRef(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:185
HRESULT WINAPI INetCfg_fnCancel(INetCfg *iface)
Definition: netcfg_iface.c:772
HRESULT WINAPI INetCfg_fnEnumComponents(INetCfg *iface, const GUID *pguidClass, IEnumNetCfgComponent **ppenumComponent)
Definition: netcfg_iface.c:789
HRESULT WINAPI INetCfg_fnInitialize(INetCfg *iface, PVOID pReserved)
Definition: netcfg_iface.c:609
VOID ApplyOrCancelChanges(NetCfgComponentItem *pHead, const CLSID *lpClassGUID, BOOL bApply)
Definition: netcfg_iface.c:642
HRESULT WINAPI INetCfgLock_fnAcquireWriteLock(INetCfgLock *iface, DWORD cmsTimeout, LPCWSTR pszwClientDescription, LPWSTR *ppszwClientDescription)
Definition: netcfg_iface.c:61
struct INetCfgImpl * LPINetCfgImpl
static const INetCfgLockVtbl vt_NetCfgLock
Definition: netcfg_iface.c:158
HRESULT WINAPI INetCfgPnpReconfigCallback_fnQueryInterface(INetCfgPnpReconfigCallback *iface, REFIID iid, LPVOID *ppvObj)
Definition: netcfg_iface.c:174
HRESULT WINAPI INetCfg_fnUninitialize(INetCfg *iface)
Definition: netcfg_iface.c:705
HRESULT WINAPI INetCfgLock_fnReleaseWriteLock(INetCfgLock *iface)
Definition: netcfg_iface.c:110
ULONG WINAPI INetCfgLock_fnRelease(INetCfgLock *iface)
Definition: netcfg_iface.c:52
HRESULT EnumClientServiceProtocol(HKEY hKey, const GUID *pGuid, NetCfgComponentItem **pHead)
Definition: netcfg_iface.c:265
ULONG WINAPI INetCfgPnpReconfigCallback_fnRelease(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:195
HRESULT WINAPI INetCfgLock_fnIsWriteLocked(INetCfgLock *iface, LPWSTR *ppszwClientDescription)
Definition: netcfg_iface.c:127
HRESULT WINAPI INetCfg_fnQueryNetCfgClass(INetCfg *iface, const GUID *pguidClass, REFIID riid, void **ppvObject)
Definition: netcfg_iface.c:842
HRESULT WINAPI INetCfg_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
Definition: netcfg_iface.c:865
HRESULT EnumerateNetworkComponent(const GUID *pGuid, NetCfgComponentItem **pHead)
Definition: netcfg_iface.c:382
HRESULT WINAPI INetCfg_fnQueryInterface(INetCfg *iface, REFIID iid, LPVOID *ppvObj)
Definition: netcfg_iface.c:542
HRESULT ReadBindingString(NetCfgComponentItem *Item)
Definition: netcfg_iface.c:230
HRESULT WINAPI INetCfgLock_fnQueryInterface(INetCfgLock *iface, REFIID iid, LPVOID *ppvObj)
Definition: netcfg_iface.c:30
ULONG WINAPI INetCfg_fnRelease(INetCfg *iface)
Definition: netcfg_iface.c:594
static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback *iface)
Definition: netcfg_iface.c:22
HRESULT WINAPI INetCfg_fnFindComponent(INetCfg *iface, LPCWSTR pszwComponentId, INetCfgComponent **pComponent)
Definition: netcfg_iface.c:814
static const INetCfgVtbl vt_NetCfg
Definition: netcfg_iface.c:851
VOID FreeComponentItem(NetCfgComponentItem *pItem)
Definition: netcfg_iface.c:692
ULONG WINAPI INetCfg_fnAddRef(INetCfg *iface)
Definition: netcfg_iface.c:583
#define INetCfgComponentControl_ApplyRegistryChanges(p)
Definition: netcfgn.h:52
#define INetCfgComponentControl_CancelChanges(p)
Definition: netcfgn.h:54
EXTERN_C const IID IID_INetCfgPnpReconfigCallback
Definition: netcfgn.h:29
#define INetCfgPnpReconfigCallback_AddRef(p)
Definition: netcfgn.h:24
NCPNP_RECONFIG_LAYER
Definition: netcfgn.h:5
#define INetCfg_Release(p)
Definition: netcfgx.h:289
#define INetCfg_QueryInterface(p, a, b)
Definition: netcfgx.h:287
EXTERN_C const IID IID_INetCfgLock
Definition: netcfgx.h:17
EXTERN_C const IID IID_INetCfgComponent
Definition: netcfgx.h:77
#define INetCfgLock_AddRef(p)
Definition: netcfgx.h:22
#define INetCfg_AddRef(p)
Definition: netcfgx.h:288
#define NETCFG_E_NOT_INITIALIZED
Definition: netcfgx.h:303
EXTERN_C const IID IID_IEnumNetCfgComponent
Definition: netcfgx.h:266
EXTERN_C const IID IID_INetCfg
Definition: netcfgx.h:300
#define NETCFG_E_ALREADY_INITIALIZED
Definition: netcfgx.h:302
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define DWORD
Definition: nt_native.h:44
#define LPVOID
Definition: nt_native.h:45
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
static const WCHAR szName[]
Definition: powrprof.c:45
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SPDRP_DRIVER
Definition: setupapi.h:516
#define SPDRP_DEVICEDESC
Definition: setupapi.h:507
#define SetupDiGetClassDevs
Definition: setupapi.h:2593
#define DIGCF_PRESENT
Definition: setupapi.h:171
HRESULT hr
Definition: shlfolder.c:183
NetCfgComponentItem * pClient
Definition: netcfg_iface.c:13
BOOL bInitialized
Definition: netcfg_iface.c:9
const INetCfgLock * lpVtblLock
Definition: netcfg_iface.c:6
const INetCfgPnpReconfigCallback * lpVtblPnpReconfigCallback
Definition: netcfg_iface.c:7
HANDLE hMutex
Definition: netcfg_iface.c:10
NetCfgComponentItem * pService
Definition: netcfg_iface.c:12
const INetCfg * lpVtbl
Definition: netcfg_iface.c:5
NetCfgComponentItem * pProtocol
Definition: netcfg_iface.c:14
NetCfgComponentItem * pNet
Definition: netcfg_iface.c:11
Definition: xml2sdb.h:111
INetCfgComponentControl * pNCCC
Definition: precomp.h:52
struct tagNetCfgComponentItem * pNext
Definition: precomp.h:51
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define ZeroMemory
Definition: winbase.h:1712
#define CopyMemory
Definition: winbase.h:1710
#define WAIT_OBJECT_0
Definition: winbase.h:406
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
#define E_POINTER
Definition: winerror.h:2365
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185