ReactOS 0.4.16-dev-197-g92996da
prop.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Window properties
5 * FILE: win32ss/user/ntuser/prop.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 */
8
9#include <win32k.h>
11
12/* STATIC FUNCTIONS **********************************************************/
13
20{
21 PLIST_ENTRY ListEntry;
23 UINT i;
24 WORD SystemFlag = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
25
27 ListEntry = Window->PropListHead.Flink;
28
29 for (i = 0; i < Window->PropListItems; i++)
30 {
31 Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
32 ListEntry = ListEntry->Flink;
33
34 if (Property->Atom == Atom &&
35 (Property->fs & PROPERTY_FLAG_SYSTEM) == SystemFlag)
36 {
37 return Property;
38 }
39 }
40 NT_ASSERT(ListEntry == &Window->PropListHead);
41 return NULL;
42}
43
50{
51 PPROPERTY Prop;
52
55 return Prop ? Prop->Data : NULL;
56}
57
58_Success_(return)
65{
66 PPROPERTY Prop;
68
71 if (Prop == NULL)
72 {
73 return NULL;
74 }
75
76 Data = Prop->Data;
78 UserHeapFree(Prop);
79 Window->PropListItems--;
80 return Data;
81}
82
83_Success_(return)
84BOOL
86UserSetProp(
91{
92 PPROPERTY Prop;
93
96 if (Prop == NULL)
97 {
98 Prop = UserHeapAlloc(sizeof(PROPERTY));
99 if (Prop == NULL)
100 {
101 return FALSE;
102 }
103 Prop->Atom = Atom;
104 Prop->fs = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
105 InsertTailList(&Window->PropListHead, &Prop->PropListEntry);
106 Window->PropListItems++;
107 }
108
109 Prop->Data = Data;
110 return TRUE;
111}
112
113VOID
117{
118 PLIST_ENTRY ListEntry;
120
122 while (!IsListEmpty(&Window->PropListHead))
123 {
124 ListEntry = Window->PropListHead.Flink;
125 Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
126 RemoveEntryList(&Property->PropListEntry);
128 Window->PropListItems--;
129 }
130 return;
131}
132
133/* FUNCTIONS *****************************************************************/
134
138 _In_ HWND hWnd,
142{
143 PWND Window;
145 PLIST_ENTRY ListEntry;
146 PROPLISTITEM listitem = { 0 }, *li;
148 DWORD Cnt = 0;
149
150 TRACE("Enter NtUserBuildPropList\n");
152
154 if (Window == NULL)
155 {
157 goto Exit;
158 }
159
160 if (Buffer)
161 {
162 if (!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
163 {
165 goto Exit;
166 }
167
168 /* Copy list */
170 ListEntry = Window->PropListHead.Flink;
171 while ((BufferSize >= sizeof(PROPLISTITEM)) &&
172 (ListEntry != &Window->PropListHead))
173 {
174 Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
175 ListEntry = ListEntry->Flink;
176 if (!(Property->fs & PROPERTY_FLAG_SYSTEM))
177 {
178 listitem.Atom = Property->Atom;
179 listitem.Data = Property->Data;
180
181 Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
182 if (!NT_SUCCESS(Status))
183 {
184 goto Exit;
185 }
186
187 BufferSize -= sizeof(PROPLISTITEM);
188 Cnt++;
189 li++;
190 }
191 }
192
193 }
194 else
195 {
196 /* FIXME: This counts user and system props */
197 Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
198 }
199
200 if (Count)
201 {
202 Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
203 if (!NT_SUCCESS(Status))
204 {
205 goto Exit;
206 }
207 }
208
210
211Exit:
212 TRACE("Leave NtUserBuildPropList, ret=%lx\n", Status);
213 UserLeave();
214
215 return Status;
216}
217
218HANDLE
221 _In_ HWND hWnd,
222 _In_ ATOM Atom)
223{
224 PWND Window;
225 HANDLE Data = NULL;
226
227 TRACE("Enter NtUserRemoveProp\n");
229
231 if (Window == NULL)
232 {
233 goto Exit;
234 }
235
237
238Exit:
239 TRACE("Leave NtUserRemoveProp, ret=%p\n", Data);
240 UserLeave();
241
242 return Data;
243}
244
245BOOL
248 _In_ HWND hWnd,
249 _In_ ATOM Atom,
251{
252 PWND Window;
253 BOOL Ret;
254
255 TRACE("Enter NtUserSetProp\n");
257
259 if (Window == NULL)
260 {
261 Ret = FALSE;
262 goto Exit;
263 }
264
265 Ret = UserSetProp(Window, Atom, Data, FALSE);
266
267Exit:
268 TRACE("Leave NtUserSetProp, ret=%i\n", Ret);
269 UserLeave();
270
271 return Ret;
272}
273
274/* EOF */
unsigned char BOOLEAN
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
Definition: bufpool.h:45
_Out_ RTL_ATOM * Atom
Definition: class.h:54
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define APIENTRY
Definition: api.h:79
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
Status
Definition: gdiplustypes.h:25
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
struct _PROPLISTITEM PROPLISTITEM
#define PROPERTY_FLAG_SYSTEM
Definition: ntuser.h:1096
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define _Out_opt_
Definition: ms_sal.h:346
#define _Success_(expr)
Definition: ms_sal.h:259
#define _Out_writes_bytes_to_opt_(size, count)
Definition: ms_sal.h:361
#define _In_
Definition: ms_sal.h:308
unsigned int UINT
Definition: ndis.h:50
int Count
Definition: noreturn.cpp:7
#define FASTCALL
Definition: nt_native.h:50
BOOL FASTCALL UserIsEntered(VOID)
Definition: ntuser.c:225
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231
_In_ ATOM _In_ HANDLE _In_ BOOLEAN SystemProp
Definition: prop.h:24
HANDLE FASTCALL UserRemoveProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
#define STATUS_SUCCESS
Definition: shellext.h:65
static void Exit(void)
Definition: sock.c:1330
#define TRACE(s)
Definition: solgame.cpp:4
Definition: window.c:28
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
WORD fs
Definition: ntuser.h:1103
HANDLE Data
Definition: ntuser.h:1101
LIST_ENTRY PropListEntry
Definition: ntuser.h:1100
ATOM Atom
Definition: ntuser.h:1102
HANDLE Data
Definition: ntuser.h:1093
Definition: ntuser.h:694
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:124
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:44
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
VOID FASTCALL UserRemoveWindowProps(_In_ PWND Window)
Definition: prop.c:115
HANDLE APIENTRY NtUserRemoveProp(_In_ HWND hWnd, _In_ ATOM Atom)
Definition: prop.c:220
PPROPERTY FASTCALL IntGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:16
BOOL APIENTRY NtUserSetProp(_In_ HWND hWnd, _In_ ATOM Atom, _In_ HANDLE Data)
Definition: prop.c:247
NTSTATUS APIENTRY NtUserBuildPropList(_In_ HWND hWnd, _Out_writes_bytes_to_opt_(BufferSize, *Count *sizeof(PROPLISTITEM)) LPVOID Buffer, _In_ DWORD BufferSize, _Out_opt_ DWORD *Count)
Definition: prop.c:137
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46
#define NT_ASSERT
Definition: rtlfuncs.h:3324