ReactOS  0.4.13-dev-79-gcd489d8
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. More...
 

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  {
109  _SEH2_TRY
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  }
137  _SEH2_END
138  }
139 
140  /* Return the length in characters */
141  return cjLength / sizeof(WCHAR);
142 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned short RTL_ATOM
Definition: atom.c:42
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
#define UNICODE_NULL
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
static const WCHAR L[]
Definition: oid.c:1250
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
_SEH2_END
Definition: create.c:4424
#define min(a, b)
Definition: monoChain.cc:55
ULONG FASTCALL IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG cjBufSize)
Definition: useratom.c:37
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

◆ 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;
17  RTL_ATOM Atom;
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 }
unsigned short RTL_ATOM
Definition: atom.c:42
NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
_Out_ RTL_ATOM * Atom
Definition: class.h:54
struct _DESKTOP * rpdesk
Definition: win32.h:91
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by co_IntShellHookNotify(), and NtUserRegisterWindowMessage().

◆ IntAddGlobalAtom()

RTL_ATOM FASTCALL IntAddGlobalAtom ( LPWSTR  lpBuffer,
BOOL  PinAtom 
)

Definition at line 62 of file useratom.c.

63 {
64  RTL_ATOM Atom;
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 }
unsigned short RTL_ATOM
Definition: atom.c:42
NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
LONG NTSTATUS
Definition: precomp.h:26
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
NTSYSAPI NTSTATUS NTAPI RtlPinAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
_Out_ RTL_ATOM * Atom
Definition: class.h:54
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
return STATUS_SUCCESS
Definition: btrfs.c:2725

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 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
struct _DESKTOP * rpdesk
Definition: win32.h:91
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by _Success_(), and NtUserGetClipboardFormatName().