From 85d5b2ea3f22f269526eeaeb2839f4dd9250d516 Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Thu, 13 Oct 2005 12:44:58 +0000 Subject: [PATCH] make classes use session wide atom table. should fix bug 899 svn path=/trunk/; revision=18427 --- reactos/subsys/win32k/include/userfuncs.h | 12 ++++--- reactos/subsys/win32k/ntuser/class.c | 34 ++++-------------- reactos/subsys/win32k/ntuser/ntuser.c | 8 +++++ reactos/subsys/win32k/ntuser/session.c | 43 +++++++++++++++++++++++ reactos/subsys/win32k/win32k.xml | 1 + 5 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 reactos/subsys/win32k/ntuser/session.c diff --git a/reactos/subsys/win32k/include/userfuncs.h b/reactos/subsys/win32k/include/userfuncs.h index 72d2fbe4444..b0ef13562f5 100644 --- a/reactos/subsys/win32k/include/userfuncs.h +++ b/reactos/subsys/win32k/include/userfuncs.h @@ -73,12 +73,9 @@ ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type ); #define UserDerefObject(o) ObmDereferenceObject(o) BOOL FASTCALL ObmCreateHandleTable(); - -extern USER_HANDLE_TABLE gHandleTable; - - /******************** HANDLE.C ***************/ +extern USER_HANDLE_TABLE gHandleTable; PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle ); VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes); @@ -120,6 +117,13 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags); DWORD FASTCALL UserGetWindowDC(PWINDOW_OBJECT Wnd); + +/*************** SESSION.C ***************/ + +extern PRTL_ATOM_TABLE gAtomTable; + +NTSTATUS FASTCALL InitSessionImpl(VOID); + /*************** METRIC.C ***************/ ULONG FASTCALL diff --git a/reactos/subsys/win32k/ntuser/class.c b/reactos/subsys/win32k/ntuser/class.c index c2eb65930ca..5f919052bfb 100644 --- a/reactos/subsys/win32k/ntuser/class.c +++ b/reactos/subsys/win32k/ntuser/class.c @@ -48,7 +48,6 @@ CleanupClassImpl(VOID) } -/* return TRUE if class became destroyed */ inline VOID FASTCALL ClassDerefObject(PWNDCLASS_OBJECT Class) { @@ -67,22 +66,10 @@ ClassRefObject(PWNDCLASS_OBJECT Class) VOID FASTCALL DestroyClass(PWNDCLASS_OBJECT Class) { - PWINSTATION_OBJECT WinSta; - ASSERT(Class->refs == 0); + RemoveEntryList(&Class->ListEntry); - - /* FIXME See bug 899 */ - if (NULL != PsGetWin32Thread()) - { - WinSta = PsGetWin32Thread()->Desktop->WindowStation; - //FIXME: release ATOM - RtlDeleteAtomFromAtomTable(WinSta->AtomTable, Class->Atom); - } - else - { - DPRINT1("Can't locate window station, see bug 899\n"); - } + RtlDeleteAtomFromAtomTable(gAtomTable, Class->Atom); ExFreePool(Class); } @@ -122,17 +109,14 @@ ClassGetClassByAtom(RTL_ATOM Atom, HINSTANCE hInstance) PWNDCLASS_OBJECT FASTCALL ClassGetClassByName(LPCWSTR ClassName, HINSTANCE hInstance) { - PWINSTATION_OBJECT WinSta; NTSTATUS Status; RTL_ATOM Atom; if (!ClassName || !PsGetWin32Thread()->Desktop) return FALSE; - WinSta = PsGetWin32Thread()->Desktop->WindowStation; - Status = RtlLookupAtomInAtomTable( - WinSta->AtomTable, + gAtomTable, (LPWSTR)ClassName, &Atom); @@ -445,7 +429,6 @@ NtUserRegisterClassExWOW( */ { WNDCLASSEXW SafeClass; - PWINSTATION_OBJECT WinSta; NTSTATUS Status; RTL_ATOM Atom; DECLARE_RETURN(RTL_ATOM); @@ -485,14 +468,12 @@ NtUserRegisterClassExWOW( RETURN( (RTL_ATOM)0); } - WinSta = PsGetWin32Thread()->Desktop->WindowStation; - //FIXME: make ClassName ptr the atom, not buffer if (ClassName->Length > 0) { DPRINT("NtUserRegisterClassExWOW(%S)\n", ClassName->Buffer); /* FIXME - Safely copy/verify the buffer first!!! */ - Status = RtlAddAtomToAtomTable(WinSta->AtomTable, + Status = RtlAddAtomToAtomTable(gAtomTable, ClassName->Buffer, &Atom); if (!NT_SUCCESS(Status)) @@ -518,7 +499,7 @@ NtUserRegisterClassExWOW( { if (ClassName->Length) { - RtlDeleteAtomFromAtomTable(WinSta->AtomTable, Atom); + RtlDeleteAtomFromAtomTable(gAtomTable, Atom); } DPRINT("Failed creating window class object\n"); RETURN((RTL_ATOM)0); @@ -717,7 +698,6 @@ NtUserGetClassName ( { PWINDOW_OBJECT Window; DECLARE_RETURN(DWORD); - PWINSTATION_OBJECT WinSta; NTSTATUS Status; UserEnterShared(); @@ -728,12 +708,10 @@ NtUserGetClassName ( RETURN(0); } - WinSta = PsGetWin32Thread()->Desktop->WindowStation; - nMaxCount *= sizeof(WCHAR); //FIXME: wrap in SEH to protect lpClassName access - Status = RtlQueryAtomInAtomTable(WinSta->AtomTable, + Status = RtlQueryAtomInAtomTable(gAtomTable, Window->Class->Atom, NULL, NULL, lpClassName, &nMaxCount); if (!NT_SUCCESS(Status)) diff --git a/reactos/subsys/win32k/ntuser/ntuser.c b/reactos/subsys/win32k/ntuser/ntuser.c index b8a6c2856fa..0417568d83b 100644 --- a/reactos/subsys/win32k/ntuser/ntuser.c +++ b/reactos/subsys/win32k/ntuser/ntuser.c @@ -46,6 +46,7 @@ DWORD _locked=0; NTSTATUS FASTCALL InitUserImpl(VOID) { //PVOID mem; + NTSTATUS Status; // DPRINT("Enter InitUserImpl\n"); // ExInitializeResourceLite(&UserLock); @@ -58,6 +59,13 @@ NTSTATUS FASTCALL InitUserImpl(VOID) return STATUS_INSUFFICIENT_RESOURCES; } + Status = InitSessionImpl(); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Error init session impl.\n"); + return Status; + } + return STATUS_SUCCESS; } diff --git a/reactos/subsys/win32k/ntuser/session.c b/reactos/subsys/win32k/ntuser/session.c new file mode 100644 index 00000000000..bcc19dea3fc --- /dev/null +++ b/reactos/subsys/win32k/ntuser/session.c @@ -0,0 +1,43 @@ +/* + * ReactOS W32 Subsystem + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Session stuff + * FILE: subsys/win32k/ntuser/session.c + * PROGRAMER: Gunnar + */ + +#include + +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +PRTL_ATOM_TABLE gAtomTable = NULL; + +/* FUNCTIONS *******************************************************************/ + +NTSTATUS FASTCALL +InitSessionImpl(VOID) +{ + return RtlCreateAtomTable(37, &gAtomTable); +} + diff --git a/reactos/subsys/win32k/win32k.xml b/reactos/subsys/win32k/win32k.xml index d1bdbb0bfba..fced1280033 100644 --- a/reactos/subsys/win32k/win32k.xml +++ b/reactos/subsys/win32k/win32k.xml @@ -89,6 +89,7 @@ painting.c prop.c scrollbar.c + session.c stubs.c timer.c useratom.c