[ros-diffs] [janderwald] 22179: fix apps depending on INVALID_HANDLE_VALUE bug report & patch by w3seek

janderwald at svn.reactos.org janderwald at svn.reactos.org
Fri Jun 2 16:37:26 CEST 2006


Author: janderwald
Date: Fri Jun  2 18:37:25 2006
New Revision: 22179

URL: http://svn.reactos.ru/svn/reactos?rev=22179&view=rev
Log:
fix apps depending on INVALID_HANDLE_VALUE 
bug report & patch by w3seek

Modified:
    trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
    trunk/reactos/dll/cpl/desk/classinst.c
    trunk/reactos/dll/win32/netcfgx/netcfgx.c
    trunk/reactos/ntoskrnl/io/pnpmgr.c

Modified: trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/services/umpnpmgr/umpnpmgr.c?rev=22179&r1=22178&r2=22179&view=diff
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/umpnpmgr.c (original)
+++ trunk/reactos/base/services/umpnpmgr/umpnpmgr.c Fri Jun  2 18:37:25 2006
@@ -1169,7 +1169,7 @@
 static BOOL
 SetupIsActive(VOID)
 {
-    HKEY hKey = INVALID_HANDLE_VALUE;
+    HKEY hKey = NULL;
     DWORD regType, active, size;
     LONG rc;
     BOOL ret = FALSE;
@@ -1188,7 +1188,7 @@
     ret = (active != 0);
 
 cleanup:
-    if (hKey != INVALID_HANDLE_VALUE)
+    if (hKey != NULL)
         RegCloseKey(hKey);
 
     DPRINT("System setup in progress? %S\n", ret ? L"YES" : L"NO");

Modified: trunk/reactos/dll/cpl/desk/classinst.c
URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/cpl/desk/classinst.c?rev=22179&r1=22178&r2=22179&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/desk/classinst.c (original)
+++ trunk/reactos/dll/cpl/desk/classinst.c Fri Jun  2 18:37:25 2006
@@ -24,11 +24,11 @@
 	TCHAR SectionName[MAX_PATH];
 	TCHAR ServiceName[MAX_SERVICE_NAME_LEN];
 	SP_DRVINFO_DETAIL_DATA DriverInfoDetailData;
-	HKEY hDriverKey = INVALID_HANDLE_VALUE;
-	HKEY hSettingsKey = INVALID_HANDLE_VALUE;
-	HKEY hServicesKey = INVALID_HANDLE_VALUE;
-	HKEY hServiceKey = INVALID_HANDLE_VALUE;
-	HKEY hDeviceSubKey = INVALID_HANDLE_VALUE;
+	HKEY hDriverKey = INVALID_HANDLE_VALUE; /* SetupDiOpenDevRegKey returns INVALID_HANDLE_VALUE in case of error! */
+	HKEY hSettingsKey = NULL;
+	HKEY hServicesKey = NULL;
+	HKEY hServiceKey = NULL;
+	HKEY hDeviceSubKey = NULL;
 	DWORD disposition;
 	BOOL result;
 	LONG rc;
@@ -214,14 +214,17 @@
 	if (hInf != INVALID_HANDLE_VALUE)
 		SetupCloseInfFile(hInf);
 	if (hDriverKey != INVALID_HANDLE_VALUE)
+	{
+		/* SetupDiOpenDevRegKey returns INVALID_HANDLE_VALUE in case of error! */
 		RegCloseKey(hDriverKey);
-	if (hSettingsKey != INVALID_HANDLE_VALUE)
+	}
+	if (hSettingsKey != NULL)
 		RegCloseKey(hSettingsKey);
-	if (hServicesKey != INVALID_HANDLE_VALUE)
+	if (hServicesKey != NULL)
 		RegCloseKey(hServicesKey);
-	if (hServiceKey != INVALID_HANDLE_VALUE)
+	if (hServiceKey != NULL)
 		RegCloseKey(hServiceKey);
-	if (hDeviceSubKey != INVALID_HANDLE_VALUE)
+	if (hDeviceSubKey != NULL)
 		RegCloseKey(hDeviceSubKey);
 
 	return rc;

Modified: trunk/reactos/dll/win32/netcfgx/netcfgx.c
URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfgx.c?rev=22179&r1=22178&r2=22179&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/netcfgx.c (original)
+++ trunk/reactos/dll/win32/netcfgx/netcfgx.c Fri Jun  2 18:37:25 2006
@@ -184,10 +184,10 @@
 	LPWSTR ExportName = NULL;
 	LONG rc;
 	DWORD dwShowIcon, dwLength;
-	HKEY hKey = INVALID_HANDLE_VALUE;
-	HKEY hLinkageKey = INVALID_HANDLE_VALUE;
-	HKEY hNetworkKey = INVALID_HANDLE_VALUE;
-	HKEY hConnectionKey = INVALID_HANDLE_VALUE;
+	HKEY hKey = NULL;
+	HKEY hLinkageKey = NULL;
+	HKEY hNetworkKey = NULL;
+	HKEY hConnectionKey = NULL;
 	
 	if (InstallFunction != DIF_INSTALLDEVICE)
 		return ERROR_DI_DO_DEFAULT;
@@ -279,7 +279,7 @@
 		goto cleanup;
 	}
 	RegCloseKey(hKey);
-	hKey = INVALID_HANDLE_VALUE;
+	hKey = NULL;
 	rc = RegCreateKeyExW(hNetworkKey, L"Parameters\\Tcpip", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL);
 	if (rc != ERROR_SUCCESS)
 	{
@@ -287,7 +287,7 @@
 		goto cleanup;
 	}
 	RegCloseKey(hNetworkKey);
-	hNetworkKey = INVALID_HANDLE_VALUE;
+	hNetworkKey = NULL;
 	rc = RegSetValueExW(hKey, L"DefaultGateway", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR));
 	if (rc != ERROR_SUCCESS)
 	{
@@ -307,7 +307,7 @@
 		goto cleanup;
 	}
 	RegCloseKey(hKey);
-	hKey = INVALID_HANDLE_VALUE;
+	hKey = NULL;
 
 	/* Write 'Linkage' key in hardware key */
 #if _WIN32_WINNT >= 0x502
@@ -319,6 +319,7 @@
 		hKey = SetupDiCreateDevRegKeyW(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, NULL, NULL);
 	if (hKey == INVALID_HANDLE_VALUE)
 	{
+		hKey = NULL;
 		rc = GetLastError();
 		DPRINT("SetupDiCreateDevRegKeyW() failed with error 0x%lx\n", rc);
 		goto cleanup;
@@ -354,7 +355,7 @@
 		goto cleanup;
 	}
 	RegCloseKey(hKey);
-	hKey = INVALID_HANDLE_VALUE;
+	hKey = NULL;
 
 	/* Write connection information in network subkey */
 	rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}", 0, NULL, REG_OPTION_NON_VOLATILE, 0, NULL, &hNetworkKey, NULL);
@@ -371,7 +372,7 @@
 	}
 	rc = RegCreateKeyExW(hKey, L"Connection", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hConnectionKey, NULL);
 	RegCloseKey(hKey);
-	hKey = INVALID_HANDLE_VALUE;
+	hKey = NULL;
 	if (rc != ERROR_SUCCESS)
 	{
 		DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc);
@@ -446,13 +447,13 @@
 	HeapFree(GetProcessHeap(), 0, UuidString);
 	HeapFree(GetProcessHeap(), 0, DeviceName);
 	HeapFree(GetProcessHeap(), 0, ExportName);
-	if (hKey != INVALID_HANDLE_VALUE)
+	if (hKey != NULL)
 		RegCloseKey(hKey);
-	if (hLinkageKey != INVALID_HANDLE_VALUE)
+	if (hLinkageKey != NULL)
 		RegCloseKey(hLinkageKey);
-	if (hNetworkKey != INVALID_HANDLE_VALUE)
+	if (hNetworkKey != NULL)
 		RegCloseKey(hNetworkKey);
-	if (hConnectionKey != INVALID_HANDLE_VALUE)
+	if (hConnectionKey != NULL)
 		RegCloseKey(hConnectionKey);
 
 	if (rc == ERROR_SUCCESS)

Modified: trunk/reactos/ntoskrnl/io/pnpmgr.c
URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr.c?rev=22179&r1=22178&r2=22179&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/io/pnpmgr.c (original)
+++ trunk/reactos/ntoskrnl/io/pnpmgr.c Fri Jun  2 18:37:25 2006
@@ -1317,7 +1317,7 @@
    UNICODE_STRING KeyValue;
    UNICODE_STRING ValueName;
    OBJECT_ATTRIBUTES ObjectAttributes;
-   HANDLE hKey = INVALID_HANDLE_VALUE;
+   HANDLE hKey = NULL;
    ULONG crc32;
    NTSTATUS Status;
 
@@ -1395,7 +1395,7 @@
    }
    ExFreePool(ParentIdPrefixInformation);
    ExFreePool(KeyNameBuffer);
-   if (hKey != INVALID_HANDLE_VALUE)
+   if (hKey != NULL)
       ZwClose(hKey);
    return Status;
 }




More information about the Ros-diffs mailing list