[WIN32K]: Use the logon process ID instead of a full win32k process object, it simplifies code in some parts.

svn path=/trunk/; revision=65465
This commit is contained in:
Hermès Bélusca-Maïto 2014-11-23 16:09:00 +00:00
parent 72074af697
commit 60205c7b0b
5 changed files with 34 additions and 36 deletions

View 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);

View 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.DesktopOkToCloseProcedure = IntDesktopOkToClose;
CalloutData.DesktopDeleteProcedure = IntDesktopObjectDelete;
CalloutData.DesktopCloseProcedure = IntDesktopObjectClose;
CalloutData.DesktopOpenProcedure = IntDesktopObjectOpen;
// CalloutData.GlobalAtomTableCallout = NULL;
// CalloutData.PowerEventCallout = NULL;
// CalloutData.PowerStateCallout = NULL;
// CalloutData.JobCallout = NULL;
CalloutData.BatchFlushRoutine = NtGdiFlushUserBatch;
CalloutData.DesktopOpenProcedure = IntDesktopObjectOpen;
CalloutData.DesktopOkToCloseProcedure = IntDesktopOkToClose;
CalloutData.DesktopCloseProcedure = IntDesktopObjectClose;
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

View 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));

View 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;
}

View 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;