mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Handle NULL pointer in INetCfgComponent::GetDisplayName and INetCfgComponent_GetHelpText
- Initialize to zero NetCfgComponentItem - Dont fail if subkey is not a guid (required because ReactOS TCP/IP guid is not yet generated) - Fix enumeration of network components - Register CNetCfg class svn path=/trunk/; revision=36080
This commit is contained in:
parent
fd6ffc2459
commit
ff228503bf
6 changed files with 73 additions and 31 deletions
|
@ -69,16 +69,26 @@ INetCfgComponent_fnGetDisplayName(
|
|||
LPWSTR * ppszwDisplayName)
|
||||
{
|
||||
LPWSTR szName;
|
||||
UINT Length;
|
||||
INetCfgComponentImpl * This = (INetCfgComponentImpl*)iface;
|
||||
|
||||
if (This == NULL || ppszwDisplayName == NULL)
|
||||
return E_POINTER;
|
||||
|
||||
szName = CoTaskMemAlloc((wcslen(This->pItem->szDisplayName)+1) * sizeof(WCHAR));
|
||||
if (This->pItem->szDisplayName)
|
||||
Length = wcslen(This->pItem->szDisplayName)+1;
|
||||
else
|
||||
Length = 1;
|
||||
|
||||
szName = CoTaskMemAlloc(Length * sizeof(WCHAR));
|
||||
if (!szName)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
wcscpy(szName, This->pItem->szDisplayName);
|
||||
if (Length > 1)
|
||||
wcscpy(szName, This->pItem->szDisplayName);
|
||||
else
|
||||
szName[0] = L'\0';
|
||||
|
||||
*ppszwDisplayName = szName;
|
||||
|
||||
return S_OK;
|
||||
|
@ -123,16 +133,26 @@ INetCfgComponent_fnGetHelpText(
|
|||
LPWSTR * ppszwHelpText)
|
||||
{
|
||||
LPWSTR szHelp;
|
||||
UINT Length;
|
||||
INetCfgComponentImpl * This = (INetCfgComponentImpl*)iface;
|
||||
|
||||
if (This == NULL || ppszwHelpText == NULL)
|
||||
return E_POINTER;
|
||||
|
||||
szHelp = CoTaskMemAlloc((wcslen(This->pItem->szHelpText)+1) * sizeof(WCHAR));
|
||||
if (This->pItem->szHelpText)
|
||||
Length = wcslen(This->pItem->szHelpText)+1;
|
||||
else
|
||||
Length = 1;
|
||||
|
||||
szHelp = CoTaskMemAlloc(Length * sizeof(WCHAR));
|
||||
if (!szHelp)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
wcscpy(szHelp, This->pItem->szHelpText);
|
||||
if (Length > 1)
|
||||
wcscpy(szHelp, This->pItem->szHelpText);
|
||||
else
|
||||
szHelp[0] = L'\0';
|
||||
|
||||
*ppszwHelpText = szHelp;
|
||||
|
||||
return S_OK;
|
||||
|
|
|
@ -178,7 +178,6 @@ EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem **
|
|||
NetCfgComponentItem * pLast = NULL, *pCurrent;
|
||||
|
||||
*pHead = NULL;
|
||||
|
||||
do
|
||||
{
|
||||
dwCharacteristics = 0;
|
||||
|
@ -191,29 +190,25 @@ EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem **
|
|||
if (!pCurrent)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
pCurrent->bChanged = FALSE;
|
||||
pCurrent->pNext = NULL;
|
||||
pCurrent->Status = 0; /* unused */
|
||||
pCurrent->szNodeId = 0; /* unused */
|
||||
ZeroMemory(pCurrent, sizeof(NetCfgComponentItem));
|
||||
CopyMemory(&pCurrent->ClassGUID, pGuid, sizeof(GUID));
|
||||
|
||||
if (FAILED(CLSIDFromString(szName, &pCurrent->InstanceId)))
|
||||
{
|
||||
CoTaskMemFree(pCurrent);
|
||||
return E_FAIL;
|
||||
/// ReactOS tcpip guid is not yet generated
|
||||
//CoTaskMemFree(pCurrent);
|
||||
//return E_FAIL;
|
||||
}
|
||||
|
||||
if (RegOpenKeyExW(hKey, szName, 0, KEY_READ, &hSubKey) == ERROR_SUCCESS)
|
||||
{
|
||||
/* retrieve Characteristics */
|
||||
dwSize = sizeof(DWORD);
|
||||
pCurrent->dwCharacteristics = 0;
|
||||
|
||||
RegQueryValueExW(hSubKey, L"Characteristics", NULL, &dwType, (LPBYTE)&pCurrent->dwCharacteristics, &dwSize);
|
||||
if (dwType != REG_DWORD)
|
||||
pCurrent->dwCharacteristics = 0;
|
||||
|
||||
/* retrieve ComponentId */
|
||||
pCurrent->szId = NULL;
|
||||
dwSize = sizeof(szText);
|
||||
if (RegQueryValueExW(hSubKey, L"ComponentId", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -227,7 +222,6 @@ EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem **
|
|||
}
|
||||
|
||||
/* retrieve Description */
|
||||
pCurrent->szDisplayName = NULL;
|
||||
dwSize = sizeof(szText);
|
||||
if (RegQueryValueExW(hSubKey, L"Description", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -243,7 +237,6 @@ EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem **
|
|||
if (RegOpenKeyExW(hKey, L"NDI", 0, KEY_READ, &hNDIKey) == ERROR_SUCCESS)
|
||||
{
|
||||
/* retrieve HelpText */
|
||||
pCurrent->szHelpText = NULL;
|
||||
dwSize = sizeof(szText);
|
||||
if (RegQueryValueExW(hNDIKey, L"HelpText", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -256,8 +249,7 @@ EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem **
|
|||
}
|
||||
}
|
||||
|
||||
/* retrieve HelpText */
|
||||
pCurrent->szBindName = NULL;
|
||||
/* retrieve Service */
|
||||
dwSize = sizeof(szText);
|
||||
if (RegQueryValueExW(hNDIKey, L"Service", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -303,7 +295,7 @@ EnumerateNetworkComponent(
|
|||
if (SUCCEEDED(hr))
|
||||
{
|
||||
swprintf(szName, L"SYSTEM\\CurrentControlSet\\Control\\Network\\%s", pszGuid);
|
||||
if (RegOpenKeyExW(hKey, szName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
hr = EnumClientServiceProtocol(hKey, pGuid, pHead);
|
||||
RegCloseKey(hKey);
|
||||
|
|
|
@ -55,9 +55,34 @@ DllCanUnloadNow(void)
|
|||
STDAPI
|
||||
DllRegisterServer(void)
|
||||
{
|
||||
//FIXME
|
||||
// implement registering services
|
||||
//
|
||||
HKEY hKey, hSubKey;
|
||||
LPOLESTR pStr;
|
||||
WCHAR szName[MAX_PATH] = L"CLSID\\";
|
||||
|
||||
if (FAILED(StringFromCLSID(&CLSID_CNetCfg, &pStr)))
|
||||
return SELFREG_E_CLASS;
|
||||
|
||||
wcscpy(&szName[6], pStr);
|
||||
CoTaskMemFree(pStr);
|
||||
|
||||
if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szName, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS)
|
||||
return SELFREG_E_CLASS;
|
||||
|
||||
if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
if (!GetModuleFileNameW(netcfgx_hInstance, szName, sizeof(szName)/sizeof(WCHAR)))
|
||||
{
|
||||
RegCloseKey(hSubKey);
|
||||
RegCloseKey(hKey);
|
||||
return SELFREG_E_CLASS;
|
||||
}
|
||||
szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
|
||||
RegSetValueW(hSubKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10);
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<module name="netcfgx" type="win32dll" baseaddress="${BASEADDRESS_NETCFGX}" installbase="system32" installname="netcfgx.dll">
|
||||
<importlibrary definition="netcfgx.spec.def" />
|
||||
<autoregister infsection="OleControlDlls" type="DllRegisterServer" />
|
||||
<library>ntdll</library>
|
||||
<library>rpcrt4</library>
|
||||
<library>setupapi</library>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <setupapi.h>
|
||||
#include <stdio.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <olectl.h>
|
||||
|
||||
typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
|
||||
typedef struct {
|
||||
|
|
|
@ -135,17 +135,20 @@ EnumComponents(HWND hDlgCtrl, INetConnectionPropertyUiImpl * This, INetCfg * pNC
|
|||
pHelpText = NULL;
|
||||
hr = INetCfgComponent_GetDisplayName(pNCfgComp, &pDisplayName);
|
||||
hr = INetCfgComponent_GetHelpText(pNCfgComp, &pHelpText);
|
||||
bChecked = TRUE; //ReactOS hack
|
||||
hr = INetCfgComponent_QueryInterface(pNCfgComp, &IID_INetCfgComponentBindings, (LPVOID*)&pCompBind);
|
||||
|
||||
bChecked = FALSE;
|
||||
if (GetINetCfgComponent(pNCfg, This, &pAdapterCfgComp))
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = INetCfgComponentBindings_IsBoundTo(pCompBind, pAdapterCfgComp);
|
||||
if (hr == S_OK)
|
||||
bChecked = TRUE;
|
||||
else
|
||||
bChecked = FALSE;
|
||||
INetCfgComponent_Release(pAdapterCfgComp);
|
||||
if (GetINetCfgComponent(pNCfg, This, &pAdapterCfgComp))
|
||||
{
|
||||
hr = INetCfgComponentBindings_IsBoundTo(pCompBind, pAdapterCfgComp);
|
||||
if (hr == S_OK)
|
||||
bChecked = TRUE;
|
||||
else
|
||||
bChecked = FALSE;
|
||||
INetCfgComponent_Release(pAdapterCfgComp);
|
||||
INetCfgComponentBindings_Release(pCompBind);
|
||||
}
|
||||
}
|
||||
pItem = CoTaskMemAlloc(sizeof(NET_ITEM));
|
||||
if (!pItem)
|
||||
|
|
Loading…
Reference in a new issue