https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d958dc9bc2bfb818f0604…
commit d958dc9bc2bfb818f0604c471e6d9dc84beab4a5
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Fri Jul 30 15:42:09 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Tue Aug 3 23:13:19 2021 +0200
[WIN32K:NTUSER] Assert global user lock is held exclusively when using global &
desktop heaps
They're explicitly not serialized because we count on this.
---
win32ss/user/ntuser/desktop.h | 7 +++++++
win32ss/user/ntuser/usrheap.h | 7 +++++++
win32ss/win32kp.h | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/win32ss/user/ntuser/desktop.h b/win32ss/user/ntuser/desktop.h
index 3043af678c4..5a7f4bca500 100644
--- a/win32ss/user/ntuser/desktop.h
+++ b/win32ss/user/ntuser/desktop.h
@@ -230,6 +230,8 @@ static __inline PVOID
DesktopHeapAlloc(IN PDESKTOP Desktop,
IN SIZE_T Bytes)
{
+ /* Desktop heap has no lock, using global user lock instead. */
+ ASSERT(UserIsEnteredExclusive());
return RtlAllocateHeap(Desktop->pheapDesktop,
HEAP_NO_SERIALIZE,
Bytes);
@@ -239,6 +241,8 @@ static __inline BOOL
DesktopHeapFree(IN PDESKTOP Desktop,
IN PVOID lpMem)
{
+ /* Desktop heap has no lock, using global user lock instead. */
+ ASSERT(UserIsEnteredExclusive());
return RtlFreeHeap(Desktop->pheapDesktop,
HEAP_NO_SERIALIZE,
lpMem);
@@ -259,6 +263,9 @@ DesktopHeapReAlloc(IN PDESKTOP Desktop,
SIZE_T PrevSize;
PVOID pNew;
+ /* Desktop heap has no lock, using global user lock instead. */
+ ASSERT(UserIsEnteredExclusive());
+
PrevSize = RtlSizeHeap(Desktop->pheapDesktop,
HEAP_NO_SERIALIZE,
lpMem);
diff --git a/win32ss/user/ntuser/usrheap.h b/win32ss/user/ntuser/usrheap.h
index e652b80fa35..fb2051eae09 100644
--- a/win32ss/user/ntuser/usrheap.h
+++ b/win32ss/user/ntuser/usrheap.h
@@ -33,6 +33,8 @@ MapGlobalUserHeap(IN PEPROCESS Process,
static __inline PVOID
UserHeapAlloc(SIZE_T Bytes)
{
+ /* User heap has no lock, using global user lock instead. */
+ ASSERT(UserIsEnteredExclusive());
return RtlAllocateHeap(GlobalUserHeap,
HEAP_NO_SERIALIZE,
Bytes);
@@ -41,6 +43,8 @@ UserHeapAlloc(SIZE_T Bytes)
static __inline BOOL
UserHeapFree(PVOID lpMem)
{
+ /* User heap has no lock, using global user lock instead. */
+ ASSERT(UserIsEnteredExclusive());
return RtlFreeHeap(GlobalUserHeap,
HEAP_NO_SERIALIZE,
lpMem);
@@ -60,6 +64,9 @@ UserHeapReAlloc(PVOID lpMem,
SIZE_T PrevSize;
PVOID pNew;
+ /* User heap has no lock, using global user lock instead. */
+ ASSERT(UserIsEnteredExclusive());
+
PrevSize = RtlSizeHeap(GlobalUserHeap,
HEAP_NO_SERIALIZE,
lpMem);
diff --git a/win32ss/win32kp.h b/win32ss/win32kp.h
index 06ff74638ff..a336c2fe42c 100644
--- a/win32ss/win32kp.h
+++ b/win32ss/win32kp.h
@@ -58,9 +58,9 @@ typedef struct _DC *PDC;
#include "user/ntuser/win32.h"
#include "user/ntuser/tags.h"
#ifndef __cplusplus
+#include "user/ntuser/ntuser.h"
#include "user/ntuser/usrheap.h"
#include "user/ntuser/object.h"
-#include "user/ntuser/ntuser.h"
#include "user/ntuser/shutdown.h"
#include "user/ntuser/cursoricon.h"
#include "user/ntuser/accelerator.h"