[ros-diffs] [tkreuzer] 50824: [WIN32K] - Add ros specific member cExclusiveLocks to THREADINFO to track number of acquired locks - Add functions/macros to check lock count - Move some definitions into gdidebug...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sat Feb 19 21:56:43 UTC 2011


Author: tkreuzer
Date: Sat Feb 19 21:56:43 2011
New Revision: 50824

URL: http://svn.reactos.org/svn/reactos?rev=50824&view=rev
Log:
[WIN32K]
- Add ros specific member cExclusiveLocks to THREADINFO to track number of acquired locks
- Add functions/macros to check lock count
- Move some definitions into gdidebug.h for global use
- Fix broken GdiDbgHTIntegrityCheck
- Add pre and post syscall hook functions (unused yet)

Modified:
    trunk/reactos/subsystems/win32/win32k/include/gdidebug.h
    trunk/reactos/subsystems/win32/win32k/include/win32.h
    trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c

Modified: trunk/reactos/subsystems/win32/win32k/include/gdidebug.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/gdidebug.h?rev=50824&r1=50823&r2=50824&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/gdidebug.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/gdidebug.h [iso-8859-1] Sat Feb 19 21:56:43 2011
@@ -1,6 +1,12 @@
 #pragma once
 
 extern ULONG gulDebugChannels;
+
+#define GDI_STACK_LEVELS 20
+extern ULONG_PTR GDIHandleAllocator[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
+extern ULONG_PTR GDIHandleLocker[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
+extern ULONG_PTR GDIHandleShareLocker[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
+extern ULONG_PTR GDIHandleDeleter[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
 
 enum _DEBUGCHANNELS
 {
@@ -10,6 +16,10 @@
     DbgXlate = 8,
     DbgModeSwitch = 16,
 };
+
+void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable);
+ULONG CaptureStackBackTace(PVOID* pFrames, ULONG nFramesToCapture);
+BOOL GdiDbgHTIntegrityCheck();
 
 #define DBGENABLE(ch) gulDebugChannels |= (ch);
 #define DBGDISABLE(ch) gulDebugChannels &= ~(ch);
@@ -73,3 +83,31 @@
 
 #endif /* GDI_DEBUG */
 
+#if DBG
+void
+NTAPI
+DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
+
+ULONG_PTR
+NTAPI
+DbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
+
+#define ID_Win32PreServiceHook 'WSH0'
+#define ID_Win32PostServiceHook 'WSH1'
+
+FORCEINLINE void
+DbgAssertNoGdiLocks(char * pszFile, ULONG nLine)
+{
+    PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
+    if (pti && pti->cExclusiveLocks != 0)
+    {
+        DbgPrint("(%s:%ld) There are %ld exclusive locks!\n",
+                 pszFile, nLine, pti->cExclusiveLocks);
+        ASSERT(FALSE);
+    }
+}
+#define ASSERT_NOGDILOCKS() DbgAssertNoGdiLocks(__FILE__,__LINE__)
+#else
+#define ASSERT_NOGDILOCKS()
+#endif
+

Modified: trunk/reactos/subsystems/win32/win32k/include/win32.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/win32.h?rev=50824&r1=50823&r2=50824&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] Sat Feb 19 21:56:43 2011
@@ -99,10 +99,13 @@
 
     LIST_ENTRY          aphkStart[NB_HOOKS];
     CLIENTTHREADINFO    cti;  // Used only when no Desktop or pcti NULL.
-  /* ReactOS */
-  LIST_ENTRY WindowListHead;
-  LIST_ENTRY W32CallbackListHead;
-  SINGLE_LIST_ENTRY  ReferencesList;
+
+    /* ReactOS */
+    LIST_ENTRY WindowListHead;
+    LIST_ENTRY W32CallbackListHead;
+    SINGLE_LIST_ENTRY  ReferencesList;
+    ULONG cExclusiveLocks;
+
 } THREADINFO;
 
 #include <poppack.h>

Modified: trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c?rev=50824&r1=50823&r2=50824&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c [iso-8859-1] Sat Feb 19 21:56:43 2011
@@ -17,11 +17,10 @@
 
 #ifdef GDI_DEBUG
 
-#define GDI_STACK_LEVELS 20
-static ULONG_PTR GDIHandleAllocator[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
-static ULONG_PTR GDIHandleLocker[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
-static ULONG_PTR GDIHandleShareLocker[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
-static ULONG_PTR GDIHandleDeleter[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
+ULONG_PTR GDIHandleAllocator[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
+ULONG_PTR GDIHandleLocker[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
+ULONG_PTR GDIHandleShareLocker[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
+ULONG_PTR GDIHandleDeleter[GDI_HANDLE_COUNT][GDI_STACK_LEVELS+1];
 struct DbgOpenGDIHandle
 {
     ULONG idx;
@@ -172,44 +171,42 @@
 	/* FIXME: check reserved entries */
 
 	/* Now go through the deleted objects */
-	i = GdiHandleTable->FirstFree;
-	if (i)
+	i = GdiHandleTable->FirstFree & 0xffff;
+	while (i)
 	{
 		pEntry = &GdiHandleTable->Entries[i];
-		for (;;)
-		{
-			nDeleted++;
-
-			/* Check the entry */
-			if ((pEntry->Type & GDI_ENTRY_BASETYPE_MASK) != 0)
-			{
-				r = 0;
-				DPRINT1("Deleted Entry has a type != 0\n");
-			}
-			if ((ULONG_PTR)pEntry->KernelData >= GDI_HANDLE_COUNT)
-			{
-				r = 0;
-				DPRINT1("Deleted entries KernelPointer too big\n");
-			}
-			if (pEntry->UserData != NULL)
-			{
-				r = 0;
-				DPRINT1("Deleted entry has UserData != 0\n");
-			}
-			if (pEntry->ProcessId != 0)
-			{
-				r = 0;
-				DPRINT1("Deleted entry has ProcessId != 0\n");
-			}
-
-			i = (ULONG_PTR)pEntry->KernelData;
-			if (!i)
-			{
-				break;
-			}
-			pEntry = &GdiHandleTable->Entries[i];
-		}
-	}
+		if (i > GDI_HANDLE_COUNT)
+		{
+		    DPRINT1("nDeleted=%ld\n", nDeleted);
+		    ASSERT(FALSE);
+		}
+
+        nDeleted++;
+
+        /* Check the entry */
+        if ((pEntry->Type & GDI_ENTRY_BASETYPE_MASK) != 0)
+        {
+            r = 0;
+            DPRINT1("Deleted Entry has a type != 0\n");
+        }
+        if ((ULONG_PTR)pEntry->KernelData >= GDI_HANDLE_COUNT)
+        {
+            r = 0;
+            DPRINT1("Deleted entries KernelPointer too big\n");
+        }
+        if (pEntry->UserData != NULL)
+        {
+            r = 0;
+            DPRINT1("Deleted entry has UserData != 0\n");
+        }
+        if (pEntry->ProcessId != 0)
+        {
+            r = 0;
+            DPRINT1("Deleted entry has ProcessId != 0\n");
+        }
+
+        i = (ULONG_PTR)pEntry->KernelData & 0xffff;
+	};
 
 	for (i = GdiHandleTable->FirstUnused;
 	     i < GDI_HANDLE_COUNT;
@@ -295,3 +292,31 @@
 
 #endif /* GDI_DEBUG */
 
+void
+NTAPI
+DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
+{
+    PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
+    if (pti && pti->cExclusiveLocks != 0)
+    {
+        DbgPrint("FATAL: Win32DbgPreServiceHook(%ld): There are %ld exclusive locks!\n",
+                 ulSyscallId, pti->cExclusiveLocks);
+        ASSERT(FALSE);
+    }
+
+}
+
+ULONG_PTR
+NTAPI
+DbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
+{
+    PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
+    if (pti && pti->cExclusiveLocks != 0)
+    {
+        DbgPrint("FATAL: Win32DbgPostServiceHook(%ld): There are %ld exclusive locks!\n",
+                 ulSyscallId, pti->cExclusiveLocks);
+        ASSERT(FALSE);
+    }
+    return ulResult;
+}
+




More information about the Ros-diffs mailing list