Author: tkreuzer
Date: Sat Feb 19 22:03:34 2011
New Revision: 50825
URL:
http://svn.reactos.org/svn/reactos?rev=50825&view=rev
Log:
[WIN32K]
- add tracing of exclusive gdi locks
- add some asserts
Modified:
trunk/reactos/subsystems/win32/win32k/include/gdiobj.h
trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
Modified: trunk/reactos/subsystems/win32/win32k/include/gdiobj.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/gdiobj.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/gdiobj.h [iso-8859-1] Sat Feb 19
22:03:34 2011
@@ -8,6 +8,9 @@
/* Public GDI Object/Handle definitions */
#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
{
@@ -105,6 +108,19 @@
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;
@@ -120,6 +136,7 @@
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);
}
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1] Sat Feb 19 22:03:34
2011
@@ -38,7 +38,7 @@
gpsi->atomSysClass[ICLS_SWITCH] = 32771;
gpsi->atomSysClass[ICLS_ICONTITLE] = 32772;
gpsi->atomSysClass[ICLS_TOOLTIPS] = 32774;
-
+
/* System Message Atom */
AtomMessage = IntAddGlobalAtom(L"Message", TRUE);
gpsi->atomSysClass[ICLS_HWNDMESSAGE] = AtomMessage;
@@ -112,7 +112,7 @@
// {
GetW32ThreadInfo();
-
+
// Callback to User32 Client Thread Setup
co_IntClientThreadSetup();
@@ -208,12 +208,14 @@
VOID FASTCALL UserEnterExclusive(VOID)
{
+ ASSERT_NOGDILOCKS();
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&UserLock, TRUE);
}
VOID FASTCALL UserLeave(VOID)
{
+ ASSERT_NOGDILOCKS();
ExReleaseResourceLite(&UserLock);
KeLeaveCriticalRegion();
}
Modified: trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] Sat Feb 19
22:03:34 2011
@@ -16,9 +16,6 @@
(((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))])
-
-/* apparently the first 10 entries are never used in windows as they are empty */
-#define RESERVE_ENTRIES_COUNT 10
#define BASE_OBJTYPE_COUNT 32
@@ -483,6 +480,9 @@
newObject->ulShareCount = 0;
newObject->cExclusiveLock = 1;
newObject->Tid = Thread;
+#if DBG
+ if (Thread) Thread->cExclusiveLocks++;
+#endif
AllocTypeDataDump(TypeInfo);
@@ -603,11 +603,11 @@
((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == (HandleUpper &
GDI_ENTRY_BASETYPE_MASK)) )
{
POBJ Object;
+ PTHREADINFO Thread = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
Object = Entry->KernelData;
- if ((Object->cExclusiveLock == 0 ||
- Object->Tid == (PTHREADINFO)PsGetCurrentThreadWin32Thread())
&&
+ if ((Object->cExclusiveLock == 0 || Object->Tid == Thread) &&
Object->ulShareCount == 0)
{
BOOL Ret;
@@ -623,6 +623,18 @@
InterlockedPushFreeEntry(GDI_ENTRY_TO_INDEX(GdiHandleTable, Entry));
Object->hHmgr = NULL;
+#if DBG
+ if (Thread)
+ {
+ if (Thread->cExclusiveLocks < Object->cExclusiveLock)
+ {
+ DPRINT1("cExclusiveLocks = %ld, object: %ld\n",
+ Thread->cExclusiveLocks, Object->cExclusiveLock);
+ ASSERT(FALSE);
+ }
+ Thread->cExclusiveLocks -= Object->cExclusiveLock;
+ }
+#endif
if (W32Process != NULL)
{
@@ -1056,6 +1068,9 @@
Object->Tid = Thread;
Object->cExclusiveLock = 1;
GDIDBG_CAPTURELOCKER(GDI_HANDLE_GET_INDEX(hObj))
+#if DBG
+ if (Thread) Thread->cExclusiveLocks++;
+#endif
}
else
{
@@ -1068,6 +1083,9 @@
continue;
}
InterlockedIncrement((PLONG)&Object->cExclusiveLock);
+#if DBG
+ if (Thread) Thread->cExclusiveLocks++;
+#endif
}
}
else