MCPcopy Create free account
hub / github.com/JochenKalmbach/StackWalker / StackWalkerInternal

Class StackWalkerInternal

Main/StackWalker/StackWalker.cpp:249–870  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247#define USED_CONTEXT_FLAGS CONTEXT_FULL
248
249class StackWalkerInternal
250{
251public:
252 StackWalkerInternal(StackWalker* parent, HANDLE hProcess)
253 {
254 m_parent = parent;
255 m_hDbhHelp = NULL;
256 pSC = NULL;
257 m_hProcess = hProcess;
258 m_szSymPath = NULL;
259 pSFTA = NULL;
260 pSGLFA = NULL;
261 pSGMB = NULL;
262 pSGMI = NULL;
263 pSGO = NULL;
264 pSGSFA = NULL;
265 pSI = NULL;
266 pSLM = NULL;
267 pSSO = NULL;
268 pSW = NULL;
269 pUDSN = NULL;
270 pSGSP = NULL;
271 }
272 ~StackWalkerInternal()
273 {
274 if (pSC != NULL)
275 pSC(m_hProcess); // SymCleanup
276 if (m_hDbhHelp != NULL)
277 FreeLibrary(m_hDbhHelp);
278 m_hDbhHelp = NULL;
279 m_parent = NULL;
280 if (m_szSymPath != NULL)
281 free(m_szSymPath);
282 m_szSymPath = NULL;
283 }
284 BOOL Init(LPCSTR szSymPath)
285 {
286 if (m_parent == NULL)
287 return FALSE;
288 // Dynamically load the Entry-Points for dbghelp.dll:
289 // First try to load the newest one from
290 TCHAR szTemp[4096];
291 // But before we do this, we first check if the ".local" file exists
292 if (GetModuleFileName(NULL, szTemp, 4096) > 0)
293 {
294 _tcscat_s(szTemp, _T(".local"));
295 if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES)
296 {
297 // ".local" file does not exist, so we can try to load the dbghelp.dll from the "Debugging Tools for Windows"
298 // Ok, first try the new path according to the architecture:
299#ifdef _M_IX86
300 if ((m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0))
301 {
302 _tcscat_s(szTemp, _T("\\Debugging Tools for Windows (x86)\\dbghelp.dll"));
303 // now check if the file exists:
304 if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
305 {
306 m_hDbhHelp = LoadLibrary(szTemp);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected