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
467#ifdef HASH_ENTRY_REMOVE_AT_FREE
499#if API_VERSION_NUMBER >= 9
590#ifdef WITH_IMALLOC_SPY
620 _ftprintf(
g_fFile,
_T(
"\n##### Memory Report ########################################\n"));
625#ifndef HASH_ENTRY_REMOVE_AT_FREE
628 _ftprintf(
g_fFile,
_T(
"##### Memory used: #########################################\n"));
634 _ftprintf(
g_fFile,
_T(
"\n##### Leaks: ###############################################\n"));
669#ifdef WITH_IMALLOC_SPY
672 _ftprintf(
g_fFile,
_T(
"\n##### COM-Leaks: ###############################################\n"));
850#ifdef HASH_ENTRY_REMOVE_AT_FREE
891#if API_VERSION_NUMBER >= 9
1009#define nNoMansLandSize 4
1038#define pbData(pblock) ((unsigned char *)((_CrtMemBlockHeader *)pblock + 1))
1039#define pHdr(pbData) (((_CrtMemBlockHeader *)pbData)-1)
1078#ifdef IGNORE_CRT_ALLOC
1254#define gle (GetLastError())
1255#define lenof(a) (sizeof(a) / sizeof((a)[0]))
1256#define MAXNAMELEN 1024
1257#define IMGSYMLEN ( sizeof IMAGEHLP_SYMBOL )
1258#define TTBUFLEN 8096
1328typedef std::vector< ModuleEntry >
ModuleList;
1333#define MAX_MODULE_NAME32 255
1334#define TH32CS_SNAPMODULE 0x00000008
1335#pragma pack( push, 8 )
1375 me.dwSize =
sizeof(
me);
1404 e.imageName =
me.szExePath;
1405 e.moduleName =
me.szModule;
1406 e.baseAddress = (
DWORD)
me.modBaseAddr;
1407 e.size =
me.modBaseSize;
1488 e.baseAddress = (
DWORD)
mi.lpBaseOfDll;
1489 e.size =
mi.SizeOfImage;
1524 img[
sizeof(
img) - 1] = 0;
1525 mod[
sizeof(
mod) - 1] = 0;
1551 printf(
"LoadLibrary( \"dbghelp.dll\" ): GetLastError = %lu\n",
gle );
1573 printf(
"GetProcAddress(): some required function not found.\n" );
1592 _T(
"*** Unhandled Exception!\n")
1593 _T(
" ExpCode: 0x%8.8X\n")
1594 _T(
" ExpFlags: %d\n")
1595 _T(
" ExpAddress: 0x%8.8X\n")
1596 _T(
" Please report!"),
1597 pExPtrs->ExceptionRecord->ExceptionCode,
1598 pExPtrs->ExceptionRecord->ExceptionFlags,
1599 pExPtrs->ExceptionRecord->ExceptionAddress);
1628 return _T(
"<unkown exception>");
1665 szRet.append(
"&");
1668 szRet.append(
"<");
1671 szRet.append(
">");
1674 szRet.append(
""");
1677 szRet.append(
"'");
1752 memset( &s,
'\0',
sizeof s );
1802 if ( *p ==
'\\' || *p ==
'/' || *p ==
':' )
1863 s.AddrPC.Offset =
c.Eip;
1865 s.AddrFrame.Offset =
c.Ebp;
1872 memset( &Line,
'\0',
sizeof Line );
1873 Line.SizeOfStruct =
sizeof Line;
1875 memset( &Module,
'\0',
sizeof Module );
1892 if ( s.AddrPC.Offset == 0 )
1981 fprintf(
fLogFile,
"srcfile=\"%s\" line=\"%lu\" line_offset=\"%+ld\" ",
1999 switch (
Module.SymType )
2068 if ( s.AddrReturn.Offset == 0 )
2118#ifdef WITH_IMALLOC_SPY
2126 _tprintf(
_T(
"\nCoRegisterMallocSpay failed with %.8x"),
hr);
2187#ifdef WITH_IMALLOC_SPY
2278 ep->ExceptionRecord->ExceptionCode,
2279 ep->ExceptionRecord->ExceptionAddress);
2287 ep->ExceptionRecord->ExceptionCode,
2288 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