July 23, 2024, 08:10:17 AM


IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

Stack walk - SymFromAddr failing

Started by sapero, October 10, 2009, 04:12:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


October 10, 2009, 04:12:43 AM Last Edit: October 10, 2009, 05:02:33 AM by sapero
I have started with dbghelp, have all the required symbols installed and updated, and the _NT_SYMBOL_PATH variable is set correctly. All the debuggers I have are showing me the correct symbols, but this small project - fails even to get the name of SendMessage. Symbols manually added by SymAddSymbol (loaded from .map file) are shown.
My trace looks like this:1 test.exe WorkspaceDlgProc + 6051
2  test.exe WorkspaceDlgProc + 1308
3  USER32.DLL 0x7E368734 // this should be _InternalCallWinProc@20
4  USER32.DLL 0x7E373CE4 // this should be _UserCallDlgProcCheckWow@32
5  USER32.DLL 0x7E373B30 // this should be _DefDlgProcWorker@20
6  USER32.DLL 0x7E37309B // this should be _SendMessageWorker@20
7  USER32.DLL 0x7E3792E3 // this should be _SendMessageW@16
8  test.exe ApplicationSimulateResize + 97
9  test.exe BuildDockUndock + 52
10 test.exe main + 1020
11 test.exe _main + 67

As the trigger for exception, I have sent WM_NOTIFY with invalid lParam to one of my windows. The code uses the .map file to load all global symbols used to build current executable (LoadSymbols subroutine), and the stack trace executes in CallStackThread subroutine.

Debughelp dll is loaded from Aurora/bin, because the one from /system32 does not have SymAddSymbol, and the newest version from /ProgramFiles does not find any symbols (listview is empty).

What I'm doing wrong? Calling SymFromAddr for user32.dll address space, Im getting ERROR_INVALID_ADDRESS error, but after calling SymGetModuleInfo I see that user32.pdb is loaded.

EDIT: found invalid frame.*.Mode initialization, fixed, and still addresses instead names.


I have it working. After fixing the STACKFRAME structure, I've changed dbghelp.dll location to /ProgramFiles/Debugging Tools for Windows:
#include "shlobj.inc" // added

global sub InitializeUnhandledExceptionFilter()
dstring path[MAX_PATH];
// remove cchMax and SHGetValue
SHGetSpecialFolderPath(0, path, CSIDL_PROGRAM_FILES, FALSE);
path += "\\Debugging Tools for Windows\\dbghelp.dll";

HMODULE hMod = LoadLibrary(path);

sub CallStackThread(THREAD_DATA *data)
frame.AddrPC.Offset    = data->ExceptionInfo->ContextRecord->Eip;
frame.AddrPC.Mode      = AddrModeFlat;
frame.AddrStack.Offset = data->ExceptionInfo->ContextRecord->Esp;
frame.AddrStack.Mode   = AddrModeFlat; // fix
frame.AddrFrame.Offset = data->ExceptionInfo->ContextRecord->Ebp;
frame.AddrFrame.Mode   = AddrModeFlat; // fix