Overriding CreateDevice menu

User Tag List

Results 1 to 3 of 3
  1. #1
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Overriding CreateDevice

    Hi everyone,

    I am trying to hook EndScene in C# but I am still far away. Project BabBot is using the approach listed at Programming Stuff: Hooking Direct3D9 with C#. and I was trying this too.

    BabBot's/my approach is to start WoW as suspended and after that hook Direct3DCreate9. I am able to do this but then after overriding functions from VF table my CreateDevice() is never executed and I have no idea why.

    Can anyone help on this (my code snippets from the injected DLL follow)?

    Initialize VF table.
    Code:
    private void InitializeVFTable()
            {
                // If we don't have a real IDirect3D9 object yet then do nothing.
                if (NativeIDirect3D9 == null) return;
                
                // Save off the original VFTable (only if it really is the original).
                if (OriginalVFTable == null) OriginalVFTable = NativeIDirect3D9->VFTable;
                
                // IDirect3D9 has 17 members.
                UInt32 VFTableLength = 17;
                // Allocate space for our new VFTable.
                IntPtr* NewVFTable = (IntPtr*)Win32.Kernel32.HeapAlloc(Win32.Kernel32.GetProcessHeap(), 0, (UIntPtr)(VFTableLength * sizeof(IntPtr)));
                
                // Copy all of the original function pointers into our new VFTable.
                for (int i = 0; i < VFTableLength; i++)
                {
                    NewVFTable[i] = OriginalVFTable[i];
                }
                
                // Set the Real IDirect3D9 implementation's VFTable to point at our custom one.
                NativeIDirect3D9->VFTable = NewVFTable;
            }
    Override functions method. Last log I can see is "Overriding ...".
    Code:
    private void OverrideFunctions()
            {
                // this is the last log I can see
                HookedDLL.Hook.LoggingInterface.L("Overriding ...");
                InitializeVFTable();
    
                // #16: STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) PURE;
                DelegateCreateDevice MyCD = new DelegateCreateDevice(CreateDevice);
                IntPtr PointerToMyCD = Marshal.GetFunctionPointerForDelegate(MyCD);
                NativeIDirect3D9->VFTable[16] = PointerToMyCD;
            }
    This never is executed. Strangly it works for BabBot creators.
    Code:
           public delegate uint DelegateCreateDevice(
                Win32.D3D9.IDirect3D9* This, uint adapter, uint deviceType, IntPtr focusWindow, uint behaviorFlags,
                IntPtr presentationParameters, Win32.D3D9.IDirect3DDevice9* deviceInterface);
    
            public uint CreateDevice(Win32.D3D9.IDirect3D9* This, uint adapter, uint deviceType, IntPtr focusWindow,
                                     uint behaviorFlags, IntPtr presentationParameters,
                                     Win32.D3D9.IDirect3DDevice9* deviceInterface)
            {
                // never executed
                HookedDLL.Hook.LoggingInterface.L("CreateDevice Start ...");
                
                return 1;
            }
    I hope I described my problem clearly. If not just tell me what you need to know to at least try to help on this.
    Last edited by Viano; 08-23-2009 at 10:38 AM.
    Viano

    Overriding CreateDevice
  2. #2
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As 3 posts from this thread magicly vanished after the server downtime, I beg you all for help once more. I am able to hook Direct3DCreate9 and then create a new native IDirect3D object but fail at overriding CreateDevice() for some ****ing unknown reason. I am stuck with this over weeks now :-/

    I am attaching all relevant code this time. I hope some will point me in the right direction.

    Starting WoW, Injecting DLL, Resuming WoW.
    C# pastebin - collaborative debugging tool

    Hooking Direct3DCreate9. Everything fine in here.
    C# pastebin - collaborative debugging tool

    CreateDevice is never reached. This is the place where shit happens.
    C# pastebin - collaborative debugging tool

    Maybe it is just bad timing and CreateDevice() is executed somewhere else by WoW? Is this possible?
    Last edited by Viano; 09-05-2009 at 05:54 AM.
    Viano

  3. #3
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dunno, I don't code in C#, so this is pretty alien to myself. You might want to call the original Direct3DCreate9 and then pass that to your MyDirect3D, like this:

    (Don't know what C# would look like)
    IDirect3D9 * pDirect3D = originalDirect3DCreate9( SDKVersion );

    then pass that to your MyDirect3D or whatever it is.

    return pDevice;


    Also, in your CreateDevice callback or whatever you want to call it, you do Win32.D3D9.IDirect3DDevice9* deviceInterface, which I do in C++ like:

    IDirect3DDevice9 ** ppReturnedDeviceInterface,

    so should yours not be "Win32.D3D9.IDirect3DDevice9 ** ppDeviceInterface"?

    Just bare with my, I don't know limitations of C# or anything with pointers. :>

Similar Threads

  1. Command Overrides?
    By daggetoface in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 08-23-2009, 01:42 PM
  2. Item Sheath Display - An override for Ranged to show for all players?
    By KinkyKing in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 08-17-2009, 12:14 PM
  3. Commnad Override
    By delldude1989 in forum World of Warcraft Emulator Servers
    Replies: 11
    Last Post: 05-18-2008, 02:05 AM
  4. command override
    By Denelly in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 02-27-2008, 05:39 PM
  5. [Command OverRide] HALP! i are most confuseded :[
    By Ghosthopper in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 01-24-2008, 11:34 PM
All times are GMT -5. The time now is 05:57 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