Hey all, as some of you may already know, one of the modules in my HadesMem project is a manual mapper. The overall aim is to write a stable and reliable manual mapper for both x86 and x64.
Currently I have the basics working under both architectures (imports, relocs, sections, etc), however I'm having a bit of trouble with getting exception handling working.
Because of new security mechanisms in Windows, for targets with DEP enabled you can no longer just inject your code and run it, as exception handlers are now validated. So I'm using a VEH under x86 to 'manually' dispatch exceptions. Currently the code is a disgusting hack, but it's only a PoC, and it works, so that's all fine.
The real problems are occurring under x64 targets. At the moment I have SEH working, but C++ EH is not. Under x64 I'm using the 'RtlAddFunctionTable' to add the handlers for my module to the list, and that is working great for SEH, however whenever I throw a C+++ exception it goes unhandled. I ensured that the number of handlers being added by the API was correct by checking it against the number dumped by PEDUMP, and now I'm at a loss as to what could be causing it to bomb out.
Anyway, sorry for the long intro. Tl;dr version is:
Under x64 targets, exception handling is not working in my manual mapper. SEH works fine in my tests, but C++ EH is not. My C++ exceptions are going unhandled.
If anyone could please take a look at my code and point out any flaws they see that could be causing this particular bug it would be hugely appreciated. I've tried to reverse the exception dispatcher but the symbol server is being retarded and I can't get symbols for my build of Windows for some reason. (I'm gonna set up a VM soon, but I'm not even sure if reversing the dispatcher is gonna help, as I have no idea where to begin.)
Code here:
http://code.google.com/p/hadesmem/so...er/DllMain.cpp <-- The module I'm mapping.
http://code.google.com/p/hadesmem/so.../ManualMap.cpp <-- Manual mapper code
http://code.google.com/p/hadesmem/so...ry/ManualMap.h <-- Manual mapper code
http://code.google.com/p/hadesmem/so...nDbgManMap.lua <-- Script to pass to sandbox (WinDbg is the target I'm mapping into)
Also, if you see any other problems with the manual mapper feel free to point them out. I'm aware of some of them, but have been too lazy to tag them, so I may already know, but then again, you may see something I've overlooked, so please, go nuts, and be brutal! The more bugs you can find the better!
P.S. If you want me to post binaries so you can test without having to compile everything yourself please let me know and I'll upload them.
P.P.S. Yes, the code is a cluster**** of failure at the moment. Sorry about that, but like I said, it's currently only a PoC and undergoing heavy testing and changes, so bear with me. Don't let that stop you from pointing out any problems you see though! Again, be brutal!