Manual Mapping and EH support menu

Shout-Out

User Tag List

Results 1 to 8 of 8
  1. #1
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Manual Mapping and EH support

    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!
    Last edited by Cypher; 10-06-2010 at 10:43 PM.

    Manual Mapping and EH support
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fixed the links, sorry about that.

    Thanks Namreeb for pointing that out.
    Last edited by Cypher; 10-04-2010 at 03:03 PM.

  3. #3
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is like going into a kindergarten asking kids about quantum physics.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  4. #4
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Worth a try though.

  5. #5
    andy012345's Avatar Active Member
    Reputation
    59
    Join Date
    Oct 2007
    Posts
    124
    Thanks G/R
    0/7
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It really depends on what compiler you're using. C++ exceptions are part of the language, using objects, so different compilers can implement it in different ways.

    Visual C++ implements it by transforming it into SEH and the throw becomes a call to RaiseException. You might want to look there for your answers.

  6. #6
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by andy012345 View Post
    It really depends on what compiler you're using. C++ exceptions are part of the language, using objects, so different compilers can implement it in different ways.

    Visual C++ implements it by transforming it into SEH and the throw becomes a call to RaiseException. You might want to look there for your answers.
    This is obviously Windows-only code and all Windows compilers I can think of use SEH 'under the hood' to implement C++ EH (at least, I think they all do). Yes, they use different methods, but I'm still pretty sure they're all using SEH to handle the low level exception dispatching.

    The problem is that despite all the handlers being correctly registered it's still not working correctly. Compounding that was the fact that previously I couldn't pull down symbols which was making reversing the exception dispatcher way too much work. Now I've gotten WinDbg pulling down symbols correctly but IDA is still being retarded. It happened since I applied the latest patches, I'm gonna need to set up a VM to reverse in I think.

    To make matters even more confusing, C++EH works under x86 targets, even when DEP is enabled and handler validation occurs, because I'm using a VEH to implement my own 'manual' dispatcher (which is currently unfiltered, I know, but it's just a PoC).

    Tl;dr:
    I know where to look, I'm just hoping somebody else might have some clever ideas or notice an obvious bug which could be causing my issues, so I can avoid spending hours and hours tracing through the exception-dispatcher's implementation to work out what the hell is going on.

  7. #7
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MaiN View Post
    This is like going into a kindergarten asking kids about quantum physics.
    rofl so true, makes me semi happy I don't have to worry about this on a mac (Yes I know everyone hates them, not trying to change the topic)
    https://tanaris4.com

  8. #8
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In-case anybody tried compiling and using the ManualMapper recently and noticed it was severely broken, I'm sorry. That was caused by a regression introduced into MemoryMgr::Call when I added code to allow return values to be retrieved that are the full size for the given architecture, rather than being truncated to 32-bits under x64.

    This bug is now fixed and the manual mapper is back to working in the state described in the original post (i.e. currently everything but C++EH works under x64).

Similar Threads

  1. Manual Mapping and SEH Handler Validation (aka SafeSEH)
    By Cypher in forum WoW Memory Editing
    Replies: 8
    Last Post: 03-11-2010, 11:15 PM
  2. [Observation]STV map and India
    By kazi88 in forum World of Warcraft General
    Replies: 22
    Last Post: 06-06-2008, 03:33 AM
  3. All Map And Instance ID's
    By megamoocow in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 05-12-2008, 11:35 AM
  4. [GUIDE] Mining 1-375 With Maps and pictures!
    By -Lex in forum World of Warcraft Guides
    Replies: 13
    Last Post: 04-02-2008, 08:32 AM
  5. Live WoWemu And Mongos support
    By mchugh in forum Suggestions
    Replies: 12
    Last Post: 04-13-2007, 06:54 PM
All times are GMT -5. The time now is 10:51 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search