本文主要是介绍xxxInitInput函数和RIT线程的关系【原创】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
xxxInitInput函数和RIT线程的关系
第一部分:调用栈,在winlogon.exe执行。
KeWaitForSingleObjec
InitCreateSystemThreadsMsg
xxxInitInput
作用范围:在winlongon.exe执行。
/*
* Create the RIT and let it run.
*/
代码里面的一句,我们得信。
但是如何让它run,得到csrss中。
第二部分:CST_RIT等于2
/***************************************************************************\
* xxxInitInput
*
* This function is called from CreateTerminalInput() and gets USER setup to
* process keyboard and mouse input. It starts the RIT for that terminal.
* History:
* 11-26-90 DavidPe Created.
\***************************************************************************/
BOOL xxxInitInput(
PTERMINAL pTerm)
{
NTSTATUS Status;
USER_API_MSG m;
RIT_INIT initData;
UserAssert(pTerm != NULL);
#ifdef MOUSE_LOCK_CODE
/*
* Lock RIT pages into memory
*/
LockMouseInputCodePages();
#endif
initData.pTerm = pTerm;
initData.pRitReadyEvent = CreateKernelEvent(SynchronizationEvent, FALSE);
if (initData.pRitReadyEvent == NULL) {
return FALSE;
}
/*
* Create the RIT and let it run.
*/
if (!InitCreateSystemThreadsMsg(&m, CST_RIT, &initData, 0, FALSE)) {
FreeKernelEvent(&initData.pRitReadyEvent);
return FALSE;
}
/*
* Be sure that we are not in CSRSS context.
* WARNING: If for any reason we changed this to run in CSRSS context then we have to use
* LpcRequestPort instead of LpcRequestWaitReplyPort.
*/
UserAssert (!ISCSRSS());
LeaveCrit();
Status = LpcRequestWaitReplyPort(CsrApiPort, (PPORT_MESSAGE)&m, (PPORT_MESSAGE)&m);
if (!NT_SUCCESS(Status)) {
goto Exit;
}
KeWaitForSingleObject(initData.pRitReadyEvent, WrUserRequest,
KernelMode, FALSE, NULL);
Exit:
FreeKernelEvent(&initData.pRitReadyEvent);
EnterCrit();
return (gptiRit != NULL);
}
第三部分:相关数据结构
typedef struct _RIT_INIT {
PTERMINAL pTerm;
PKEVENT pRitReadyEvent;
} RIT_INIT, *PRIT_INIT;
typedef struct tagTERMINAL {
DWORD dwTERMF_Flags; // terminal flags
/*
* System Information
*/
PWND spwndDesktopOwner; // mother desktop
PTHREADINFO ptiDesktop;
PQ pqDesktop;
PKEVENT pEventTermInit;
PKEVENT pEventDestroyDesktop; // Used for destroying desktops
PDESKTOP rpdeskDestroy; // Desktop destroy list.
PKEVENT pEventInputReady; // input ready event. This is created in
// CreateTerminal. RIT and the desktop thread
// will wait for it. It will be set when the
// first desktop in that terminal will be created.
} TERMINAL, *PTERMINAL;
第四部分:功能填好相关数据,线程换出后到csrss.exe后执行。
__inline BOOL InitCreateSystemThreadsMsg(
PUSER_API_MSG pMsg,
UINT ThreadID,
PVOID pVoid,
HANDLE UniqueProcessId,
BOOL bRemoteThread)
{
UserAssert(CsrApiPort != NULL);
if (!CSTPush(ThreadID, pVoid, UniqueProcessId, bRemoteThread)) {
return FALSE;
}
pMsg->h.u1.s1.DataLength = (USHORT)(sizeof(USER_API_MSG) - sizeof(PORT_MESSAGE));
pMsg->h.u1.s1.TotalLength = (USHORT)sizeof(USER_API_MSG);
pMsg->h.u2.ZeroInit = 0;
pMsg->CaptureBuffer = NULL;
pMsg->ApiNumber = CSR_MAKE_API_NUMBER(USERSRV_SERVERDLL_INDEX, UserpCreateSystemThreads);
pMsg->u.CreateSystemThreads.bRemoteThread = bRemoteThread;
return TRUE;
}
这篇关于xxxInitInput函数和RIT线程的关系【原创】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!