mirror of
https://github.com/reactos/reactos.git
synced 2025-05-30 22:49:12 +00:00
[NTOSKRNK]
Implement ExpWin32SessionCallout, which attaches to the session that the object (desktop or window station) belongs to before invoking any callbacks. The session side of support for this is currently hardcoded to support only a single session. To make this properly work, all callbacks that go through this function have the same function pointer type now, fix this in win32k accordingly. svn path=/trunk/; revision=61052
This commit is contained in:
parent
69b8eb2c54
commit
f200563361
9 changed files with 334 additions and 86 deletions
|
@ -559,7 +559,7 @@ NTSTATUS
|
|||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
NTSTATUS
|
||||
(NTAPI *PKWIN32_DELETEMETHOD_CALLOUT)(
|
||||
_In_ struct _WIN32_DELETEMETHOD_PARAMETERS *Parameters
|
||||
);
|
||||
|
@ -570,6 +570,12 @@ NTSTATUS
|
|||
_In_ struct _WIN32_PARSEMETHOD_PARAMETERS *Parameters
|
||||
);
|
||||
|
||||
typedef
|
||||
NTSTATUS
|
||||
(NTAPI *PKWIN32_SESSION_CALLOUT)(
|
||||
_In_ PVOID Parameter
|
||||
);
|
||||
|
||||
typedef
|
||||
NTSTATUS
|
||||
(NTAPI *PKWIN32_WIN32DATACOLLECTION_CALLOUT)(
|
||||
|
@ -1406,15 +1412,15 @@ typedef struct _WIN32_CALLOUTS_FPNS
|
|||
PKWIN32_POWERSTATE_CALLOUT PowerStateCallout;
|
||||
PKWIN32_JOB_CALLOUT JobCallout;
|
||||
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine;
|
||||
PKWIN32_OPENMETHOD_CALLOUT DesktopOpenProcedure;
|
||||
PKWIN32_OKTOCLOSEMETHOD_CALLOUT DesktopOkToCloseProcedure;
|
||||
PKWIN32_CLOSEMETHOD_CALLOUT DesktopCloseProcedure;
|
||||
PKWIN32_DELETEMETHOD_CALLOUT DesktopDeleteProcedure;
|
||||
PKWIN32_OKTOCLOSEMETHOD_CALLOUT WindowStationOkToCloseProcedure;
|
||||
PKWIN32_CLOSEMETHOD_CALLOUT WindowStationCloseProcedure;
|
||||
PKWIN32_DELETEMETHOD_CALLOUT WindowStationDeleteProcedure;
|
||||
PKWIN32_PARSEMETHOD_CALLOUT WindowStationParseProcedure;
|
||||
PKWIN32_OPENMETHOD_CALLOUT WindowStationOpenProcedure;
|
||||
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure;
|
||||
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure;
|
||||
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure;
|
||||
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure;
|
||||
PKWIN32_SESSION_CALLOUT WindowStationOkToCloseProcedure;
|
||||
PKWIN32_SESSION_CALLOUT WindowStationCloseProcedure;
|
||||
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure;
|
||||
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure;
|
||||
PKWIN32_SESSION_CALLOUT WindowStationOpenProcedure;
|
||||
PKWIN32_WIN32DATACOLLECTION_CALLOUT Win32DataCollectionProcedure;
|
||||
} WIN32_CALLOUTS_FPNS, *PWIN32_CALLOUTS_FPNS;
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
#pragma alloc_text(INIT, ExpWin32kInit)
|
||||
#endif
|
||||
|
||||
typedef struct _WIN32_KERNEL_OBJECT_HEADER
|
||||
{
|
||||
ULONG SessionId;
|
||||
} WIN32_KERNEL_OBJECT_HEADER, *PWIN32_KERNEL_OBJECT_HEADER;
|
||||
|
||||
|
||||
/* DATA **********************************************************************/
|
||||
|
||||
POBJECT_TYPE ExWindowStationObjectType = NULL;
|
||||
|
@ -35,16 +41,77 @@ GENERIC_MAPPING ExpDesktopMapping =
|
|||
STANDARD_RIGHTS_REQUIRED
|
||||
};
|
||||
|
||||
PKWIN32_PARSEMETHOD_CALLOUT ExpWindowStationObjectParse = NULL;
|
||||
PKWIN32_DELETEMETHOD_CALLOUT ExpWindowStationObjectDelete = NULL;
|
||||
PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpWindowStationObjectOkToClose = NULL;
|
||||
PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpDesktopObjectOkToClose = NULL;
|
||||
PKWIN32_DELETEMETHOD_CALLOUT ExpDesktopObjectDelete = NULL;
|
||||
PKWIN32_OPENMETHOD_CALLOUT ExpDesktopObjectOpen = NULL;
|
||||
PKWIN32_CLOSEMETHOD_CALLOUT ExpDesktopObjectClose = NULL;
|
||||
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectParse = NULL;
|
||||
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectDelete = NULL;
|
||||
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectOkToClose = NULL;
|
||||
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOkToClose = NULL;
|
||||
PKWIN32_SESSION_CALLOUT ExpDesktopObjectDelete = NULL;
|
||||
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOpen = NULL;
|
||||
PKWIN32_SESSION_CALLOUT ExpDesktopObjectClose = NULL;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ExpWin32SessionCallout(
|
||||
_In_ PVOID Object,
|
||||
_In_ PKWIN32_SESSION_CALLOUT CalloutProcedure,
|
||||
_Inout_opt_ PVOID Parameter)
|
||||
{
|
||||
PWIN32_KERNEL_OBJECT_HEADER Win32ObjectHeader;
|
||||
PVOID SessionEntry = NULL;
|
||||
KAPC_STATE ApcState;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* The objects have a common header. And the kernel accesses it!
|
||||
Thanks MS for this kind of retarded "design"! */
|
||||
Win32ObjectHeader = Object;
|
||||
|
||||
/* Check if we are not already in the correct session */
|
||||
if (!PsGetCurrentProcess()->ProcessInSession ||
|
||||
(PsGetCurrentProcessSessionId() != Win32ObjectHeader->SessionId))
|
||||
{
|
||||
/* Get the session from the objects session Id */
|
||||
DPRINT1("SessionId == %d\n", Win32ObjectHeader->SessionId);
|
||||
SessionEntry = MmGetSessionById(Win32ObjectHeader->SessionId);
|
||||
if (SessionEntry == NULL)
|
||||
{
|
||||
/* The requested session does not even exist! */
|
||||
NT_ASSERT(FALSE);
|
||||
return STATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* Attach to the session */
|
||||
Status = MmAttachSession(SessionEntry, &ApcState);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Could not attach to 0x%p, object %p, callout 0x%p\n",
|
||||
SessionEntry,
|
||||
Win32ObjectHeader,
|
||||
CalloutProcedure);
|
||||
|
||||
/* Cleanup and return */
|
||||
MmQuitNextSession(SessionEntry);
|
||||
NT_ASSERT(FALSE);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Call the callout routine */
|
||||
Status = CalloutProcedure(Parameter);
|
||||
|
||||
/* Check if we have a session */
|
||||
if (SessionEntry != NULL)
|
||||
{
|
||||
/* Detach from the session and quit using it */
|
||||
MmDetachSession(SessionEntry, &ApcState);
|
||||
MmQuitNextSession(SessionEntry);
|
||||
}
|
||||
|
||||
/* Return the callback status */
|
||||
return Status;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ExpDesktopOkToClose( IN PEPROCESS Process OPTIONAL,
|
||||
|
@ -53,13 +120,18 @@ ExpDesktopOkToClose( IN PEPROCESS Process OPTIONAL,
|
|||
IN KPROCESSOR_MODE AccessMode)
|
||||
{
|
||||
WIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters;
|
||||
NTSTATUS Status;
|
||||
|
||||
Parameters.Process = Process;
|
||||
Parameters.Object = Object;
|
||||
Parameters.Handle = Handle;
|
||||
Parameters.PreviousMode = AccessMode;
|
||||
|
||||
return NT_SUCCESS(ExpDesktopObjectOkToClose(&Parameters));
|
||||
Status = ExpWin32SessionCallout(Object,
|
||||
ExpDesktopObjectOkToClose,
|
||||
&Parameters);
|
||||
|
||||
return NT_SUCCESS(Status);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
|
@ -70,13 +142,18 @@ ExpWindowStationOkToClose( IN PEPROCESS Process OPTIONAL,
|
|||
IN KPROCESSOR_MODE AccessMode)
|
||||
{
|
||||
WIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters;
|
||||
NTSTATUS Status;
|
||||
|
||||
Parameters.Process = Process;
|
||||
Parameters.Object = Object;
|
||||
Parameters.Handle = Handle;
|
||||
Parameters.PreviousMode = AccessMode;
|
||||
|
||||
return NT_SUCCESS(ExpWindowStationObjectOkToClose(&Parameters));
|
||||
Status = ExpWin32SessionCallout(Object,
|
||||
ExpWindowStationObjectOkToClose,
|
||||
&Parameters);
|
||||
|
||||
return NT_SUCCESS(Status);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -88,8 +165,9 @@ ExpWinStaObjectDelete(PVOID DeletedObject)
|
|||
/* Fill out the callback structure */
|
||||
Parameters.Object = DeletedObject;
|
||||
|
||||
/* Call the Registered Callback */
|
||||
ExpWindowStationObjectDelete(&Parameters);
|
||||
ExpWin32SessionCallout(DeletedObject,
|
||||
ExpWindowStationObjectDelete,
|
||||
&Parameters);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -119,8 +197,9 @@ ExpWinStaObjectParse(IN PVOID ParseObject,
|
|||
Parameters.SecurityQos = SecurityQos;
|
||||
Parameters.Object = Object;
|
||||
|
||||
/* Call the Registered Callback */
|
||||
return ExpWindowStationObjectParse(&Parameters);
|
||||
return ExpWin32SessionCallout(ParseObject,
|
||||
ExpWindowStationObjectParse,
|
||||
&Parameters);
|
||||
}
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -131,12 +210,13 @@ ExpDesktopDelete(PVOID DeletedObject)
|
|||
/* Fill out the callback structure */
|
||||
Parameters.Object = DeletedObject;
|
||||
|
||||
/* Call the Registered Callback */
|
||||
ExpDesktopObjectDelete(&Parameters);
|
||||
ExpWin32SessionCallout(DeletedObject,
|
||||
ExpDesktopObjectDelete,
|
||||
&Parameters);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NTAPI
|
||||
ExpDesktopOpen(IN OB_OPEN_REASON Reason,
|
||||
IN PEPROCESS Process OPTIONAL,
|
||||
IN PVOID ObjectBody,
|
||||
|
@ -151,11 +231,13 @@ ExpDesktopOpen(IN OB_OPEN_REASON Reason,
|
|||
Parameters.GrantedAccess = GrantedAccess;
|
||||
Parameters.HandleCount = HandleCount;
|
||||
|
||||
return ExpDesktopObjectOpen(&Parameters);
|
||||
return ExpWin32SessionCallout(ObjectBody,
|
||||
ExpDesktopObjectOpen,
|
||||
&Parameters);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
NTAPI
|
||||
ExpDesktopClose(IN PEPROCESS Process OPTIONAL,
|
||||
IN PVOID Object,
|
||||
IN ACCESS_MASK GrantedAccess,
|
||||
|
@ -170,7 +252,9 @@ ExpDesktopClose(IN PEPROCESS Process OPTIONAL,
|
|||
Parameters.ProcessHandleCount = ProcessHandleCount;
|
||||
Parameters.SystemHandleCount = SystemHandleCount;
|
||||
|
||||
ExpDesktopObjectClose(&Parameters);
|
||||
ExpWin32SessionCallout(Object,
|
||||
ExpDesktopObjectClose,
|
||||
&Parameters);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
|
@ -202,7 +286,7 @@ ExpWin32kInit(VOID)
|
|||
NULL,
|
||||
&ExWindowStationObjectType);
|
||||
if (!NT_SUCCESS(Status)) return FALSE;
|
||||
|
||||
|
||||
/* Create desktop object type */
|
||||
RtlInitUnicodeString(&Name, L"Desktop");
|
||||
ObjectTypeInitializer.GenericMapping = ExpDesktopMapping;
|
||||
|
@ -216,7 +300,7 @@ ExpWin32kInit(VOID)
|
|||
NULL,
|
||||
&ExDesktopObjectType);
|
||||
if (!NT_SUCCESS(Status)) return FALSE;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1770,3 +1770,31 @@ ExpCheckPoolAllocation(
|
|||
PVOID P,
|
||||
POOL_TYPE PoolType,
|
||||
ULONG Tag);
|
||||
|
||||
|
||||
/* session.c *****************************************************************/
|
||||
|
||||
_IRQL_requires_max_(APC_LEVEL)
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
MmAttachSession(
|
||||
_Inout_ PVOID SessionEntry,
|
||||
_Out_ PKAPC_STATE ApcState);
|
||||
|
||||
_IRQL_requires_max_(APC_LEVEL)
|
||||
VOID
|
||||
NTAPI
|
||||
MmDetachSession(
|
||||
_Inout_ PVOID SessionEntry,
|
||||
_Out_ PKAPC_STATE ApcState);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
MmQuitNextSession(
|
||||
_Inout_ PVOID SessionEntry);
|
||||
|
||||
PVOID
|
||||
NTAPI
|
||||
MmGetSessionById(
|
||||
_In_ ULONG SessionId);
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ LONG MmSessionDataPages;
|
|||
PRTL_BITMAP MiSessionIdBitmap;
|
||||
volatile LONG MiSessionLeaderExists;
|
||||
|
||||
// HACK: we support only one process. The creator is CSRSS and that lives!
|
||||
PEPROCESS Session0CreatorProcess;
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
|
@ -607,6 +610,10 @@ MiSessionCreateInternal(OUT PULONG SessionId)
|
|||
ASSERT(SessionGlobal->ProcessReferenceToSession == 0);
|
||||
SessionGlobal->ProcessReferenceToSession = 1;
|
||||
|
||||
// HACK: we only support 1 session and save the creator process
|
||||
NT_ASSERT(Session0CreatorProcess == NULL);
|
||||
Session0CreatorProcess = PsGetCurrentProcess();
|
||||
|
||||
/* We're done */
|
||||
InterlockedIncrement(&MmSessionDataPages);
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -700,3 +707,74 @@ MmSessionDelete(IN ULONG SessionId)
|
|||
/* All done */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(APC_LEVEL)
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
MmAttachSession(
|
||||
_Inout_ PVOID SessionEntry,
|
||||
_Out_ PKAPC_STATE ApcState)
|
||||
{
|
||||
PEPROCESS EntryProcess;
|
||||
|
||||
/* The parameter is the actual process! */
|
||||
EntryProcess = SessionEntry;
|
||||
NT_ASSERT(EntryProcess != NULL);
|
||||
|
||||
/* HACK: for now we only support 1 session! */
|
||||
NT_ASSERT(((PMM_SESSION_SPACE)EntryProcess->Session)->SessionId == 1);
|
||||
|
||||
/* Very simple for now: just attach to the process we have */
|
||||
KeStackAttachProcess(&EntryProcess->Pcb, ApcState);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(APC_LEVEL)
|
||||
VOID
|
||||
NTAPI
|
||||
MmDetachSession(
|
||||
_Inout_ PVOID SessionEntry,
|
||||
_In_ PKAPC_STATE ApcState)
|
||||
{
|
||||
PEPROCESS EntryProcess;
|
||||
|
||||
/* The parameter is the actual process! */
|
||||
EntryProcess = SessionEntry;
|
||||
NT_ASSERT(EntryProcess != NULL);
|
||||
|
||||
/* HACK: for now we only support 1 session! */
|
||||
NT_ASSERT(((PMM_SESSION_SPACE)EntryProcess->Session)->SessionId == 0);
|
||||
|
||||
/* Very simple for now: just detach */
|
||||
KeUnstackDetachProcess(ApcState);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
MmQuitNextSession(
|
||||
_Inout_ PVOID SessionEntry)
|
||||
{
|
||||
PEPROCESS EntryProcess;
|
||||
|
||||
/* The parameter is the actual process! */
|
||||
EntryProcess = SessionEntry;
|
||||
NT_ASSERT(EntryProcess != NULL);
|
||||
|
||||
/* HACK: for now we only support 1 session! */
|
||||
NT_ASSERT(((PMM_SESSION_SPACE)EntryProcess->Session)->SessionId == 0);
|
||||
|
||||
/* Get rid of the reference we got */
|
||||
ObDereferenceObject(SessionEntry);
|
||||
}
|
||||
|
||||
PVOID
|
||||
NTAPI
|
||||
MmGetSessionById(
|
||||
_In_ ULONG SessionId)
|
||||
{
|
||||
/* HACK: for now we only support 1 session! */
|
||||
NT_ASSERT(SessionId == 0);
|
||||
|
||||
/* Just return the sessions creator process, which is csrss and still alive. */
|
||||
return Session0CreatorProcess;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout = NULL;
|
||||
PKWIN32_THREAD_CALLOUT PspW32ThreadCallout = NULL;
|
||||
PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch = NULL;
|
||||
extern PKWIN32_PARSEMETHOD_CALLOUT ExpWindowStationObjectParse;
|
||||
extern PKWIN32_DELETEMETHOD_CALLOUT ExpWindowStationObjectDelete;
|
||||
extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpWindowStationObjectOkToClose;
|
||||
extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpDesktopObjectOkToClose;
|
||||
extern PKWIN32_DELETEMETHOD_CALLOUT ExpDesktopObjectDelete;
|
||||
extern PKWIN32_OPENMETHOD_CALLOUT ExpDesktopObjectOpen;
|
||||
extern PKWIN32_CLOSEMETHOD_CALLOUT ExpDesktopObjectClose;
|
||||
extern PKWIN32_SESSION_CALLOUT ExpWindowStationObjectParse;
|
||||
extern PKWIN32_SESSION_CALLOUT ExpWindowStationObjectDelete;
|
||||
extern PKWIN32_SESSION_CALLOUT ExpWindowStationObjectOkToClose;
|
||||
extern PKWIN32_SESSION_CALLOUT ExpDesktopObjectOkToClose;
|
||||
extern PKWIN32_SESSION_CALLOUT ExpDesktopObjectDelete;
|
||||
extern PKWIN32_SESSION_CALLOUT ExpDesktopObjectOpen;
|
||||
extern PKWIN32_SESSION_CALLOUT ExpDesktopObjectClose;
|
||||
extern PKWIN32_POWEREVENT_CALLOUT PopEventCallout;
|
||||
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
|
|
@ -138,10 +138,13 @@ IntDesktopObjectParse(IN PVOID ParseObject,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID APIENTRY
|
||||
IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters)
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopObjectDelete(
|
||||
_In_ PVOID Parameters)
|
||||
{
|
||||
PDESKTOP pdesk = (PDESKTOP)Parameters->Object;
|
||||
PWIN32_DELETEMETHOD_PARAMETERS DeleteParameters = Parameters;
|
||||
PDESKTOP pdesk = (PDESKTOP)DeleteParameters->Object;
|
||||
|
||||
TRACE("Deleting desktop object 0x%p\n", pdesk);
|
||||
|
||||
|
@ -158,11 +161,15 @@ IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters)
|
|||
|
||||
/* Free the heap */
|
||||
IntFreeDesktopHeap(pdesk);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters)
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopOkToClose(
|
||||
_In_ PVOID Parameters)
|
||||
{
|
||||
PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS OkToCloseParameters = Parameters;
|
||||
PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
|
||||
|
||||
if( pti == NULL)
|
||||
|
@ -172,8 +179,8 @@ IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters)
|
|||
}
|
||||
|
||||
/* Do not allow the current desktop or the initial desktop to be closed */
|
||||
if( Parameters->Handle == pti->ppi->hdeskStartup ||
|
||||
Parameters->Handle == pti->hdesk)
|
||||
if( OkToCloseParameters->Handle == pti->ppi->hdeskStartup ||
|
||||
OkToCloseParameters->Handle == pti->hdesk)
|
||||
{
|
||||
return STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
@ -181,18 +188,26 @@ IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI IntDesktopObjectOpen(PWIN32_OPENMETHOD_PARAMETERS Parameters)
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopObjectOpen(
|
||||
_In_ PVOID Parameters)
|
||||
{
|
||||
PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process);
|
||||
PWIN32_OPENMETHOD_PARAMETERS OpenParameters = Parameters;
|
||||
PPROCESSINFO ppi = PsGetProcessWin32Process(OpenParameters->Process);
|
||||
if (ppi == NULL)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
return IntMapDesktopView((PDESKTOP)Parameters->Object);
|
||||
return IntMapDesktopView((PDESKTOP)OpenParameters->Object);
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters)
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopObjectClose(
|
||||
_In_ PVOID Parameters)
|
||||
{
|
||||
PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process);
|
||||
PWIN32_CLOSEMETHOD_PARAMETERS CloseParameters = Parameters;
|
||||
PPROCESSINFO ppi = PsGetProcessWin32Process(CloseParameters->Process);
|
||||
if (ppi == NULL)
|
||||
{
|
||||
/* This happens when the process leaks desktop handles.
|
||||
|
@ -200,7 +215,7 @@ NTSTATUS NTAPI IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return IntUnmapDesktopView((PDESKTOP)Parameters->Object);
|
||||
return IntUnmapDesktopView((PDESKTOP)CloseParameters->Object);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1341,6 +1356,7 @@ NtUserCreateDesktop(
|
|||
RETURN(NULL);
|
||||
}
|
||||
|
||||
pdesk->dwSessionId = PsGetCurrentProcessSessionId();
|
||||
pdesk->DesktopWindow = pWnd->head.h;
|
||||
pdesk->pDeskInfo->spwnd = pWnd;
|
||||
pWnd->fnid = FNID_DESKTOP;
|
||||
|
@ -1638,7 +1654,7 @@ NtUserSwitchDesktop(HDESK hdesk)
|
|||
if (PsGetCurrentProcessSessionId() != pdesk->rpwinstaParent->dwSessionId)
|
||||
{
|
||||
ERR("NtUserSwitchDesktop called for a desktop of a different session\n");
|
||||
RETURN(FALSE);
|
||||
RETURN(FALSE);
|
||||
}
|
||||
|
||||
if(pdesk == gpdeskInputDesktop)
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
typedef struct _DESKTOP
|
||||
{
|
||||
/* Must be the first member */
|
||||
DWORD dwSessionId;
|
||||
|
||||
PDESKTOPINFO pDeskInfo;
|
||||
LIST_ENTRY ListEntry;
|
||||
/* Pointer to the associated window station. */
|
||||
|
@ -99,17 +102,25 @@ IntDesktopObjectParse(IN PVOID ParseObject,
|
|||
IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
|
||||
OUT PVOID *Object);
|
||||
|
||||
VOID APIENTRY
|
||||
IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters);
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopObjectDelete(
|
||||
_In_ PVOID Parameters);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters);
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopOkToClose(
|
||||
_In_ PVOID Parameters);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
IntDesktopObjectOpen(PWIN32_OPENMETHOD_PARAMETERS Parameters);
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopObjectOpen(
|
||||
_In_ PVOID Parameters);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters);
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntDesktopObjectClose(
|
||||
_In_ PVOID Parameters);
|
||||
|
||||
HDC FASTCALL
|
||||
IntGetScreenDC(VOID);
|
||||
|
|
|
@ -95,10 +95,13 @@ UserCreateWinstaDirectory()
|
|||
|
||||
/* OBJECT CALLBACKS **********************************************************/
|
||||
|
||||
VOID APIENTRY
|
||||
IntWinStaObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters)
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
IntWinStaObjectDelete(
|
||||
_In_ PVOID Parameters)
|
||||
{
|
||||
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)Parameters->Object;
|
||||
PWIN32_DELETEMETHOD_PARAMETERS DeleteParameters = Parameters;
|
||||
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeleteParameters->Object;
|
||||
|
||||
TRACE("Deleting window station (0x%p)\n", WinSta);
|
||||
|
||||
|
@ -107,30 +110,34 @@ IntWinStaObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters)
|
|||
RtlDestroyAtomTable(WinSta->AtomTable);
|
||||
|
||||
RtlFreeUnicodeString(&WinSta->Name);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
IntWinStaObjectParse(PWIN32_PARSEMETHOD_PARAMETERS Parameters)
|
||||
IntWinStaObjectParse(
|
||||
_In_ PVOID Parameters)
|
||||
{
|
||||
PUNICODE_STRING RemainingName = Parameters->RemainingName;
|
||||
PWIN32_PARSEMETHOD_PARAMETERS ParseParameters = Parameters;
|
||||
PUNICODE_STRING RemainingName = ParseParameters->RemainingName;
|
||||
|
||||
/* Assume we don't find anything */
|
||||
*Parameters->Object = NULL;
|
||||
*ParseParameters->Object = NULL;
|
||||
|
||||
/* Check for an empty name */
|
||||
if (!RemainingName->Length)
|
||||
{
|
||||
/* Make sure this is a window station, can't parse a desktop now */
|
||||
if (Parameters->ObjectType != ExWindowStationObjectType)
|
||||
if (ParseParameters->ObjectType != ExWindowStationObjectType)
|
||||
{
|
||||
/* Fail */
|
||||
return STATUS_OBJECT_TYPE_MISMATCH;
|
||||
}
|
||||
|
||||
/* Reference the window station and return */
|
||||
ObReferenceObject(Parameters->ParseObject);
|
||||
*Parameters->Object = Parameters->ParseObject;
|
||||
ObReferenceObject(ParseParameters->ParseObject);
|
||||
*ParseParameters->Object = ParseParameters->ParseObject;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -153,19 +160,19 @@ IntWinStaObjectParse(PWIN32_PARSEMETHOD_PARAMETERS Parameters)
|
|||
/*
|
||||
* Check if we are parsing a desktop.
|
||||
*/
|
||||
if (Parameters->ObjectType == ExDesktopObjectType)
|
||||
if (ParseParameters->ObjectType == ExDesktopObjectType)
|
||||
{
|
||||
/* Then call the desktop parse routine */
|
||||
return IntDesktopObjectParse(Parameters->ParseObject,
|
||||
Parameters->ObjectType,
|
||||
Parameters->AccessState,
|
||||
Parameters->AccessMode,
|
||||
Parameters->Attributes,
|
||||
Parameters->CompleteName,
|
||||
return IntDesktopObjectParse(ParseParameters->ParseObject,
|
||||
ParseParameters->ObjectType,
|
||||
ParseParameters->AccessState,
|
||||
ParseParameters->AccessMode,
|
||||
ParseParameters->Attributes,
|
||||
ParseParameters->CompleteName,
|
||||
RemainingName,
|
||||
Parameters->Context,
|
||||
Parameters->SecurityQos,
|
||||
Parameters->Object);
|
||||
ParseParameters->Context,
|
||||
ParseParameters->SecurityQos,
|
||||
ParseParameters->Object);
|
||||
}
|
||||
|
||||
/* Should hopefully never get here */
|
||||
|
@ -174,13 +181,15 @@ IntWinStaObjectParse(PWIN32_PARSEMETHOD_PARAMETERS Parameters)
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntWinstaOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters)
|
||||
IntWinstaOkToClose(
|
||||
_In_ PVOID Parameters)
|
||||
{
|
||||
PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS OkToCloseParameters = Parameters;
|
||||
PPROCESSINFO ppi;
|
||||
|
||||
ppi = PsGetCurrentProcessWin32Process();
|
||||
|
||||
if(ppi && (Parameters->Handle == ppi->hwinsta))
|
||||
if(ppi && (OkToCloseParameters->Handle == ppi->hwinsta))
|
||||
{
|
||||
return STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
|
|
@ -71,18 +71,34 @@ INIT_FUNCTION
|
|||
NTSTATUS
|
||||
NTAPI
|
||||
InitWindowStationImpl(VOID);
|
||||
NTSTATUS NTAPI UserCreateWinstaDirectory();
|
||||
|
||||
VOID APIENTRY IntWinStaObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters);
|
||||
NTSTATUS APIENTRY IntWinStaObjectParse(PWIN32_PARSEMETHOD_PARAMETERS Parameters);
|
||||
NTSTATUS NTAPI IntWinstaOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters);
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
UserCreateWinstaDirectory();
|
||||
|
||||
NTSTATUS FASTCALL
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
IntWinStaObjectDelete(
|
||||
_In_ PVOID Parameters);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
IntWinStaObjectParse(
|
||||
_In_ PVOID Parameters);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IntWinstaOkToClose(
|
||||
_In_ PVOID Parameters);
|
||||
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
IntValidateWindowStationHandle(
|
||||
HWINSTA WindowStation,
|
||||
KPROCESSOR_MODE AccessMode,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
PWINSTATION_OBJECT *Object);
|
||||
|
||||
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation);
|
||||
|
||||
BOOL FASTCALL co_IntInitializeDesktopGraphics(VOID);
|
||||
|
|
Loading…
Reference in a new issue