ReactOS 0.4.15-dev-7842-g558ab78
useratom.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: User Atom helper routines
5 * FILE: win32ss/user/ntuser/useratom.c
6 * PROGRAMER: Filip Navara <xnavara@volny.cz>
7 */
8
9#include <win32k.h>
11
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}
35
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}
60
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}
80
94_Success_(return != 0)
95_At_(pustrName->Buffer, _Out_z_bytecap_post_bytecount_(pustrName->MaximumLength, return * 2 + 2))
98NtUserGetAtomName(
99 _In_ ATOM atom,
100 _Inout_ PUNICODE_STRING pustrName)
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}
143
144/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: debug.h:110
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:103
return
Definition: dirsup.c:529
Definition: bufpool.h:45
_Out_ RTL_ATOM * Atom
Definition: class.h:54
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define APIENTRY
Definition: api.h:79
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
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
#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 _Success_(expr)
Definition: ms_sal.h:259
#define _Inout_
Definition: ms_sal.h:378
#define _Out_z_bytecap_post_bytecount_(cap, count)
Definition: ms_sal.h:911
#define _At_(target, annos)
Definition: ms_sal.h:244
#define _In_
Definition: ms_sal.h:308
NTSYSAPI NTSTATUS NTAPI RtlPinAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
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)
#define FASTCALL
Definition: nt_native.h:50
#define UNICODE_NULL
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define L(x)
Definition: ntvdm.h:50
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _DESKTOP * rpdesk
Definition: win32.h:92
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
RTL_ATOM FASTCALL IntAddAtom(LPWSTR AtomName)
Definition: useratom.c:13
RTL_ATOM FASTCALL IntAddGlobalAtom(LPWSTR lpBuffer, BOOL PinAtom)
Definition: useratom.c:62
ULONG FASTCALL IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG cjBufSize)
Definition: useratom.c:37
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184