[NTOSKRNL/USERINIT/WIN32K]
[reactos.git] / reactos / subsystems / win32 / win32k / ntuser / metric.c
index 850f1cf..060f0df 100644 (file)
@@ -9,7 +9,7 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <w32k.h>
+#include <win32k.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -23,30 +23,33 @@ BOOL
 FASTCALL
 InitMetrics(VOID)
 {
-    NTSTATUS Status;
-    PWINSTATION_OBJECT WinStaObject;
-    ULONG Width = 640, Height = 480;
-    PSYSTEM_CURSORINFO CurInfo;
-    INT *piSysMet;
-
-    Width = pPrimarySurface->GDIInfo.ulHorzRes;
-    Height = pPrimarySurface->GDIInfo.ulVertRes;
-
-    Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                            KernelMode,
-                                            0,
-                                            &WinStaObject);
-    if (NT_SUCCESS(Status))
+    INT *piSysMet = gpsi->aiSysMet;
+    ULONG Width, Height;
+
+    /* note: used for the SM_CLEANBOOT metric */
+    DWORD dwValue = 0;
+    HKEY hKey = 0;
+
+    /* Clean boot */
+    piSysMet[SM_CLEANBOOT] = 0; // fallback value of 0 (normal mode)
+    if(NT_SUCCESS(RegOpenKey(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", &hKey)))
+    {
+        if(RegReadDWORD(hKey, L"OptionValue", &dwValue)) piSysMet[SM_CLEANBOOT] = (INT)dwValue;
+        ZwClose(hKey);
+    }
+
+    /* FIXME: HACK, due to missing PDEV on first init */
+    if (!pPrimarySurface)
     {
-        CurInfo = IntGetSysCursorInfo(WinStaObject);
+        Width = 640;
+        Height = 480;
     }
     else
     {
-        CurInfo = NULL;
+        Width = pPrimarySurface->gdiinfo.ulHorzRes;
+        Height = pPrimarySurface->gdiinfo.ulVertRes;
     }
 
-    piSysMet = gpsi->aiSysMet;
-
     /* Screen sizes */
     piSysMet[SM_CXSCREEN] = Width;
     piSysMet[SM_CYSCREEN] = Height;
@@ -133,9 +136,9 @@ InitMetrics(VOID)
     piSysMet[SM_MOUSEPRESENT] = 1;
     piSysMet[SM_MOUSEWHEELPRESENT] = 1;
     piSysMet[SM_CMOUSEBUTTONS] = 2;
-    piSysMet[SM_SWAPBUTTON] = gspv.bMouseBtnSwap ? 1 : 0; //CurInfo ? CurInfo->SwapButtons : 0;
-    piSysMet[SM_CXDOUBLECLK] = gspv.iDblClickWidth;//CurInfo ? CurInfo->DblClickWidth : 4;
-    piSysMet[SM_CYDOUBLECLK] = gspv.iDblClickHeight;//CurInfo ? CurInfo->DblClickWidth : 4;
+    piSysMet[SM_SWAPBUTTON] = gspv.bMouseBtnSwap ? 1 : 0;
+    piSysMet[SM_CXDOUBLECLK] = gspv.iDblClickWidth;
+    piSysMet[SM_CYDOUBLECLK] = gspv.iDblClickHeight;
 #if (_WIN32_WINNT >= 0x0600)
     piSysMet[SM_MOUSEHORIZONTALWHEELPRESENT] = 0;
 #endif
@@ -153,7 +156,6 @@ InitMetrics(VOID)
     piSysMet[SM_SLOWMACHINE] = 0;
     piSysMet[SM_SECURE] = 0;
     piSysMet[SM_DBCSENABLED] = 0;
-    piSysMet[SM_CLEANBOOT] = 0;
     piSysMet[SM_SHOWSOUNDS] = gspv.bShowSounds;
     piSysMet[SM_MIDEASTENABLED] = 0;
     piSysMet[SM_CMONITORS] = 1;
@@ -175,11 +177,6 @@ InitMetrics(VOID)
     gpsi->dwSRVIFlags |= SRVINFO_METRICS;
     Setup = TRUE;
 
-    if (NT_SUCCESS(Status))
-    {
-        ObDereferenceObject(WinStaObject);
-    }
-
     return TRUE;
 }