C# Troubleshooting my endscene detour 3.3.5 (12340) menu

Shout-Out

User Tag List

Results 1 to 12 of 12
  1. #1
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C# Troubleshooting my endscene detour 3.3.5 (12340)

    I stopped writing my wow bot project in order to focus more on uni work. A few days ago I decided to return to it to try to implement some design patterns and clean it up..

    My problem:

    It's been about 4 months since I last tested this project and it seems that the endscene hook that I previously never had a problem with, is causing a major spanner in the works.

    Notes:
    • I'm using visual studio 2010, the original source was written in visual studio 2008. I opened the project in VS2010 and let it do it's conversion thing.
    • The Wow version used for testing is Version 3.3.5(12340).
    • The assembly is loaded from a native bootstrap which is injected using Cypher's Loader_IA32.exe.
    • All code in the function posted below can be debugged.



    Below is a heavily commented test version of the endscene hook.
    Code:
    public static void DetourEndscene()
    {
        //Offsets posted by JuJuBoSc
        //http://www.mmowned.com/forums/world-of-warcraft/bots-programs/memory-editing/300463-wow-3-3-5-12340-info-dump-thread.html
        //public enum Direct3D9
        //{
            
            //    pDevicePtr_1 = 0x00C5DF88,                  // 3.3.5a 12340
            //    pDevicePtr_2 = 0x397C,                      // 3.3.5a 12340
            //    oBeginScene = 0xA4,                         // 3.3.5a 12340
            //    oEndScene = 0xA8,                           // 3.3.5a 12340
            //    oClear = 0xAC,                              // 3.3.5a 12340
            
        //}
        
        
        //Careful reads aren't working.
        //uint pDevicePtr = Magic.Instance.Read<uint>(0x00C5DF88);
        //pDevicePtr = Magic.Instance.Read<uint>(pDevicePtr + 0x397C); //<-- returns 0 here No exception thrown.
        
        
        //uint endSceneAddr = Magic.Instance.Read<uint>(pDevicePtr); // <-- The previous 0 makes this line angry.
        //endSceneAddr = Magic.Instance.Read<uint>(endSceneAddr + 0xA8);
        
        //My original code isn't working.
        //IntPtr endSceneAddr = Magic.Instance.GetObjectVtableFunction
        //(Magic.Instance.Read<IntPtr>(0x0C5DF88, 0x397C), 42); <-- This fails, Hence the above tests
        
        //The code below doesn't install the detour, or detours something
        //that isn't endscene.
        
        //In case the addresses were wrong, I implemented this DirectX class by Apoc / Onyx team.
        //http://www.mmowned.com/forums/world-of-warcraft/bots-programs/memory-editing/299688-finding-direct3d-vmt-table-hook-endscene.html
        IntPtr endSceneAddr = DirectX.GetEndScenePointer();
        
        //WhiteMagic Detour.
        Magic.Instance.Detours.CreateAndApply(Magic.Instance.RegisterDelegate<EndSceneDelegate>(endSceneAddr), EndSceneHandler, "EndScene");
        
        
    }
    I hate to post for help, I've been staring at this for hours and I can't see the solution, Any help would be greatly appreciated.

    C# Troubleshooting my endscene detour 3.3.5 (12340)
  2. #2
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the signature of your EndSceneDelegate?

  3. #3
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This:

    Code:
           //Direct3dEndScene delegate
            [UnmanagedFunctionPointer(CallingConvention.Winapi)]
            public delegate int EndSceneDelegate(IntPtr instance);
            private static readonly EndSceneDelegate EndSceneHandler = EndScene;

  4. #4
    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)
    Try:
    uint devicePtr = *(uint*)((*(uint*)0xC5DF8 + 0x397C);
    If that's zero, then you should control when you are injecting your dll.
    [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

  5. #5
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Main, I tried that, and it was zero.

    Would you mind elaborating on what you mean by controlling when I inject my dll?

  6. #6
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    he means that you are probably executing your dll code before the directx stuff is loaded by wow (can ofc only happen if you are injecting the dll at startup and not while wow is already running)

  7. #7
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow is running, it can be at the login screen or in game. Either way there's no dice here.

    I tried reading from a native module and those reads still returned a zero.

  8. #8
    barthen's Avatar Contributor Authenticator enabled
    Reputation
    94
    Join Date
    Apr 2007
    Posts
    112
    Thanks G/R
    4/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  9. #9
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your post barthen but my endscene hook uses exactly the same code as yours, and your doesn't work for me either.

    It returns I_POINTER to the bootstrap when it tries to read (*(uint*)0xC5DF8 + 0x397C, gets a zero and passes it to GetObjectVtableFunction.

    I started again from the ground up back in VS2008, racking my tiny brain but still no dice.

    I redid the bootstrap and after receiving E_POINTER from ExecuteInDefaultAppDomain I suspected the issue to be the same as mentioned here:

    Link:

    Just to make sure this was covered I added VirtualProtect calls in WhiteMagic (well, I think I did). but it still never managed to solve my issue.

    I gave up on using hard coded offsets to read the pointers to the dx interface because
    Magic.Instance.Read<uint>(pDevicePtr + 0x397C); is always zero when the game is open and the assembly is definately inside it, and that just sux..


    and like I said before:
    Code:
    IntPtr endSceneAddr = DirectX.GetEndScenePointer(); //Using apocs code to be sure
    Magic.Instance.Detours.CreateAndApply(m.RegisterDelegate<EndSceneDelegate>(endSceneAddr), EndSceneHandler, "EndScene");
    executes fine with S_OK to my bootstrap but the function Endscene never gets hit which I'm guessing means no detour.

    I then thought that maybe I was building the WhiteMagic lib all wrong (which is probably the case knowing me) but I used the whitemagic lib included in barthen's post and got exactly the same results. are you positive this code works for you mate? I ran your project on my server2008 machine and it did exactly the same thing as mine


    This is doing my head in, everything looks perfect, if anything it's way neater than it ever was when it was working perfectly.

    Is WhiteMagic still working fine for everyone else? I can't figure out why the detour isn't working and I'm all out of ideas.

  10. #10
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the pointer to the dx device: uint devicePtr = *(uint*)((*(uint*)0xC5DF8 + 0x397C);
    is always zero and you say "everything looks perfect"? not really...

  11. #11
    opulent's Avatar Member
    Reputation
    5
    Join Date
    Apr 2009
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It took me 6 days but I finally got it to work. I have no idea how this solved the issue but it did.

    • I rewrote the bootstrap to include .NET v4.0.X support (get the meat here)
    • I updated all projects in my solution to reflect this change. Now I'm using v4.0.30319 and everything works perfectly.


    Thanks all for your helpful posts..

    Peace.

  12. #12
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of hardcoding the framework version, you could also use Assembly.ImageRuntimeVersion as your version string.

Similar Threads

  1. Endscene Detour
    By unbekannt1 in forum Hearthstone: Heroes of Warcraft
    Replies: 10
    Last Post: 06-05-2014, 03:04 PM
  2. EndScene detour question
    By bad6oy30 in forum WoW Memory Editing
    Replies: 4
    Last Post: 02-23-2011, 05:37 PM
  3. Replies: 11
    Last Post: 01-06-2011, 02:59 PM
  4. Grabbing the DX device in endscene detour
    By ggg898 in forum WoW Memory Editing
    Replies: 0
    Last Post: 09-08-2009, 06:41 AM
All times are GMT -5. The time now is 11:03 PM. 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