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
#define _WIN32K_USERFUNCS_H
extern PUSER_HANDLE_TABLE gHandleTable;
/*************** WINSTA.C ***************/
HWINSTA FASTCALL UserGetProcessWindowStation(VOID);

View file

@ -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;

View file

@ -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);

View file

@ -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);

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));
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))
{

View file

@ -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))
{

View file

@ -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;

View file

@ -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 ); ? */

View file

@ -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))
{

View file

@ -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;

View file

@ -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

View file

@ -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
);

View file

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

View file

@ -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;