43 typedef unsigned __int64 DWORD64, *PDWORD64;
45 typedef unsigned __int64 SIZE_T, *PSIZE_T;
47 typedef unsigned long SIZE_T, *PSIZE_T;
49 #endif // _MSC_VER < 1300
59 typedef enum StackWalkOptions
72 RetrieveModuleInfo = 4,
75 RetrieveFileVersion = 8,
78 RetrieveVerbose = 0xF,
94 int options = OptionsAll,
95 LPCSTR szSymPath = NULL,
96 DWORD dwProcessId = GetCurrentProcessId(),
97 HANDLE hProcess = GetCurrentProcess()
102 typedef BOOL (__stdcall *PReadProcessMemoryRoutine)(
104 DWORD64 qwBaseAddress,
107 LPDWORD lpNumberOfBytesRead,
114 HANDLE hThread = GetCurrentThread(),
115 const CONTEXT *context = NULL,
116 PReadProcessMemoryRoutine readMemoryFunction = NULL,
117 LPVOID pUserData = NULL
125 enum { STACKWALK_MAX_NAMELEN = 1024 };
132 CHAR name[STACKWALK_MAX_NAMELEN];
133 CHAR undName[STACKWALK_MAX_NAMELEN];
134 CHAR undFullName[STACKWALK_MAX_NAMELEN];
135 DWORD64 offsetFromSmybol;
136 DWORD offsetFromLine;
138 CHAR lineFileName[STACKWALK_MAX_NAMELEN];
140 LPCSTR symTypeString;
141 CHAR moduleName[STACKWALK_MAX_NAMELEN];
143 CHAR loadedImageName[STACKWALK_MAX_NAMELEN];
146 typedef enum CallstackEntryType {firstEntry, nextEntry, lastEntry};
148 virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName);
149 virtual void OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion);
150 virtual void OnCallstackEntry(CallstackEntryType eType, CallstackEntry &entry);
151 virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
152 virtual void OnOutput(LPCSTR szText);
157 BOOL m_modulesLoaded;
161 int m_MaxRecursionCount;
163 static BOOL __stdcall myReadProcMem(HANDLE hProcess, DWORD64 qwBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead);
181 #ifdef CURRENT_THREAD_VIA_EXCEPTION
184 #define GET_CURRENT_CONTEXT(c, contextFlags) \
186 memset(&c, 0, sizeof(CONTEXT)); \
187 EXCEPTION_POINTERS *pExp = NULL; \
190 } __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \
192 memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \
193 c.ContextFlags = contextFlags; \
197 #define GET_CURRENT_CONTEXT(c, contextFlags) \
199 memset(&c, 0, sizeof(CONTEXT)); \
200 c.ContextFlags = contextFlags; \
203 __asm mov c.Eip, eax \
204 __asm mov c.Ebp, ebp \
205 __asm mov c.Esp, esp \
212 #define GET_CURRENT_CONTEXT(c, contextFlags) \
214 memset(&c, 0, sizeof(CONTEXT)); \
215 c.ContextFlags = contextFlags; \
216 RtlCaptureContext(&c); \