make handle table session global

svn path=/trunk/; revision=17694
This commit is contained in:
Gunnar Dalsnes 2005-09-06 10:05:31 +00:00
parent 5d3bcdcc13
commit 4e5ef38048
14 changed files with 46 additions and 43 deletions

View file

@ -1,6 +1,10 @@
#ifndef _WIN32K_USERFUNCS_H #ifndef _WIN32K_USERFUNCS_H
#define _WIN32K_USERFUNCS_H #define _WIN32K_USERFUNCS_H
extern PUSER_HANDLE_TABLE gHandleTable;
/*************** WINSTA.C ***************/ /*************** WINSTA.C ***************/
HWINSTA FASTCALL UserGetProcessWindowStation(VOID); HWINSTA FASTCALL UserGetProcessWindowStation(VOID);

View file

@ -27,7 +27,6 @@ typedef struct _WINSTATION_OBJECT
UNICODE_STRING Name; UNICODE_STRING Name;
LIST_ENTRY DesktopListHead; LIST_ENTRY DesktopListHead;
PRTL_ATOM_TABLE AtomTable; PRTL_ATOM_TABLE AtomTable;
PVOID HandleTable;
HANDLE SystemMenuTemplate; HANDLE SystemMenuTemplate;
PVOID SystemCursor; PVOID SystemCursor;
UINT CaretBlinkRate; UINT CaretBlinkRate;

View file

@ -94,10 +94,11 @@ NtUserCopyAcceleratorTable(
RETURN(0); RETURN(0);
} }
Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
Table, Table,
otAcceleratorTable, otAcceleratorTable,
(PVOID*)&AcceleratorTable); (PVOID*)&AcceleratorTable);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE);
@ -161,7 +162,7 @@ NtUserCreateAcceleratorTable(
} }
AcceleratorTable = ObmCreateObject( AcceleratorTable = ObmCreateObject(
WindowStation->HandleTable, gHandleTable,
(PHANDLE)&Handle, (PHANDLE)&Handle,
otAcceleratorTable, otAcceleratorTable,
sizeof(ACCELERATOR_TABLE)); sizeof(ACCELERATOR_TABLE));
@ -179,7 +180,7 @@ NtUserCreateAcceleratorTable(
AcceleratorTable->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL); AcceleratorTable->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL);
if (AcceleratorTable->Table == NULL) if (AcceleratorTable->Table == NULL)
{ {
ObmCloseHandle(WindowStation->HandleTable, Handle); ObmCloseHandle(gHandleTable, Handle);
ObDereferenceObject(WindowStation); ObDereferenceObject(WindowStation);
SetLastNtError(Status); SetLastNtError(Status);
DPRINT1("E3\n"); DPRINT1("E3\n");
@ -190,7 +191,7 @@ NtUserCreateAcceleratorTable(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ExFreePool(AcceleratorTable->Table); ExFreePool(AcceleratorTable->Table);
ObmCloseHandle(WindowStation->HandleTable, Handle); ObmCloseHandle(gHandleTable, Handle);
ObDereferenceObject(WindowStation); ObDereferenceObject(WindowStation);
SetLastNtError(Status); SetLastNtError(Status);
DPRINT1("E4\n"); DPRINT1("E4\n");
@ -240,7 +241,7 @@ NtUserDestroyAcceleratorTable(
RETURN( FALSE); RETURN( FALSE);
} }
Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
Table, Table,
otAcceleratorTable, otAcceleratorTable,
(PVOID*)&AcceleratorTable); (PVOID*)&AcceleratorTable);
@ -252,7 +253,7 @@ NtUserDestroyAcceleratorTable(
RETURN( FALSE); RETURN( FALSE);
} }
ObmCloseHandle(WindowStation->HandleTable, Table); ObmCloseHandle(gHandleTable, Table);
if (AcceleratorTable->Table != NULL) if (AcceleratorTable->Table != NULL)
{ {
@ -503,7 +504,7 @@ NtUserTranslateAccelerator(
RETURN( 0); RETURN( 0);
} }
Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
Table, Table,
otAcceleratorTable, otAcceleratorTable,
(PVOID*)&AcceleratorTable); (PVOID*)&AcceleratorTable);

View file

@ -77,7 +77,7 @@ IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle)
PCURICON_OBJECT Object; PCURICON_OBJECT Object;
NTSTATUS Status; NTSTATUS Status;
Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
Handle, otCursorIcon, (PVOID*)&Object); Handle, otCursorIcon, (PVOID*)&Object);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -391,7 +391,7 @@ IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
PCURICON_OBJECT Object; PCURICON_OBJECT Object;
HANDLE Handle; HANDLE Handle;
Object = ObmCreateObject(WinStaObject->HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT)); Object = ObmCreateObject(gHandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT));
if(!Object) if(!Object)
{ {
@ -405,7 +405,7 @@ IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
if (! ReferenceCurIconByProcess(Object)) if (! ReferenceCurIconByProcess(Object))
{ {
DPRINT1("Failed to add process\n"); DPRINT1("Failed to add process\n");
ObmCloseHandle(WinStaObject->HandleTable, Handle); ObmCloseHandle(gHandleTable, Handle);
ObmDereferenceObject(Object); ObmDereferenceObject(Object);
return NULL; return NULL;
} }
@ -483,7 +483,7 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT Object,
bmpMask = Object->IconInfo.hbmMask; bmpMask = Object->IconInfo.hbmMask;
bmpColor = Object->IconInfo.hbmColor; bmpColor = Object->IconInfo.hbmColor;
Ret = NT_SUCCESS(ObmCloseHandle(WinStaObject->HandleTable, Object->Self)); Ret = NT_SUCCESS(ObmCloseHandle(gHandleTable, Object->Self));
/* delete bitmaps */ /* delete bitmaps */
if(bmpMask) if(bmpMask)
@ -941,7 +941,7 @@ NtUserDestroyCursorIcon(
RETURN( FALSE); RETURN( FALSE);
} }
Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object); Status = ObmReferenceObjectByHandle(gHandleTable, Handle, otCursorIcon, (PVOID*)&Object);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
ObDereferenceObject(WinStaObject); ObDereferenceObject(WinStaObject);

View file

@ -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)); otHookProc, sizeof(HOOK));
if (NULL == Hook) if (NULL == Hook)
{ {
@ -180,7 +180,7 @@ IntFreeHook(PHOOKTABLE Table, PHOOK Hook, PWINSTATION_OBJECT WinStaObj)
} }
/* Close handle */ /* Close handle */
ObmCloseHandle(WinStaObj->HandleTable, Hook->Self); ObmCloseHandle(gHandleTable, Hook->Self);
} }
/* remove a hook, freeing it if the chain is not in use */ /* remove a hook, freeing it if the chain is not in use */
@ -399,7 +399,7 @@ NtUserCallNextHookEx(
RETURN( FALSE); RETURN( FALSE);
} }
Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook, Status = ObmReferenceObjectByHandle(gHandleTable, Hook,
otHookProc, (PVOID *) &HookObj); otHookProc, (PVOID *) &HookObj);
ObDereferenceObject(WinStaObj); ObDereferenceObject(WinStaObj);
if (! NT_SUCCESS(Status)) if (! NT_SUCCESS(Status))
@ -687,7 +687,7 @@ NtUserUnhookWindowsHookEx(
RETURN( FALSE); RETURN( FALSE);
} }
Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook, Status = ObmReferenceObjectByHandle(gHandleTable, Hook,
otHookProc, (PVOID *) &HookObj); otHookProc, (PVOID *) &HookObj);
if (! NT_SUCCESS(Status)) if (! NT_SUCCESS(Status))
{ {

View file

@ -378,7 +378,7 @@ IntKeyboardSendWinKeyMsg()
MSG Mesg; MSG Mesg;
NTSTATUS Status; NTSTATUS Status;
Status = ObmReferenceObjectByHandle(InputWindowStation->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
InputWindowStation->ShellWindow, InputWindowStation->ShellWindow,
otWindow, otWindow,
(PVOID *)&Window); (PVOID *)&Window);
@ -947,7 +947,7 @@ IntMouseInput(MOUSEINPUT *mi)
MousePos.y += mi->dy; MousePos.y += mi->dy;
} }
Status = ObmReferenceObjectByHandle(WinSta->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
WinSta->ActiveDesktop->DesktopWindow, otWindow, (PVOID*)&DesktopWindow); WinSta->ActiveDesktop->DesktopWindow, otWindow, (PVOID*)&DesktopWindow);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {

View file

@ -142,7 +142,7 @@ IntGetMenuObject(HMENU hMenu)
return NULL; return NULL;
} }
NTSTATUS Status = ObmReferenceObjectByHandle(W32Thread->Desktop->WindowStation->HandleTable, NTSTATUS Status = ObmReferenceObjectByHandle(gHandleTable,
hMenu, otMenu, (PVOID*)&MenuObject); hMenu, otMenu, (PVOID*)&MenuObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -243,7 +243,7 @@ IntDestroyMenuObject(PMENU_OBJECT MenuObject,
NULL); NULL);
if(NT_SUCCESS(Status)) if(NT_SUCCESS(Status))
{ {
ObmCloseHandle(WindowStation->HandleTable, MenuObject->MenuInfo.Self); ObmCloseHandle(gHandleTable, MenuObject->MenuInfo.Self);
ObDereferenceObject(WindowStation); ObDereferenceObject(WindowStation);
return TRUE; return TRUE;
} }
@ -255,10 +255,9 @@ PMENU_OBJECT FASTCALL
IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar) IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar)
{ {
PMENU_OBJECT MenuObject; PMENU_OBJECT MenuObject;
PW32THREAD Win32Thread = PsGetWin32Thread();
MenuObject = (PMENU_OBJECT)ObmCreateObject( MenuObject = (PMENU_OBJECT)ObmCreateObject(
Win32Thread->Desktop->WindowStation->HandleTable, Handle, gHandleTable, Handle,
otMenu, sizeof(MENU_OBJECT)); otMenu, sizeof(MENU_OBJECT));
if(!MenuObject) if(!MenuObject)
@ -367,7 +366,7 @@ IntCloneMenu(PMENU_OBJECT Source)
return NULL; return NULL;
MenuObject = (PMENU_OBJECT)ObmCreateObject( MenuObject = (PMENU_OBJECT)ObmCreateObject(
PsGetWin32Thread()->Desktop->WindowStation->HandleTable, &Handle, gHandleTable, &Handle,
otMenu, sizeof(MENU_OBJECT)); otMenu, sizeof(MENU_OBJECT));
if(!MenuObject) if(!MenuObject)
return NULL; return NULL;

View file

@ -91,7 +91,7 @@ IntCreateMonitorObject()
HANDLE Handle; HANDLE Handle;
PMONITOR_OBJECT Monitor; 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) if (Monitor == NULL)
{ {
return NULL; return NULL;
@ -141,7 +141,7 @@ IntGetMonitorObject(IN HMONITOR hMonitor)
PMONITOR_OBJECT Monitor; PMONITOR_OBJECT Monitor;
NTSTATUS Status; 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) if (!NT_SUCCESS(Status) || Monitor == NULL)
{ {
/* FIXME: SetLastNtError( status ); ? */ /* FIXME: SetLastNtError( status ); ? */

View file

@ -733,7 +733,7 @@ MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
} }
WinSta = Win32Thread->Desktop->WindowStation; WinSta = Win32Thread->Desktop->WindowStation;
Status = ObmReferenceObjectByHandle(WinSta->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
hWnd, otWindow, (PVOID*)&Window); hWnd, otWindow, (PVOID*)&Window);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -49,6 +49,15 @@ NTSTATUS FASTCALL InitUserImpl(VOID)
// DPRINT("Enter InitUserImpl\n"); // DPRINT("Enter InitUserImpl\n");
// ExInitializeResourceLite(&UserLock); // ExInitializeResourceLite(&UserLock);
gHandleTable = ObmCreateHandleTable();
if (!gHandleTable)
{
DPRINT("Failed creating handle table\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
ExInitializeFastMutex(&UserLock); ExInitializeFastMutex(&UserLock);
return STATUS_SUCCESS; return STATUS_SUCCESS;

View file

@ -40,6 +40,9 @@
#define USER_BODY_TO_HEADER(ObjectBody) \ #define USER_BODY_TO_HEADER(ObjectBody) \
((PUSER_OBJECT_HEADER)(((PUSER_OBJECT_HEADER)ObjectBody) - 1)) ((PUSER_OBJECT_HEADER)(((PUSER_OBJECT_HEADER)ObjectBody) - 1))
PUSER_HANDLE_TABLE gHandleTable = NULL;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID FASTCALL VOID FASTCALL

View file

@ -129,7 +129,7 @@ IntGetProcessWindowObject(PW32THREAD Thread, HWND hWnd)
if(Thread->Desktop != NULL) if(Thread->Desktop != NULL)
{ {
Status = ObmReferenceObjectByHandle(Thread->Desktop->WindowStation->HandleTable, Status = ObmReferenceObjectByHandle(gHandleTable,
hWnd, otWindow, (PVOID*)&WindowObject); hWnd, otWindow, (PVOID*)&WindowObject);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
@ -418,7 +418,7 @@ static LRESULT co_IntDestroyWindow(PWINDOW_OBJECT Window,
IntUnlinkWindow(Window); IntUnlinkWindow(Window);
IntReferenceWindowObject(Window); IntReferenceWindowObject(Window);
ObmCloseHandle(ThreadData->Desktop->WindowStation->HandleTable, Window->Self); ObmCloseHandle(gHandleTable, Window->Self);
IntDestroyScrollBars(Window); IntDestroyScrollBars(Window);
@ -1498,7 +1498,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
/* Create the window object. */ /* Create the window object. */
WindowObject = (PWINDOW_OBJECT) WindowObject = (PWINDOW_OBJECT)
ObmCreateObject(PsGetWin32Thread()->Desktop->WindowStation->HandleTable, &Handle, ObmCreateObject(gHandleTable, &Handle,
otWindow, sizeof(WINDOW_OBJECT) + ClassObject->cbWndExtra otWindow, sizeof(WINDOW_OBJECT) + ClassObject->cbWndExtra
); );

View file

@ -1256,7 +1256,7 @@ co_WinPosShowWindow(HWND Wnd, INT Cmd)
// HRGN VisibleRgn; // HRGN VisibleRgn;
Status = Status =
ObmReferenceObjectByHandle(PsGetWin32Thread()->Desktop->WindowStation->HandleTable, ObmReferenceObjectByHandle(gHandleTable,
Wnd, Wnd,
otWindow, otWindow,
(PVOID*)&Window); (PVOID*)&Window);

View file

@ -535,18 +535,6 @@ NtUserCreateWindowStation(
return 0; 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); InitHotKeys(WindowStationObject);
CurInfo->Enabled = FALSE; CurInfo->Enabled = FALSE;