#include <win32k/ntgdihdl.h>
#include "win32.h"
+/* apparently the first 10 entries are never used in windows as they are empty */
+#define RESERVE_ENTRIES_COUNT 10
+
typedef struct _GDI_HANDLE_TABLE
{
/* The table must be located at the beginning of this structure so it can be
FORCEINLINE
GDIOBJ_UnlockObjByPtr(POBJ Object)
{
+#if DBG
+ PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
+ if (pti)
+ {
+ if (pti->cExclusiveLocks < 1)
+ {
+ DbgPrint("cExclusiveLocks = %ld, object: %ld\n",
+ pti->cExclusiveLocks, Object->cExclusiveLock);
+ ASSERT(FALSE);
+ }
+ pti->cExclusiveLocks--;
+ }
+#endif
INT cLocks = InterlockedDecrement((PLONG)&Object->cExclusiveLock);
ASSERT(cLocks >= 0);
return cLocks;
ASSERT(cLocks >= 0);
if ((flags & BASEFLAG_READY_TO_DIE) && (cLocks == 0))
{
+ ASSERT(Object->cExclusiveLock == 0);
GDIOBJ_SetOwnership(hobj, PsGetCurrentProcess());
GDIOBJ_FreeObjByHandle(hobj, GDI_OBJECT_TYPE_DONTCARE);
}
#define GDIOBJ_GetKernelObj(Handle) \
((PGDI_TABLE_ENTRY)&GdiHandleTable->Entries[GDI_HANDLE_GET_INDEX(Handle)])->KernelData
+#define GDI_ENTRY_TO_INDEX(ht, e) \
+ (((ULONG_PTR)(e) - (ULONG_PTR)&((ht)->Entries[0])) / sizeof(GDI_TABLE_ENTRY))
+#define GDI_HANDLE_GET_ENTRY(HandleTable, h) \
+ (&(HandleTable)->Entries[GDI_HANDLE_GET_INDEX((h))])