Hi there. Since I want to start working on "semi-injected" work, I recently started working on different ways to inject my code in external processes using .NET, may it be with a DLL or without one. I started working on something pretty interesting, hooking thread using VEH/SEH (Vectored/Structured Exception Handlers). The idea of adding my own handler on top of the VEH structure seemed pretty interesting seeing how quick it is to just link/unlink your handler to the list and because this handler would be one of the firsts (if not the first) handlers called, resulting in a lot faster hooks.
However when doing my tests I realized that the application (WoW, in my test) is constantly overwriting the first VEH entry in the linked list with its own exception handler. I then tried to add it to the end of the list, but it seems like this made the exceptions never get to my handler.
By using SetUnhandledExceptionFilter WinAPI to add my handler the exception handler does get called, but from what I read the SEH entries are getting called later than VEH entries, which could be bad for performances.
I would like to get some comments on what you think may be the cause of the overwrite (does SEH bases on VEH structure to work?), and if it would be possible for me to add my exception handler to the top of the the list. Additionally, I would like to know if anyone knows how the SetUnhandledExceptionFilter WinAPI works internally, is it a different structure than the VEH or are those working together?
Tl;dr: Gief info on how to have my handler on top of the 'list' and explain how SEH works internally.
I will continue searching about this on the web, but I have to say the information about those are often limited on how to call it / use it in a simple ASM-coded program.
Thanks in advanced for any help / heads up!