1 #ifndef __STACKWALKER_H__ 2 #define __STACKWALKER_H__ 47 #pragma warning(disable : 4091) 52 typedef unsigned __int64 DWORD64, *PDWORD64;
54 typedef unsigned __int64 SIZE_T, *PSIZE_T;
56 typedef unsigned long SIZE_T, *PSIZE_T;
58 #endif // _MSC_VER < 1300 64 typedef enum StackWalkOptions
77 RetrieveModuleInfo = 4,
80 RetrieveFileVersion = 8,
83 RetrieveVerbose = 0xF,
98 StackWalker(
int options = OptionsAll,
99 LPCSTR szSymPath = NULL,
100 DWORD dwProcessId = GetCurrentProcessId(),
101 HANDLE hProcess = GetCurrentProcess());
102 StackWalker(DWORD dwProcessId, HANDLE hProcess);
103 virtual ~StackWalker();
105 typedef BOOL(__stdcall* PReadProcessMemoryRoutine)(
107 DWORD64 qwBaseAddress,
110 LPDWORD lpNumberOfBytesRead,
117 HANDLE hThread = GetCurrentThread(),
118 const CONTEXT* context = NULL,
119 PReadProcessMemoryRoutine readMemoryFunction = NULL,
120 LPVOID pUserData = NULL
123 BOOL ShowObject(LPVOID pObject);
132 STACKWALK_MAX_NAMELEN = 1024
137 typedef struct CallstackEntry
140 CHAR name[STACKWALK_MAX_NAMELEN];
141 CHAR undName[STACKWALK_MAX_NAMELEN];
142 CHAR undFullName[STACKWALK_MAX_NAMELEN];
143 DWORD64 offsetFromSmybol;
144 DWORD offsetFromLine;
146 CHAR lineFileName[STACKWALK_MAX_NAMELEN];
148 LPCSTR symTypeString;
149 CHAR moduleName[STACKWALK_MAX_NAMELEN];
151 CHAR loadedImageName[STACKWALK_MAX_NAMELEN];
154 typedef enum CallstackEntryType
159 } CallstackEntryType;
161 virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName);
162 virtual void OnLoadModule(LPCSTR img,
169 ULONGLONG fileVersion);
170 virtual void OnCallstackEntry(CallstackEntryType eType, CallstackEntry& entry);
171 virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
172 virtual void OnOutput(LPCSTR szText);
177 BOOL m_modulesLoaded;
181 int m_MaxRecursionCount;
183 static BOOL __stdcall myReadProcMem(HANDLE hProcess,
184 DWORD64 qwBaseAddress,
187 LPDWORD lpNumberOfBytesRead);
204 #ifdef CURRENT_THREAD_VIA_EXCEPTION 207 #define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \ 210 memset(&c, 0, sizeof(CONTEXT)); \ 211 EXCEPTION_POINTERS* pExp = NULL; \ 216 __except (((pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER \ 217 : EXCEPTION_EXECUTE_HANDLER)) \ 221 memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \ 222 c.ContextFlags = contextFlags; \ 227 #define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \ 230 memset(&c, 0, sizeof(CONTEXT)); \ 231 c.ContextFlags = contextFlags; \ 234 __asm mov c.Eip, eax \ 235 __asm mov c.Ebp, ebp \ 236 __asm mov c.Esp, esp \ 244 #define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \ 247 memset(&c, 0, sizeof(CONTEXT)); \ 248 c.ContextFlags = contextFlags; \ 249 RtlCaptureContext(&c); \ 253 #endif //defined(_MSC_VER) 255 #endif // __STACKWALKER_H__ Definition: StackWalker.cpp:249