20ULONG gulLogUnique = 0;
23DBG_CHANNEL DbgChannels[DbgChCount] = {
24 {
L"EngBlt", DbgChEngBlt},
25 {
L"EngBrush", DbgChEngBrush},
26 {
L"EngClip", DbgChEngClip},
27 {
L"EngCursor", DbgChEngCursor},
28 {
L"EngDev", DbgChEngDev},
29 {
L"EngErr", DbgChEngErr},
30 {
L"EngEvent", DbgChEngEvent},
31 {
L"EngGrad", DbgChEngGrad},
32 {
L"EngLDev", DbgChEngLDev},
33 {
L"EngLine", DbgChEngLine},
34 {
L"EngMapping", DbgChEngMapping},
35 {
L"EngMDev", DbgChEngMDev},
36 {
L"EngPDev", DbgChEngPDev},
37 {
L"EngSurface", DbgChEngSurface},
38 {
L"EngWnd", DbgChEngWnd},
39 {
L"EngXlate", DbgChEngXlate},
40 {
L"GdiBitmap", DbgChGdiBitmap},
41 {
L"GdiBlt", DbgChGdiBlt},
42 {
L"GdiBrush", DbgChGdiBrush},
43 {
L"GdiClipRgn", DbgChGdiClipRgn},
44 {
L"GdiCoord", DbgChGdiCoord},
45 {
L"GdiDC", DbgChGdiDC},
46 {
L"GdiDCAttr", DbgChGdiDCAttr},
47 {
L"GdiDCState", DbgChGdiDCState},
48 {
L"GdiDev", DbgChGdiDev},
49 {
L"GdiDib", DbgChGdiDib},
50 {
L"GdiFont", DbgChGdiFont},
51 {
L"GdiLine", DbgChGdiLine},
52 {
L"GdiObj", DbgChGdiObj},
53 {
L"GdiPalette", DbgChGdiPalette},
54 {
L"GdiPath", DbgChGdiPath},
55 {
L"GdiPen", DbgChGdiPen},
56 {
L"GdiPool", DbgChGdiPool},
57 {
L"GdiRgn", DbgChGdiRgn},
58 {
L"GdiText", DbgChGdiText},
59 {
L"GdiXFormObj", DbgChGdiXFormObj},
60 {
L"UserAccel", DbgChUserAccel},
61 {
L"UserCallback", DbgChUserCallback},
62 {
L"UserCallProc", DbgChUserCallProc},
63 {
L"UserCaret", DbgChUserCaret},
64 {
L"UserClass", DbgChUserClass},
65 {
L"UserClipbrd", DbgChUserClipbrd},
66 {
L"UserCsr", DbgChUserCsr},
67 {
L"UserDce", DbgChUserDce},
68 {
L"UserDefwnd", DbgChUserDefwnd},
69 {
L"UserDesktop", DbgChUserDesktop},
70 {
L"UserDisplay",DbgChUserDisplay},
71 {
L"UserEvent", DbgChUserEvent},
72 {
L"UserFocus", DbgChUserFocus},
73 {
L"UserHook", DbgChUserHook},
74 {
L"UserHotkey", DbgChUserHotkey},
75 {
L"UserIcon", DbgChUserIcon},
76 {
L"UserInput", DbgChUserInput},
77 {
L"UserKbd", DbgChUserKbd},
78 {
L"UserKbdLayout", DbgChUserKbdLayout},
79 {
L"UserMenu", DbgChUserMenu},
80 {
L"UserMetric", DbgChUserMetric},
81 {
L"UserMisc", DbgChUserMisc},
82 {
L"UserMonitor", DbgChUserMonitor},
83 {
L"UserMsg", DbgChUserMsg},
84 {
L"UserMsgQ", DbgChUserMsgQ},
85 {
L"UserObj", DbgChUserObj},
86 {
L"UserPainting", DbgChUserPainting},
87 {
L"UserProcess", DbgChUserProcess},
88 {
L"UserPowerManager", DbgChUserPowerManager},
89 {
L"UserProp", DbgChUserProp},
90 {
L"UserScrollbar", DbgChUserScrollbar},
91 {
L"UserSecurity", DbgChUserSecurity},
92 {
L"UserShutdown", DbgChUserShutdown},
93 {
L"UserSysparams", DbgChUserSysparams},
94 {
L"UserTimer", DbgChUserTimer},
95 {
L"UserThread", DbgChUserThread},
96 {
L"UserWinpos", DbgChUserWinpos},
97 {
L"UserWinsta", DbgChUserWinsta},
98 {
L"UserWnd", DbgChUserWnd}
119 if (cFramesToSkip > cFrameCount)
123 cFrameCount -= cFramesToSkip;
124 cFrameCount =
min(cFrameCount, cFramesToCapture);
128 if (cFrameCount < cFramesToCapture)
132 cFramesToCapture - cFrameCount,
139#if DBG_ENABLE_GDIOBJ_BACKTRACES
158 if (pobj1->apvBackTrace[iLevel] != pobj2->apvBackTrace[iLevel])
175DbgDumpGdiHandleTableWithBT(
void)
179 BOOL bAlreadyPresent;
189 DPRINT1(
"GDI handle abusers already reported!\n");
193 bLeakReported =
TRUE;
194 DPRINT1(
"Reporting GDI handle abusers:\n");
209 bAlreadyPresent =
FALSE;
212 if (CompareBacktraces(
idx,
j))
214 bAlreadyPresent =
TRUE;
219 if (bAlreadyPresent)
continue;
225 if (CompareBacktraces(
idx,
j))
235 if (aBacktraceTable[
j].iCount < iCount)
242 &aBacktraceTable[
j + 1],
247 aBacktraceTable[
j].idx =
idx;
248 aBacktraceTable[
j].iCount = iCount;
257 DbgPrint(
"Count Handle Backtrace\n");
258 DbgPrint(
"------------------------------------------------\n");
261 idx = aBacktraceTable[
j].idx;
268 DbgPrint(
"%5d %08lx ", aBacktraceTable[
j].iCount, ulObj);
271 DbgPrint(
"%p,", pobj->apvBackTrace[iLevel]);
289 ULONG i, nDeleted = 0, nFree = 0, nUsed = 0;
304 DPRINT1(
"nDeleted=%lu\n", nDeleted);
314 DPRINT1(
"Deleted Entry has a type != 0\n");
319 DPRINT1(
"Deleted entries KernelPointer too big\n");
324 DPRINT1(
"Deleted entry has UserData != 0\n");
326 if (
pEntry->ProcessId != 0)
329 DPRINT1(
"Deleted entry has ProcessId != 0\n");
344 DPRINT1(
"Free Entry has a type != 0\n");
349 DPRINT1(
"Free entries KernelPointer != 0\n");
354 DPRINT1(
"Free entry has UserData != 0\n");
356 if (
pEntry->ProcessId != 0)
359 DPRINT1(
"Free entry has ProcessId != 0\n");
378 DPRINT1(
"Used entry has KernelData == 0\n");
383 DPRINT1(
"Used entry invalid KernelData\n");
388 DPRINT1(
"Used entry %lu, has invalid hHmg %p (expected: %p)\n",
398 DPRINT1(
"Number of all entries incorrect: RESERVE_ENTRIES_COUNT = %lu, nDeleted = %lu, nFree = %lu, nUsed = %lu\n",
410#if DBG_ENABLE_EVENT_LOGGING
422 pLogEntry =
EngAllocMem(0,
sizeof(LOGENTRY),
'golG');
423 if (!pLogEntry)
return;
426 pLogEntry->nEventType = nEventType;
430 pLogEntry->lParam =
lParam;
438 case EVENT_CREATE_HANDLE:
439 case EVENT_REFERENCE:
440 case EVENT_DEREFERENCE:
445 case EVENT_SET_OWNER:
454#define REL_ADDR(va) ((ULONG_PTR)va - (ULONG_PTR)&__ImageBase)
458DbgPrintEvent(PLOGENTRY pLogEntry)
462 switch (pLogEntry->nEventType)
464 case EVENT_ALLOCATE: pstr =
"Allocate";
break;
465 case EVENT_CREATE_HANDLE: pstr =
"CreatHdl";
break;
466 case EVENT_REFERENCE: pstr =
"Ref";
break;
467 case EVENT_DEREFERENCE: pstr =
"Deref";
break;
468 case EVENT_LOCK: pstr =
"Lock";
break;
469 case EVENT_UNLOCK: pstr =
"Unlock";
break;
470 case EVENT_DELETE: pstr =
"Delete";
break;
471 case EVENT_FREE: pstr =
"Free";
break;
472 case EVENT_SET_OWNER: pstr =
"SetOwner";
break;
473 default: pstr =
"Unknown";
break;
476 DbgPrint(
"[%lu] %03x:%03x %.8s val=%p <%lx,%lx,%lx,%lx>\n",
478 pLogEntry->dwProcessId,
479 pLogEntry->dwThreadId,
481 (
PVOID)pLogEntry->lParam,
482 REL_ADDR(pLogEntry->apvBackTrace[2]),
483 REL_ADDR(pLogEntry->apvBackTrace[3]),
484 REL_ADDR(pLogEntry->apvBackTrace[4]),
485 REL_ADDR(pLogEntry->apvBackTrace[5]));
498 DbgPrintEvent(pLogEntry);
518#if 1 || DBG_ENABLE_SERVICE_HOOKS
535 DPRINT1(
"Locked object: %lx, type = %lx. allocated from:\n",
550 DbgPrint(
"FATAL: Win32DbgPreServiceHook(0x%lx): There are %lu exclusive locks!\n",
565 DbgPrint(
"FATAL: Win32DbgPostServiceHook(0x%lx): There are %lu exclusive locks!\n",
648DbgCompareChannels(
const void *
a,
const void *
b)
656 DBG_CHANNEL *ChannelEntry;
657 UINT iLevel, iChannel;
660 if (
wcscmp(channel,
L"all") == 0)
662 for (iChannel = 0; iChannel < DbgChCount; iChannel++)
664 DbgAddDebugChannel(ppi, DbgChannels[iChannel].
Name,
level,
op);
669 ChannelEntry = (DBG_CHANNEL*)
bsearch(channel,
674 if(ChannelEntry ==
NULL)
679 iChannel = ChannelEntry->Id;
680 ASSERT(iChannel < DbgChCount);
687 iLevel = FIXME_LEVEL;
691 iLevel = TRACE_LEVEL;
730 DbgAddDebugChannel(ppi,
c,
str,
op);
741 WCHAR valBuffer[100];
751 sizeof(ppi->DbgChannelLevel),
755 Value.Buffer = valBuffer;
757 Value.MaximumLength =
sizeof(valBuffer);
783 if(
Value.Buffer != valBuffer)
795 if(
Value.Buffer != valBuffer)
#define InterlockedIncrement
#define DbgParseDebugChannels(val)
#define NT_SUCCESS(StatCode)
ULONG NTAPI RtlWalkFrameChain(OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags)
static const WCHAR separator[]
#define KeRaiseIrql(irql, oldIrql)
#define KeLowerIrql(oldIrql)
#define ExAllocatePool(type, size)
#define DBG_DUMP_EVENT_LIST(pslh)
BOOL NTAPI DbgGdiHTIntegrityCheck(VOID)
ULONG NTAPI DbgCaptureStackBackTace(_Out_writes_(cFramesToCapture) PVOID *ppvFrames, _In_ ULONG cFramesToSkip, _In_ ULONG cFramesToCapture)
VOID NTAPI DbgDumpLockedGdiHandles(VOID)
#define GDI_OBJECT_STACK_LEVELS
static const unsigned RESERVE_ENTRIES_COUNT
GLdouble GLdouble GLdouble r
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RtlFillMemory(Dest, Length, Fill)
void __cdecl __debugbreak(void)
#define KeLeaveCriticalRegion()
#define KeEnterCriticalRegion()
#define memcpy(s1, s2, n)
PVOID PVOID PWCHAR PVOID Environment
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define GDI_ENTRY_BASETYPE_MASK
#define GDI_ENTRY_UPPER_SHIFT
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
HANDLE NTAPI PsGetCurrentProcessId(VOID)
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
#define STATUS_VARIABLE_NOT_FOUND
struct _THREADINFO * PTHREADINFO
void * EngAllocMem(int zero, unsigned long size, int tag=0)
PVOID MmHighestUserAddress
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define STATUS_BUFFER_TOO_SMALL
union _ENTRY::_EINFO einfo
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
struct _BASEOBJECT * pobj
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
BOOL DbgInitDebugChannels()
#define DBG_ENABLE_CHANNEL(ppi, ch, level)
#define DBG_DISABLE_CHANNEL(ppi, ch, level)
volatile ULONG gulFirstFree
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
#define QueryDepthSList(SListHead)
#define InterlockedPushEntrySList(SListHead, SListEntry)
#define InterlockedPopEntrySList(SListHead)