ReactOS 0.4.16-dev-289-g096a551
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:541
@ UserGetCPDA2U
Definition: ntuser.h:540
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:614
GETCPD wType
Definition: ntuser.h:553
WNDPROC pfnClientPrevious
Definition: ntuser.h:552
struct _CALLPROCDATA * spcpdNext
Definition: ntuser.h:551
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 305 of file class.c.

306{
307 PCLS Class;
309
310 if (pi != NULL)
311 {
312 /* Free all local classes */
313 Class = pi->pclsPrivateList;
314 while (Class != NULL)
315 {
316 pi->pclsPrivateList = Class->pclsNext;
317
318 ASSERT(Class->pclsBase == Class);
320
321 Class = pi->pclsPrivateList;
322 }
323
324 /* Free all global classes */
325 Class = pi->pclsPublicList;
326 while (Class != NULL)
327 {
328 pi->pclsPublicList = Class->pclsNext;
329
330 ASSERT(Class->pclsBase == Class);
332
333 Class = pi->pclsPublicList;
334 }
335 }
336}
_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:566
static VOID IntDestroyClass(IN OUT PCLS Class)
Definition: class.c:233

Referenced by ExitThreadCallback().

◆ IntCheckProcessDesktopClasses()

BOOL IntCheckProcessDesktopClasses ( IN PDESKTOP  Desktop,
IN BOOL  FreeOnFailure 
)

Definition at line 1017 of file class.c.

1019{
1021 BOOL Ret = TRUE;
1022
1024
1025 /* Check all local classes */
1027 &pi->pclsPrivateList,
1028 FreeOnFailure,
1029 &Ret);
1030
1031 /* Check all global classes */
1033 &pi->pclsPublicList,
1034 FreeOnFailure,
1035 &Ret);
1036 if (!Ret)
1037 {
1038 ERR("Failed to move process classes from desktop 0x%p to the shared heap!\n", Desktop);
1040 }
1041
1042 return Ret;
1043}
#define ERR(fmt,...)
Definition: precomp.h:57
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _PROCESSINFO * GetW32ProcessInfo(VOID)
Definition: misc.c:801
static VOID IntCheckDesktopClasses(IN PDESKTOP Desktop, IN OUT PCLS *ClassList, IN BOOL FreeOnFailure, OUT BOOL *Ret)
Definition: class.c:948
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22

Referenced by IntSetThreadDesktop().

◆ IntDereferenceClass()

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

Definition at line 820 of file class.c.

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

Referenced by co_UserCreateWindowEx(), and co_UserFreeWindow().

◆ IntGetAndReferenceClass()

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

Definition at line 1450 of file class.c.

1451{
1452 PCLS *ClassLink, Class = NULL;
1453 RTL_ATOM ClassAtom;
1454 PTHREADINFO pti;
1455
1456 if (bDesktopThread)
1457 pti = gptiDesktopThread;
1458 else
1460
1461 if ( !(pti->ppi->W32PF_flags & W32PF_CLASSESREGISTERED ))
1462 {
1464 }
1465
1466 /* Check the class. */
1467
1468 TRACE("Finding Class %wZ for hInstance 0x%p\n", ClassName, hInstance);
1469
1470 ClassAtom = IntGetClassAtom(ClassName,
1471 hInstance,
1472 pti->ppi,
1473 &Class,
1474 &ClassLink);
1475
1476 if (ClassAtom == (RTL_ATOM)0)
1477 {
1478 if (IS_ATOM(ClassName->Buffer))
1479 {
1480 ERR("Class 0x%p not found\n", ClassName->Buffer);
1481 }
1482 else
1483 {
1484 ERR("Class \"%wZ\" not found\n", ClassName);
1485 }
1486
1487 return NULL;
1488 }
1489
1490 TRACE("Referencing Class 0x%p with atom 0x%x\n", Class, ClassAtom);
1492 ClassLink,
1493 pti->rpdesk);
1494 if (Class == NULL)
1495 {
1496 ERR("Failed to reference window class!\n");
1497 return NULL;
1498 }
1499
1500 return Class;
1501}
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:754
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:1377
BOOL FASTCALL UserRegisterSystemClasses(VOID)
Definition: class.c:2337
PTHREADINFO gptiDesktopThread
Definition: desktop.c:54

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 133 of file class.c.

134{
135 int i;
136
137 for ( i = 0; i < ARRAYSIZE(FnidToiCls); i++)
138 {
139 if (FnidToiCls[i].FnId == FnId)
140 {
141 if (iCls) *iCls = FnidToiCls[i].ClsId;
142 return TRUE;
143 }
144 }
145 if (iCls) *iCls = 0;
146 return FALSE;
147}
#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:108
static struct @5128 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 152 of file class.c.

155{
157 UNICODE_STRING ustrCopy;
158
159 /* Default to NULL */
160 RtlInitEmptyUnicodeString(pustrOut, NULL, 0);
161
163 {
164 ProbeForRead(pustrUnsafe, sizeof(UNICODE_STRING), 1);
165
166 ustrCopy = *pustrUnsafe;
167
168 /* Validate the string */
169 if ((ustrCopy.Length & 1) || (ustrCopy.Buffer == NULL))
170 {
171 /* This is not legal */
173 }
174
175 /* Check if this is an atom */
176 if (IS_ATOM(ustrCopy.Buffer))
177 {
178 /* Copy the atom, length is 0 */
179 pustrOut->MaximumLength = pustrOut->Length = 0;
180 pustrOut->Buffer = ustrCopy.Buffer;
181 }
182 else
183 {
184 /* Get the length, maximum length includes zero termination */
185 pustrOut->Length = ustrCopy.Length;
186 pustrOut->MaximumLength = pustrOut->Length + sizeof(WCHAR);
187
188 /* Allocate a buffer */
189 pustrOut->Buffer = ExAllocatePoolWithTag(PagedPool,
190 pustrOut->MaximumLength,
191 TAG_STRING);
192 if (!pustrOut->Buffer)
193 {
195 }
196
197 /* Copy the string and zero terminate it */
198 ProbeForRead(ustrCopy.Buffer, pustrOut->Length, 1);
199 RtlCopyMemory(pustrOut->Buffer, ustrCopy.Buffer, pustrOut->Length);
200 pustrOut->Buffer[pustrOut->Length / sizeof(WCHAR)] = L'\0';
201 }
202 }
204 {
205 /* Check if we already allocated a buffer */
206 if (pustrOut->Buffer)
207 {
208 /* Free the buffer */
209 ExFreePoolWithTag(pustrOut->Buffer, TAG_STRING);
211 }
212 }
213 _SEH2_END;
214
215 return Status;
216}
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
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define L(x)
Definition: ntvdm.h:50
#define TAG_STRING
Definition: oslist.h:22
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#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 428 of file class.c.

430{
431 PCLS BaseClass;
432
433 ASSERT(CallProc->spcpdNext == NULL);
434
435 BaseClass = Class->pclsBase;
436 ASSERT(CallProc->spcpdNext == NULL);
437 CallProc->spcpdNext = BaseClass->spcpdFirst;
438 BaseClass->spcpdFirst = CallProc;
439
440 /* Update all clones */
441 Class = Class->pclsClone;
442 while (Class != NULL)
443 {
444 Class->spcpdFirst = BaseClass->spcpdFirst;
445 Class = Class->pclsNext;
446 }
447}
PCALLPROCDATA spcpdFirst
Definition: ntuser.h:576

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 1647 of file class.c.

1651{
1653 WCHAR szStaticTemp[32];
1654 PWSTR szTemp = NULL;
1655 ULONG BufLen = sizeof(szStaticTemp);
1656 INT Ret = 0;
1657
1658 /* Note: Accessing the buffer in ClassName may raise an exception! */
1659
1660 _SEH2_TRY
1661 {
1662 if (Ansi)
1663 {
1664 PANSI_STRING AnsiClassName = (PANSI_STRING)ClassName;
1665 UNICODE_STRING UnicodeClassName;
1666
1667 /* Limit the size of the static buffer on the stack to the
1668 size of the buffer provided by the caller */
1669 if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength)
1670 {
1671 BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR);
1672 }
1673
1674 /* Find out how big the buffer needs to be */
1676 Class->atomClassName,
1677 NULL,
1678 NULL,
1679 szStaticTemp,
1680 &BufLen);
1682 {
1683 if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength)
1684 {
1685 /* The buffer required exceeds the ansi buffer provided,
1686 pretend like we're using the ansi buffer and limit the
1687 size to the buffer size provided */
1688 BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR);
1689 }
1690
1691 /* Allocate a temporary buffer that can hold the unicode class name */
1693 BufLen,
1695 if (szTemp == NULL)
1696 {
1699 }
1700
1701 /* Query the class name */
1703 Atom ? Atom : Class->atomNVClassName,
1704 NULL,
1705 NULL,
1706 szTemp,
1707 &BufLen);
1708 }
1709 else
1710 szTemp = szStaticTemp;
1711
1712 if (NT_SUCCESS(Status))
1713 {
1714 /* Convert the atom name to ansi */
1715
1716 RtlInitUnicodeString(&UnicodeClassName,
1717 szTemp);
1718
1719 Status = RtlUnicodeStringToAnsiString(AnsiClassName,
1720 &UnicodeClassName,
1721 FALSE);
1722 if (!NT_SUCCESS(Status))
1723 {
1726 }
1727 }
1728
1729 Ret = BufLen / sizeof(WCHAR);
1730 }
1731 else /* !ANSI */
1732 {
1733 BufLen = ClassName->MaximumLength;
1734
1735 /* Query the atom name */
1737 Atom ? Atom : Class->atomNVClassName,
1738 NULL,
1739 NULL,
1740 ClassName->Buffer,
1741 &BufLen);
1742
1743 if (!NT_SUCCESS(Status))
1744 {
1747 }
1748
1749 Ret = BufLen / sizeof(WCHAR);
1750 }
1751 }
1753 {
1755 }
1756 _SEH2_END;
1757
1758 if (Ansi && szTemp != NULL && szTemp != szStaticTemp)
1759 {
1761 }
1762
1763 return Ret;
1764}
_Out_ RTL_ATOM * Atom
Definition: class.h:54
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ANSI_STRING * PANSI_STRING
Definition: env_spec_w32.h:380
#define BufLen
Definition: fatfs.h:167
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 _SEH2_LEAVE
Definition: pseh2_64.h:167
#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(_In_ NTSTATUS Status)
Definition: error.c:31
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:545
@ UserGetCPDDialog
Definition: ntuser.h:544
@ UserGetCPDWindow
Definition: ntuser.h:543
struct _DESKTOP * rpdeskParent
Definition: ntuser.h:571
RTL_ATOM atomClassName
Definition: ntuser.h:568
Definition: ntuser.h:694
PCLS pcls
Definition: ntuser.h:720
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

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

◆ UserRegisterSystemClasses()

BOOL FASTCALL UserRegisterSystemClasses ( VOID  )

Definition at line 2337 of file class.c.

2338{
2339 UINT i;
2340 UNICODE_STRING ClassName, MenuName;
2342 WNDCLASSEXW wc;
2343 PCLS Class;
2344 BOOL Ret = TRUE;
2345 HBRUSH hBrush;
2346 DWORD Flags = 0;
2347
2348 if (ppi->W32PF_flags & W32PF_CLASSESREGISTERED)
2349 return TRUE;
2350
2351 if ( hModClient == NULL)
2352 return FALSE;
2353
2354 RtlZeroMemory(&ClassName, sizeof(ClassName));
2355 RtlZeroMemory(&MenuName, sizeof(MenuName));
2356
2357 for (i = 0; i != ARRAYSIZE(DefaultServerClasses); i++)
2358 {
2359 if (!IS_ATOM(DefaultServerClasses[i].ClassName))
2360 {
2361 RtlInitUnicodeString(&ClassName, DefaultServerClasses[i].ClassName);
2362 }
2363 else
2364 {
2365 ClassName.Buffer = DefaultServerClasses[i].ClassName;
2366 ClassName.Length = 0;
2367 ClassName.MaximumLength = 0;
2368 }
2369
2370 wc.cbSize = sizeof(wc);
2372
2374
2375 if (DefaultServerClasses[i].ProcW)
2376 {
2378 wc.hInstance = hModuleWin;
2379 }
2380 else
2381 {
2383 wc.hInstance = hModClient;
2384 }
2385
2386 wc.cbClsExtra = 0;
2388 wc.hIcon = NULL;
2389
2391 wc.hCursor = NULL;
2392 if (DefaultServerClasses[i].hCursor == (HICON)OCR_NORMAL)
2393 {
2394 if (SYSTEMCUR(ARROW) == NULL)
2395 {
2396 ERR("SYSTEMCUR(ARROW) == NULL, should not happen!!\n");
2397 }
2398 else
2399 {
2400 wc.hCursor = UserHMGetHandle(SYSTEMCUR(ARROW));
2401 }
2402 }
2403
2404 hBrush = DefaultServerClasses[i].hBrush;
2405 if (hBrush <= (HBRUSH)COLOR_MENUBAR)
2406 {
2407 hBrush = IntGetSysColorBrush(HandleToUlong(hBrush));
2408 }
2409 wc.hbrBackground = hBrush;
2410 wc.lpszMenuName = NULL;
2411 wc.lpszClassName = ClassName.Buffer;
2412 wc.hIconSm = NULL;
2413
2414 Class = IntCreateClass( &wc,
2415 &ClassName,
2416 &ClassName,
2417 &MenuName,
2418 DefaultServerClasses[i].fiId,
2419 Flags,
2420 NULL,
2421 ppi);
2422 if (Class != NULL)
2423 {
2424 Class->pclsNext = ppi->pclsPublicList;
2426 Class);
2427
2429 }
2430 else
2431 {
2432 ERR("!!! Registering system class failed!\n");
2433 Ret = FALSE;
2434 }
2435 }
2436 if (Ret) ppi->W32PF_flags |= W32PF_CLASSESREGISTERED;
2437 return Ret;
2438}
#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:902
#define GETPFNSERVER(fnid)
Definition: ntuser.h:909
#define CSF_SERVERSIDEPROC
Definition: ntuser.h:556
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
static HICON
Definition: imagelist.c:80
unsigned int UINT
Definition: ndis.h:50
HINSTANCE hModClient
Definition: ntuser.c:25
DWORD dwRegisteredClasses
Definition: win32.h:281
struct _CLS * pclsPublicList
Definition: win32.h:261
WNDPROC ProcW
Definition: ntuser.h:488
LPCWSTR lpszClassName
Definition: winuser.h:3229
LPCWSTR lpszMenuName
Definition: winuser.h:3228
HBRUSH hbrBackground
Definition: winuser.h:3227
WNDPROC lpfnWndProc
Definition: winuser.h:3221
UINT cbSize
Definition: winuser.h:3219
int cbWndExtra
Definition: winuser.h:3223
HCURSOR hCursor
Definition: winuser.h:3226
HICON hIconSm
Definition: winuser.h:3230
HINSTANCE hInstance
Definition: winuser.h:3224
UINT style
Definition: winuser.h:3220
int cbClsExtra
Definition: winuser.h:3222
HICON hIcon
Definition: winuser.h:3225
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
REGISTER_SYSCLASS DefaultServerClasses[]
Definition: class.c:37
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:1047
HANDLE hModuleWin
Definition: main.c:16

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

Variable Documentation

◆ Atom