[WIN32K]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 16 Dec 2012 14:01:32 +0000 (14:01 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 16 Dec 2012 14:01:32 +0000 (14:01 +0000)
Fix BSOD when starting ReactOS in Safe Mode :
NEVER dereference a NULL pointer in a DPRINT or you are dead !! (here, the possible NULL pointer is GetW32ProcessInfo()->prpwinsta).
More precisely, you obtain:

<NTOSKRNL.EXE:112296 (ReactOS/ntoskrnl/ke/i386/traphdlr.c:1246 (@KiTrap0EHandler@4))>
<NTOSKRNL.EXE:110154 (ReactOS/ntoskrnl/ke/i386/trap.s:0 (_KiTrap0E))>
<NTOSKRNL.EXE:142926 (ReactOS/lib/sdk/crt/printf/streamout.c:644 (streamout))>
<NTOSKRNL.EXE:140631 (ReactOS/lib/sdk/crt/printf/_sxprintf.c:61 (_vsnprintf))>
<NTOSKRNL.EXE:12736a (ReactOS/lib/rtl/debug.c:85 (vDbgPrintExWithPrefixInternal@24))>
<NTOSKRNL.EXE:12751c (ReactOS/lib/rtl/debug.c:209 (DbgPrint))>
<win32k.sys:55034 (ReactOS/win32ss/user/ntuser/sysparams.c:451 (SpiGet))>
<win32k.sys:56bc7 (ReactOS/win32ss/user/ntuser/sysparams.c:963 (@UserSystemParametersInfo@16)

svn path=/trunk/; revision=57923

reactos/win32ss/user/ntuser/sysparams.c

index 50edb52..24f943c 100644 (file)
@@ -25,9 +25,18 @@ BOOL g_PaintDesktopVersion = FALSE;
 #define METRIC2REG(met) (-((((met) * 1440)- 0) / dpi))
 
 #define REQ_INTERACTIVE_WINSTA(err) \
 #define METRIC2REG(met) (-((((met) * 1440)- 0) / dpi))
 
 #define REQ_INTERACTIVE_WINSTA(err) \
-    if ( GetW32ProcessInfo()->prpwinsta != InputWindowStation) \
+    if (GetW32ProcessInfo()->prpwinsta) \
     { \
     { \
-        ERR("NtUserSystemParametersInfo requires interactive window station (current is %wZ)\n", &GetW32ProcessInfo()->prpwinsta->Name); \
+        if (GetW32ProcessInfo()->prpwinsta != InputWindowStation) \
+        { \
+            ERR("NtUserSystemParametersInfo requires interactive window station (current is %wZ)\n", &GetW32ProcessInfo()->prpwinsta->Name); \
+            EngSetLastError(err); \
+            return 0; \
+        } \
+    } \
+    else \
+    { \
+        ERR("NtUserSystemParametersInfo called without active window station, and it requires an interactive one.\n"); \
         EngSetLastError(err); \
         return 0; \
     }
         EngSetLastError(err); \
         return 0; \
     }
@@ -1568,7 +1577,7 @@ UserSystemParametersInfo(
     /* Get a pointer to the current Windowstation */
     if (!ppi->prpwinsta)
     {
     /* Get a pointer to the current Windowstation */
     if (!ppi->prpwinsta)
     {
-        ERR("UserSystemParametersInfo called without active windowstation.\n");
+        ERR("UserSystemParametersInfo called without active window station.\n");
         //ASSERT(FALSE);
         //return FALSE;
     }
         //ASSERT(FALSE);
         //return FALSE;
     }