diff --git a/reactos/subsys/win32k/include/userfuncs.h b/reactos/subsys/win32k/include/userfuncs.h index 1c3e12ed455..e63c27e9daa 100644 --- a/reactos/subsys/win32k/include/userfuncs.h +++ b/reactos/subsys/win32k/include/userfuncs.h @@ -1,6 +1,10 @@ #ifndef _WIN32K_USERFUNCS_H #define _WIN32K_USERFUNCS_H + +extern PUSER_HANDLE_TABLE gHandleTable; + + /*************** WINSTA.C ***************/ HWINSTA FASTCALL UserGetProcessWindowStation(VOID); diff --git a/reactos/subsys/win32k/include/winsta.h b/reactos/subsys/win32k/include/winsta.h index 7d10a2c1e9b..f21e5c6377d 100644 --- a/reactos/subsys/win32k/include/winsta.h +++ b/reactos/subsys/win32k/include/winsta.h @@ -27,7 +27,6 @@ typedef struct _WINSTATION_OBJECT UNICODE_STRING Name; LIST_ENTRY DesktopListHead; PRTL_ATOM_TABLE AtomTable; - PVOID HandleTable; HANDLE SystemMenuTemplate; PVOID SystemCursor; UINT CaretBlinkRate; diff --git a/reactos/subsys/win32k/ntuser/accelerator.c b/reactos/subsys/win32k/ntuser/accelerator.c index 591cbec3d79..a48358f76ed 100644 --- a/reactos/subsys/win32k/ntuser/accelerator.c +++ b/reactos/subsys/win32k/ntuser/accelerator.c @@ -94,10 +94,11 @@ NtUserCopyAcceleratorTable( RETURN(0); } - Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, Table, otAcceleratorTable, (PVOID*)&AcceleratorTable); + if (!NT_SUCCESS(Status)) { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); @@ -161,7 +162,7 @@ NtUserCreateAcceleratorTable( } AcceleratorTable = ObmCreateObject( - WindowStation->HandleTable, + gHandleTable, (PHANDLE)&Handle, otAcceleratorTable, sizeof(ACCELERATOR_TABLE)); @@ -179,7 +180,7 @@ NtUserCreateAcceleratorTable( AcceleratorTable->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL); if (AcceleratorTable->Table == NULL) { - ObmCloseHandle(WindowStation->HandleTable, Handle); + ObmCloseHandle(gHandleTable, Handle); ObDereferenceObject(WindowStation); SetLastNtError(Status); DPRINT1("E3\n"); @@ -190,7 +191,7 @@ NtUserCreateAcceleratorTable( if (!NT_SUCCESS(Status)) { ExFreePool(AcceleratorTable->Table); - ObmCloseHandle(WindowStation->HandleTable, Handle); + ObmCloseHandle(gHandleTable, Handle); ObDereferenceObject(WindowStation); SetLastNtError(Status); DPRINT1("E4\n"); @@ -240,7 +241,7 @@ NtUserDestroyAcceleratorTable( RETURN( FALSE); } - Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, Table, otAcceleratorTable, (PVOID*)&AcceleratorTable); @@ -252,7 +253,7 @@ NtUserDestroyAcceleratorTable( RETURN( FALSE); } - ObmCloseHandle(WindowStation->HandleTable, Table); + ObmCloseHandle(gHandleTable, Table); if (AcceleratorTable->Table != NULL) { @@ -503,7 +504,7 @@ NtUserTranslateAccelerator( RETURN( 0); } - Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, Table, otAcceleratorTable, (PVOID*)&AcceleratorTable); diff --git a/reactos/subsys/win32k/ntuser/cursoricon.c b/reactos/subsys/win32k/ntuser/cursoricon.c index 3af19a775da..e1b4f81e3aa 100644 --- a/reactos/subsys/win32k/ntuser/cursoricon.c +++ b/reactos/subsys/win32k/ntuser/cursoricon.c @@ -77,7 +77,7 @@ IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle) PCURICON_OBJECT Object; NTSTATUS Status; - Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, Handle, otCursorIcon, (PVOID*)&Object); if (!NT_SUCCESS(Status)) { @@ -391,7 +391,7 @@ IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject) PCURICON_OBJECT Object; HANDLE Handle; - Object = ObmCreateObject(WinStaObject->HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT)); + Object = ObmCreateObject(gHandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT)); if(!Object) { @@ -405,7 +405,7 @@ IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject) if (! ReferenceCurIconByProcess(Object)) { DPRINT1("Failed to add process\n"); - ObmCloseHandle(WinStaObject->HandleTable, Handle); + ObmCloseHandle(gHandleTable, Handle); ObmDereferenceObject(Object); return NULL; } @@ -483,7 +483,7 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT Object, bmpMask = Object->IconInfo.hbmMask; bmpColor = Object->IconInfo.hbmColor; - Ret = NT_SUCCESS(ObmCloseHandle(WinStaObject->HandleTable, Object->Self)); + Ret = NT_SUCCESS(ObmCloseHandle(gHandleTable, Object->Self)); /* delete bitmaps */ if(bmpMask) @@ -941,7 +941,7 @@ NtUserDestroyCursorIcon( RETURN( FALSE); } - Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object); + Status = ObmReferenceObjectByHandle(gHandleTable, Handle, otCursorIcon, (PVOID*)&Object); if(!NT_SUCCESS(Status)) { ObDereferenceObject(WinStaObject); diff --git a/reactos/subsys/win32k/ntuser/hook.c b/reactos/subsys/win32k/ntuser/hook.c index 0147de4a1e4..55fa5fdcf22 100644 --- a/reactos/subsys/win32k/ntuser/hook.c +++ b/reactos/subsys/win32k/ntuser/hook.c @@ -83,7 +83,7 @@ IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinSt } } - Hook = ObmCreateObject(WinStaObj->HandleTable, &Handle, + Hook = ObmCreateObject(gHandleTable, &Handle, otHookProc, sizeof(HOOK)); if (NULL == Hook) { @@ -180,7 +180,7 @@ IntFreeHook(PHOOKTABLE Table, PHOOK Hook, PWINSTATION_OBJECT WinStaObj) } /* Close handle */ - ObmCloseHandle(WinStaObj->HandleTable, Hook->Self); + ObmCloseHandle(gHandleTable, Hook->Self); } /* remove a hook, freeing it if the chain is not in use */ @@ -399,7 +399,7 @@ NtUserCallNextHookEx( RETURN( FALSE); } - Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook, + Status = ObmReferenceObjectByHandle(gHandleTable, Hook, otHookProc, (PVOID *) &HookObj); ObDereferenceObject(WinStaObj); if (! NT_SUCCESS(Status)) @@ -687,7 +687,7 @@ NtUserUnhookWindowsHookEx( RETURN( FALSE); } - Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook, + Status = ObmReferenceObjectByHandle(gHandleTable, Hook, otHookProc, (PVOID *) &HookObj); if (! NT_SUCCESS(Status)) { diff --git a/reactos/subsys/win32k/ntuser/input.c b/reactos/subsys/win32k/ntuser/input.c index 69871218fbb..0d072f8aa93 100644 --- a/reactos/subsys/win32k/ntuser/input.c +++ b/reactos/subsys/win32k/ntuser/input.c @@ -378,7 +378,7 @@ IntKeyboardSendWinKeyMsg() MSG Mesg; NTSTATUS Status; - Status = ObmReferenceObjectByHandle(InputWindowStation->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, InputWindowStation->ShellWindow, otWindow, (PVOID *)&Window); @@ -947,7 +947,7 @@ IntMouseInput(MOUSEINPUT *mi) MousePos.y += mi->dy; } - Status = ObmReferenceObjectByHandle(WinSta->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, WinSta->ActiveDesktop->DesktopWindow, otWindow, (PVOID*)&DesktopWindow); if (NT_SUCCESS(Status)) { diff --git a/reactos/subsys/win32k/ntuser/menu.c b/reactos/subsys/win32k/ntuser/menu.c index f26fec030f7..4cf363128ab 100644 --- a/reactos/subsys/win32k/ntuser/menu.c +++ b/reactos/subsys/win32k/ntuser/menu.c @@ -142,7 +142,7 @@ IntGetMenuObject(HMENU hMenu) return NULL; } - NTSTATUS Status = ObmReferenceObjectByHandle(W32Thread->Desktop->WindowStation->HandleTable, + NTSTATUS Status = ObmReferenceObjectByHandle(gHandleTable, hMenu, otMenu, (PVOID*)&MenuObject); if (!NT_SUCCESS(Status)) { @@ -243,7 +243,7 @@ IntDestroyMenuObject(PMENU_OBJECT MenuObject, NULL); if(NT_SUCCESS(Status)) { - ObmCloseHandle(WindowStation->HandleTable, MenuObject->MenuInfo.Self); + ObmCloseHandle(gHandleTable, MenuObject->MenuInfo.Self); ObDereferenceObject(WindowStation); return TRUE; } @@ -255,10 +255,9 @@ PMENU_OBJECT FASTCALL IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar) { PMENU_OBJECT MenuObject; - PW32THREAD Win32Thread = PsGetWin32Thread(); MenuObject = (PMENU_OBJECT)ObmCreateObject( - Win32Thread->Desktop->WindowStation->HandleTable, Handle, + gHandleTable, Handle, otMenu, sizeof(MENU_OBJECT)); if(!MenuObject) @@ -367,7 +366,7 @@ IntCloneMenu(PMENU_OBJECT Source) return NULL; MenuObject = (PMENU_OBJECT)ObmCreateObject( - PsGetWin32Thread()->Desktop->WindowStation->HandleTable, &Handle, + gHandleTable, &Handle, otMenu, sizeof(MENU_OBJECT)); if(!MenuObject) return NULL; diff --git a/reactos/subsys/win32k/ntuser/monitor.c b/reactos/subsys/win32k/ntuser/monitor.c index 8ee500eb261..b6b89544220 100644 --- a/reactos/subsys/win32k/ntuser/monitor.c +++ b/reactos/subsys/win32k/ntuser/monitor.c @@ -91,7 +91,7 @@ IntCreateMonitorObject() HANDLE Handle; PMONITOR_OBJECT Monitor; - Monitor = ObmCreateObject(PsGetWin32Thread()->Desktop->WindowStation->HandleTable, &Handle, otMonitor, sizeof (MONITOR_OBJECT)); + Monitor = ObmCreateObject(gHandleTable, &Handle, otMonitor, sizeof (MONITOR_OBJECT)); if (Monitor == NULL) { return NULL; @@ -141,7 +141,7 @@ IntGetMonitorObject(IN HMONITOR hMonitor) PMONITOR_OBJECT Monitor; NTSTATUS Status; - Status = ObmReferenceObjectByHandle(PsGetWin32Thread()->Desktop->WindowStation->HandleTable, hMonitor, otMonitor, (PVOID *)&Monitor); + Status = ObmReferenceObjectByHandle(gHandleTable, hMonitor, otMonitor, (PVOID *)&Monitor); if (!NT_SUCCESS(Status) || Monitor == NULL) { /* FIXME: SetLastNtError( status ); ? */ diff --git a/reactos/subsys/win32k/ntuser/msgqueue.c b/reactos/subsys/win32k/ntuser/msgqueue.c index 6610f316bba..3b97f10dcbc 100644 --- a/reactos/subsys/win32k/ntuser/msgqueue.c +++ b/reactos/subsys/win32k/ntuser/msgqueue.c @@ -733,7 +733,7 @@ MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam) } WinSta = Win32Thread->Desktop->WindowStation; - Status = ObmReferenceObjectByHandle(WinSta->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, hWnd, otWindow, (PVOID*)&Window); if (!NT_SUCCESS(Status)) { diff --git a/reactos/subsys/win32k/ntuser/ntuser.c b/reactos/subsys/win32k/ntuser/ntuser.c index f1463f8a5da..966ee84e30c 100644 --- a/reactos/subsys/win32k/ntuser/ntuser.c +++ b/reactos/subsys/win32k/ntuser/ntuser.c @@ -49,6 +49,15 @@ NTSTATUS FASTCALL InitUserImpl(VOID) // DPRINT("Enter InitUserImpl\n"); // ExInitializeResourceLite(&UserLock); + + + gHandleTable = ObmCreateHandleTable(); + if (!gHandleTable) + { + DPRINT("Failed creating handle table\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + ExInitializeFastMutex(&UserLock); return STATUS_SUCCESS; diff --git a/reactos/subsys/win32k/ntuser/object.c b/reactos/subsys/win32k/ntuser/object.c index 3b66810bf40..9d5b06f68e0 100644 --- a/reactos/subsys/win32k/ntuser/object.c +++ b/reactos/subsys/win32k/ntuser/object.c @@ -40,6 +40,9 @@ #define USER_BODY_TO_HEADER(ObjectBody) \ ((PUSER_OBJECT_HEADER)(((PUSER_OBJECT_HEADER)ObjectBody) - 1)) + +PUSER_HANDLE_TABLE gHandleTable = NULL; + /* FUNCTIONS *****************************************************************/ VOID FASTCALL diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 04f18832dc2..73622f3782f 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -129,7 +129,7 @@ IntGetProcessWindowObject(PW32THREAD Thread, HWND hWnd) if(Thread->Desktop != NULL) { - Status = ObmReferenceObjectByHandle(Thread->Desktop->WindowStation->HandleTable, + Status = ObmReferenceObjectByHandle(gHandleTable, hWnd, otWindow, (PVOID*)&WindowObject); if (NT_SUCCESS(Status)) { @@ -418,7 +418,7 @@ static LRESULT co_IntDestroyWindow(PWINDOW_OBJECT Window, IntUnlinkWindow(Window); IntReferenceWindowObject(Window); - ObmCloseHandle(ThreadData->Desktop->WindowStation->HandleTable, Window->Self); + ObmCloseHandle(gHandleTable, Window->Self); IntDestroyScrollBars(Window); @@ -1498,7 +1498,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, /* Create the window object. */ WindowObject = (PWINDOW_OBJECT) - ObmCreateObject(PsGetWin32Thread()->Desktop->WindowStation->HandleTable, &Handle, + ObmCreateObject(gHandleTable, &Handle, otWindow, sizeof(WINDOW_OBJECT) + ClassObject->cbWndExtra ); diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 34e942b25da..0068eac710e 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -1256,7 +1256,7 @@ co_WinPosShowWindow(HWND Wnd, INT Cmd) // HRGN VisibleRgn; Status = - ObmReferenceObjectByHandle(PsGetWin32Thread()->Desktop->WindowStation->HandleTable, + ObmReferenceObjectByHandle(gHandleTable, Wnd, otWindow, (PVOID*)&Window); diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c index fd2020c1425..d46b82bc3c7 100644 --- a/reactos/subsys/win32k/ntuser/winsta.c +++ b/reactos/subsys/win32k/ntuser/winsta.c @@ -535,18 +535,6 @@ NtUserCreateWindowStation( return 0; } - WindowStationObject->HandleTable = ObmCreateHandleTable(); - if (!WindowStationObject->HandleTable) - { - DPRINT("Failed creating handle table\n"); - ExFreePool(CurInfo); - ExFreePool(WindowStationName.Buffer); - /* FIXME - Delete window station object */ - ObDereferenceObject(WindowStationObject); - SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); - return 0; - } - InitHotKeys(WindowStationObject); CurInfo->Enabled = FALSE;