[WIN32K]: Use the logon process ID instead of a full win32k process object, it simpli...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 23 Nov 2014 16:09:00 +0000 (16:09 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 23 Nov 2014 16:09:00 +0000 (16:09 +0000)
svn path=/trunk/; revision=65465

reactos/win32ss/user/ntuser/desktop.c
reactos/win32ss/user/ntuser/main.c
reactos/win32ss/user/ntuser/simplecall.c
reactos/win32ss/user/ntuser/winsta.c
reactos/win32ss/user/ntuser/winsta.h

index 37357ac..857da89 100644 (file)
@@ -1701,7 +1701,7 @@ NtUserSwitchDesktop(HDESK hdesk)
     * is the logon application itself
     */
    if((pdesk->rpwinstaParent->Flags & WSS_LOCKED) &&
-      LogonProcess != PsGetCurrentProcessWin32Process())
+      gpidLogon != PsGetCurrentProcessId())
    {
       ObDereferenceObject(pdesk);
       ERR("Switching desktop 0x%p denied because the window station is locked!\n", hdesk);
index bfc68de..44648aa 100644 (file)
@@ -213,10 +213,8 @@ DestroyProcessInfo(PEPROCESS Process)
     /*
      * Deregister logon application automatically
      */
-    if(LogonProcess == ppiCurrent)
-    {
-        LogonProcess = NULL;
-    }
+    if (gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
+        gpidLogon = 0;
 
     /* Close the current window station */
     UserSetProcessWindowStation(NULL);
@@ -409,7 +407,7 @@ UserCreateThreadInfo(struct _ETHREAD *Thread)
 
     /* Assign a default window station and desktop to the process */
     /* Do not try to open a desktop or window station before winlogon initializes */
-    if(ptiCurrent->ppi->hdeskStartup == NULL && LogonProcess != NULL)
+    if (ptiCurrent->ppi->hdeskStartup == NULL && gpidLogon != 0)
     {
         HWINSTA hWinSta = NULL;
         HDESK hDesk = NULL;
@@ -749,17 +747,23 @@ DriverEntry(
     /* Register Object Manager Callbacks */
     CalloutData.ProcessCallout = Win32kProcessCallback;
     CalloutData.ThreadCallout = Win32kThreadCallback;
-    CalloutData.WindowStationParseProcedure = IntWinStaObjectParse;
-    CalloutData.WindowStationDeleteProcedure = IntWinStaObjectDelete;
-    CalloutData.WindowStationOkToCloseProcedure = IntWinstaOkToClose;
+    // CalloutData.GlobalAtomTableCallout = NULL;
+    // CalloutData.PowerEventCallout = NULL;
+    // CalloutData.PowerStateCallout = NULL;
+    // CalloutData.JobCallout = NULL;
+    CalloutData.BatchFlushRoutine = NtGdiFlushUserBatch;
+    CalloutData.DesktopOpenProcedure = IntDesktopObjectOpen;
     CalloutData.DesktopOkToCloseProcedure = IntDesktopOkToClose;
-    CalloutData.DesktopDeleteProcedure = IntDesktopObjectDelete;
     CalloutData.DesktopCloseProcedure = IntDesktopObjectClose;
-    CalloutData.DesktopOpenProcedure = IntDesktopObjectOpen;
-    CalloutData.BatchFlushRoutine = NtGdiFlushUserBatch;
+    CalloutData.DesktopDeleteProcedure = IntDesktopObjectDelete;
+    CalloutData.WindowStationOkToCloseProcedure = IntWinstaOkToClose;
+    // CalloutData.WindowStationCloseProcedure = NULL;
+    CalloutData.WindowStationDeleteProcedure = IntWinStaObjectDelete;
+    CalloutData.WindowStationParseProcedure = IntWinStaObjectParse;
+    // CalloutData.WindowStationOpenProcedure = NULL;
 
     /* Register our per-process and per-thread structures. */
-    PsEstablishWin32Callouts((PWIN32_CALLOUTS_FPNS)&CalloutData);
+    PsEstablishWin32Callouts(&CalloutData);
 
     /* Register service hook callbacks */
 #if DBG
index 7996c9f..3bcb5aa 100644 (file)
@@ -12,8 +12,8 @@
 
 DBG_DEFAULT_CHANNEL(UserMisc);
 
-/* registered Logon process */
-PPROCESSINFO LogonProcess = NULL;
+/* Registered logon process ID */
+HANDLE gpidLogon = 0;
 
 BOOL FASTCALL
 co_IntRegisterLogonProcess(HANDLE ProcessId, BOOL Register)
@@ -21,39 +21,34 @@ co_IntRegisterLogonProcess(HANDLE ProcessId, BOOL Register)
    NTSTATUS Status;
    PEPROCESS Process;
 
-   Status = PsLookupProcessByProcessId(ProcessId,
-                                       &Process);
+   Status = PsLookupProcessByProcessId(ProcessId, &Process);
    if (!NT_SUCCESS(Status))
    {
       EngSetLastError(RtlNtStatusToDosError(Status));
       return FALSE;
    }
 
+   ProcessId = Process->UniqueProcessId;
+
+   ObDereferenceObject(Process);
+
    if (Register)
    {
       /* Register the logon process */
-      if (LogonProcess != NULL)
-      {
-         ObDereferenceObject(Process);
+      if (gpidLogon != 0)
          return FALSE;
-      }
 
-      LogonProcess = (PPROCESSINFO)Process->Win32Process;
+      gpidLogon = ProcessId;
    }
    else
    {
       /* Deregister the logon process */
-      if (LogonProcess != (PPROCESSINFO)Process->Win32Process)
-      {
-         ObDereferenceObject(Process);
+      if (gpidLogon != ProcessId)
          return FALSE;
-      }
 
-      LogonProcess = NULL;
+      gpidLogon = 0;
    }
 
-   ObDereferenceObject(Process);
-
    return TRUE;
 }
 
@@ -451,7 +446,6 @@ NtUserCallTwoParam(
          STUB
          RETURN( 0);
 
-
       case TWOPARAM_ROUTINE_SETCARETPOS:
          RETURN( (DWORD_PTR)co_IntSetCaretPos((int)Param1, (int)Param2));
 
index 8fcc7b7..7782bd8 100644 (file)
@@ -947,7 +947,7 @@ NtUserLockWindowStation(HWINSTA hWindowStation)
    TRACE("About to set process window station with handle (%p)\n",
          hWindowStation);
 
-   if(PsGetCurrentProcessWin32Process() != LogonProcess)
+   if (gpidLogon != PsGetCurrentProcessId())
    {
       ERR("Unauthorized process attempted to lock the window station!\n");
       EngSetLastError(ERROR_ACCESS_DENIED);
@@ -992,7 +992,7 @@ NtUserUnlockWindowStation(HWINSTA hWindowStation)
    TRACE("About to set process window station with handle (%p)\n",
          hWindowStation);
 
-   if(PsGetCurrentProcessWin32Process() != LogonProcess)
+   if (gpidLogon != PsGetCurrentProcessId())
    {
       ERR("Unauthorized process attempted to unlock the window station!\n");
       EngSetLastError(ERROR_ACCESS_DENIED);
@@ -1338,12 +1338,12 @@ NtUserBuildNameList(
 BOOL APIENTRY
 NtUserSetLogonNotifyWindow(HWND hWnd)
 {
-    if(LogonProcess != PsGetCurrentProcessWin32Process())
+    if (gpidLogon != PsGetCurrentProcessId())
     {
         return FALSE;
     }
 
-    if(!IntIsWindow(hWnd))
+    if (!IntIsWindow(hWnd))
     {
         return FALSE;
     }
index 04fd007..d592247 100644 (file)
@@ -35,7 +35,7 @@ typedef struct _WINSTATION_OBJECT
 } WINSTATION_OBJECT, *PWINSTATION_OBJECT;
 
 extern WINSTATION_OBJECT *InputWindowStation;
-extern PPROCESSINFO LogonProcess;
+extern HANDLE gpidLogon;
 extern HWND hwndSAS;
 extern UNICODE_STRING gustrWindowStationsDir;