ReactOS  0.4.14-dev-98-gb0d4763
connectmanager.cpp File Reference
#include "precomp.h"
Include dependency graph for connectmanager.cpp:

Go to the source code of this file.

Functions

VOID NormalizeOperStatus (MIB_IFROW *IfEntry, NETCON_PROPERTIES *Props)
 
BOOL FindNetworkAdapter (HDEVINFO hInfo, SP_DEVINFO_DATA *pDevInfo, LPWSTR pGuid)
 
HRESULT WINAPI CNetConnection_CreateInstance (PINetConnectionItem pItem, REFIID riid, LPVOID *ppv)
 
BOOL GetAdapterIndexFromNetCfgInstanceId (PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetCfg, PDWORD pIndex)
 
HRESULT WINAPI CNetConnectionManager_CreateInstance (REFIID riid, LPVOID *ppv)
 

Function Documentation

◆ CNetConnection_CreateInstance()

HRESULT WINAPI CNetConnection_CreateInstance ( PINetConnectionItem  pItem,
REFIID  riid,
LPVOID ppv 
)

Definition at line 364 of file connectmanager.cpp.

365 {
366  return ShellObjectCreatorInit<CNetConnection>(pItem, riid, ppv);
367 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by CNetConnectionManager::Next().

◆ CNetConnectionManager_CreateInstance()

HRESULT WINAPI CNetConnectionManager_CreateInstance ( REFIID  riid,
LPVOID ppv 
)

Definition at line 696 of file connectmanager.cpp.

697 {
698 #if USE_CUSTOM_CONMGR
699  return ShellObjectCreatorInit<CNetConnectionManager>(riid, ppv);
700 #else
701  return CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_ALL, riid, ppv);
702 #endif
703 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
EXTERN_C const CLSID CLSID_ConnectionManager
Definition: netcon.h:172
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234

Referenced by ILGetConnection(), CEnumIDList::Initialize(), and CLanStatus::InitializeNetTaskbarNotifications().

◆ FindNetworkAdapter()

BOOL FindNetworkAdapter ( HDEVINFO  hInfo,
SP_DEVINFO_DATA pDevInfo,
LPWSTR  pGuid 
)

Definition at line 54 of file connectmanager.cpp.

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 }
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 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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
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
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
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)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define SPDRP_DRIVER
Definition: setupapi.h:511

Referenced by CNetConnection::Disconnect().

◆ GetAdapterIndexFromNetCfgInstanceId()

BOOL GetAdapterIndexFromNetCfgInstanceId ( PIP_ADAPTER_INFO  pAdapterInfo,
LPWSTR  szNetCfg,
PDWORD  pIndex 
)

Definition at line 454 of file connectmanager.cpp.

455 {
456  WCHAR szBuffer[50];
457  IP_ADAPTER_INFO * pCurrentAdapter;
458 
459  pCurrentAdapter = pAdapterInfo;
460  while (pCurrentAdapter)
461  {
462  szBuffer[0] = L'\0';
463  if (MultiByteToWideChar(CP_ACP, 0, pCurrentAdapter->AdapterName, -1, szBuffer, sizeof(szBuffer)/sizeof(szBuffer[0])))
464  {
465  szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
466  }
467  if (!_wcsicmp(szBuffer, szNetCfg))
468  {
469  *pIndex = pCurrentAdapter->Index;
470  return TRUE;
471  }
472  pCurrentAdapter = pCurrentAdapter->Next;
473  }
474  return FALSE;
475 }
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:99
char AdapterName[MAX_ADAPTER_NAME_LENGTH+4]
Definition: iptypes.h:55
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4564
#define MultiByteToWideChar
Definition: compat.h:100
_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

Referenced by CNetConnectionManager::EnumerateINetConnections(), and InitializePropertyDialog().

◆ NormalizeOperStatus()

VOID NormalizeOperStatus ( MIB_IFROW IfEntry,
NETCON_PROPERTIES Props 
)

Definition at line 478 of file connectmanager.cpp.

481 {
482  switch (IfEntry->dwOperStatus)
483  {
485  Props->Status = NCS_HARDWARE_DISABLED;
486  break;
488  Props->Status = NCS_DISCONNECTED;
489  break;
492  break;
494  Props->Status = NCS_CONNECTING;
495  break;
497  Props->Status = NCS_CONNECTED;
498  break;
500  Props->Status = NCS_CONNECTED;
501  break;
502  default:
503  break;
504  }
505 }
#define MIB_IF_OPER_STATUS_DISCONNECTED
Definition: ipifcons.h:248
#define MIB_IF_OPER_STATUS_NON_OPERATIONAL
Definition: ipifcons.h:246
#define MIB_IF_OPER_STATUS_UNREACHABLE
Definition: ipifcons.h:247
#define MIB_IF_OPER_STATUS_CONNECTING
Definition: ipifcons.h:249
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
NETCON_STATUS Status
Definition: netcon.h:86
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
#define MIB_IF_OPER_STATUS_OPERATIONAL
Definition: ipifcons.h:251

Referenced by CNetConnectionManager::EnumerateINetConnections(), and CNetConnection::GetProperties().