[ros-diffs] [gadamopoulos] 54124: [win32k] - Fix and simplify retrieving the current process window station. All processes that enter win32k have a window station (including csrss)

gadamopoulos at svn.reactos.org gadamopoulos at svn.reactos.org
Thu Oct 13 22:16:58 UTC 2011


Author: gadamopoulos
Date: Thu Oct 13 22:16:58 2011
New Revision: 54124

URL: http://svn.reactos.org/svn/reactos?rev=54124&view=rev
Log:
[win32k]
- Fix and simplify retrieving the current process window station. All processes that enter win32k have a window station (including csrss)

Modified:
    trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c?rev=54124&r1=54123&r2=54124&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] Thu Oct 13 22:16:58 2011
@@ -242,7 +242,7 @@
 
    if (WindowStation == NULL)
    {
-      //      ERR("Invalid window station handle\n");
+      WARN("Invalid window station handle\n");
       EngSetLastError(ERROR_INVALID_HANDLE);
       return STATUS_INVALID_HANDLE;
    }
@@ -802,34 +802,11 @@
 HWINSTA FASTCALL
 UserGetProcessWindowStation(VOID)
 {
-   NTSTATUS Status;
-   PTHREADINFO pti;
-   HWINSTA WinSta;
-
-   if(PsGetCurrentProcess() != CsrProcess)
-   {
-      return PsGetCurrentProcess()->Win32WindowStation;
-   }
-   else
-   {
-      ERR("Should use ObFindHandleForObject\n");
-      pti = PsGetCurrentThreadWin32Thread();
-      Status = ObOpenObjectByPointer(pti->rpdesk->rpwinstaParent,
-                                     0,
-                                     NULL,
-                                     WINSTA_ALL_ACCESS,
-                                     ExWindowStationObjectType,
-                                     UserMode,
-                                     (PHANDLE) &WinSta);
-      if (! NT_SUCCESS(Status))
-      {
-         SetLastNtError(Status);
-         ERR("Unable to open handle for CSRSSs winsta, status 0x%08x\n",
-                 Status);
-         return NULL;
-      }
-      return WinSta;
-   }
+    PPROCESSINFO ppi = PsGetCurrentProcessWin32Process();
+
+    //ASSERT(ppi->hwinsta);
+
+    return ppi->hwinsta;
 }
 
 
@@ -856,36 +833,19 @@
 PWINSTATION_OBJECT FASTCALL
 IntGetWinStaObj(VOID)
 {
-   PWINSTATION_OBJECT WinStaObj;
-   PTHREADINFO Win32Thread;
-   PEPROCESS CurrentProcess;
-
-   /*
-    * just a temporary hack, this will be gone soon
-    */
-
-   Win32Thread = PsGetCurrentThreadWin32Thread();
-   if(Win32Thread != NULL && Win32Thread->rpdesk != NULL)
-   {
-      WinStaObj = Win32Thread->rpdesk->rpwinstaParent;
-      ObReferenceObjectByPointer(WinStaObj, KernelMode, ExWindowStationObjectType, 0);
-   }
-   else if((CurrentProcess = PsGetCurrentProcess()) != CsrProcess)
-   {
-      NTSTATUS Status = IntValidateWindowStationHandle(CurrentProcess->Win32WindowStation,
+    PWINSTATION_OBJECT WinStaObj;
+    NTSTATUS Status;
+   
+    Status = IntValidateWindowStationHandle(
+                        UserGetProcessWindowStation(),
                         KernelMode,
                         0,
                         &WinStaObj);
-      if(!NT_SUCCESS(Status))
-      {
-         SetLastNtError(Status);
-         return NULL;
-      }
-   }
-   else
-   {
-      WinStaObj = NULL;
-   }
+    if(!NT_SUCCESS(Status))
+    {
+        SetLastNtError(Status);
+        return NULL;
+    }
 
    return WinStaObj;
 }




More information about the Ros-diffs mailing list