[ros-diffs] [amunger] 22182: Merge w3seek fixes from trunk. Revisions: 22177-22179

amunger at svn.reactos.org amunger at svn.reactos.org
Fri Jun 2 16:53:35 CEST 2006


Author: amunger
Date: Fri Jun  2 18:53:34 2006
New Revision: 22182

URL: http://svn.reactos.ru/svn/reactos?rev=22182&view=rev
Log:
Merge w3seek fixes from trunk.
Revisions: 22177-22179

Modified:
    branches/ros-branch-0_3_0/reactos/base/services/umpnpmgr/umpnpmgr.c
    branches/ros-branch-0_3_0/reactos/dll/cpl/desk/classinst.c
    branches/ros-branch-0_3_0/reactos/dll/win32/netcfgx/netcfgx.c
    branches/ros-branch-0_3_0/reactos/include/reactos/probe.h
    branches/ros-branch-0_3_0/reactos/ntoskrnl/cm/ntfunc.c
    branches/ros-branch-0_3_0/reactos/ntoskrnl/io/pnpmgr.c

Modified: branches/ros-branch-0_3_0/reactos/base/services/umpnpmgr/umpnpmgr.c
URL: http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/base/services/umpnpmgr/umpnpmgr.c?rev=22182&r1=22181&r2=22182&view=diff
==============================================================================
--- branches/ros-branch-0_3_0/reactos/base/services/umpnpmgr/umpnpmgr.c (original)
+++ branches/ros-branch-0_3_0/reactos/base/services/umpnpmgr/umpnpmgr.c Fri Jun  2 18:53:34 2006
@@ -1170,7 +1170,7 @@
 static BOOL
 SetupIsActive(VOID)
 {
-    HKEY hKey = INVALID_HANDLE_VALUE;
+    HKEY hKey = NULL;
     DWORD regType, active, size;
     LONG rc;
     BOOL ret = FALSE;
@@ -1189,7 +1189,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: branches/ros-branch-0_3_0/reactos/dll/cpl/desk/classinst.c
URL: http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/dll/cpl/desk/classinst.c?rev=22182&r1=22181&r2=22182&view=diff
==============================================================================
--- branches/ros-branch-0_3_0/reactos/dll/cpl/desk/classinst.c (original)
+++ branches/ros-branch-0_3_0/reactos/dll/cpl/desk/classinst.c Fri Jun  2 18:53:34 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: branches/ros-branch-0_3_0/reactos/dll/win32/netcfgx/netcfgx.c
URL: http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/dll/win32/netcfgx/netcfgx.c?rev=22182&r1=22181&r2=22182&view=diff
==============================================================================
--- branches/ros-branch-0_3_0/reactos/dll/win32/netcfgx/netcfgx.c (original)
+++ branches/ros-branch-0_3_0/reactos/dll/win32/netcfgx/netcfgx.c Fri Jun  2 18:53:34 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: branches/ros-branch-0_3_0/reactos/include/reactos/probe.h
URL: http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/include/reactos/probe.h?rev=22182&r1=22181&r2=22182&view=diff
==============================================================================
--- branches/ros-branch-0_3_0/reactos/include/reactos/probe.h (original)
+++ branches/ros-branch-0_3_0/reactos/include/reactos/probe.h Fri Jun  2 18:53:34 2006
@@ -73,6 +73,15 @@
 #define ProbeForReadLargeInteger(Ptr) ProbeForReadGenericType(Ptr, LARGE_INTEGER, __emptyLargeInteger)
 #define ProbeForReadUlargeInteger(Ptr) ProbeForReadGenericType(Ptr, ULARGE_INTEGER, __emptyULargeInteger)
 #define ProbeForReadUnicodeString(Ptr) ProbeForReadGenericType(Ptr, UNICODE_STRING, __emptyUnicodeString)
+
+#define ProbeAndZeroHandle(Ptr) \
+    do {                                                                       \
+        if ((ULONG_PTR)(Ptr) + sizeof(HANDLE) - 1 < (ULONG_PTR)(Ptr) ||        \
+            (ULONG_PTR)(Ptr) + sizeof(HANDLE) - 1 >= (ULONG_PTR)MmUserProbeAddress) { \
+            RtlRaiseStatus (STATUS_ACCESS_VIOLATION);                          \
+        }                                                                      \
+        *(volatile HANDLE *)(Ptr) = NULL;                                      \
+    } while (0)
 
 /*
  * Inlined Probing Macros

Modified: branches/ros-branch-0_3_0/reactos/ntoskrnl/cm/ntfunc.c
URL: http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/ntoskrnl/cm/ntfunc.c?rev=22182&r1=22181&r2=22182&view=diff
==============================================================================
--- branches/ros-branch-0_3_0/reactos/ntoskrnl/cm/ntfunc.c (original)
+++ branches/ros-branch-0_3_0/reactos/ntoskrnl/cm/ntfunc.c Fri Jun  2 18:53:34 2006
@@ -208,7 +208,7 @@
   {
       _SEH_TRY
       {
-          ProbeForWriteHandle(KeyHandle);
+          ProbeAndZeroHandle(KeyHandle);
           if (Disposition != NULL)
           {
               ProbeForWriteUlong(Disposition);
@@ -1281,7 +1281,7 @@
   {
     _SEH_TRY
     {
-      ProbeForWriteHandle(KeyHandle);
+      ProbeAndZeroHandle(KeyHandle);
     }
     _SEH_HANDLE
     {

Modified: branches/ros-branch-0_3_0/reactos/ntoskrnl/io/pnpmgr.c
URL: http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/ntoskrnl/io/pnpmgr.c?rev=22182&r1=22181&r2=22182&view=diff
==============================================================================
--- branches/ros-branch-0_3_0/reactos/ntoskrnl/io/pnpmgr.c (original)
+++ branches/ros-branch-0_3_0/reactos/ntoskrnl/io/pnpmgr.c Fri Jun  2 18:53:34 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