You need to put the code for this in your exception filter, by the time you get to the exception handler, most of the context information for the exception has been lost.
try {
Your filter will look something like this.
LONG WINAPI MyExceptionFilter ( EXCEPTION_POINTERS * pExcept, BOOL fPassOn) { EXCEPTION_RECORD * pER = pExcept->ExceptionRecord; DWORD dwExceptionCode = pER->ExceptionCode; TCHAR szOut[MAX_PATH*4]; // exception output goes here. szOut[0] = 0; MEMORY_BASIC_INFORMATION mbi; DWORD cb = VirtualQuery (pER->ExceptionAddress, &mbi, sizeof(mbi)); if (cb == sizeof(mbi)) { TCHAR szModule[MAX_PATH]; if (GetModuleFileName ((HMODULE)mbi.AllocationBase, szModule, MAX_PATH)) { wsprintf(szOut, "Exception at '%s' + 0x%X", szModule, (ULONG_PTR)pER->ExceptionAddress - (ULONG_PTR)mbi.AllocationBase); } } return EXCEPTION_EXECUTE_HANDLER; }
Of course, you will need to adjust the bit a bit for 64-bit architectures, because in this case ExceptionAddress and AllocationBase will have 64-bit values.
John knoeller
source share