Question

I've created a memory manager that allocates memory surrounded by two pages with protection PAGE_NOACCESS. I call a function that uses this memory in a SEH block, and I catch ACCESS_VIOLATION exceptions (if any) that happens in this block. Now, in my exception handler, is it possible to retrieve the address that the program didn't have rights to access? I know you can get a pointer to the faulting instruction, but then you would have to actually parse the assembly?

This is so I know whether the violation was caused in my guarded memory (from which I can continue execution; this can be expected behavior) or if it was another (unknown) place, from which i probably would have to terminate the process. I thought about using PAGE_GUARD protection instead, which would help me identify that the memory accessed could have been from my guarded memory, but it is not certain (ie. the memory after the stack is protected with PAGE_GUARD afaik).

Any help appreciated :)

Was it helpful?

Solution

The attempted address is stored in ExceptionInformation[1], as per the EXCEPTION_RECORD documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top