From dfc5f7e3fa113313c4812235749fb0d8085905f7 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 22 Nov 2013 11:48:51 +0000 Subject: [PATCH] [NTOSKRNL/WIN32K] Always call the win32 process callout from PsConvertToGuiThread and handle the case where we alrady have an allocated win32 process there. (The original win32k sometimes allocates a win32 process, but doesn't initialize it, so it needs to be called again to do so) svn path=/trunk/; revision=61072 --- reactos/ntoskrnl/ps/win32.c | 10 +++------- reactos/win32ss/user/ntuser/main.c | 28 ++++++++++++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/reactos/ntoskrnl/ps/win32.c b/reactos/ntoskrnl/ps/win32.c index b64dd2a4e03..a0309b804b2 100644 --- a/reactos/ntoskrnl/ps/win32.c +++ b/reactos/ntoskrnl/ps/win32.c @@ -82,13 +82,9 @@ PsConvertToGuiThread(VOID) MmDeleteKernelStack(OldStack, FALSE); } - /* This check is bizare. Check out win32k later */ - if (!Process->Win32Process) - { - /* Now tell win32k about us */ - Status = PspW32ProcessCallout(Process, TRUE); - if (!NT_SUCCESS(Status)) return Status; - } + /* Always do the process callout! */ + Status = PspW32ProcessCallout(Process, TRUE); + if (!NT_SUCCESS(Status)) return Status; /* Set the new service table */ Thread->Tcb.ServiceTable = KeServiceDescriptorTableShadow; diff --git a/reactos/win32ss/user/ntuser/main.c b/reactos/win32ss/user/ntuser/main.c index 44c0692ba64..4485c5d4929 100644 --- a/reactos/win32ss/user/ntuser/main.c +++ b/reactos/win32ss/user/ntuser/main.c @@ -57,7 +57,7 @@ Win32kProcessCallback(struct _EPROCESS *Process, BOOLEAN Create) { PPROCESSINFO ppiCurrent, *pppi; - DECLARE_RETURN(NTSTATUS); + NTSTATUS Status; ASSERT(Process->Peb); @@ -69,18 +69,26 @@ Win32kProcessCallback(struct _EPROCESS *Process, LARGE_INTEGER Offset; PVOID UserBase = NULL; PRTL_USER_PROCESS_PARAMETERS pParams = Process->Peb->ProcessParameters; - NTSTATUS Status; - ASSERT(PsGetProcessWin32Process(Process) == NULL); + /* We might be called with an already allocated win32 process */ + ppiCurrent = PsGetProcessWin32Process(Process); + if (ppiCurrent != NULL) + { + /* There is no more to do for us (this is a success code!) */ + Status = STATUS_ALREADY_WIN32; + goto Leave; + } + /* Allocate a new win32 process */ ppiCurrent = ExAllocatePoolWithTag(NonPagedPool, sizeof(PROCESSINFO), USERTAG_PROCESSINFO); - if (ppiCurrent == NULL) { - ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n", HandleToUlong(Process->UniqueProcessId)); - RETURN( STATUS_NO_MEMORY); + ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n", + HandleToUlong(Process->UniqueProcessId)); + Status = STATUS_NO_MEMORY; + goto Leave; } RtlZeroMemory(ppiCurrent, sizeof(PROCESSINFO)); @@ -111,7 +119,7 @@ Win32kProcessCallback(struct _EPROCESS *Process, if (!NT_SUCCESS(Status)) { TRACE_CH(UserProcess,"Failed to map the global heap! 0x%x\n", Status); - RETURN(Status); + goto Leave; } ppiCurrent->HeapMappings.Next = NULL; ppiCurrent->HeapMappings.KernelMapping = (PVOID)GlobalUserHeap; @@ -241,11 +249,11 @@ Win32kProcessCallback(struct _EPROCESS *Process, ExFreePoolWithTag(ppiCurrent, USERTAG_PROCESSINFO); } - RETURN( STATUS_SUCCESS); + Status = STATUS_SUCCESS; -CLEANUP: +Leave: UserLeave(); - END_CLEANUP; + return Status; } NTSTATUS NTAPI