mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- RegisterClassExA: Don't try to convert a class name which is an atom
to unicode. - NtUserRegisterClass: Track classes by atom not by name. svn path=/trunk/; revision=5293
This commit is contained in:
parent
df807693a0
commit
2ce9849248
4 changed files with 85 additions and 71 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: class.c,v 1.20 2003/07/10 21:04:31 chorns Exp $
|
/* $Id: class.c,v 1.21 2003/07/27 21:35:50 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS user32.dll
|
* PROJECT: ReactOS user32.dll
|
||||||
|
@ -241,23 +241,27 @@ RegisterClassExA(CONST WNDCLASSEXA *lpwcx)
|
||||||
WNDCLASSEXW Class;
|
WNDCLASSEXW Class;
|
||||||
RTL_ATOM Atom;
|
RTL_ATOM Atom;
|
||||||
|
|
||||||
if (!RtlCreateUnicodeStringFromAsciiz(&MenuName, (PCSZ)lpwcx->lpszMenuName))
|
|
||||||
{
|
|
||||||
RtlFreeUnicodeString(&MenuName);
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return (ATOM)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!RtlCreateUnicodeStringFromAsciiz(&ClassName, (PCSZ)lpwcx->lpszClassName))
|
|
||||||
{
|
|
||||||
RtlFreeUnicodeString(&ClassName);
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return (ATOM)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlMoveMemory(&Class, lpwcx, sizeof(WNDCLASSEXA));
|
RtlMoveMemory(&Class, lpwcx, sizeof(WNDCLASSEXA));
|
||||||
Class.lpszMenuName = MenuName.Buffer;
|
if (HIWORD((ULONG)lpwcx->lpszMenuName) != 0)
|
||||||
Class.lpszClassName = ClassName.Buffer;
|
{
|
||||||
|
if (!RtlCreateUnicodeStringFromAsciiz(&MenuName, (PCSZ)lpwcx->lpszMenuName))
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString(&MenuName);
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return (ATOM)0;
|
||||||
|
}
|
||||||
|
Class.lpszMenuName = MenuName.Buffer;
|
||||||
|
}
|
||||||
|
if (HIWORD((ULONG)lpwcx->lpszClassName) != 0)
|
||||||
|
{
|
||||||
|
if (!RtlCreateUnicodeStringFromAsciiz(&ClassName, (PCSZ)lpwcx->lpszClassName))
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString(&ClassName);
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return (ATOM)0;
|
||||||
|
}
|
||||||
|
Class.lpszClassName = ClassName.Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
Atom = NtUserRegisterClassExWOW(&Class,
|
Atom = NtUserRegisterClassExWOW(&Class,
|
||||||
FALSE,
|
FALSE,
|
||||||
|
@ -266,8 +270,14 @@ RegisterClassExA(CONST WNDCLASSEXA *lpwcx)
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&ClassName);
|
if (HIWORD((ULONG)lpwcx->lpszMenuName) != 0)
|
||||||
RtlFreeUnicodeString(&MenuName);
|
{
|
||||||
|
RtlFreeUnicodeString(&ClassName);
|
||||||
|
}
|
||||||
|
if (HIWORD((ULONG)lpwcx->lpszClassName )!= 0)
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString(&MenuName);
|
||||||
|
}
|
||||||
|
|
||||||
return (ATOM)Atom;
|
return (ATOM)Atom;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +291,7 @@ RegisterClassExW(CONST WNDCLASSEXW *lpwcx)
|
||||||
{
|
{
|
||||||
RTL_ATOM Atom;
|
RTL_ATOM Atom;
|
||||||
|
|
||||||
Atom = NtUserRegisterClassExWOW((WNDCLASSEX*)lpwcx,
|
Atom = NtUserRegisterClassExWOW((WNDCLASSEXW*)lpwcx,
|
||||||
TRUE,
|
TRUE,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -22,8 +22,7 @@ NTSTATUS FASTCALL
|
||||||
CleanupClassImpl(VOID);
|
CleanupClassImpl(VOID);
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
ClassReferenceClassByName(PW32PROCESS Process,
|
ClassReferenceClassByName(PWNDCLASS_OBJECT *Class,
|
||||||
PWNDCLASS_OBJECT *Class,
|
|
||||||
LPWSTR ClassName);
|
LPWSTR ClassName);
|
||||||
|
|
||||||
NTSTATUS FASTCALL
|
NTSTATUS FASTCALL
|
||||||
|
@ -35,7 +34,8 @@ ClassReferenceClassByNameOrAtom(PWNDCLASS_OBJECT *Class,
|
||||||
LPWSTR ClassNameOrAtom);
|
LPWSTR ClassNameOrAtom);
|
||||||
PWNDCLASS_OBJECT FASTCALL
|
PWNDCLASS_OBJECT FASTCALL
|
||||||
W32kCreateClass(LPWNDCLASSEXW lpwcx,
|
W32kCreateClass(LPWNDCLASSEXW lpwcx,
|
||||||
BOOL bUnicodeClass);
|
BOOL bUnicodeClass,
|
||||||
|
RTL_ATOM ClassName);
|
||||||
struct _WINDOW_OBJECT;
|
struct _WINDOW_OBJECT;
|
||||||
ULONG FASTCALL
|
ULONG FASTCALL
|
||||||
W32kGetClassLong(struct _WINDOW_OBJECT *WindowObject, ULONG Offset);
|
W32kGetClassLong(struct _WINDOW_OBJECT *WindowObject, ULONG Offset);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: class.c,v 1.19 2003/07/11 17:08:44 chorns Exp $
|
/* $Id: class.c,v 1.20 2003/07/27 21:35:50 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -56,13 +56,13 @@ CleanupClassImpl(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS FASTCALL
|
||||||
ClassReferenceClassByName(PW32PROCESS Process,
|
ClassReferenceClassByAtom(PWNDCLASS_OBJECT* Class,
|
||||||
PWNDCLASS_OBJECT* Class,
|
RTL_ATOM Atom)
|
||||||
LPWSTR ClassName)
|
|
||||||
{
|
{
|
||||||
PWNDCLASS_OBJECT Current;
|
PWNDCLASS_OBJECT Current;
|
||||||
PLIST_ENTRY CurrentEntry;
|
PLIST_ENTRY CurrentEntry;
|
||||||
|
PW32PROCESS Process = PsGetWin32Process();
|
||||||
|
|
||||||
ExAcquireFastMutexUnsafe (&Process->ClassListLock);
|
ExAcquireFastMutexUnsafe (&Process->ClassListLock);
|
||||||
CurrentEntry = Process->ClassListHead.Flink;
|
CurrentEntry = Process->ClassListHead.Flink;
|
||||||
|
@ -70,7 +70,7 @@ ClassReferenceClassByName(PW32PROCESS Process,
|
||||||
{
|
{
|
||||||
Current = CONTAINING_RECORD(CurrentEntry, WNDCLASS_OBJECT, ListEntry);
|
Current = CONTAINING_RECORD(CurrentEntry, WNDCLASS_OBJECT, ListEntry);
|
||||||
|
|
||||||
if (_wcsicmp(ClassName, Current->Class.lpszClassName) == 0)
|
if (Current->Class.lpszClassName == (LPWSTR)(ULONG)Atom)
|
||||||
{
|
{
|
||||||
*Class = Current;
|
*Class = Current;
|
||||||
ObmReferenceObject(Current);
|
ObmReferenceObject(Current);
|
||||||
|
@ -85,16 +85,15 @@ ClassReferenceClassByName(PW32PROCESS Process,
|
||||||
return(STATUS_NOT_FOUND);
|
return(STATUS_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS FASTCALL
|
NTSTATUS STDCALL
|
||||||
ClassReferenceClassByAtom(PWNDCLASS_OBJECT *Class,
|
ClassReferenceClassByName(PWNDCLASS_OBJECT *Class,
|
||||||
RTL_ATOM ClassAtom)
|
PWSTR ClassName)
|
||||||
{
|
{
|
||||||
PWINSTATION_OBJECT WinStaObject;
|
PWINSTATION_OBJECT WinStaObject;
|
||||||
ULONG ClassNameLength;
|
|
||||||
WCHAR ClassName[256];
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
RTL_ATOM ClassAtom;
|
||||||
|
|
||||||
if (!ClassAtom)
|
if (!ClassName)
|
||||||
{
|
{
|
||||||
return(STATUS_INVALID_PARAMETER);
|
return(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
@ -110,20 +109,19 @@ ClassReferenceClassByAtom(PWNDCLASS_OBJECT *Class,
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassNameLength = sizeof(ClassName);
|
Status = RtlLookupAtomInAtomTable(WinStaObject->AtomTable,
|
||||||
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
|
ClassName,
|
||||||
ClassAtom,
|
&ClassAtom);
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&ClassName[0],
|
|
||||||
&ClassNameLength);
|
|
||||||
|
|
||||||
Status = ClassReferenceClassByName(PsGetWin32Process(),
|
if (!NT_SUCCESS(Status))
|
||||||
Class,
|
{
|
||||||
&ClassName[0]);
|
ObDereferenceObject(WinStaObject);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
Status = ClassReferenceClassByAtom(Class,
|
||||||
|
ClassAtom);
|
||||||
|
|
||||||
ObDereferenceObject(WinStaObject);
|
ObDereferenceObject(WinStaObject);
|
||||||
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +138,7 @@ ClassReferenceClassByNameOrAtom(PWNDCLASS_OBJECT *Class,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Status = ClassReferenceClassByName(PsGetWin32Process(), Class,
|
Status = ClassReferenceClassByName(Class,
|
||||||
ClassNameOrAtom);
|
ClassNameOrAtom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,15 +183,15 @@ NtUserGetWOWClass(DWORD Unknown0,
|
||||||
|
|
||||||
PWNDCLASS_OBJECT FASTCALL
|
PWNDCLASS_OBJECT FASTCALL
|
||||||
W32kCreateClass(LPWNDCLASSEXW lpwcx,
|
W32kCreateClass(LPWNDCLASSEXW lpwcx,
|
||||||
BOOL bUnicodeClass)
|
BOOL bUnicodeClass,
|
||||||
|
RTL_ATOM Atom)
|
||||||
{
|
{
|
||||||
PWNDCLASS_OBJECT ClassObject;
|
PWNDCLASS_OBJECT ClassObject;
|
||||||
WORD objectSize;
|
WORD objectSize;
|
||||||
LPTSTR namePtr;
|
LPTSTR namePtr;
|
||||||
|
|
||||||
objectSize = sizeof(WNDCLASS_OBJECT) +
|
objectSize = sizeof(WNDCLASS_OBJECT) +
|
||||||
(lpwcx->lpszMenuName != 0 ? ((wcslen (lpwcx->lpszMenuName) + 1) * 2) : 0) +
|
(lpwcx->lpszMenuName != 0 ? ((wcslen (lpwcx->lpszMenuName) + 1) * 2) : 0);
|
||||||
((wcslen (lpwcx->lpszClassName) + 1) * 2);
|
|
||||||
ClassObject = ObmCreateObject(NULL, NULL, otClass, objectSize);
|
ClassObject = ObmCreateObject(NULL, NULL, otClass, objectSize);
|
||||||
if (ClassObject == 0)
|
if (ClassObject == 0)
|
||||||
{
|
{
|
||||||
|
@ -202,15 +200,13 @@ W32kCreateClass(LPWNDCLASSEXW lpwcx,
|
||||||
|
|
||||||
ClassObject->Class = *lpwcx;
|
ClassObject->Class = *lpwcx;
|
||||||
ClassObject->Unicode = bUnicodeClass;
|
ClassObject->Unicode = bUnicodeClass;
|
||||||
namePtr = (LPTSTR)(((PCHAR)ClassObject) + sizeof (WNDCLASS_OBJECT));
|
|
||||||
if (lpwcx->lpszMenuName != 0)
|
if (lpwcx->lpszMenuName != 0)
|
||||||
{
|
{
|
||||||
|
namePtr = (LPTSTR)(((PCHAR)ClassObject) + sizeof (WNDCLASS_OBJECT));
|
||||||
ClassObject->Class.lpszMenuName = namePtr;
|
ClassObject->Class.lpszMenuName = namePtr;
|
||||||
wcscpy (namePtr, lpwcx->lpszMenuName);
|
wcscpy (namePtr, lpwcx->lpszMenuName);
|
||||||
namePtr += wcslen (lpwcx->lpszMenuName) + 1;
|
|
||||||
}
|
}
|
||||||
ClassObject->Class.lpszClassName = namePtr;
|
ClassObject->Class.lpszClassName = (LPWSTR)(ULONG)Atom;
|
||||||
wcscpy (namePtr, lpwcx->lpszClassName);
|
|
||||||
return(ClassObject);
|
return(ClassObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,23 +246,31 @@ NtUserRegisterClassExWOW(LPWNDCLASSEXW lpwcx,
|
||||||
PROCESS_WINDOW_STATION());
|
PROCESS_WINDOW_STATION());
|
||||||
return((RTL_ATOM)0);
|
return((RTL_ATOM)0);
|
||||||
}
|
}
|
||||||
|
if (!IS_ATOM(lpwcx->lpszClassName))
|
||||||
Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
|
|
||||||
(LPWSTR)lpwcx->lpszClassName,
|
|
||||||
&Atom);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
ObDereferenceObject(WinStaObject);
|
Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
|
||||||
DPRINT("Failed adding class name (%wS) to atom table\n",
|
(LPWSTR)lpwcx->lpszClassName,
|
||||||
lpwcx->lpszClassName);
|
&Atom);
|
||||||
SetLastNtError(Status);
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
return((RTL_ATOM)0);
|
ObDereferenceObject(WinStaObject);
|
||||||
|
DPRINT("Failed adding class name (%wS) to atom table\n",
|
||||||
|
lpwcx->lpszClassName);
|
||||||
|
SetLastNtError(Status);
|
||||||
|
return((RTL_ATOM)0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ClassObject = W32kCreateClass(lpwcx, bUnicodeClass);
|
else
|
||||||
|
{
|
||||||
|
Atom = (RTL_ATOM)(ULONG)lpwcx->lpszClassName;
|
||||||
|
}
|
||||||
|
ClassObject = W32kCreateClass(lpwcx, bUnicodeClass, Atom);
|
||||||
if (ClassObject == NULL)
|
if (ClassObject == NULL)
|
||||||
{
|
{
|
||||||
RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
|
if (!IS_ATOM(lpwcx->lpszClassName))
|
||||||
|
{
|
||||||
|
RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
|
||||||
|
}
|
||||||
ObDereferenceObject(WinStaObject);
|
ObDereferenceObject(WinStaObject);
|
||||||
DPRINT("Failed creating window class object\n");
|
DPRINT("Failed creating window class object\n");
|
||||||
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: winsta.c,v 1.19 2003/07/27 11:54:42 dwelch Exp $
|
/* $Id: winsta.c,v 1.20 2003/07/27 21:35:50 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -167,7 +167,7 @@ InitWindowStationImpl(VOID)
|
||||||
wcx.hbrBackground = NULL;
|
wcx.hbrBackground = NULL;
|
||||||
wcx.lpszMenuName = NULL;
|
wcx.lpszMenuName = NULL;
|
||||||
wcx.lpszClassName = L"DesktopWindowClass";
|
wcx.lpszClassName = L"DesktopWindowClass";
|
||||||
DesktopWindowClass = W32kCreateClass(&wcx, TRUE);
|
DesktopWindowClass = W32kCreateClass(&wcx, TRUE, (RTL_ATOM)32880);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue