From ed013220f727b971775538ba216e3415d2a069c7 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Thu, 13 Oct 2011 22:38:58 +0000 Subject: [PATCH] [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 --- .../subsystems/win32/csrss/win32csr/dllmain.c | 26 ++++------ .../subsystems/win32/win32k/ntuser/input.c | 50 +------------------ 2 files changed, 12 insertions(+), 64 deletions(-) diff --git a/reactos/subsystems/win32/csrss/win32csr/dllmain.c b/reactos/subsystems/win32/csrss/win32csr/dllmain.c index aa763b191ab..ac956978e69 100644 --- a/reactos/subsystems/win32/csrss/win32csr/dllmain.c +++ b/reactos/subsystems/win32/csrss/win32csr/dllmain.c @@ -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; } diff --git a/reactos/subsystems/win32/win32k/ntuser/input.c b/reactos/subsystems/win32/win32k/ntuser/input.c index c8ea14c1d4d..e51667753c8 100644 --- a/reactos/subsystems/win32/win32k/ntuser/input.c +++ b/reactos/subsystems/win32/win32k/ntuser/input.c @@ -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);