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"UserProp", DbgChUserProp},
89 {
L"UserScrollbar", DbgChUserScrollbar},
90 {
L"UserSecurity", DbgChUserSecurity},
91 {
L"UserShutdown", DbgChUserShutdown},
92 {
L"UserSysparams", DbgChUserSysparams},
93 {
L"UserTimer", DbgChUserTimer},
94 {
L"UserThread", DbgChUserThread},
95 {
L"UserWinpos", DbgChUserWinpos},
96 {
L"UserWinsta", DbgChUserWinsta},
97 {
L"UserWnd", DbgChUserWnd}
118 if (cFramesToSkip > cFrameCount)
122 cFrameCount -= cFramesToSkip;
123 cFrameCount =
min(cFrameCount, cFramesToCapture);
127 if (cFrameCount < cFramesToCapture)
131 cFramesToCapture - cFrameCount,
138#if DBG_ENABLE_GDIOBJ_BACKTRACES
157 if (pobj1->apvBackTrace[iLevel] != pobj2->apvBackTrace[iLevel])
174DbgDumpGdiHandleTableWithBT(
void)
178 BOOL bAlreadyPresent;
188 DPRINT1(
"GDI handle abusers already reported!\n");
192 bLeakReported =
TRUE;
193 DPRINT1(
"Reporting GDI handle abusers:\n");
208 bAlreadyPresent =
FALSE;
211 if (CompareBacktraces(
idx,
j))
213 bAlreadyPresent =
TRUE;
218 if (bAlreadyPresent)
continue;
224 if (CompareBacktraces(
idx,
j))
234 if (aBacktraceTable[
j].iCount < iCount)
241 &aBacktraceTable[
j + 1],
246 aBacktraceTable[
j].idx =
idx;
247 aBacktraceTable[
j].iCount = iCount;
256 DbgPrint(
"Count Handle Backtrace\n");
257 DbgPrint(
"------------------------------------------------\n");
260 idx = aBacktraceTable[
j].idx;
267 DbgPrint(
"%5d %08lx ", aBacktraceTable[
j].iCount, ulObj);
270 DbgPrint(
"%p,", pobj->apvBackTrace[iLevel]);
288 ULONG i, nDeleted = 0, nFree = 0, nUsed = 0;
303 DPRINT1(
"nDeleted=%lu\n", nDeleted);
313 DPRINT1(
"Deleted Entry has a type != 0\n");
318 DPRINT1(
"Deleted entries KernelPointer too big\n");
323 DPRINT1(
"Deleted entry has UserData != 0\n");
325 if (
pEntry->ProcessId != 0)
328 DPRINT1(
"Deleted entry has ProcessId != 0\n");
343 DPRINT1(
"Free Entry has a type != 0\n");
348 DPRINT1(
"Free entries KernelPointer != 0\n");
353 DPRINT1(
"Free entry has UserData != 0\n");
355 if (
pEntry->ProcessId != 0)
358 DPRINT1(
"Free entry has ProcessId != 0\n");
377 DPRINT1(
"Used entry has KernelData == 0\n");
382 DPRINT1(
"Used entry invalid KernelData\n");
387 DPRINT1(
"Used entry %lu, has invalid hHmg %p (expected: %p)\n",
397 DPRINT1(
"Number of all entries incorrect: RESERVE_ENTRIES_COUNT = %lu, nDeleted = %lu, nFree = %lu, nUsed = %lu\n",
409#if DBG_ENABLE_EVENT_LOGGING
421 pLogEntry =
EngAllocMem(0,
sizeof(LOGENTRY),
'golG');
422 if (!pLogEntry)
return;
425 pLogEntry->nEventType = nEventType;
429 pLogEntry->lParam =
lParam;
437 case EVENT_CREATE_HANDLE:
438 case EVENT_REFERENCE:
439 case EVENT_DEREFERENCE:
444 case EVENT_SET_OWNER:
453#define REL_ADDR(va) ((ULONG_PTR)va - (ULONG_PTR)&__ImageBase)
457DbgPrintEvent(PLOGENTRY pLogEntry)
461 switch (pLogEntry->nEventType)
463 case EVENT_ALLOCATE: pstr =
"Allocate";
break;
464 case EVENT_CREATE_HANDLE: pstr =
"CreatHdl";
break;
465 case EVENT_REFERENCE: pstr =
"Ref";
break;
466 case EVENT_DEREFERENCE: pstr =
"Deref";
break;
467 case EVENT_LOCK: pstr =
"Lock";
break;
468 case EVENT_UNLOCK: pstr =
"Unlock";
break;
469 case EVENT_DELETE: pstr =
"Delete";
break;
470 case EVENT_FREE: pstr =
"Free";
break;
471 case EVENT_SET_OWNER: pstr =
"SetOwner";
break;
472 default: pstr =
"Unknown";
break;
475 DbgPrint(
"[%lu] %03x:%03x %.8s val=%p <%lx,%lx,%lx,%lx>\n",
477 pLogEntry->dwProcessId,
478 pLogEntry->dwThreadId,
480 (
PVOID)pLogEntry->lParam,
481 REL_ADDR(pLogEntry->apvBackTrace[2]),
482 REL_ADDR(pLogEntry->apvBackTrace[3]),
483 REL_ADDR(pLogEntry->apvBackTrace[4]),
484 REL_ADDR(pLogEntry->apvBackTrace[5]));
497 DbgPrintEvent(pLogEntry);
517#if 1 || DBG_ENABLE_SERVICE_HOOKS
534 DPRINT1(
"Locked object: %lx, type = %lx. allocated from:\n",
549 DbgPrint(
"FATAL: Win32DbgPreServiceHook(0x%lx): There are %lu exclusive locks!\n",
564 DbgPrint(
"FATAL: Win32DbgPostServiceHook(0x%lx): There are %lu exclusive locks!\n",
647DbgCompareChannels(
const void *
a,
const void *
b)
655 DBG_CHANNEL *ChannelEntry;
656 UINT iLevel, iChannel;
659 if (
wcscmp(channel,
L"all") == 0)
661 for (iChannel = 0; iChannel < DbgChCount; iChannel++)
663 DbgAddDebugChannel(ppi, DbgChannels[iChannel].
Name,
level,
op);
668 ChannelEntry = (DBG_CHANNEL*)
bsearch(channel,
673 if(ChannelEntry ==
NULL)
678 iChannel = ChannelEntry->Id;
679 ASSERT(iChannel < DbgChCount);
686 iLevel = FIXME_LEVEL;
690 iLevel = TRACE_LEVEL;
729 DbgAddDebugChannel(ppi,
c,
str,
op);
740 WCHAR valBuffer[100];
750 sizeof(ppi->DbgChannelLevel),
754 Value.Buffer = valBuffer;
756 Value.MaximumLength =
sizeof(valBuffer);
782 if(
Value.Buffer != valBuffer)
794 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
#define _Out_writes_(size)
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)