views:

29

answers:

1
+1  Q: 

Exception handling

I was trying to write a code to handle exceptions, but overriding another exception handler, is it possible?

I was developing an exe in asm to debug a dll, and detect some exceptions that are raised (access violation) but the dll has its own exception handling, so a normal SEH should not work, i would like to know if there is any kind of global exception handler that could override these existing ones.

Thanks in advance.

+2  A: 

Take a look at Vectored Exception Handling (http://msdn.microsoft.com/en-us/library/ms681420.aspx). The page states that "An application can register a function to watch or handle all exceptions for the application. Vectored handlers are not frame-based, therefore, you can add a handler that will be called regardless of where you are in a call frame. Vectored handlers are called in the order that they were added, after the debugger gets a first chance notification, but before the system begins unwinding the stack."

Patrick
Oh, Thanks, it seems to work nice for me, but i also wanted to ask, can you give me some extra-info about this handling? i mean, i wanted infos like the address where the problem happened, wich kind of exception, and if it was an access violation, where it tried to write/read
Information about the exception are passed to your exception handler function. http://msdn.microsoft.com/en-us/library/ms681419.aspx explains the exception handler and its argument. On http://msdn.microsoft.com/en-us/library/aa363082.aspx you find a description about the exception record that is part of the exception pointers argument of your exception handler. It includes the exception code and the address where the exception occurred. http://msdn.microsoft.com/en-us/library/cc301714.aspx gives some under the hood explanations.
Patrick
You can use SetUnhandledExceptionFilter() API, but your handler will be called after all other handlers.
ruslik