Author: janderwald Date: Tue Sep 9 06:26:54 2008 New Revision: 36080
URL: http://svn.reactos.org/svn/reactos?rev=36080&view=rev Log: - 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
Modified: trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c trunk/reactos/dll/win32/netcfgx/netcfg_iface.c trunk/reactos/dll/win32/netcfgx/netcfgx.c trunk/reactos/dll/win32/netcfgx/netcfgx.rbuild trunk/reactos/dll/win32/netcfgx/precomp.h trunk/reactos/dll/win32/netshell/lanconnectui.c
Modified: trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/inetcfgco... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/inetcfgcomp_iface.c [iso-8859-1] Tue Sep 9 06:26:54 2008 @@ -69,16 +69,26 @@ 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 @@ 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;
Modified: trunk/reactos/dll/win32/netcfgx/netcfg_iface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfg_if... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/netcfg_iface.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/netcfg_iface.c [iso-8859-1] Tue Sep 9 06:26:54 2008 @@ -178,7 +178,6 @@ NetCfgComponentItem * pLast = NULL, *pCurrent;
*pHead = NULL; - do { dwCharacteristics = 0; @@ -191,29 +190,25 @@ 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 @@ }
/* retrieve Description */ - pCurrent->szDisplayName = NULL; dwSize = sizeof(szText); if (RegQueryValueExW(hSubKey, L"Description", NULL, &dwType, (LPBYTE)szText, &dwSize) == ERROR_SUCCESS) { @@ -243,7 +237,6 @@ 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 @@ } }
- /* 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 @@ 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);
Modified: trunk/reactos/dll/win32/netcfgx/netcfgx.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfgx.c... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/netcfgx.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/netcfgx.c [iso-8859-1] Tue Sep 9 06:26:54 2008 @@ -55,9 +55,34 @@ 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; }
Modified: trunk/reactos/dll/win32/netcfgx/netcfgx.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfgx.r... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/netcfgx.rbuild [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/netcfgx.rbuild [iso-8859-1] Tue Sep 9 06:26:54 2008 @@ -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>
Modified: trunk/reactos/dll/win32/netcfgx/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/precomp.h... ============================================================================== --- trunk/reactos/dll/win32/netcfgx/precomp.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netcfgx/precomp.h [iso-8859-1] Tue Sep 9 06:26:54 2008 @@ -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 {
Modified: trunk/reactos/dll/win32/netshell/lanconnectui.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lanconne... ============================================================================== --- trunk/reactos/dll/win32/netshell/lanconnectui.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netshell/lanconnectui.c [iso-8859-1] Tue Sep 9 06:26:54 2008 @@ -135,17 +135,20 @@ 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)