Author: tkreuzer Date: Thu Dec 18 08:12:28 2014 New Revision: 65731
URL: http://svn.reactos.org/svn/reactos?rev=65731&view=rev Log: [WIN32K] Implement exclusive lock order checks for GDI objects in debug builds
Modified: trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c?... ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] Thu Dec 18 08:12:28 2014 @@ -71,6 +71,22 @@ }
#if DBG +VOID +ASSERT_LOCK_ORDER( + _In_ UCHAR objt) +{ + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + ULONG i; + + if (pti) + { + /* Ensure correct locking order! */ + for (i = objt + 1; i < GDIObjTypeTotal; i++) + { + NT_ASSERT(pti->acExclusiveLockCount[i] == 0); + } + } +} #define ASSERT_SHARED_OBJECT_TYPE(objt) \ ASSERT((objt) == GDIObjType_SURF_TYPE || \ (objt) == GDIObjType_PAL_TYPE || \ @@ -83,6 +99,7 @@ #define ASSERT_TRYLOCK_OBJECT_TYPE(objt) \ ASSERT((objt) == GDIObjType_DRVOBJ_TYPE) #else +#define ASSERT_LOCK_ORDER(hobj) #define ASSERT_SHARED_OBJECT_TYPE(objt) #define ASSERT_EXCLUSIVE_OBJECT_TYPE(objt) #define ASSERT_TRYLOCK_OBJECT_TYPE(objt) @@ -669,6 +686,9 @@ return NULL; }
+ /* Make sure lock order is correct */ + ASSERT_LOCK_ORDER(objt); + /* Reference the handle entry */ pentry = ENTRY_ReferenceEntryByHandle(hobj, 0); if (!pentry) @@ -734,6 +754,9 @@ DPRINT("Wrong object type: hobj=0x%p, objt=0x%x\n", hobj, objt); return NULL; } + + /* Make sure lock order is correct */ + ASSERT_LOCK_ORDER(objt);
/* Reference the handle entry */ pentry = ENTRY_ReferenceEntryByHandle(hobj, 0);