ReactOS  0.4.15-dev-509-g96a357b
connectmanager.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Shell
3  * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE: CNetConnectionManager class
5  * COPYRIGHT: Copyright 2008 Johannes Anderwald (johannes.anderwald@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
11 
12 /***************************************************************
13  * INetConnection Interface
14  */
15 
16 HRESULT
17 WINAPI
19 {
20  m_Props = pItem->Props;
22 
23  if (pItem->Props.pszwName)
24  {
25  m_Props.pszwName = static_cast<PWSTR>(CoTaskMemAlloc((wcslen(pItem->Props.pszwName)+1)*sizeof(WCHAR)));
26  if (m_Props.pszwName)
28  }
29 
30  if (pItem->Props.pszwDeviceName)
31  {
32  m_Props.pszwDeviceName = static_cast<PWSTR>(CoTaskMemAlloc((wcslen(pItem->Props.pszwDeviceName)+1)*sizeof(WCHAR)));
35  }
36 
37  return S_OK;
38 }
39 
41 {
44 }
45 
46 HRESULT
47 WINAPI
49 {
50  return E_NOTIMPL;
51 }
52 
53 BOOL
55 {
56  DWORD dwIndex, dwSize;
57  HKEY hSubKey;
58  WCHAR szNetCfg[50];
59  WCHAR szDetail[200] = L"SYSTEM\\CurrentControlSet\\Control\\Class\\";
60 
61  dwIndex = 0;
62  do
63  {
64  ZeroMemory(pDevInfo, sizeof(SP_DEVINFO_DATA));
65  pDevInfo->cbSize = sizeof(SP_DEVINFO_DATA);
66 
67  /* get device info */
68  if (!SetupDiEnumDeviceInfo(hInfo, dwIndex++, pDevInfo))
69  break;
70 
71  /* get device software registry path */
72  if (!SetupDiGetDeviceRegistryPropertyW(hInfo, pDevInfo, SPDRP_DRIVER, NULL, (LPBYTE)&szDetail[39], sizeof(szDetail)/sizeof(WCHAR) - 40, &dwSize))
73  break;
74 
75  /* open device registry key */
76  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szDetail, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS)
77  break;
78 
79  /* query NetCfgInstanceId for current device */
80  dwSize = sizeof(szNetCfg);
81  if (RegQueryValueExW(hSubKey, L"NetCfgInstanceId", NULL, NULL, (LPBYTE)szNetCfg, &dwSize) != ERROR_SUCCESS)
82  {
83  RegCloseKey(hSubKey);
84  break;
85  }
86  RegCloseKey(hSubKey);
87  if (!_wcsicmp(pGuid, szNetCfg))
88  {
89  return TRUE;
90  }
91  } while (TRUE);
92 
93  return FALSE;
94 }
95 
96 HRESULT
97 WINAPI
99 {
100  HKEY hKey;
101  NETCON_PROPERTIES * pProperties;
102  LPOLESTR pDisplayName;
103  WCHAR szPath[200];
104  DWORD dwSize, dwType;
105  LPWSTR pPnp;
106  HDEVINFO hInfo;
107  SP_DEVINFO_DATA DevInfo;
108  SP_PROPCHANGE_PARAMS PropChangeParams;
109  HRESULT hr;
110 
111  hr = GetProperties(&pProperties);
112  if (FAILED_UNEXPECTEDLY(hr))
113  return hr;
114 
115  hInfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT );
116  if (!hInfo)
117  {
118  NcFreeNetconProperties(pProperties);
119  return E_FAIL;
120  }
121 
122  if (FAILED(StringFromCLSID((CLSID)pProperties->guidId, &pDisplayName)))
123  {
124  NcFreeNetconProperties(pProperties);
126  return E_FAIL;
127  }
128  NcFreeNetconProperties(pProperties);
129 
130  if (FindNetworkAdapter(hInfo, &DevInfo, pDisplayName))
131  {
132  PropChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
134  PropChangeParams.StateChange = DICS_DISABLE;
135  PropChangeParams.Scope = DICS_FLAG_CONFIGSPECIFIC;
136  PropChangeParams.HwProfile = 0;
137 
138  if (SetupDiSetClassInstallParams(hInfo, &DevInfo, &PropChangeParams.ClassInstallHeader, sizeof(SP_PROPCHANGE_PARAMS)))
139  {
141  }
142  }
144 
145  swprintf(szPath, L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", pDisplayName);
146  CoTaskMemFree(pDisplayName);
147 
149  return E_FAIL;
150 
151  dwSize = 0;
152  if (RegQueryValueExW(hKey, L"PnpInstanceID", NULL, &dwType, NULL, &dwSize) != ERROR_SUCCESS || dwType != REG_SZ)
153  {
154  RegCloseKey(hKey);
155  return E_FAIL;
156  }
157 
158  pPnp = static_cast<PWSTR>(CoTaskMemAlloc(dwSize));
159  if (!pPnp)
160  {
161  RegCloseKey(hKey);
162  return E_FAIL;
163  }
164 
165  if (RegQueryValueExW(hKey, L"PnpInstanceID", NULL, &dwType, (LPBYTE)pPnp, &dwSize) != ERROR_SUCCESS)
166  {
167  CoTaskMemFree(pPnp);
168  RegCloseKey(hKey);
169  return E_FAIL;
170  }
171  RegCloseKey(hKey);
172 
173  swprintf(szPath, L"System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Enum\\%s", pPnp);
174  CoTaskMemFree(pPnp);
175 
177  return E_FAIL;
178 
179  dwSize = 1; /* enable = 0, disable = 1 */
180  RegSetValueExW(hKey, L"CSConfigFlags", 0, REG_DWORD, (LPBYTE)&dwSize, sizeof(DWORD));
181  RegCloseKey(hKey);
182 
183  return S_OK;
184 }
185 
186 HRESULT
187 WINAPI
189 {
190  return E_NOTIMPL;
191 }
192 
193 HRESULT
194 WINAPI
196  LPCWSTR pszwDuplicateName,
197  INetConnection **ppCon)
198 {
199  return E_NOTIMPL;
200 }
201 
202 HRESULT
203 WINAPI
205 {
206  MIB_IFROW IfEntry;
207  HKEY hKey;
208  LPOLESTR pStr;
209  WCHAR szName[140];
210  DWORD dwShowIcon, dwNotifyDisconnect, dwType, dwSize;
211  NETCON_PROPERTIES * pProperties;
212  HRESULT hr;
213 
214  if (!ppProps)
215  return E_POINTER;
216 
217  pProperties = static_cast<NETCON_PROPERTIES*>(CoTaskMemAlloc(sizeof(NETCON_PROPERTIES)));
218  if (!pProperties)
219  return E_OUTOFMEMORY;
220 
221  CopyMemory(pProperties, &m_Props, sizeof(NETCON_PROPERTIES));
222  pProperties->pszwName = NULL;
223 
225  {
226  pProperties->pszwDeviceName = static_cast<LPWSTR>(CoTaskMemAlloc((wcslen(m_Props.pszwDeviceName)+1)*sizeof(WCHAR)));
227  if (pProperties->pszwDeviceName)
229  }
230 
231  *ppProps = pProperties;
232 
233  /* get updated adapter characteristics */
234  ZeroMemory(&IfEntry, sizeof(IfEntry));
235  IfEntry.dwIndex = m_dwAdapterIndex;
236  if (GetIfEntry(&IfEntry) != NO_ERROR)
237  return NOERROR;
238 
239  NormalizeOperStatus(&IfEntry, pProperties);
240 
241 
243  if (SUCCEEDED(hr))
244  {
245  wcscpy(szName, L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\");
246  wcscat(szName, pStr);
247  wcscat(szName, L"\\Connection");
248 
250  {
251  dwSize = sizeof(dwShowIcon);
252  if (RegQueryValueExW(hKey, L"ShowIcon", NULL, &dwType, (LPBYTE)&dwShowIcon, &dwSize) == ERROR_SUCCESS && dwType == REG_DWORD)
253  {
254  if (dwShowIcon)
255  pProperties->dwCharacter |= NCCF_SHOW_ICON;
256  else
257  pProperties->dwCharacter &= ~NCCF_SHOW_ICON;
258  }
259 
260  dwSize = sizeof(dwNotifyDisconnect);
261  if (RegQueryValueExW(hKey, L"IpCheckingEnabled", NULL, &dwType, (LPBYTE)&dwNotifyDisconnect, &dwSize) == ERROR_SUCCESS && dwType == REG_DWORD)
262  {
263  if (dwNotifyDisconnect)
264  pProperties->dwCharacter |= NCCF_NOTIFY_DISCONNECTED;
265  else
266  pProperties->dwCharacter &= ~NCCF_NOTIFY_DISCONNECTED;
267  }
268 
269  dwSize = sizeof(szName);
270  if (RegQueryValueExW(hKey, L"Name", NULL, &dwType, (LPBYTE)szName, &dwSize) == ERROR_SUCCESS)
271  {
272  /* use updated name */
273  dwSize = wcslen(szName) + 1;
274  pProperties->pszwName = static_cast<PWSTR>(CoTaskMemAlloc(dwSize * sizeof(WCHAR)));
275  if (pProperties->pszwName)
276  CopyMemory(pProperties->pszwName, szName, dwSize * sizeof(WCHAR));
277  }
278  else
279  {
280  /* use cached name */
281  if (m_Props.pszwName)
282  {
283  pProperties->pszwName = static_cast<PWSTR>(CoTaskMemAlloc((wcslen(m_Props.pszwName)+1)*sizeof(WCHAR)));
284  if (pProperties->pszwName)
285  wcscpy(pProperties->pszwName, m_Props.pszwName);
286  }
287  }
288  RegCloseKey(hKey);
289  }
290  CoTaskMemFree(pStr);
291  }
292 
293  /* Enable 'Rename' and 'Delete' for Adminstrators only */
294  if (IsUserAdmin())
295  {
296  pProperties->dwCharacter |= NCCF_ALLOW_RENAME;
297 
298  /* Virtual network interfaces can be deleted */
299  if (IfEntry.dwType == IF_TYPE_TUNNEL)
300  {
301  pProperties->dwCharacter |= NCCF_ALLOW_REMOVAL;
302  }
303  }
304  else
305  {
306  pProperties->dwCharacter &= ~(NCCF_ALLOW_RENAME | NCCF_ALLOW_REMOVAL);
307  }
308 
309  return S_OK;
310 }
311 
312 HRESULT
313 WINAPI
315 {
316  if (m_Props.MediaType == NCM_LAN)
317  {
318  CopyMemory(pclsid, &CLSID_LanConnectionUi, sizeof(CLSID));
319  return S_OK;
320  }
321 
322  return E_NOTIMPL;
323 }
324 
325 HRESULT
326 WINAPI
327 CNetConnection::Rename(LPCWSTR pszwDuplicateName)
328 {
329  WCHAR szName[140];
330  LPOLESTR pStr;
331  DWORD dwSize;
332  HKEY hKey;
333  HRESULT hr;
334 
335  if (pszwDuplicateName == NULL || wcslen(pszwDuplicateName) == 0)
336  return S_OK;
337 
338  if (m_Props.pszwName)
339  {
342  }
343 
344  dwSize = (wcslen(pszwDuplicateName) + 1) * sizeof(WCHAR);
345  m_Props.pszwName = static_cast<PWSTR>(CoTaskMemAlloc(dwSize));
346  if (m_Props.pszwName == NULL)
347  return E_OUTOFMEMORY;
348 
349  wcscpy(m_Props.pszwName, pszwDuplicateName);
350 
352  if (SUCCEEDED(hr))
353  {
354  wcscpy(szName, L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\");
355  wcscat(szName, pStr);
356  wcscat(szName, L"\\Connection");
357 
359  {
361  RegCloseKey(hKey);
362  }
363 
364  CoTaskMemFree(pStr);
365  }
366 
367  return hr;
368 }
369 
371 {
372  return ShellObjectCreatorInit<CNetConnection>(pItem, riid, ppv);
373 }
374 
375 
376 
378  m_pHead(NULL),
379  m_pCurrent(NULL)
380 {
381 }
382 
383 HRESULT
384 WINAPI
387  IEnumNetConnection **ppEnum)
388 {
389  TRACE("EnumConnections\n");
390 
391  if (!ppEnum)
392  return E_POINTER;
393 
394  if (Flags != NCME_DEFAULT)
395  return E_FAIL;
396 
397  *ppEnum = static_cast<IEnumNetConnection*>(this);
398  AddRef();
399  return S_OK;
400 }
401 
402 /***************************************************************
403  * IEnumNetConnection Interface
404  */
405 
406 HRESULT
407 WINAPI
409  ULONG celt,
410  INetConnection **rgelt,
411  ULONG *pceltFetched)
412 {
413  HRESULT hr;
414 
415  if (!pceltFetched || !rgelt)
416  return E_POINTER;
417 
418  if (celt != 1)
419  return E_FAIL;
420 
421  if (!m_pCurrent)
422  return S_FALSE;
423 
426 
427  return hr;
428 }
429 
430 HRESULT
431 WINAPI
433 {
434  while (m_pCurrent && celt-- > 0)
436 
437  if (celt)
438  return S_FALSE;
439  else
440  return S_OK;
441 
442 }
443 
444 HRESULT
445 WINAPI
447 {
449  return S_OK;
450 }
451 
452 HRESULT
453 WINAPI
454 CNetConnectionManager::Clone(IEnumNetConnection **ppenum)
455 {
456  return E_NOTIMPL;
457 }
458 
459 BOOL
461 {
462  WCHAR szBuffer[50];
463  IP_ADAPTER_INFO * pCurrentAdapter;
464 
465  pCurrentAdapter = pAdapterInfo;
466  while (pCurrentAdapter)
467  {
468  szBuffer[0] = L'\0';
469  if (MultiByteToWideChar(CP_ACP, 0, pCurrentAdapter->AdapterName, -1, szBuffer, sizeof(szBuffer)/sizeof(szBuffer[0])))
470  {
471  szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
472  }
473  if (!_wcsicmp(szBuffer, szNetCfg))
474  {
475  *pIndex = pCurrentAdapter->Index;
476  return TRUE;
477  }
478  pCurrentAdapter = pCurrentAdapter->Next;
479  }
480  return FALSE;
481 }
482 
483 VOID
485  MIB_IFROW *IfEntry,
486  NETCON_PROPERTIES * Props)
487 {
488  switch (IfEntry->dwOperStatus)
489  {
491  Props->Status = NCS_HARDWARE_DISABLED;
492  break;
494  Props->Status = NCS_DISCONNECTED;
495  break;
498  break;
500  Props->Status = NCS_CONNECTING;
501  break;
503  Props->Status = NCS_CONNECTED;
504  break;
506  Props->Status = NCS_CONNECTED;
507  break;
508  default:
509  break;
510  }
511 }
512 
513 HRESULT
515 {
516  DWORD dwSize, dwResult, dwIndex, dwAdapterIndex, dwShowIcon, dwNotifyDisconnect;
517  MIB_IFTABLE *pIfTable;
518  MIB_IFROW IfEntry;
519  IP_ADAPTER_INFO * pAdapterInfo;
520  HDEVINFO hInfo;
521  SP_DEVINFO_DATA DevInfo;
522  HKEY hSubKey;
523  WCHAR szNetCfg[50];
524  WCHAR szAdapterNetCfg[50];
525  WCHAR szDetail[200] = L"SYSTEM\\CurrentControlSet\\Control\\Class\\";
526  WCHAR szName[130] = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
527  PINetConnectionItem pCurrent = NULL;
528 
529  /* get the IfTable */
530  dwSize = 0;
532  return E_FAIL;
533 
534  pIfTable = static_cast<PMIB_IFTABLE>(CoTaskMemAlloc(dwSize));
535  if (!pIfTable)
536  return E_OUTOFMEMORY;
537 
538  dwResult = GetIfTable(pIfTable, &dwSize, TRUE);
539  if (dwResult != NO_ERROR)
540  {
541  CoTaskMemFree(pIfTable);
542  return HRESULT_FROM_WIN32(dwResult);
543  }
544 
545  dwSize = 0;
546  dwResult = GetAdaptersInfo(NULL, &dwSize);
547  if (dwResult!= ERROR_BUFFER_OVERFLOW)
548  {
549  CoTaskMemFree(pIfTable);
550  return HRESULT_FROM_WIN32(dwResult);
551  }
552 
553  pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
554  if (!pAdapterInfo)
555  {
556  CoTaskMemFree(pIfTable);
557  return E_OUTOFMEMORY;
558  }
559 
560  dwResult = GetAdaptersInfo(pAdapterInfo, &dwSize);
561  if (dwResult != NO_ERROR)
562  {
563  CoTaskMemFree(pIfTable);
564  CoTaskMemFree(pAdapterInfo);
565  return HRESULT_FROM_WIN32(dwResult);
566  }
567 
568  hInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT );
569  if (!hInfo)
570  {
571  CoTaskMemFree(pIfTable);
572  CoTaskMemFree(pAdapterInfo);
573  return E_FAIL;
574  }
575 
576  dwIndex = 0;
577  do
578  {
579  ZeroMemory(&DevInfo, sizeof(SP_DEVINFO_DATA));
580  DevInfo.cbSize = sizeof(DevInfo);
581 
582  /* get device info */
583  if (!SetupDiEnumDeviceInfo(hInfo, dwIndex++, &DevInfo))
584  break;
585 
586  /* get device software registry path */
587  if (!SetupDiGetDeviceRegistryPropertyW(hInfo, &DevInfo, SPDRP_DRIVER, NULL, (LPBYTE)&szDetail[39], sizeof(szDetail)/sizeof(WCHAR) - 40, &dwSize))
588  break;
589 
590  /* open device registry key */
591  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szDetail, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS)
592  break;
593 
594  /* query NetCfgInstanceId for current device */
595  dwSize = sizeof(szNetCfg);
596  if (RegQueryValueExW(hSubKey, L"NetCfgInstanceId", NULL, NULL, (LPBYTE)szNetCfg, &dwSize) != ERROR_SUCCESS)
597  {
598  RegCloseKey(hSubKey);
599  break;
600  }
601  RegCloseKey(hSubKey);
602 
603  /* get the current adapter index from NetCfgInstanceId */
604  if (!GetAdapterIndexFromNetCfgInstanceId(pAdapterInfo, szNetCfg, &dwAdapterIndex))
605  continue;
606 
607  /* get detailed adapter info */
608  ZeroMemory(&IfEntry, sizeof(IfEntry));
609  IfEntry.dwIndex = dwAdapterIndex;
610  if (GetIfEntry(&IfEntry) != NO_ERROR)
611  break;
612 
613  /* allocate new INetConnectionItem */
614  PINetConnectionItem pNew = static_cast<PINetConnectionItem>(CoTaskMemAlloc(sizeof(INetConnectionItem)));
615  if (!pNew)
616  break;
617 
618  ZeroMemory(pNew, sizeof(INetConnectionItem));
619  pNew->dwAdapterIndex = dwAdapterIndex;
620  /* store NetCfgInstanceId */
621  CLSIDFromString(szNetCfg, &pNew->Props.guidId);
622  NormalizeOperStatus(&IfEntry, &pNew->Props);
623 
624  switch (IfEntry.dwType)
625  {
627  pNew->Props.MediaType = NCM_LAN;
628  break;
629  case IF_TYPE_IEEE80211:
631  break;
632  default:
633  break;
634  }
635  /* open network connections details */
636  wcscpy(&szName[80], szNetCfg);
637  wcscpy(&szName[118], L"\\Connection");
638 
640  {
641  /* retrieve name of connection */
642  dwSize = sizeof(szAdapterNetCfg);
643  if (RegQueryValueExW(hSubKey, L"Name", NULL, NULL, (LPBYTE)szAdapterNetCfg, &dwSize) == ERROR_SUCCESS)
644  {
645  pNew->Props.pszwName = static_cast<PWSTR>(CoTaskMemAlloc((wcslen(szAdapterNetCfg)+1) * sizeof(WCHAR)));
646  if (pNew->Props.pszwName)
647  wcscpy(pNew->Props.pszwName, szAdapterNetCfg);
648  }
649  dwSize = sizeof(dwShowIcon);
650  if (RegQueryValueExW(hSubKey, L"ShowIcon", NULL, NULL, (LPBYTE)&dwShowIcon, &dwSize) == ERROR_SUCCESS)
651  {
652  if (dwShowIcon)
654  }
655  dwSize = sizeof(dwNotifyDisconnect);
656  if (RegQueryValueExW(hSubKey, L"IpCheckingEnabled", NULL, NULL, (LPBYTE)&dwNotifyDisconnect, &dwSize) == ERROR_SUCCESS)
657  {
658  if (dwNotifyDisconnect)
660  }
661  RegCloseKey(hSubKey);
662  }
663 
664  /* Get the adapter device description */
665  dwSize = 0;
667  if (dwSize != 0)
668  {
669  pNew->Props.pszwDeviceName = static_cast<PWSTR>(CoTaskMemAlloc(dwSize));
670  if (pNew->Props.pszwDeviceName)
672  }
673 
674  if (pCurrent)
675  pCurrent->Next = pNew;
676  else
677  m_pHead = pNew;
678 
679  pCurrent = pNew;
680  } while (TRUE);
681 
682  CoTaskMemFree(pIfTable);
683  CoTaskMemFree(pAdapterInfo);
685 
687  return (m_pHead != NULL ? S_OK : S_FALSE);
688 }
689 
691 {
693  if (FAILED_UNEXPECTEDLY(hr))
694  {
695  /* If something went wrong during the enumeration print an error don't enumerate anything */
696  m_pCurrent = m_pHead = NULL;
697  return S_FALSE;
698  }
699  return S_OK;
700 }
701 
703 {
704 #if USE_CUSTOM_CONMGR
705  return ShellObjectCreatorInit<CNetConnectionManager>(riid, ppv);
706 #else
707  return CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_ALL, riid, ppv);
708 #endif
709 }
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1792
virtual HRESULT WINAPI EnumConnections(NETCONMGR_ENUM_FLAGS Flags, IEnumNetConnection **ppEnum)
BOOL GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetCfg, PDWORD pIndex)
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
virtual HRESULT WINAPI Reset()
LPWSTR pszwDeviceName
Definition: netcon.h:85
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT EnumerateINetConnections()
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
DWORD dwType
Definition: ifmib.h:39
#define NOERROR
Definition: winerror.h:2354
#define IF_TYPE_TUNNEL
Definition: ipifcons.h:151
BOOL FindNetworkAdapter(HDEVINFO hInfo, SP_DEVINFO_DATA *pDevInfo, LPWSTR pGuid)
HDEVINFO WINAPI SetupDiGetClassDevsW(CONST GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
Definition: devinst.c:2297
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
REFIID riid
Definition: precomp.h:44
#define CP_ACP
Definition: compat.h:99
REFIID LPVOID * ppv
Definition: atlbase.h:39
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:1648
HRESULT WINAPI Delete()
BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4029
PINetConnectionItem m_pCurrent
#define DIF_PROPERTYCHANGE
Definition: setupapi.h:137
HRESULT WINAPI Initialize(PINetConnectionItem pItem)
static LPOLESTR
Definition: stg_prop.c:27
DWORD m_dwAdapterIndex
#define NO_ERROR
Definition: dderror.h:5
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
#define MIB_IF_OPER_STATUS_DISCONNECTED
Definition: ipifcons.h:248
PINetConnectionItem m_pHead
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
EXTERN_C const CLSID CLSID_ConnectionManager
Definition: netcon.h:172
char AdapterName[MAX_ADAPTER_NAME_LENGTH+4]
Definition: iptypes.h:55
DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
#define MIB_IF_OPER_STATUS_NON_OPERATIONAL
Definition: ipifcons.h:246
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DICS_DISABLE
Definition: setupapi.h:114
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
#define S_FALSE
Definition: winerror.h:2357
#define NCCF_NOTIFY_DISCONNECTED
Definition: precomp.h:76
smooth NULL
Definition: ftsmooth.c:416
#define IF_TYPE_IEEE80211
Definition: ipifcons.h:91
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
#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
SP_CLASSINSTALL_HEADER ClassInstallHeader
Definition: setupapi.h:911
HRESULT WINAPI Rename(LPCWSTR pszwDuplicateName)
#define TRACE(s)
Definition: solgame.cpp:4
#define MIB_IF_OPER_STATUS_UNREACHABLE
Definition: ipifcons.h:247
#define MIB_IF_OPER_STATUS_CONNECTING
Definition: ipifcons.h:249
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:78
#define DICS_FLAG_CONFIGSPECIFIC
Definition: setupapi.h:115
HRESULT WINAPI Disconnect()
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:6
#define CopyMemory
Definition: winbase.h:1646
Definition: netcon.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID NormalizeOperStatus(MIB_IFROW *IfEntry, NETCON_PROPERTIES *Props)
HRESULT WINAPI GetUiObjectClassId(CLSID *pclsid)
NETCON_PROPERTIES Props
Definition: connectmanager.h:6
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
NETCONMGR_ENUM_FLAGS
Definition: netcon.h:8
static const WCHAR L[]
Definition: oid.c:1250
#define SetupDiGetClassDevs
Definition: setupapi.h:2588
#define SPDRP_DEVICEDESC
Definition: setupapi.h:502
virtual HRESULT WINAPI Clone(IEnumNetConnection **ppenum)
struct tagINetConnectionItem * Next
Definition: connectmanager.h:4
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:59
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4564
#define IF_TYPE_ETHERNET_CSMACD
Definition: ipifcons.h:26
LPCWSTR szPath
Definition: env.c:35
HRESULT WINAPI CNetConnectionManager_CreateInstance(REFIID riid, LPVOID *ppv)
HRESULT WINAPI CNetConnection_CreateInstance(PINetConnectionItem pItem, REFIID riid, LPVOID *ppv)
#define E_NOTIMPL
Definition: ddrawi.h:99
NETCON_MEDIATYPE MediaType
Definition: netcon.h:87
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
DWORD * PDWORD
Definition: pedump.c:68
#define MultiByteToWideChar
Definition: compat.h:100
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
struct _SP_CLASSINSTALL_HEADER SP_CLASSINSTALL_HEADER
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
static const WCHAR szName[]
Definition: msipriv.h:1194
HRESULT WINAPI Connect()
NETCON_STATUS Status
Definition: netcon.h:86
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
NETCON_PROPERTIES m_Props
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
virtual HRESULT WINAPI Next(ULONG celt, INetConnection **rgelt, ULONG *pceltFetched)
DWORD dwIndex
Definition: ifmib.h:38
virtual HRESULT WINAPI Skip(ULONG celt)
#define SetupDiSetClassInstallParams
Definition: setupapi.h:2612
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
HRESULT WINAPI GetProperties(NETCON_PROPERTIES **ppProps)
HRESULT WINAPI Duplicate(LPCWSTR pszwDuplicateName, INetConnection **ppCon)
#define REG_DWORD
Definition: sdbapi.c:596
#define MIB_IF_OPER_STATUS_OPERATIONAL
Definition: ipifcons.h:251
BYTE * PBYTE
Definition: pedump.c:66
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
DI_FUNCTION InstallFunction
Definition: setupapi.h:899
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define DIGCF_PRESENT
Definition: setupapi.h:171
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define SPDRP_DRIVER
Definition: setupapi.h:511
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22