Author: gadamopoulos
Date: Fri Apr 29 17:50:30 2011
New Revision: 51496
URL:
http://svn.reactos.org/svn/reactos?rev=51496&view=rev
Log:
[win32k]
- UserSetProcessWindowStation: Use PsGetProcessWin32WindowStation and
PsSetProcessWindowStation. Close the prevoious window station handle only when the window
station was not set by UserSetProcessWindowStation (should be the case for console apps)
Modified:
trunk/reactos/include/ndk/psfuncs.h
trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
Modified: trunk/reactos/include/ndk/psfuncs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/psfuncs.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/psfuncs.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/psfuncs.h [iso-8859-1] Fri Apr 29 17:50:30 2011
@@ -76,6 +76,21 @@
NTAPI
PsGetThreadWin32Thread(
PETHREAD Thread
+);
+
+NTKERNELAPI
+PVOID
+NTAPI
+PsGetProcessWin32WindowStation(
+ PEPROCESS Process
+);
+
+NTKERNELAPI
+VOID
+NTAPI
+PsSetProcessWindowStation(
+ PEPROCESS Process,
+ PVOID WindowStation
);
NTKERNELAPI
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] Fri Apr 29 17:50:30
2011
@@ -940,6 +940,7 @@
ppi = PsGetCurrentProcessWin32Process();
+ /* Reference the new window station */
if(hWindowStation !=NULL)
{
Status = IntValidateWindowStationHandle( hWindowStation,
@@ -956,27 +957,28 @@
}
OldWinSta = ppi->prpwinsta;
- hwinstaOld = ppi->hwinsta;
+ hwinstaOld = PsGetProcessWin32WindowStation(ppi->peProcess);
+
+ /* Dereference the previous window station */
+ if(OldWinSta != NULL)
+ {
+ ObDereferenceObject(OldWinSta);
+ }
+
+ /* Check if we have a stale handle (it should happen for console apps) */
+ if(hwinstaOld != ppi->hwinsta)
+ {
+ ObCloseHandle(hwinstaOld, UserMode);
+ }
/*
* FIXME - don't allow changing the window station if there are threads that are
attached to desktops and own gui objects
*/
-
- InterlockedExchangePointer(&PsGetCurrentProcess()->Win32WindowStation,
hWindowStation);
+
+ PsSetProcessWindowStation(ppi->peProcess, hWindowStation);
ppi->prpwinsta = NewWinSta;
ppi->hwinsta = hWindowStation;
-
-
- if(OldWinSta != NULL)
- {
- ObDereferenceObject(OldWinSta);
- }
-
- if(hwinstaOld != NULL)
- {
- ObCloseHandle(hwinstaOld, UserMode);
- }
return TRUE;
}