mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 14:32:56 +00:00
[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) svn path=/trunk/; revision=51496
This commit is contained in:
parent
3ff2ee5566
commit
1396412b7c
2 changed files with 29 additions and 12 deletions
|
@ -78,6 +78,21 @@ PsGetThreadWin32Thread(
|
||||||
PETHREAD Thread
|
PETHREAD Thread
|
||||||
);
|
);
|
||||||
|
|
||||||
|
NTKERNELAPI
|
||||||
|
PVOID
|
||||||
|
NTAPI
|
||||||
|
PsGetProcessWin32WindowStation(
|
||||||
|
PEPROCESS Process
|
||||||
|
);
|
||||||
|
|
||||||
|
NTKERNELAPI
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
PsSetProcessWindowStation(
|
||||||
|
PEPROCESS Process,
|
||||||
|
PVOID WindowStation
|
||||||
|
);
|
||||||
|
|
||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
PTEB
|
PTEB
|
||||||
NTAPI
|
NTAPI
|
||||||
|
|
|
@ -940,6 +940,7 @@ UserSetProcessWindowStation(HWINSTA hWindowStation)
|
||||||
|
|
||||||
ppi = PsGetCurrentProcessWin32Process();
|
ppi = PsGetCurrentProcessWin32Process();
|
||||||
|
|
||||||
|
/* Reference the new window station */
|
||||||
if(hWindowStation !=NULL)
|
if(hWindowStation !=NULL)
|
||||||
{
|
{
|
||||||
Status = IntValidateWindowStationHandle( hWindowStation,
|
Status = IntValidateWindowStationHandle( hWindowStation,
|
||||||
|
@ -956,28 +957,29 @@ UserSetProcessWindowStation(HWINSTA hWindowStation)
|
||||||
}
|
}
|
||||||
|
|
||||||
OldWinSta = ppi->prpwinsta;
|
OldWinSta = ppi->prpwinsta;
|
||||||
hwinstaOld = ppi->hwinsta;
|
hwinstaOld = PsGetProcessWin32WindowStation(ppi->peProcess);
|
||||||
|
|
||||||
/*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
ppi->prpwinsta = NewWinSta;
|
|
||||||
ppi->hwinsta = hWindowStation;
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Dereference the previous window station */
|
||||||
if(OldWinSta != NULL)
|
if(OldWinSta != NULL)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(OldWinSta);
|
ObDereferenceObject(OldWinSta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hwinstaOld != NULL)
|
/* Check if we have a stale handle (it should happen for console apps) */
|
||||||
|
if(hwinstaOld != ppi->hwinsta)
|
||||||
{
|
{
|
||||||
ObCloseHandle(hwinstaOld, UserMode);
|
ObCloseHandle(hwinstaOld, UserMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME - don't allow changing the window station if there are threads that are attached to desktops and own gui objects
|
||||||
|
*/
|
||||||
|
|
||||||
|
PsSetProcessWindowStation(ppi->peProcess, hWindowStation);
|
||||||
|
|
||||||
|
ppi->prpwinsta = NewWinSta;
|
||||||
|
ppi->hwinsta = hWindowStation;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue