ReactOS 0.4.15-dev-5853-gcb454ef
class.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _WNDPROC_INFO
 

Macros

#define IS_ATOM(x)    (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
 

Typedefs

typedef struct _WNDPROC_INFO WNDPROC_INFO
 
typedef struct _WNDPROC_INFOPWNDPROC_INFO
 

Functions

static __inline BOOL IsCallProcHandle (IN WNDPROC lpWndProc)
 
BOOLEAN DestroyCallProc (_Inout_ PVOID Object)
 
PCALLPROCDATA CreateCallProc (IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
 
BOOL UserGetCallProcInfo (IN HANDLE hCallProc, OUT PWNDPROC_INFO wpInfo)
 
void FASTCALL DestroyProcessClasses (PPROCESSINFO Process)
 
VOID IntDereferenceClass (IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
 
PCLS IntGetAndReferenceClass (PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread)
 
BOOL FASTCALL UserRegisterSystemClasses (VOID)
 
VOID UserAddCallProcToClass (IN OUT PCLS Class, IN PCALLPROCDATA CallProc)
 
 _Success_ (return) BOOL NTAPI IntGetAtomFromStringOrAtom(_In_ PUNICODE_STRING ClassName
 
BOOL IntCheckProcessDesktopClasses (IN PDESKTOP Desktop, IN BOOL FreeOnFailure)
 
ULONG_PTR FASTCALL UserGetCPD (PVOID, GETCPD, ULONG_PTR)
 
_Must_inspect_result_ NTSTATUS NTAPI ProbeAndCaptureUnicodeStringOrAtom (_Out_ _When_(return >=0, _At_(pustrOut->Buffer, _Post_ _Notnull_)) PUNICODE_STRING pustrOut, __in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe)
 
BOOL FASTCALL LookupFnIdToiCls (int FnId, int *iCls)
 
INT UserGetClassName (IN PCLS Class, IN OUT PUNICODE_STRING ClassName, IN RTL_ATOM Atom, IN BOOL Ansi)
 

Variables

_Out_ RTL_ATOMAtom
 

Macro Definition Documentation

◆ IS_ATOM

#define IS_ATOM (   x)     (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))

Definition at line 3 of file class.h.

Typedef Documentation

◆ PWNDPROC_INFO

◆ WNDPROC_INFO

Function Documentation

◆ _Success_()

_Success_ ( return  )

◆ CreateCallProc()

PCALLPROCDATA CreateCallProc ( IN PDESKTOP  Desktop,
IN WNDPROC  WndProc,
IN BOOL  Unicode,
IN PPROCESSINFO  pi 
)

Definition at line 29 of file callproc.c.

33{
34 PCALLPROCDATA NewCallProc;
36
37 /* We can send any thread pointer to the object manager here,
38 * What's important is the process info */
40 Desktop,
41 pi->ptiList,
42 &Handle,
44 sizeof(CALLPROCDATA));
45 if (NewCallProc != NULL)
46 {
47 NewCallProc->pfnClientPrevious = WndProc;
48 NewCallProc->wType |= Unicode ? UserGetCPDA2U : UserGetCPDU2A ;
49 NewCallProc->spcpdNext = NULL;
50
51 /* Release the extra reference (UserCreateObject added 2 references) */
52 UserDereferenceObject(NewCallProc);
53 }
54
55 return NewCallProc;
56}
#define NULL
Definition: types.h:112
ULONG Handle
Definition: gdb_input.c:15
@ UserGetCPDU2A
Definition: ntuser.h:536
@ UserGetCPDA2U
Definition: ntuser.h:535
struct _CALLPROCDATA * PCALLPROCDATA
@ TYPE_CALLPROC
Definition: ntuser.h:47
static refpint_t pi[]
Definition: server.c:96
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:613
GETCPD wType
Definition: ntuser.h:548
WNDPROC pfnClientPrevious
Definition: ntuser.h:547
struct _CALLPROCDATA * spcpdNext
Definition: ntuser.h:546
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568

Referenced by IntCreateWindow(), and UserGetCPD().

◆ DestroyCallProc()

BOOLEAN DestroyCallProc ( _Inout_ PVOID  Object)

Definition at line 22 of file callproc.c.

23{
25 return TRUE;
26}
#define TRUE
Definition: types.h:120
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717

Referenced by IntDestroyClass().

◆ DestroyProcessClasses()

void FASTCALL DestroyProcessClasses ( PPROCESSINFO  Process)

Definition at line 300 of file class.c.

301{
302 PCLS Class;
304
305 if (pi != NULL)
306 {
307 /* Free all local classes */
308 Class = pi->pclsPrivateList;
309 while (Class != NULL)
310 {
311 pi->pclsPrivateList = Class->pclsNext;
312
313 ASSERT(Class->pclsBase == Class);
315
316 Class = pi->pclsPrivateList;
317 }
318
319 /* Free all global classes */
320 Class = pi->pclsPublicList;
321 while (Class != NULL)
322 {
323 pi->pclsPublicList = Class->pclsNext;
324
325 ASSERT(Class->pclsBase == Class);
327
328 Class = pi->pclsPublicList;
329 }
330 }
331}
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define ASSERT(a)
Definition: mode.c:44
struct _PROCESSINFO * PPROCESSINFO
Definition: ntwin32.h:5
Definition: ntuser.h:561
static VOID IntDestroyClass(IN OUT PCLS Class)
Definition: class.c:228

Referenced by ExitThreadCallback().

◆ IntCheckProcessDesktopClasses()

BOOL IntCheckProcessDesktopClasses ( IN PDESKTOP  Desktop,
IN BOOL  FreeOnFailure 
)

Definition at line 1012 of file class.c.

1014{
1016 BOOL Ret = TRUE;
1017
1019
1020 /* Check all local classes */
1022 &pi->pclsPrivateList,
1023 FreeOnFailure,
1024 &Ret);
1025
1026 /* Check all global classes */
1028 &pi->pclsPublicList,
1029 FreeOnFailure,
1030 &Ret);
1031 if (!Ret)
1032 {
1033 ERR("Failed to move process classes from desktop 0x%p to the shared heap!\n", Desktop);
1035 }
1036
1037 return Ret;
1038}
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _PROCESSINFO * GetW32ProcessInfo(VOID)
Definition: misc.c:795
static VOID IntCheckDesktopClasses(IN PDESKTOP Desktop, IN OUT PCLS *ClassList, IN BOOL FreeOnFailure, OUT BOOL *Ret)
Definition: class.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by IntSetThreadDesktop().

◆ IntDereferenceClass()

VOID IntDereferenceClass ( IN OUT PCLS  Class,
IN PDESKTOPINFO  Desktop,
IN PPROCESSINFO  pi 
)

Definition at line 815 of file class.c.

818{
819 PCLS *PrevLink, BaseClass, CurrentClass;
820
821 ASSERT(Class->cWndReferenceCount >= 1);
822
823 BaseClass = Class->pclsBase;
824
825 if (--Class->cWndReferenceCount == 0)
826 {
827 if (BaseClass == Class)
828 {
829 ASSERT(Class->pclsBase == Class);
830
831 TRACE("IntDereferenceClass 0x%p\n", Class);
832 /* Check if there are clones of the class on other desktops,
833 link the first clone in if possible. If there are no clones
834 then leave the class on the desktop heap. It will get moved
835 to the shared heap when the thread detaches. */
836 if (BaseClass->pclsClone != NULL)
837 {
838 if (BaseClass->Global)
839 PrevLink = &pi->pclsPublicList;
840 else
841 PrevLink = &pi->pclsPrivateList;
842
843 CurrentClass = *PrevLink;
844 while (CurrentClass != BaseClass)
845 {
846 ASSERT(CurrentClass != NULL);
847
848 PrevLink = &CurrentClass->pclsNext;
849 CurrentClass = CurrentClass->pclsNext;
850 }
851
852 ASSERT(*PrevLink == BaseClass);
853
854 /* Make the first clone become the new base class */
856 PrevLink,
857 &BaseClass->pclsClone);
858
859 /* Destroy the class, there's still another clone of the class
860 that now serves as a base class. Make sure we don't destruct
861 resources shared by all classes (Base = NULL)! */
862 BaseClass->pclsBase = NULL;
863 BaseClass->pclsClone = NULL;
864 IntDestroyClass(BaseClass);
865 }
866 }
867 else
868 {
869 TRACE("IntDereferenceClass1 0x%p\n", Class);
870
871 /* Locate the cloned class and unlink it */
872 PrevLink = &BaseClass->pclsClone;
873 CurrentClass = BaseClass->pclsClone;
874 while (CurrentClass != Class)
875 {
876 ASSERT(CurrentClass != NULL);
877
878 PrevLink = &CurrentClass->pclsNext;
879 CurrentClass = CurrentClass->pclsNext;
880 }
881
882 ASSERT(CurrentClass == Class);
883
885 Class->pclsNext);
886
887 ASSERT(Class->pclsBase == BaseClass);
888 ASSERT(Class->pclsClone == NULL);
889
890 /* The class was just a clone, we don't need it anymore */
892 }
893 }
894}
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define TRACE(s)
Definition: solgame.cpp:4
struct _CLS * pclsBase
Definition: ntuser.h:572
UINT Global
Definition: ntuser.h:588
struct _CLS * pclsClone
Definition: ntuser.h:573
struct _CLS * pclsNext
Definition: ntuser.h:562
static VOID IntMakeCloneBaseClass(IN OUT PCLS Class, IN OUT PCLS *BaseClassLink, IN OUT PCLS *CloneLink)
Definition: class.c:777

Referenced by co_UserCreateWindowEx(), and co_UserFreeWindow().

◆ IntGetAndReferenceClass()

PCLS IntGetAndReferenceClass ( PUNICODE_STRING  ClassName,
HINSTANCE  hInstance,
BOOL  bDesktopThread 
)

Definition at line 1437 of file class.c.

1438{
1439 PCLS *ClassLink, Class = NULL;
1440 RTL_ATOM ClassAtom;
1441 PTHREADINFO pti;
1442
1443 if (bDesktopThread)
1444 pti = gptiDesktopThread;
1445 else
1447
1448 if ( !(pti->ppi->W32PF_flags & W32PF_CLASSESREGISTERED ))
1449 {
1451 }
1452
1453 /* Check the class. */
1454
1455 TRACE("Finding Class %wZ for hInstance 0x%p\n", ClassName, hInstance);
1456
1457 ClassAtom = IntGetClassAtom(ClassName,
1458 hInstance,
1459 pti->ppi,
1460 &Class,
1461 &ClassLink);
1462
1463 if (ClassAtom == (RTL_ATOM)0)
1464 {
1465 if (IS_ATOM(ClassName->Buffer))
1466 {
1467 ERR("Class 0x%p not found\n", ClassName->Buffer);
1468 }
1469 else
1470 {
1471 ERR("Class \"%wZ\" not found\n", ClassName);
1472 }
1473
1474 return NULL;
1475 }
1476
1477 TRACE("Referencing Class 0x%p with atom 0x%x\n", Class, ClassAtom);
1479 ClassLink,
1480 pti->rpdesk);
1481 if (Class == NULL)
1482 {
1483 ERR("Failed to reference window class!\n");
1484 return NULL;
1485 }
1486
1487 return Class;
1488}
HINSTANCE hInstance
Definition: charmap.c:19
#define IS_ATOM(x)
Definition: class.h:3
unsigned short RTL_ATOM
Definition: atom.c:42
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
PPROCESSINFO ppi
Definition: win32.h:88
struct _DESKTOP * rpdesk
Definition: win32.h:92
#define W32PF_CLASSESREGISTERED
Definition: win32.h:17
PCLS IntReferenceClass(IN OUT PCLS BaseClass, IN OUT PCLS *ClassLink, IN PDESKTOP Desktop)
Definition: class.c:749
RTL_ATOM IntGetClassAtom(_In_ PUNICODE_STRING ClassName, IN HINSTANCE hInstance OPTIONAL, IN PPROCESSINFO pi OPTIONAL, OUT PCLS *BaseClass OPTIONAL, OUT PCLS **Link OPTIONAL)
Definition: class.c:1364
BOOL FASTCALL UserRegisterSystemClasses(VOID)
Definition: class.c:2306
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37

Referenced by co_UserCreateWindowEx(), and IntCreateDesktop().

◆ IsCallProcHandle()

static __inline BOOL IsCallProcHandle ( IN WNDPROC  lpWndProc)
static

Definition at line 13 of file class.h.

14{
15 /* FIXME: Check for 64-bit architectures... */
16 return ((ULONG_PTR)lpWndProc & 0xFFFF0000) == 0xFFFF0000;
17}
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by CallWindowProcA(), CallWindowProcW(), IntCreateWindow(), IntSetClassWndProc(), IntSetWindowProc(), and NtUserRegisterClassExWOW().

◆ LookupFnIdToiCls()

BOOL FASTCALL LookupFnIdToiCls ( int  FnId,
int iCls 
)

Definition at line 131 of file class.c.

132{
133 int i;
134
135 for ( i = 0; i < ARRAYSIZE(FnidToiCls); i++)
136 {
137 if (FnidToiCls[i].FnId == FnId)
138 {
139 if (iCls) *iCls = FnidToiCls[i].ClsId;
140 return TRUE;
141 }
142 }
143 if (iCls) *iCls = 0;
144 return FALSE;
145}
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int FnId
Definition: class.c:106
static struct @4909 FnidToiCls[]

Referenced by IntCreateClass(), IntIsGhostWindow(), and NtUserGetClassName().

◆ ProbeAndCaptureUnicodeStringOrAtom()

_Must_inspect_result_ NTSTATUS NTAPI ProbeAndCaptureUnicodeStringOrAtom ( _Out_ _When_(return >=0, _At_(pustrOut->Buffer, _Post_ _Notnull_)) PUNICODE_STRING  pustrOut,
__in_data_source(USER_MODE) _In_ PUNICODE_STRING  pustrUnsafe 
)

Definition at line 150 of file class.c.

153{
155
156 /* Default to NULL */
157 pustrOut->Buffer = NULL;
158
160 {
161 ProbeForRead(pustrUnsafe, sizeof(UNICODE_STRING), 1);
162
163 /* Validate the string */
164 if ((pustrUnsafe->Length & 1) || (pustrUnsafe->Buffer == NULL))
165 {
166 /* This is not legal */
168 }
169
170 /* Check if this is an atom */
171 if (IS_ATOM(pustrUnsafe->Buffer))
172 {
173 /* Copy the atom, length is 0 */
174 pustrOut->MaximumLength = pustrOut->Length = 0;
175 pustrOut->Buffer = pustrUnsafe->Buffer;
176 }
177 else
178 {
179 /* Get the length, maximum length includes zero termination */
180 pustrOut->Length = pustrUnsafe->Length;
181 pustrOut->MaximumLength = pustrOut->Length + sizeof(WCHAR);
182
183 /* Allocate a buffer */
184 pustrOut->Buffer = ExAllocatePoolWithTag(PagedPool,
185 pustrOut->MaximumLength,
186 TAG_STRING);
187 if (!pustrOut->Buffer)
188 {
190 }
191
192 /* Copy the string and zero terminate it */
193 ProbeForRead(pustrUnsafe->Buffer, pustrOut->Length, 1);
194 RtlCopyMemory(pustrOut->Buffer, pustrUnsafe->Buffer, pustrOut->Length);
195 pustrOut->Buffer[pustrOut->Length / sizeof(WCHAR)] = L'\0';
196 }
197 }
199 {
200 /* Check if we already allocated a buffer */
201 if (pustrOut->Buffer)
202 {
203 /* Free the buffer */
204 ExFreePoolWithTag(pustrOut->Buffer, TAG_STRING);
206 }
207 }
208 _SEH2_END;
209
210 return Status;
211}
LONG NTSTATUS
Definition: precomp.h:26
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define L(x)
Definition: ntvdm.h:50
#define TAG_STRING
Definition: oslist.h:22
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by NtUserFindExistingCursorIcon(), NtUserGetClassInfo(), NtUserGetWOWClass(), NtUserSetCursorIconData(), and NtUserUnregisterClass().

◆ UserAddCallProcToClass()

VOID UserAddCallProcToClass ( IN OUT PCLS  Class,
IN PCALLPROCDATA  CallProc 
)

Definition at line 423 of file class.c.

425{
426 PCLS BaseClass;
427
428 ASSERT(CallProc->spcpdNext == NULL);
429
430 BaseClass = Class->pclsBase;
431 ASSERT(CallProc->spcpdNext == NULL);
432 CallProc->spcpdNext = BaseClass->spcpdFirst;
433 BaseClass->spcpdFirst = CallProc;
434
435 /* Update all clones */
436 Class = Class->pclsClone;
437 while (Class != NULL)
438 {
439 Class->spcpdFirst = BaseClass->spcpdFirst;
440 Class = Class->pclsNext;
441 }
442}
PCALLPROCDATA spcpdFirst
Definition: ntuser.h:571

Referenced by IntCreateWindow().

◆ UserGetCallProcInfo()

BOOL UserGetCallProcInfo ( IN HANDLE  hCallProc,
OUT PWNDPROC_INFO  wpInfo 
)

Definition at line 59 of file callproc.c.

61{
62 PCALLPROCDATA CallProc;
63
64 CallProc = UserGetObject(gHandleTable,
65 hCallProc,
67 if (CallProc == NULL)
68 {
69 return FALSE;
70 }
71
72/* Use Handle pEntry->ppi!
73 if (CallProc->pi != GetW32ProcessInfo())
74 {
75 return FALSE;
76 }*/
77
78 wpInfo->WindowProc = CallProc->pfnClientPrevious;
79 wpInfo->IsUnicode = !!(CallProc->wType & UserGetCPDA2U);
80
81 return TRUE;
82}
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495

◆ UserGetClassName()

INT UserGetClassName ( IN PCLS  Class,
IN OUT PUNICODE_STRING  ClassName,
IN RTL_ATOM  Atom,
IN BOOL  Ansi 
)

Definition at line 1634 of file class.c.

1638{
1640 WCHAR szStaticTemp[32];
1641 PWSTR szTemp = NULL;
1642 ULONG BufLen = sizeof(szStaticTemp);
1643 INT Ret = 0;
1644
1645 /* Note: Accessing the buffer in ClassName may raise an exception! */
1646
1647 _SEH2_TRY
1648 {
1649 if (Ansi)
1650 {
1651 PANSI_STRING AnsiClassName = (PANSI_STRING)ClassName;
1652 UNICODE_STRING UnicodeClassName;
1653
1654 /* Limit the size of the static buffer on the stack to the
1655 size of the buffer provided by the caller */
1656 if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength)
1657 {
1658 BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR);
1659 }
1660
1661 /* Find out how big the buffer needs to be */
1663 Class->atomClassName,
1664 NULL,
1665 NULL,
1666 szStaticTemp,
1667 &BufLen);
1669 {
1670 if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength)
1671 {
1672 /* The buffer required exceeds the ansi buffer provided,
1673 pretend like we're using the ansi buffer and limit the
1674 size to the buffer size provided */
1675 BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR);
1676 }
1677
1678 /* Allocate a temporary buffer that can hold the unicode class name */
1680 BufLen,
1682 if (szTemp == NULL)
1683 {
1686 }
1687
1688 /* Query the class name */
1690 Atom ? Atom : Class->atomNVClassName,
1691 NULL,
1692 NULL,
1693 szTemp,
1694 &BufLen);
1695 }
1696 else
1697 szTemp = szStaticTemp;
1698
1699 if (NT_SUCCESS(Status))
1700 {
1701 /* Convert the atom name to ansi */
1702
1703 RtlInitUnicodeString(&UnicodeClassName,
1704 szTemp);
1705
1706 Status = RtlUnicodeStringToAnsiString(AnsiClassName,
1707 &UnicodeClassName,
1708 FALSE);
1709 if (!NT_SUCCESS(Status))
1710 {
1713 }
1714 }
1715
1716 Ret = BufLen / sizeof(WCHAR);
1717 }
1718 else /* !ANSI */
1719 {
1720 BufLen = ClassName->MaximumLength;
1721
1722 /* Query the atom name */
1724 Atom ? Atom : Class->atomNVClassName,
1725 NULL,
1726 NULL,
1727 ClassName->Buffer,
1728 &BufLen);
1729
1730 if (!NT_SUCCESS(Status))
1731 {
1734 }
1735
1736 Ret = BufLen / sizeof(WCHAR);
1737 }
1738 }
1740 {
1742 }
1743 _SEH2_END;
1744
1745 if (Ansi && szTemp != NULL && szTemp != szStaticTemp)
1746 {
1748 }
1749
1750 return Ret;
1751}
_Out_ RTL_ATOM * Atom
Definition: class.h:54
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ANSI_STRING * PANSI_STRING
Definition: env_spec_w32.h:380
#define BufLen
Definition: fatfs.h:167
#define _SEH2_LEAVE
Definition: filesup.c:20
NTSYSAPI NTSTATUS NTAPI RtlQueryAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom, _Out_opt_ PULONG RefCount, _Out_opt_ PULONG PinCount, _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName, _Inout_opt_ PULONG NameLength)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
USHORT MaximumLength
Definition: env_spec_w32.h:377
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
#define USERTAG_CLASS
Definition: tags.h:204

Referenced by IntIsGhostWindow(), and NtUserGetClassName().

◆ UserGetCPD()

ULONG_PTR FASTCALL UserGetCPD ( PVOID  pvClsWnd,
GETCPD  Flags,
ULONG_PTR  ProcIn 
)

Definition at line 107 of file callproc.c.

111{
112 PCLS pCls;
113 PWND pWnd;
114 PDESKTOP pDesk;
115 PCALLPROCDATA CallProc = NULL;
116 PTHREADINFO pti;
117
119
122 {
123 pWnd = pvClsWnd;
124 pCls = pWnd->pcls;
125 }
126 else
127 pCls = pvClsWnd;
128
129 // Search Class call proc data list.
130 if (pCls->spcpdFirst)
131 CallProc = UserSearchForCallProc( pCls->spcpdFirst, (WNDPROC)ProcIn, Flags);
132
133 // No luck, create a new one for the requested proc.
134 if (!CallProc)
135 {
136 if (!pCls->rpdeskParent)
137 {
138 TRACE("Null DESKTOP Atom %u\n",pCls->atomClassName);
139 pDesk = pti->rpdesk;
140 }
141 else
142 pDesk = pCls->rpdeskParent;
143 CallProc = CreateCallProc( pDesk,
144 (WNDPROC)ProcIn,
145 !!(Flags & UserGetCPDA2U),
146 pti->ppi);
147 if (CallProc)
148 {
149 CallProc->spcpdNext = pCls->spcpdFirst;
151 CallProc);
152 CallProc->wType = Flags;
153 }
154 }
155 return (ULONG_PTR)(CallProc ? GetCallProcHandle(CallProc) : NULL);
156}
PCALLPROCDATA CreateCallProc(IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
Definition: callproc.c:29
WNDPROC GetCallProcHandle(IN PCALLPROCDATA CallProc)
Definition: callproc.c:15
PCALLPROCDATA FASTCALL UserSearchForCallProc(PCALLPROCDATA pcpd, WNDPROC WndProc, GETCPD Type)
Definition: callproc.c:89
@ UserGetCPDWndtoCls
Definition: ntuser.h:540
@ UserGetCPDDialog
Definition: ntuser.h:539
@ UserGetCPDWindow
Definition: ntuser.h:538
struct _DESKTOP * rpdeskParent
Definition: ntuser.h:566
RTL_ATOM atomClassName
Definition: ntuser.h:563
Definition: ntuser.h:689
PCLS pcls
Definition: ntuser.h:715
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2896
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by IntGetClassWndProc(), IntGetWindowProc(), and NtUserGetCPD().

◆ UserRegisterSystemClasses()

BOOL FASTCALL UserRegisterSystemClasses ( VOID  )

Definition at line 2306 of file class.c.

2307{
2308 UINT i;
2309 UNICODE_STRING ClassName, MenuName;
2311 WNDCLASSEXW wc;
2312 PCLS Class;
2313 BOOL Ret = TRUE;
2314 HBRUSH hBrush;
2315 DWORD Flags = 0;
2316
2317 if (ppi->W32PF_flags & W32PF_CLASSESREGISTERED)
2318 return TRUE;
2319
2320 if ( hModClient == NULL)
2321 return FALSE;
2322
2323 RtlZeroMemory(&ClassName, sizeof(ClassName));
2324 RtlZeroMemory(&MenuName, sizeof(MenuName));
2325
2326 for (i = 0; i != ARRAYSIZE(DefaultServerClasses); i++)
2327 {
2328 if (!IS_ATOM(DefaultServerClasses[i].ClassName))
2329 {
2330 RtlInitUnicodeString(&ClassName, DefaultServerClasses[i].ClassName);
2331 }
2332 else
2333 {
2334 ClassName.Buffer = DefaultServerClasses[i].ClassName;
2335 ClassName.Length = 0;
2336 ClassName.MaximumLength = 0;
2337 }
2338
2339 wc.cbSize = sizeof(wc);
2341
2343
2344 if (DefaultServerClasses[i].ProcW)
2345 {
2347 wc.hInstance = hModuleWin;
2348 }
2349 else
2350 {
2352 wc.hInstance = hModClient;
2353 }
2354
2355 wc.cbClsExtra = 0;
2357 wc.hIcon = NULL;
2358
2360 wc.hCursor = NULL;
2361 if (DefaultServerClasses[i].hCursor == (HICON)OCR_NORMAL)
2362 {
2363 if (SYSTEMCUR(ARROW) == NULL)
2364 {
2365 ERR("SYSTEMCUR(ARROW) == NULL, should not happen!!\n");
2366 }
2367 else
2368 {
2369 wc.hCursor = UserHMGetHandle(SYSTEMCUR(ARROW));
2370 }
2371 }
2372
2373 hBrush = DefaultServerClasses[i].hBrush;
2374 if (hBrush <= (HBRUSH)COLOR_MENUBAR)
2375 {
2376 hBrush = IntGetSysColorBrush(HandleToUlong(hBrush));
2377 }
2378 wc.hbrBackground = hBrush;
2379 wc.lpszMenuName = NULL;
2380 wc.lpszClassName = ClassName.Buffer;
2381 wc.hIconSm = NULL;
2382
2383 Class = IntCreateClass( &wc,
2384 &ClassName,
2385 &ClassName,
2386 &MenuName,
2387 DefaultServerClasses[i].fiId,
2388 Flags,
2389 NULL,
2390 ppi);
2391 if (Class != NULL)
2392 {
2393 Class->pclsNext = ppi->pclsPublicList;
2395 Class);
2396
2398 }
2399 else
2400 {
2401 ERR("!!! Registering system class failed!\n");
2402 Ret = FALSE;
2403 }
2404 }
2405 if (Ret) ppi->W32PF_flags |= W32PF_CLASSESREGISTERED;
2406 return Ret;
2407}
#define HandleToUlong(h)
Definition: basetsd.h:79
#define SYSTEMCUR(func)
Definition: cursoricon.h:129
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ICLASS_TO_MASK(iCls)
Definition: ntuser.h:897
#define GETPFNSERVER(fnid)
Definition: ntuser.h:904
#define CSF_SERVERSIDEPROC
Definition: ntuser.h:551
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
static HICON
Definition: imagelist.c:84
unsigned int UINT
Definition: ndis.h:50
HINSTANCE hModClient
Definition: ntuser.c:25
DWORD dwRegisteredClasses
Definition: win32.h:280
struct _CLS * pclsPublicList
Definition: win32.h:260
WNDPROC ProcW
Definition: ntuser.h:483
LPCWSTR lpszClassName
Definition: winuser.h:3216
LPCWSTR lpszMenuName
Definition: winuser.h:3215
HBRUSH hbrBackground
Definition: winuser.h:3214
WNDPROC lpfnWndProc
Definition: winuser.h:3208
UINT cbSize
Definition: winuser.h:3206
int cbWndExtra
Definition: winuser.h:3210
HCURSOR hCursor
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3217
HINSTANCE hInstance
Definition: winuser.h:3211
UINT style
Definition: winuser.h:3207
int cbClsExtra
Definition: winuser.h:3209
HICON hIcon
Definition: winuser.h:3212
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
REGISTER_SYSCLASS DefaultServerClasses[]
Definition: class.c:35
PCLS FASTCALL IntCreateClass(IN CONST WNDCLASSEXW *lpwcx, IN PUNICODE_STRING ClassName, IN PUNICODE_STRING ClassVersion, IN PUNICODE_STRING MenuName, IN DWORD fnID, IN DWORD dwFlags, IN PDESKTOP Desktop, IN PPROCESSINFO pi)
Definition: class.c:1042
HANDLE hModuleWin
Definition: main.c:16
#define OCR_NORMAL
Definition: winuser.h:1136

Referenced by DesktopThreadMain(), IntGetAndReferenceClass(), NtUserGetClassInfo(), and NtUserRegisterClassExWOW().

Variable Documentation

◆ Atom