ReactOS 0.4.15-dev-6657-ged9973f
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 374 of file connectmanager.cpp.

375{
376 return ShellObjectCreatorInit<CNetConnection>(pItem, riid, ppv);
377}
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by CNetConnectionManager::Next().

◆ CNetConnectionManager_CreateInstance()

HRESULT WINAPI CNetConnectionManager_CreateInstance ( REFIID  riid,
LPVOID ppv 
)

Definition at line 706 of file connectmanager.cpp.

707{
708#if USE_CUSTOM_CONMGR
709 return ShellObjectCreatorInit<CNetConnectionManager>(riid, ppv);
710#else
712#endif
713}
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
EXTERN_C const CLSID CLSID_ConnectionManager
Definition: netcon.h:172

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}
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3353
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4118
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
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define SPDRP_DRIVER
Definition: setupapi.h:516
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ZeroMemory
Definition: winbase.h:1700
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CNetConnection::Disconnect().

◆ GetAdapterIndexFromNetCfgInstanceId()

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

Definition at line 464 of file connectmanager.cpp.

465{
466 WCHAR szBuffer[50];
467 IP_ADAPTER_INFO * pCurrentAdapter;
468
469 pCurrentAdapter = pAdapterInfo;
470 while (pCurrentAdapter)
471 {
472 szBuffer[0] = L'\0';
473 if (MultiByteToWideChar(CP_ACP, 0, pCurrentAdapter->AdapterName, -1, szBuffer, sizeof(szBuffer)/sizeof(szBuffer[0])))
474 {
475 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
476 }
477 if (!_wcsicmp(szBuffer, szNetCfg))
478 {
479 *pIndex = pCurrentAdapter->Index;
480 return TRUE;
481 }
482 pCurrentAdapter = pCurrentAdapter->Next;
483 }
484 return FALSE;
485}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4565
char AdapterName[MAX_ADAPTER_NAME_LENGTH+4]
Definition: iptypes.h:55
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 488 of file connectmanager.cpp.

491{
492 switch (IfEntry->dwOperStatus)
493 {
496 break;
498 Props->Status = NCS_DISCONNECTED;
499 break;
502 break;
504 Props->Status = NCS_CONNECTING;
505 break;
507 Props->Status = NCS_CONNECTED;
508 break;
510 Props->Status = NCS_CONNECTED;
511 break;
512 default:
513 break;
514 }
515}
#define MIB_IF_OPER_STATUS_DISCONNECTED
Definition: ipifcons.h:248
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
#define MIB_IF_OPER_STATUS_CONNECTING
Definition: ipifcons.h:249
#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_OPERATIONAL
Definition: ipifcons.h:251
@ NCS_CONNECTING
Definition: netcon.h:40
@ NCS_MEDIA_DISCONNECTED
Definition: netcon.h:46
@ NCS_CONNECTED
Definition: netcon.h:41
@ NCS_DISCONNECTED
Definition: netcon.h:39
@ NCS_HARDWARE_DISABLED
Definition: netcon.h:44
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
NETCON_STATUS Status
Definition: netcon.h:86

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