- Obtain the crash address.
- Look for an address bigger than the crash address in the map file and note the preceding address.
- Calculate the offset.
crash_address - preferred_load_address - 0x1000 = offset
- Look for a greater offset value in the line number section of the .map file.
- Note the line number of the previous offset value.
Although the procedure successfully identifies the exact line number for a forced crash in my Win32testApp
app (i.e. char* pEmpty = NULL; *pEmpty = 'x')
it doesn't appear to be as accurate in my equivalent MFCtestApp.
In the MFC test the calculations only ever point to the entry point of the function with the crash, and not the line number itself. I suspect it has something to do with Win32's InitInstance() vs MFC's CTestApp::InitInstance(), which is in a class. This is just a hunch.
I would appreciate any ideas on how to make your procedure work with both Win32 and MFC applications. I can send you the two VC projects with their map files if more convenient (115k and 200k). Any help would be most appreciated. Thank you very much.
This was first published in September 2003