23#if !(defined(BI_COMP_MSC) && (defined(__DEBUG) || defined(_DEBUG)))
24#error StackWalker only supports debug mode for VC++.
44#define HASH_ENTRY_REMOVE_AT_FREE
58#define ALLOC_HASH_ENTRIES 8192
62#define MAX_ESP_LEN_BUF 0x500
66#define IGNORE_CRT_ALLOC
69#define LOG_FILE_MAX_SIZE 1024*128
72#define WITH_IMALLOC_SPY
75#ifdef WITH_IMALLOC_SPY
95 *
ppUnk = (IUnknown *)
this;
199#error "'imagehlp.h' should only included here, not before this point! Otherwise there are some problems!"
201#pragma pack( push, before_imagehlp, 8 )
203#pragma pack( pop, before_imagehlp )
204#if API_VERSION_NUMBER < 7
220#define SYMOPT_LOAD_LINES 0x00000010
276#define MAX_EIP_LEN_BUF 4
278#define ALLOC_ENTRY_NOT_FOUND 0xFFFFFFFF
309#ifdef WITH_IMALLOC_SPY
498#ifdef HASH_ENTRY_REMOVE_AT_FREE
539#if API_VERSION_NUMBER >= 9
639#ifdef WITH_IMALLOC_SPY
669 _ftprintf(
g_fFile,
_T(
"\n##### Memory Report ########################################\n"));
674#ifndef HASH_ENTRY_REMOVE_AT_FREE
677 _ftprintf(
g_fFile,
_T(
"##### Memory used: #########################################\n"));
683 _ftprintf(
g_fFile,
_T(
"\n##### Leaks: ###############################################\n"));
718#ifdef WITH_IMALLOC_SPY
721 _ftprintf(
g_fFile,
_T(
"\n##### COM-Leaks: ###############################################\n"));
902#ifdef HASH_ENTRY_REMOVE_AT_FREE
943#if API_VERSION_NUMBER >= 9
1061#define nNoMansLandSize 4
1090#define pbData(pblock) ((unsigned char *)((_CrtMemBlockHeader *)pblock + 1))
1091#define pHdr(pbData) (((_CrtMemBlockHeader *)pbData)-1)
1130#ifdef IGNORE_CRT_ALLOC
1306#define gle (GetLastError())
1307#define lenof(a) (sizeof(a) / sizeof((a)[0]))
1308#define MAXNAMELEN 1024
1309#define IMGSYMLEN ( sizeof IMAGEHLP_SYMBOL )
1310#define TTBUFLEN 8096
1380typedef std::vector< ModuleEntry >
ModuleList;
1385#define MAX_MODULE_NAME32 255
1386#define TH32CS_SNAPMODULE 0x00000008
1387#pragma pack( push, 8 )
1427 me.dwSize =
sizeof(
me);
1456 e.imageName =
me.szExePath;
1457 e.moduleName =
me.szModule;
1458 e.baseAddress = (
DWORD)
me.modBaseAddr;
1459 e.size =
me.modBaseSize;
1540 e.baseAddress = (
DWORD)
mi.lpBaseOfDll;
1541 e.size =
mi.SizeOfImage;
1576 img[
sizeof(
img) - 1] = 0;
1577 mod[
sizeof(
mod) - 1] = 0;
1603 printf(
"LoadLibrary( \"dbghelp.dll\" ): GetLastError = %lu\n",
gle );
1625 printf(
"GetProcAddress(): some required function not found.\n" );
1644 _T(
"*** Unhandled Exception!\n")
1645 _T(
" ExpCode: 0x%8.8X\n")
1646 _T(
" ExpFlags: %d\n")
1647 _T(
" ExpAddress: 0x%8.8X\n")
1648 _T(
" Please report!"),
1649 pExPtrs->ExceptionRecord->ExceptionCode,
1650 pExPtrs->ExceptionRecord->ExceptionFlags,
1651 pExPtrs->ExceptionRecord->ExceptionAddress);
1680 return _T(
"<unkown exception>");
1717 szRet.append(
"&");
1720 szRet.append(
"<");
1723 szRet.append(
">");
1726 szRet.append(
""");
1729 szRet.append(
"'");
1804 memset( &s,
'\0',
sizeof s );
1854 if ( *p ==
'\\' || *p ==
'/' || *p ==
':' )
1915 s.AddrPC.Offset =
c.Eip;
1917 s.AddrFrame.Offset =
c.Ebp;
1924 memset( &Line,
'\0',
sizeof Line );
1925 Line.SizeOfStruct =
sizeof Line;
1927 memset( &Module,
'\0',
sizeof Module );
1944 if ( s.AddrPC.Offset == 0 )
2033 fprintf(
fLogFile,
"srcfile=\"%s\" line=\"%lu\" line_offset=\"%+ld\" ",
2051 switch (
Module.SymType )
2120 if ( s.AddrReturn.Offset == 0 )
2170#ifdef WITH_IMALLOC_SPY
2180 _tprintf(
_T(
"\nCoRegisterMallocSpay failed with %.8x"),
hr);
2241#ifdef WITH_IMALLOC_SPY
2332 ep->ExceptionRecord->ExceptionCode,
2333 ep->ExceptionRecord->ExceptionAddress);
2341 ep->ExceptionRecord->ExceptionCode,
2342 ep->ExceptionRecord->ExceptionAddress);
#define LOG_FILE_MAX_SIZE
int InitAllocCheckWN(eAllocCheckOutput eOutput, LPCTSTR pszFileName, ULONG ulShowStackAtAlloc)
#define ALLOC_HASH_ENTRIES
#define TH32CS_SNAPMODULE
ULONG DeInitAllocCheck(void)
#define SYMOPT_LOAD_LINES
DWORD StackwalkFilter(EXCEPTION_POINTERS *ep, DWORD status, LPCTSTR pszLogFile)
#define ALLOC_ENTRY_NOT_FOUND
int InitAllocCheck(eAllocCheckOutput eOutput, BOOL bSetUnhandledExeptionFilter, ULONG ulShowStackAtAlloc)
#define MAX_MODULE_NAME32
#define EXCEPTION_EXECUTE_HANDLER