[WIN32K:NTUSER] Assert global user lock is held exclusively when using global & desktop heaps

They're explicitly not serialized because we count on this.
This commit is contained in:
Jérôme Gardou 2021-07-30 15:42:09 +02:00 committed by Jérôme Gardou
parent 8c098ee8d2
commit d958dc9bc2
3 changed files with 15 additions and 1 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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"