Locate modules by stack address
- by PaulH
I have a Winodws Mobile 6.1 application running on an ARMV4I processor. Given a stack address (from unwinding an exception), I like to determine what module owns that address.
Using the ToolHelpAPI, I'm able to determine most modules using the following method:
HANDLE snapshot = ::CreateToolhelp32Snapshot( TH32CS_SNAPMODULE | TH32CS_GETALLMODS, 0 );
if( INVALID_HANDLE_VALUE != snapshot )
{
MODULEENTRY32 mod = { 0 };
mod.dwSize = sizeof( mod );
if( ::Module32First( snapshot, &mod ) )
{
do {
if( stack_address > (DWORD)mod.modBaseAddr &&
stack_address < (DWORD)( mod.modBaseAddr + mod.modBaseSize ) )
{
// Found the module!
// offset = stack_address - mod.modBaseAddr
break;
}
} while( ::Module32Next( snapshot, &mod ) );
}
::CloseToolhelp32Snapshot( snapshot );
}
But, I don't always seem to be able to find a module that matches an address. For example:
stack address module offset
0x03f65bd8 coredll.dll + 0x0001bbd8
0x785cab1c mylib.dll + 0x0002ab1c
0x785ca9e8 mylib.dll + 0x0002a9e8
0x785ca0a0 mylib.dll + 0x0002a0a0
0x785c8144 mylib.dll + 0x00028144
0x3001d95c ???
0x3001dd44 ???
0x3001db90 ???
0x03f88030 coredll.dll + 0x0003e030
0x03f8e46c coredll.dll + 0x0004446c
0x801087c4 ???
0x801367b4 ???
0x8010ce78 ???
0x801086dc ???
0x03f8e588 coredll.dll + 0x00044588
0x785a56a4 mylib.dll + 0x000056a4
0x785bdd60 mylib.dll + 0x0001dd60
0x785bbd0c mylib.dll + 0x0001bd0c
0x785bdb38 mylib.dll + 0x0001db38
0x3001db20 ???
0x3001dc40 ???
0x3001a8a4 ???
0x3001a79c ???
0x03f67348 coredll.dll + 0x0001d348
Where do I find those stack addresses that are missing? Any suggestions?
Thanks,
PaulH