简体   繁体   English

通过SEH处理访问冲突

[英]Handling access violations through SEH

I've created a memory manager that allocates memory surrounded by two pages with protection PAGE_NOACCESS. 我创建了一个内存管理器,该内存管理器分配由保护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. 我在SEH块中调用了一个使用此内存的函数,并且捕获了该块中发生的ACCESS_VIOLATION异常(如果有)。 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). 我考虑过改用PAGE_GUARD保护,这可以帮助我确定访问的内存可能来自于受保护的内存,但是不确定(即,用PAGE_GUARD afaik保护堆栈后的内存)。

Any help appreciated :) 任何帮助表示赞赏:)

根据EXCEPTION_RECORD文档 ,尝试的地址存储在ExceptionInformation[1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM