1 #pragma once
2
3 #define GDI_DBG_MAX_BTS 10
4
5 #if DBG && defined(KDBG)
6 #define ASSERT_NOGDILOCKS() GdiDbgAssertNoLocks(__FILE__,__LINE__)
7 #define KeRosDumpStackFrames(Frames, Count) \
8 KdSystemDebugControl('DsoR', (PVOID)Frames, Count, NULL, 0, NULL, KernelMode)
9 #else
10 #define ASSERT_NOGDILOCKS()
11 #define KeRosDumpStackFrames(Frames, Count)
12 #endif
13
14 ULONG
15 NTAPI
16 DbgCaptureStackBackTace(
17 _Out_writes_(cFramesToCapture) PVOID* ppvFrames,
18 _In_ ULONG cFramesToSkip,
19 _In_ ULONG cFramesToCapture);
20
21 BOOL
22 NTAPI
23 DbgGdiHTIntegrityCheck(
24 VOID);
25
26 VOID
27 NTAPI
28 DbgDumpLockedGdiHandles(
29 VOID);
30
31 #if DBG_ENABLE_GDIOBJ_BACKTRACES
32
33 VOID
34 NTAPI
35 DbgDumpGdiHandleTableWithBT(VOID);
36
37 #endif
38
39 #if defined(KDBG)
40
41 BOOLEAN
42 NTAPI
43 DbgGdiKdbgCliCallback(
44 _In_ PCHAR Command,
45 _In_ ULONG Argc,
46 _In_ PCH Argv[]);
47
48 #endif
49
50 #if DBG_ENABLE_EVENT_LOGGING
51
52 typedef enum _LOG_EVENT_TYPE
53 {
54 EVENT_ALLOCATE,
55 EVENT_CREATE_HANDLE,
56 EVENT_REFERENCE,
57 EVENT_DEREFERENCE,
58 EVENT_LOCK,
59 EVENT_UNLOCK,
60 EVENT_DELETE,
61 EVENT_FREE,
62 EVENT_SET_OWNER,
63 } LOG_EVENT_TYPE;
64
65 typedef struct _LOGENTRY
66 {
67 SLIST_ENTRY sleLink;
68 LOG_EVENT_TYPE nEventType;
69 DWORD dwProcessId;
70 DWORD dwThreadId;
71 ULONG ulUnique;
72 LPARAM lParam;
73 PVOID apvBackTrace[20];
74 union
75 {
76 ULONG_PTR data1;
77 } data;
78 } LOGENTRY, *PLOGENTRY;
79
80 VOID
81 NTAPI
82 DbgDumpEventList(
83 _Inout_ PSLIST_HEADER pslh);
84
85 VOID
86 NTAPI
87 DbgLogEvent(
88 _Inout_ PSLIST_HEADER pslh,
89 _In_ LOG_EVENT_TYPE nEventType,
90 _In_ LPARAM lParam);
91
92 VOID
93 NTAPI
94 DbgCleanupEventList(
95 _Inout_ PSLIST_HEADER pslh);
96
97 VOID
98 NTAPI
99 DbgPrintEvent(
100 _Inout_ PLOGENTRY pLogEntry);
101
102 #define DBG_LOGEVENT(pslh, type, val) DbgLogEvent(pslh, type, (ULONG_PTR)val)
103 #define DBG_INITLOG(pslh) InitializeSListHead(pslh)
104 #define DBG_DUMP_EVENT_LIST(pslh) DbgDumpEventList(pslh)
105 #define DBG_CLEANUP_EVENT_LIST(pslh) DbgCleanupEventList(pslh)
106
107 #else
108
109 #define DBG_LOGEVENT(pslh, type, val) ((void)(val))
110 #define DBG_INITLOG(pslh)
111 #define DBG_DUMP_EVENT_LIST(pslh)
112 #define DBG_CLEANUP_EVENT_LIST(pslh)
113
114 #endif
115
116 #if DBG
117 void
118 NTAPI
119 GdiDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
120
121 ULONG_PTR
122 NTAPI
123 GdiDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
124
125 #define ID_Win32PreServiceHook 'WSH0'
126 #define ID_Win32PostServiceHook 'WSH1'
127
128 #ifndef __cplusplus
129 FORCEINLINE void
GdiDbgAssertNoLocks(char * pszFile,ULONG nLine)130 GdiDbgAssertNoLocks(char * pszFile, ULONG nLine)
131 {
132 PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
133 if (pti && pti->cExclusiveLocks != 0)
134 {
135 ULONG i;
136 DbgPrint("(%s:%lu) There are %lu exclusive locks!\n",
137 pszFile, nLine, pti->cExclusiveLocks);
138 for (i = 0; i < (GDIObjTypeTotal + 1); i++)
139 DbgPrint(" Type %u: %u.\n", i, pti->acExclusiveLockCount[i]);
140 ASSERT(FALSE);
141 }
142 }
143 #endif // __cplusplus
144 #endif
145
146
147