parent
df988dfff3
commit
cdf081dbd5
|
@ -438,15 +438,15 @@ struct IMAGEHLP_SYMBOL64_EXT : public IMAGEHLP_SYMBOL64 {
|
|||
};
|
||||
typedef BOOL (WINAPI *fpStackWalk64)(DWORD, HANDLE, HANDLE, LPSTACKFRAME64, PVOID, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64);
|
||||
static fpStackWalk64 pStackWalk64;
|
||||
typedef DWORD64 (WINAPI *fpSymGetModuleBase64)(HANDLE, DWORD64);
|
||||
typedef DWORD64(WINAPI *fpSymGetModuleBase64)(HANDLE, DWORD64);
|
||||
static fpSymGetModuleBase64 pSymGetModuleBase64;
|
||||
typedef BOOL (WINAPI *fpSymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
|
||||
static fpSymGetSymFromAddr64 pSymGetSymFromAddr64;
|
||||
typedef BOOL (WINAPI *fpSymGetLineFromAddr64)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
|
||||
static fpSymGetLineFromAddr64 pSymGetLineFromAddr64;
|
||||
typedef DWORD (WINAPI *fpUnDecorateSymbolName)( const TCHAR*, PTSTR, DWORD, DWORD) ;
|
||||
typedef DWORD (WINAPI *fpUnDecorateSymbolName)(const TCHAR*, PTSTR, DWORD, DWORD) ;
|
||||
static fpUnDecorateSymbolName pUnDecorateSymbolName;
|
||||
typedef PVOID (WINAPI *fpSymFunctionTableAccess64)(HANDLE, DWORD64);
|
||||
typedef PVOID(WINAPI *fpSymFunctionTableAccess64)(HANDLE, DWORD64);
|
||||
static fpSymFunctionTableAccess64 pSymFunctionTableAccess64;
|
||||
typedef BOOL (WINAPI *fpSymInitialize)(HANDLE, PCSTR, BOOL);
|
||||
static fpSymInitialize pSymInitialize;
|
||||
|
@ -480,7 +480,7 @@ static void PrintCallstack(FILE* f, PEXCEPTION_POINTERS ex)
|
|||
TRUE
|
||||
);
|
||||
CONTEXT context = *(ex->ContextRecord);
|
||||
STACKFRAME64 stack={0};
|
||||
STACKFRAME64 stack= {0};
|
||||
#ifdef _M_IX86
|
||||
stack.AddrPC.Offset = context.Eip;
|
||||
stack.AddrPC.Mode = AddrModeFlat;
|
||||
|
@ -498,12 +498,11 @@ static void PrintCallstack(FILE* f, PEXCEPTION_POINTERS ex)
|
|||
#endif
|
||||
IMAGEHLP_SYMBOL64_EXT symbol;
|
||||
IMAGEHLP_SYMBOL64* pSymbol = &symbol;
|
||||
pSymbol->SizeOfStruct = sizeof( IMAGEHLP_SYMBOL64 );
|
||||
pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
|
||||
pSymbol->MaxNameLength = maxnamelength;
|
||||
DWORD64 displacement = 0;
|
||||
int beyond_main=-1; // emergency exit, see below
|
||||
for( ULONG frame = 0; ; frame++ )
|
||||
{
|
||||
for (ULONG frame = 0; ; frame++) {
|
||||
result = pStackWalk64
|
||||
(
|
||||
#ifdef _M_IX86
|
||||
|
@ -520,16 +519,16 @@ static void PrintCallstack(FILE* f, PEXCEPTION_POINTERS ex)
|
|||
pSymGetModuleBase64,
|
||||
NULL
|
||||
);
|
||||
if( !result ) // official end...
|
||||
if (!result) // official end...
|
||||
break;
|
||||
result = pSymGetSymFromAddr64( hProcess, ( ULONG64 )stack.AddrPC.Offset, &displacement, pSymbol );
|
||||
TCHAR undname[maxnamelength]={0};
|
||||
pUnDecorateSymbolName( (const TCHAR*)pSymbol->Name, (PTSTR)undname, GetArrayLength(undname), UNDNAME_COMPLETE );
|
||||
result = pSymGetSymFromAddr64(hProcess, (ULONG64)stack.AddrPC.Offset, &displacement, pSymbol);
|
||||
TCHAR undname[maxnamelength]= {0};
|
||||
pUnDecorateSymbolName((const TCHAR*)pSymbol->Name, (PTSTR)undname, GetArrayLength(undname), UNDNAME_COMPLETE);
|
||||
if (beyond_main>=0)
|
||||
++beyond_main;
|
||||
if (_tcscmp(undname, _T("main"))==0)
|
||||
beyond_main=0;
|
||||
fprintf( f,
|
||||
fprintf(f,
|
||||
"%lu. 0x%08LX in ",
|
||||
frame, (ULONG64)stack.AddrPC.Offset);
|
||||
fputs((const char *)undname, f);
|
||||
|
|
Loading…
Reference in New Issue