From bde03977f6ec933cbc45cfaa58bdf3e6f864c39e Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 23 May 2009 00:57:51 +0000 Subject: [PATCH] - Move Process Information structure back into kernel space. We use client information via TEB to provide a pointer for user space as a reference pointer. svn path=/trunk/; revision=41051 --- reactos/include/reactos/win32k/ntuser.h | 16 +------- .../subsystems/win32/win32k/include/win32.h | 13 +++++++ .../subsystems/win32/win32k/main/dllmain.c | 14 ++----- reactos/subsystems/win32/win32k/ntuser/misc.c | 38 +------------------ .../subsystems/win32/win32k/ntuser/ntstubs.c | 8 ++-- 5 files changed, 23 insertions(+), 66 deletions(-) diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index f8f30373723..46ae2b441cf 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -1,7 +1,7 @@ #ifndef __WIN32K_NTUSER_H #define __WIN32K_NTUSER_H -struct _PROCESSINFO; +typedef struct _PROCESSINFO *PPROCESSINFO; struct _W32THREADINFO; struct _WINDOW; @@ -335,20 +335,6 @@ typedef struct _SERVERINFO DWORD SrvEventActivity; } SERVERINFO, *PSERVERINFO; -typedef struct _PROCESSINFO -{ - PVOID UserHandleTable; - HANDLE hUserHeap; - ULONG_PTR UserHeapDelta; - HINSTANCE hModUser; - PWINDOWCLASS LocalClassList; - PWINDOWCLASS GlobalClassList; - PWINDOWCLASS SystemClassList; - - UINT RegisteredSysClasses : 1; - -} PROCESSINFO, *PPROCESSINFO; - #define CTI_INSENDMESSAGE 0x0002 typedef struct _CLIENTTHREADINFO diff --git a/reactos/subsystems/win32/win32k/include/win32.h b/reactos/subsystems/win32/win32k/include/win32.h index 416954fa6a5..ecd4e808206 100644 --- a/reactos/subsystems/win32/win32k/include/win32.h +++ b/reactos/subsystems/win32/win32k/include/win32.h @@ -94,4 +94,17 @@ typedef struct _W32PROCESS PPROCESSINFO ProcessInfo; } W32PROCESS, *PW32PROCESS; +typedef struct _PROCESSINFO +{ + W32PROCESS XzyxW32Process; /* Place holder. */ + /* ReactOS */ + HINSTANCE hModUser; + PWINDOWCLASS LocalClassList; + PWINDOWCLASS GlobalClassList; + PWINDOWCLASS SystemClassList; + + UINT RegisteredSysClasses : 1; + +} PROCESSINFO; + #endif /* __INCLUDE_NAPI_WIN32_H */ diff --git a/reactos/subsystems/win32/win32k/main/dllmain.c b/reactos/subsystems/win32/win32k/main/dllmain.c index e0444489846..7062a102bf5 100644 --- a/reactos/subsystems/win32/win32k/main/dllmain.c +++ b/reactos/subsystems/win32/win32k/main/dllmain.c @@ -67,12 +67,12 @@ Win32kProcessCallback(struct _EPROCESS *Process, { /* FIXME - lock the process */ Win32Process = ExAllocatePoolWithTag(NonPagedPool, - sizeof(W32PROCESS), + sizeof(PROCESSINFO), TAG('W', '3', '2', 'p')); if (Win32Process == NULL) RETURN( STATUS_NO_MEMORY); - RtlZeroMemory(Win32Process, sizeof(W32PROCESS)); + RtlZeroMemory(Win32Process, sizeof(PROCESSINFO)); PsSetProcessWin32Process(Process, Win32Process); /* FIXME - unlock the process */ @@ -152,12 +152,6 @@ Win32kProcessCallback(struct _EPROCESS *Process, { LogonProcess = NULL; } - - if (Win32Process->ProcessInfo != NULL) - { - UserHeapFree(Win32Process->ProcessInfo); - Win32Process->ProcessInfo = NULL; - } } RETURN( STATUS_SUCCESS); @@ -339,12 +333,12 @@ Win32kInitWin32Thread(PETHREAD Thread) if (Process->Win32Process == NULL) { /* FIXME - lock the process */ - Process->Win32Process = ExAllocatePool(NonPagedPool, sizeof(W32PROCESS)); + Process->Win32Process = ExAllocatePool(NonPagedPool, sizeof(PROCESSINFO)); if (Process->Win32Process == NULL) return STATUS_NO_MEMORY; - RtlZeroMemory(Process->Win32Process, sizeof(W32PROCESS)); + RtlZeroMemory(Process->Win32Process, sizeof(PROCESSINFO)); /* FIXME - unlock the process */ Win32kProcessCallback(Process, TRUE); diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index 6f9d7a21f2d..ece9477109c 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -463,43 +463,7 @@ IntFreeNULLTerminatedFromUnicodeString(PWSTR NullTerminated, PUNICODE_STRING Uni PPROCESSINFO GetW32ProcessInfo(VOID) { - PPROCESSINFO pi; - PW32PROCESS W32Process = PsGetCurrentProcessWin32Process(); - - if (W32Process == NULL) - { - /* FIXME - temporary hack for system threads... */ - return NULL; - } - - if (W32Process->ProcessInfo == NULL) - { - pi = UserHeapAlloc(sizeof(PROCESSINFO)); - if (pi != NULL) - { - RtlZeroMemory(pi, - sizeof(PROCESSINFO)); - - /* initialize it */ - pi->UserHandleTable = gHandleTable; - pi->hUserHeap = W32Process->HeapMappings.KernelMapping; - pi->UserHeapDelta = (ULONG_PTR)W32Process->HeapMappings.KernelMapping - - (ULONG_PTR)W32Process->HeapMappings.UserMapping; - - if (InterlockedCompareExchangePointer(&W32Process->ProcessInfo, - pi, - NULL) != NULL) - { - UserHeapFree(pi); - } - } - else - { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); - } - } - - return W32Process->ProcessInfo; + return (PPROCESSINFO)PsGetCurrentProcessWin32Process(); } PW32THREADINFO diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 077d9bd7a79..dd8bd66d657 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -893,12 +893,13 @@ NtUserProcessConnect( { UserEnterShared(); GetW32ThreadInfo(); - PPROCESSINFO ppi = GetW32ProcessInfo(); + PW32PROCESS W32Process = PsGetCurrentProcessWin32Process(); _SEH2_TRY { pUserConnect->siClient.psi = gpsi; - pUserConnect->siClient.aheList = ppi->UserHandleTable; - pUserConnect->siClient.ulSharedDelta = ppi->UserHeapDelta; + pUserConnect->siClient.aheList = gHandleTable; + pUserConnect->siClient.ulSharedDelta = (ULONG_PTR)W32Process->HeapMappings.KernelMapping - + (ULONG_PTR)W32Process->HeapMappings.UserMapping; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -909,7 +910,6 @@ NtUserProcessConnect( { SetLastNtError(Status); } - DPRINT("NtUserPC SI 0x%x : HT 0x%x : D 0x%x\n", gpsi, ppi->UserHandleTable, ppi->UserHeapDelta); UserLeave(); return Status; }