ReactOS 0.4.16-dev-106-g10b08aa
useratom.c File Reference
#include <win32k.h>
Include dependency graph for useratom.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserMisc)
 
RTL_ATOM FASTCALL IntAddAtom (LPWSTR AtomName)
 
ULONG FASTCALL IntGetAtomName (RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG cjBufSize)
 
RTL_ATOM FASTCALL IntAddGlobalAtom (LPWSTR lpBuffer, BOOL PinAtom)
 
 _Success_ (return !=0)
 Returns the name of an atom.
 

Function Documentation

◆ _Success_()

_Success_ ( return = 0)

Returns the name of an atom.

Parameters
atom- The atom to be queried.
pustrName- Pointer to an initialized UNICODE_STRING that receives the name of the atom. The function does not update the Length member. The string is always NULL-terminated.
Returns
The length of the name in characters, or 0 if the function fails.
Note
The function does not aquire any global lock, since synchronisation is handled by the RtlAtom function.

Definition at line 94 of file useratom.c.

101{
102 WCHAR awcBuffer[256];
103 ULONG cjLength;
104
105 /* Retrieve the atom name into a local buffer (max length is 255 chars) */
106 cjLength = IntGetAtomName((RTL_ATOM)atom, awcBuffer, sizeof(awcBuffer));
107 if (cjLength != 0)
108 {
110 {
111 /* Probe the unicode string and the buffer */
112 ProbeForRead(pustrName, sizeof(*pustrName), 1);
113 ProbeForWrite(pustrName->Buffer, pustrName->MaximumLength, 1);
114
115 /* Check if we have enough space to write the NULL termination */
116 if (pustrName->MaximumLength >= sizeof(UNICODE_NULL))
117 {
118 /* Limit the length to the buffer size */
119 cjLength = min(pustrName->MaximumLength - sizeof(UNICODE_NULL),
120 cjLength);
121
122 /* Copy the string and NULL terminate it */
123 RtlCopyMemory(pustrName->Buffer, awcBuffer, cjLength);
124 pustrName->Buffer[cjLength / sizeof(WCHAR)] = L'\0';
125 }
126 else
127 {
128 cjLength = 0;
129 }
130 }
132 {
133 /* On exception, set last error and fail */
135 cjLength = 0;
136 }
138 }
139
140 /* Return the length in characters */
141 return cjLength / sizeof(WCHAR);
142}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned short RTL_ATOM
Definition: atom.c:42
#define min(a, b)
Definition: monoChain.cc:55
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
ULONG FASTCALL IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG cjBufSize)
Definition: useratom.c:37
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserMisc  )

◆ IntAddAtom()

RTL_ATOM FASTCALL IntAddAtom ( LPWSTR  AtomName)

Definition at line 13 of file useratom.c.

14{
16 PTHREADINFO pti;
18
20 if (pti->rpdesk == NULL)
21 {
23 return (RTL_ATOM)0;
24 }
25
27
28 if (!NT_SUCCESS(Status))
29 {
31 return (RTL_ATOM)0;
32 }
33 return Atom;
34}
LONG NTSTATUS
Definition: precomp.h:26
_Out_ RTL_ATOM * Atom
Definition: class.h:54
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _DESKTOP * rpdesk
Definition: win32.h:92
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13

Referenced by co_IntShellHookNotify(), and NtUserRegisterWindowMessage().

◆ IntAddGlobalAtom()

RTL_ATOM FASTCALL IntAddGlobalAtom ( LPWSTR  lpBuffer,
BOOL  PinAtom 
)

Definition at line 62 of file useratom.c.

63{
66
68
69 if (!NT_SUCCESS(Status))
70 {
71 ERR("Error init Global Atom.\n");
72 return 0;
73 }
74
75 if (Atom && PinAtom)
77
78 return Atom;
79}
#define ERR(fmt,...)
Definition: precomp.h:57
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
NTSYSAPI NTSTATUS NTAPI RtlPinAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)

Referenced by InitUserAtoms().

◆ IntGetAtomName()

ULONG FASTCALL IntGetAtomName ( RTL_ATOM  nAtom,
LPWSTR  lpBuffer,
ULONG  cjBufSize 
)

Definition at line 37 of file useratom.c.

38{
40 PTHREADINFO pti;
41 ULONG Size = cjBufSize;
42
44 if (pti->rpdesk == NULL)
45 {
47 return 0;
48 }
49
51
52 if (!NT_SUCCESS(Status))
53 {
55 return 0;
56 }
57
58 return Size;
59}
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)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by _Success_(), and NtUserGetClipboardFormatName().