[WIN32K/CSRSS]

- Remove outdated comments
- Make Raw Input Thread CSRSS thread too
Thanks to Smiley and ThFabba for investigating TEB issue

svn path=/trunk/; revision=54128
This commit is contained in:
Rafal Harabien 2011-10-13 22:38:58 +00:00
parent 35e585def8
commit ed013220f7
2 changed files with 12 additions and 64 deletions

View file

@ -196,6 +196,7 @@ Win32CsrInitialization(PCSRSS_API_DEFINITION *ApiDefinitions,
HANDLE ServerThread;
CLIENT_ID ClientId;
NTSTATUS Status;
UINT i;
CsrExports = *Exports;
Win32CsrApiHeap = CsrssApiHeap;
@ -214,23 +215,18 @@ Win32CsrInitialization(PCSRSS_API_DEFINITION *ApiDefinitions,
RtlInitializeCriticalSection(&Win32CsrDefineDosDeviceCritSec);
InitializeListHead(&DosDeviceHistory);
Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0, (PTHREAD_START_ROUTINE)CreateSystemThreads, (PVOID)0, &ServerThread, &ClientId);
if (NT_SUCCESS(Status))
/* Start Keyboard, Mouse and Raw Input Threads */
for (i = 0; i < 2; ++i)
{
NtResumeThread(ServerThread, NULL);
NtClose(ServerThread);
Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0, (PTHREAD_START_ROUTINE)CreateSystemThreads, (PVOID)i, &ServerThread, &ClientId);
if (NT_SUCCESS(Status))
{
NtResumeThread(ServerThread, NULL);
NtClose(ServerThread);
}
else
DPRINT1("Cannot start system thread: %u!\n", i);
}
else
DPRINT1("Cannot start keyboard thread!\n");
Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0, (PTHREAD_START_ROUTINE)CreateSystemThreads, (PVOID)1, &ServerThread, &ClientId);
if (NT_SUCCESS(Status))
{
NtResumeThread(ServerThread, NULL);
NtClose(ServerThread);
}
else
DPRINT1("Cannot start mouse thread!\n");
return TRUE;
}

View file

@ -24,8 +24,6 @@ HANDLE ghKeyboardDevice;
static DWORD LastInputTick = 0;
static HANDLE MouseDeviceHandle;
static HANDLE RawInputThreadHandle;
static CLIENT_ID RawInputThreadId;
static KEVENT InputThreadsStart;
static BOOLEAN InputThreadsRunning = FALSE;
@ -216,14 +214,6 @@ MouseThreadMain(PVOID StartContext)
FILE_SYNCHRONOUS_IO_ALERT);
} while (!NT_SUCCESS(Status));
/* Need to setup basic win32k for this thread to process WH_MOUSE_LL messages. */
/*Status = Win32kInitWin32Thread(PsGetCurrentThread());
if (!NT_SUCCESS(Status))
{
ERR("Win32K: Failed making mouse thread a win32 thread.\n");
return; //(Status);
}*/
ptiMouse = PsGetCurrentThreadWin32Thread();
ptiMouse->TIF_flags |= TIF_SYSTEMTHREAD;
TRACE("Mouse Thread 0x%x \n", ptiMouse);
@ -330,22 +320,6 @@ KeyboardThreadMain(PVOID StartContext)
UserInitKeyboard(ghKeyboardDevice);
/* Not sure if converting this thread to a win32 thread is such
a great idea. Since we're posting keyboard messages to the focus
window message queue, we'll be (indirectly) doing sendmessage
stuff from this thread (for WH_KEYBOARD_LL processing), which
means we need our own message queue. If keyboard messages were
instead queued to the system message queue, the thread removing
the message from the system message queue would be responsible
for WH_KEYBOARD_LL processing and we wouldn't need this thread
to be a win32 thread. */
/*Status = Win32kInitWin32Thread(PsGetCurrentThread());
if (!NT_SUCCESS(Status))
{
ERR("Win32K: Failed making keyboard thread a win32 thread.\n");
return; //(Status);
}*/
ptiKeyboard = PsGetCurrentThreadWin32Thread();
ptiKeyboard->TIF_flags |= TIF_SYSTEMTHREAD;
TRACE("Keyboard Thread 0x%x \n", ptiKeyboard);
@ -447,18 +421,9 @@ RawInputThreadMain(PVOID StartContext)
Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, &DueTime);
} while (!NT_SUCCESS(Status));
Objects[0] = &InputThreadsStart;
Objects[1] = MasterTimer;
// This thread requires win32k!
Status = Win32kInitWin32Thread(PsGetCurrentThread());
if (!NT_SUCCESS(Status))
{
ERR("Win32K: Failed making Raw Input thread a win32 thread.\n");
return; //(Status);
}
ptiRawInput = PsGetCurrentThreadWin32Thread();
ptiRawInput->TIF_flags |= TIF_SYSTEMTHREAD;
TRACE("Raw Input Thread 0x%x \n", ptiRawInput);
@ -501,6 +466,7 @@ CreateSystemThreads(UINT Type)
{
case 0: KeyboardThreadMain(NULL); break;
case 1: MouseThreadMain(NULL); break;
case 2: RawInputThreadMain(NULL); break;
default: ERR("Wrong type: %x\n", Type);
}
@ -514,8 +480,6 @@ NTSTATUS
NTAPI
InitInputImpl(VOID)
{
NTSTATUS Status;
KeInitializeEvent(&InputThreadsStart, NotificationEvent, FALSE);
MasterTimer = ExAllocatePoolWithTag(NonPagedPool, sizeof(KTIMER), USERTAG_SYSTEM);
@ -533,18 +497,6 @@ InitInputImpl(VOID)
ERR("Failed to initialize default keyboard layout!\n");
}
Status = PsCreateSystemThread(&RawInputThreadHandle,
THREAD_ALL_ACCESS,
NULL,
NULL,
&RawInputThreadId,
RawInputThreadMain,
NULL);
if (!NT_SUCCESS(Status))
{
ERR("Win32K: Failed to create raw thread.\n");
}
InputThreadsRunning = TRUE;
KeSetEvent(&InputThreadsStart, IO_NO_INCREMENT, FALSE);