*/
/* INCLUDES ******************************************************************/
-#include <w32k.h>
+#include <win32k.h>
#define NDEBUG
#include <debug.h>
return Atom;
}
+PCLS
+IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance)
+{
+ PCLS *ClassLink, Class = NULL;
+ RTL_ATOM ClassAtom;
+ PTHREADINFO pti;
+
+ pti = PsGetCurrentThreadWin32Thread();
+
+ if ( !(pti->ppi->W32PF_flags & W32PF_CLASSESREGISTERED ))
+ {
+ UserRegisterSystemClasses();
+ }
+
+ /* Check the class. */
+
+ DPRINT("Class %wZ\n", ClassName);
+
+ ClassAtom = IntGetClassAtom(ClassName,
+ hInstance,
+ pti->ppi,
+ &Class,
+ &ClassLink);
+
+ if (ClassAtom == (RTL_ATOM)0)
+ {
+ if (IS_ATOM(ClassName->Buffer))
+ {
+ DPRINT1("Class 0x%p not found\n", (DWORD_PTR) ClassName->Buffer);
+ }
+ else
+ {
+ DPRINT1("Class \"%wZ\" not found\n", ClassName);
+ }
+
+ SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS);
+ return NULL;
+ }
+ DPRINT("ClassAtom %x\n", ClassAtom);
+ Class = IntReferenceClass(Class,
+ ClassLink,
+ pti->rpdesk);
+ if (Class == NULL)
+ {
+ DPRINT1("Failed to reference window class!\n");
+ return NULL;
+ }
+
+ return Class;
+}
+
RTL_ATOM
UserRegisterClass(IN CONST WNDCLASSEXW* lpwcx,
IN PUNICODE_STRING ClassName,
MenuName,
fnID,
dwFlags,
- pti->Desktop,
+ pti->rpdesk,
pi);
if (Class != NULL)
}
/* allocate a temporary buffer that can hold the unicode class name */
- szTemp = ExAllocatePool(PagedPool,
- BufLen);
+ szTemp = ExAllocatePoolWithTag(PagedPool,
+ BufLen,
+ USERTAG_CLASS);
if (szTemp == NULL)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return Ret;
}
-ULONG_PTR
-UserGetClassLongPtr(IN PCLS Class,
- IN INT Index,
- IN BOOL Ansi)
-{
- ULONG_PTR Ret = 0;
-
- if (Index >= 0)
- {
- PULONG_PTR Data;
-
- TRACE("GetClassLong(%d)\n", Index);
- if (Index + sizeof(ULONG_PTR) < Index ||
- Index + sizeof(ULONG_PTR) > Class->cbclsExtra)
- {
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- Data = (PULONG_PTR)((ULONG_PTR)(Class + 1) + Index);
-
- /* FIXME - Data might be a unaligned pointer! Might be a problem on
- certain architectures, maybe using RtlCopyMemory is a
- better choice for those architectures! */
-
- TRACE("Result: %x\n", Ret);
- return *Data;
- }
-
- switch (Index)
- {
- case GCL_CBWNDEXTRA:
- Ret = (ULONG_PTR)Class->cbwndExtra;
- break;
-
- case GCL_CBCLSEXTRA:
- Ret = (ULONG_PTR)Class->cbclsExtra;
- break;
-
- case GCLP_HBRBACKGROUND:
- Ret = (ULONG_PTR)Class->hbrBackground;
- break;
-
- case GCLP_HCURSOR:
- /* FIXME - get handle from pointer to CURSOR object */
- Ret = (ULONG_PTR)Class->hCursor;
- break;
-
- case GCLP_HICON:
- /* FIXME - get handle from pointer to ICON object */
- Ret = (ULONG_PTR)Class->hIcon;
- break;
-
- case GCLP_HICONSM:
- /* FIXME - get handle from pointer to ICON object */
- Ret = (ULONG_PTR)Class->hIconSm;
- break;
-
- case GCLP_HMODULE:
- Ret = (ULONG_PTR)Class->hModule;
- break;
-
- case GCLP_MENUNAME:
- /* NOTE: Returns pointer in kernel heap! */
- if (Ansi)
- Ret = (ULONG_PTR)Class->lpszClientAnsiMenuName;
- else
- Ret = (ULONG_PTR)Class->lpszClientUnicodeMenuName;
- break;
-
- case GCL_STYLE:
- Ret = (ULONG_PTR)Class->style;
- break;
-
- case GCLP_WNDPROC:
- Ret = (ULONG_PTR)IntGetClassWndProc(Class, Ansi);
- break;
-
- case GCW_ATOM:
- Ret = (ULONG_PTR)Class->atomClassName;
- break;
-
- default:
- SetLastWin32Error(ERROR_INVALID_INDEX);
- break;
- }
-
- return Ret;
-}
-
static BOOL
IntSetClassMenuName(IN PCLS Class,
IN PUNICODE_STRING MenuName)
return Ret;
}
-ULONG_PTR APIENTRY
-NtUserGetClassLong(IN HWND hWnd,
- IN INT Offset,
- IN BOOL Ansi)
-{
- PWINDOW_OBJECT Window;
- ULONG_PTR Ret = 0;
-
- if (Offset != GCLP_WNDPROC)
- {
- UserEnterShared();
- }
- else
- {
- UserEnterExclusive();
- }
-
- Window = UserGetWindowObject(hWnd);
- if (Window != NULL)
- {
- Ret = UserGetClassLongPtr(Window->Wnd->pcls,
- Offset,
- Ansi);
-
- if ( Ret != 0 &&
- Offset == GCLP_MENUNAME &&
- Window->Wnd->pcls->MenuNameIsString)
- {
- Ret = (ULONG_PTR)UserHeapAddressToUser((PVOID)Ret);
- }
- }
-
- UserLeave();
-
- return Ret;
-}
-
-
-
ULONG_PTR APIENTRY
NtUserSetClassLong(HWND hWnd,
INT Offset,