Author: tfaber
Date: Sat Oct 10 13:48:08 2015
New Revision: 69485
URL:
http://svn.reactos.org/svn/reactos?rev=69485&view=rev
Log:
[WIN32K:NTUSER]
- Remove some DECLARE_RETURN()/RETURN()
- Add asserts for the user lock
- Annotate window property functions and use consistent parameter names
Modified:
trunk/reactos/win32ss/user/ntuser/prop.c
trunk/reactos/win32ss/user/ntuser/prop.h
Modified: trunk/reactos/win32ss/user/ntuser/prop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/prop.c…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/prop.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/prop.c [iso-8859-1] Sat Oct 10 13:48:08 2015
@@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Window properties
- * FILE: subsys/win32k/ntuser/prop.c
+ * FILE: win32ss/user/ntuser/prop.c
* PROGRAMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
*/
@@ -14,13 +14,14 @@
PPROPERTY
FASTCALL
IntGetProp(
- PWND Window,
- ATOM Atom)
+ _In_ PWND Window,
+ _In_ ATOM Atom)
{
PLIST_ENTRY ListEntry;
PPROPERTY Property;
UINT i;
+ NT_ASSERT(UserIsEntered());
ListEntry = Window->PropListHead.Flink;
for (i = 0; i < Window->PropListItems; i++)
@@ -46,22 +47,26 @@
HANDLE
FASTCALL
UserGetProp(
- PWND pWnd,
- ATOM Atom)
-{
- PPROPERTY Prop;
- Prop = IntGetProp(pWnd, Atom);
+ _In_ PWND Window,
+ _In_ ATOM Atom)
+{
+ PPROPERTY Prop;
+
+ NT_ASSERT(UserIsEntered());
+ Prop = IntGetProp(Window, Atom);
return Prop ? Prop->Data : NULL;
}
+_Success_(return)
BOOL
FASTCALL
IntRemoveProp(
- PWND Window,
- ATOM Atom)
-{
- PPROPERTY Prop;
-
+ _In_ PWND Window,
+ _In_ ATOM Atom)
+{
+ PPROPERTY Prop;
+
+ NT_ASSERT(UserIsEnteredExclusive());
Prop = IntGetProp(Window, Atom);
if (Prop == NULL)
{
@@ -74,16 +79,18 @@
return TRUE;
}
+_Success_(return)
BOOL
FASTCALL
IntSetProp(
- PWND pWnd,
- ATOM Atom,
- HANDLE Data)
-{
- PPROPERTY Prop;
-
- Prop = IntGetProp(pWnd, Atom);
+ _In_ PWND Window,
+ _In_ ATOM Atom,
+ _In_ HANDLE Data)
+{
+ PPROPERTY Prop;
+
+ NT_ASSERT(UserIsEnteredExclusive());
+ Prop = IntGetProp(Window, Atom);
if (Prop == NULL)
{
Prop = UserHeapAlloc(sizeof(PROPERTY));
@@ -92,8 +99,8 @@
return FALSE;
}
Prop->Atom = Atom;
- InsertTailList(&pWnd->PropListHead, &Prop->PropListEntry);
- pWnd->PropListItems++;
+ InsertTailList(&Window->PropListHead, &Prop->PropListEntry);
+ Window->PropListItems++;
}
Prop->Data = Data;
@@ -103,11 +110,12 @@
VOID
FASTCALL
IntRemoveWindowProp(
- PWND Window)
+ _In_ PWND Window)
{
PLIST_ENTRY ListEntry;
PPROPERTY Property;
+ NT_ASSERT(UserIsEnteredExclusive());
while (!IsListEmpty(&Window->PropListHead))
{
ListEntry = Window->PropListHead.Flink;
@@ -124,10 +132,10 @@
NTSTATUS
APIENTRY
NtUserBuildPropList(
- HWND hWnd,
- LPVOID Buffer,
- DWORD BufferSize,
- DWORD *Count)
+ _In_ HWND hWnd,
+ _Out_writes_bytes_to_opt_(BufferSize, *Count * sizeof(PROPLISTITEM)) LPVOID Buffer,
+ _In_ DWORD BufferSize,
+ _Out_opt_ DWORD *Count)
{
PWND Window;
PPROPERTY Property;
@@ -135,21 +143,23 @@
PROPLISTITEM listitem, *li;
NTSTATUS Status;
DWORD Cnt = 0;
- DECLARE_RETURN(NTSTATUS);
TRACE("Enter NtUserBuildPropList\n");
UserEnterShared();
- if (!(Window = UserGetWindowObject(hWnd)))
- {
- RETURN(STATUS_INVALID_HANDLE);
+ Window = UserGetWindowObject(hWnd);
+ if (Window == NULL)
+ {
+ Status = STATUS_INVALID_HANDLE;
+ goto Exit;
}
if (Buffer)
{
if (!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
{
- RETURN(STATUS_INVALID_PARAMETER);
+ Status = STATUS_INVALID_PARAMETER;
+ goto Exit;
}
/* Copy list */
@@ -165,7 +175,7 @@
Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
if (!NT_SUCCESS(Status))
{
- RETURN(Status);
+ goto Exit;
}
BufferSize -= sizeof(PROPLISTITEM);
@@ -185,41 +195,42 @@
Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
if (!NT_SUCCESS(Status))
{
- RETURN(Status);
- }
- }
-
- RETURN(STATUS_SUCCESS);
-
-CLEANUP:
- TRACE("Leave NtUserBuildPropList, ret=%i\n", _ret_);
+ goto Exit;
+ }
+ }
+
+ Status = STATUS_SUCCESS;
+
+Exit:
+ TRACE("Leave NtUserBuildPropList, ret=%lx\n", Status);
UserLeave();
- END_CLEANUP;
+
+ return Status;
}
HANDLE
APIENTRY
NtUserRemoveProp(
- HWND hWnd,
- ATOM Atom)
+ _In_ HWND hWnd,
+ _In_ ATOM Atom)
{
PWND Window;
PPROPERTY Prop;
- HANDLE Data;
- DECLARE_RETURN(HANDLE);
+ HANDLE Data = NULL;
TRACE("Enter NtUserRemoveProp\n");
UserEnterExclusive();
- if (!(Window = UserGetWindowObject(hWnd)))
- {
- RETURN(NULL);
+ Window = UserGetWindowObject(hWnd);
+ if (Window == NULL)
+ {
+ goto Exit;
}
Prop = IntGetProp(Window, Atom);
if (Prop == NULL)
{
- RETURN(NULL);
+ goto Exit;
}
Data = Prop->Data;
@@ -227,38 +238,40 @@
UserHeapFree(Prop);
Window->PropListItems--;
- RETURN(Data);
-
-CLEANUP:
- TRACE("Leave NtUserRemoveProp, ret=%p\n", _ret_);
+Exit:
+ TRACE("Leave NtUserRemoveProp, ret=%p\n", Data);
UserLeave();
- END_CLEANUP;
+
+ return Data;
}
BOOL
APIENTRY
NtUserSetProp(
- HWND hWnd,
- ATOM Atom,
- HANDLE Data)
+ _In_ HWND hWnd,
+ _In_ ATOM Atom,
+ _In_ HANDLE Data)
{
PWND Window;
- DECLARE_RETURN(BOOL);
+ BOOL Ret;
TRACE("Enter NtUserSetProp\n");
UserEnterExclusive();
- if (!(Window = UserGetWindowObject(hWnd)))
- {
- RETURN(FALSE);
- }
-
- RETURN(IntSetProp(Window, Atom, Data));
-
-CLEANUP:
- TRACE("Leave NtUserSetProp, ret=%i\n", _ret_);
+ Window = UserGetWindowObject(hWnd);
+ if (Window == NULL)
+ {
+ Ret = FALSE;
+ goto Exit;
+ }
+
+ Ret = IntSetProp(Window, Atom, Data);
+
+Exit:
+ TRACE("Leave NtUserSetProp, ret=%i\n", Ret);
UserLeave();
- END_CLEANUP;
+
+ return Ret;
}
/* EOF */
Modified: trunk/reactos/win32ss/user/ntuser/prop.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/prop.h…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/prop.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/prop.h [iso-8859-1] Sat Oct 10 13:48:08 2015
@@ -1,7 +1,33 @@
#pragma once
-PPROPERTY FASTCALL IntGetProp(PWND,ATOM);
-BOOL FASTCALL IntRemoveProp(PWND,ATOM);
-BOOL FASTCALL IntSetProp(PWND, ATOM, HANDLE);
-HANDLE FASTCALL UserGetProp(PWND, ATOM);
-VOID FASTCALL IntRemoveWindowProp(PWND Window);
+PPROPERTY
+FASTCALL
+IntGetProp(
+ _In_ PWND Window,
+ _In_ ATOM Atom);
+
+HANDLE
+FASTCALL
+UserGetProp(
+ _In_ PWND Window,
+ _In_ ATOM Atom);
+
+_Success_(return)
+BOOL
+FASTCALL
+IntRemoveProp(
+ _In_ PWND Window,
+ _In_ ATOM Atom);
+
+_Success_(return)
+BOOL
+FASTCALL
+IntSetProp(
+ _In_ PWND Window,
+ _In_ ATOM Atom,
+ _In_ HANDLE Data);
+
+VOID
+FASTCALL
+IntRemoveWindowProp(
+ _In_ PWND Window);