Reputation: 12882
In a Windows application, if you have a vectored exception handler:
LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS exception)
{
}
...and add it in like this...
AddVectoredExceptionHandler(1, VectoredExceptionHandler);
If the handler is called, you get contextual information on your exception such as the exception code, exception->ExceptionRecord->ExceptionCode
and exception information, exception->ExceptionRecord->ExceptionInformation
. How do you translate this information into a string type (such as TCHAR) that tells the user what the exact problem that occurred was? For example, if you were to write a mini-dump using the WINAPI method, MiniDumpWriteDump
to write a dump file, it will show you details like this in the dump file:
Exception Code: 0xC0000005
Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
I can convert the exception code quite easily, but how would you get such detailed exception information? exception->ExceptionRecord->ExceptionInformation
, which in my environment is a ULONG_PTR
(Windows 8.1 x64 running this application built in Release / x64 Platform / Multi-Byte Character Set) looks like this when I write it out to a tstringstream
: 0000000000A2DF80
Upvotes: 2
Views: 2836
Reputation: 45173
The information is documented as part of the documentation of the EXCEPTION_RECORD
structure:
ExceptionInformation
An array of additional arguments that describe the exception. ... The following table describes the exception codes whose array elements are defined.
EXCEPTION_ACCESS_VIOLATION
The first element of the array contains a read-write flag that indicates the type of operation that caused the access violation. If this value is zero, the thread attempted to read the inaccessible data. If this value is 1, the thread attempted to write to an inaccessible address. If this value is 8, the thread causes a user-mode data execution prevention (DEP) violation.
The second array element specifies the virtual address of the inaccessible data.
Upvotes: 4