Hooked GetProcAddress not picking up request for Direct3DCreate9 menu

User Tag List

Results 1 to 6 of 6
  1. #1
    revertlife's Avatar Private
    Reputation
    11
    Join Date
    Jun 2010
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hooked GetProcAddress not picking up request for Direct3DCreate9

    I wrote the following code for my injected DLL which uses the EasyHook LocalHook to hook LoadLibraryA and GetProcAddress. The LoadLibraryA hook picks up that the client loads d3d9.dll (but it's loaded 3 times apparently...) and GetProcAddress picks up a bunch of other functions, but never Direct3DCreate().

    Does anyone know why this might be or could point me in the right direction?

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Runtime.Remoting;
    using EasyHook;
    using System.Windows.Forms;
    using System.Diagnostics;
    
    namespace DllInjector
    {
    
        public class Main : EasyHook.IEntryPoint
        {
            WoWInterface Interface;
            LocalHook GetProcAddrHook, LoadLibHook,D3DCreateHook;
            IntPtr d3dHandle;
    
            public Main(RemoteHooking.IContext InContext, String InChannelName)
            {
              Interface = RemoteHooking.IpcConnectClient<WoWInterface>(InChannelName);
              Interface.WriteConsole("LOL LOADED");
            }
    
            public void Run(RemoteHooking.IContext InContext, String InChannelName)
            {
                try
                {
                    Interface.WriteConsole("LoadLibraryA Location: 0x" + LocalHook.GetProcAddress("kernel32.dll", "LoadLibraryA").ToString("X8"));
                    Interface.WriteConsole("GetProcAddress Location: 0x" + LocalHook.GetProcAddress("kernel32.dll", "GetProcAddress").ToString("X8"));
                    GetProcAddrHook = LocalHook.Create(LocalHook.GetProcAddress("kernel32.dll", "GetProcAddress"), new DGetProcAddress(_GetProcAddress), this);
                    LoadLibHook = LocalHook.Create(LocalHook.GetProcAddress("kernel32.dll", "LoadLibraryA"), new DLoadLibraryA(_LoadLibraryA), this);
                    GetProcAddrHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
                    LoadLibHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
                }
                catch (Exception ExtInfo)
                {
                    Interface.WriteConsole("Error: \r\n" + ExtInfo.ToString());
                }
                Interface.WriteConsole("GetProcAddress Hooked");
                while (true)
                {
    
                    //Byte[] playerName;
                    try
                    {
    
                        //Interface.WriteConsole(playerName.ToString() + "    -    ");
                    }
                    catch (Exception ExtInfo)
                    {
                        Interface.WriteConsole("Error: " + ExtInfo.ToString());
                    }
                }
            }
    
            public void HookD3DCreate9()
            {
    
            }
    
           [UnmanagedFunctionPointer(CallingConvention.StdCall,
                CharSet = CharSet.Unicode,
                SetLastError = true)]
            delegate IntPtr DGetProcAddress(
                IntPtr hModule,
                IntPtr lpProcName);
    
            // just use a P-Invoke implementation to get native API access from C# (this step is not necessary for C++.NET)
            [DllImport("kernel32.dll",
                CharSet = CharSet.Unicode,
                SetLastError = true,
                CallingConvention = CallingConvention.StdCall)]
            static extern IntPtr GetProcAddress(
                IntPtr hModule,
                IntPtr lpProcName);
    
    
            static IntPtr _GetProcAddress(IntPtr hModule, IntPtr lpProcName)
            {
                Main This = (Main)HookRuntimeInfo.Callback;
    
                lock (This)
                {
                    This.Interface.WriteConsole("Function loaded");
                    if (This.d3dHandle == hModule)
                    {
                        This.Interface.WriteConsole("Function loaded from target library: " + Marshal.PtrToStringAnsi(lpProcName));
                    }
    
                    if (Marshal.PtrToStringAnsi(lpProcName) == "Direct3DCreate9" || Marshal.PtrToStringUni(lpProcName) == "Direct3DCreate9")
                    {
                        This.Interface.WriteConsole("Function loaded from target library: " + Marshal.PtrToStringAnsi(lpProcName));
                    }
                }
    
                if (Marshal.PtrToStringAnsi(lpProcName) == "GetProcAddress")
                {
                    lock (This)
                    {
                        This.Interface.WriteConsole("GetProcAddress on... GetProcAddress");
                    }
                }
    
                return GetProcAddress(hModule, lpProcName);
            }
    
            [UnmanagedFunctionPointer(CallingConvention.StdCall,
            CharSet = CharSet.Unicode,
            SetLastError = true)]
            delegate IntPtr DLoadLibraryA(
                IntPtr lpProcName);
    
            // just use a P-Invoke implementation to get native API access from C# (this step is not necessary for C++.NET)
            [DllImport("kernel32.dll",
                CharSet = CharSet.Unicode,
                SetLastError = true,
                CallingConvention = CallingConvention.StdCall)]
            static extern IntPtr LoadLibraryA(
                IntPtr lpProcName);
    
    
            static IntPtr _LoadLibraryA(IntPtr libName)
            {
                try
                {
                Main This = (Main)HookRuntimeInfo.Callback;
                String strLibName;
               
                strLibName = Marshal.PtrToStringAnsi(libName);
                lock (This)
                {
                    This.Interface.WriteConsole("Loading library....  "+ strLibName);
    
                }
                if (strLibName == "d3d9.dll")
                {
                    lock (This)
                    {
                        This.Interface.WriteConsole("Target Library loaded: " + strLibName);
                        This.d3dHandle = LoadLibraryA(libName);
    
    
    
    
                        return This.d3dHandle;
                    }
    
                }
                }
                catch (Exception ExtInfo)
                {
                    MessageBox.Show("Exception: " + ExtInfo.ToString());
                }
                
                return LoadLibraryA(libName);
            }
        }
    }

    Hooked GetProcAddress not picking up request for Direct3DCreate9
  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)
    Who says that Direct3DCreate9 has to be called via GetProcAddress? It could just be statically imported.

  3. #3
    revertlife's Avatar Private
    Reputation
    11
    Join Date
    Jun 2010
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I checked the binary imports for WoW and none of the Direct3D functions are static imports.

    Also, in the disassembly Direct3DCreate9 is loaded via GetProcAddress. There are references to alGetProcAddress and alcGetProcAddress but I couldn't find any info for those functions

  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)
    Well in that case, fiik.

  5. #5
    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)
    Are you sure you're injecting your DLL at the correct time? It needs to be done very early in the startup process to be able to hook Direct3DCreate9 and get a valid result.
    [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

  6. #6
    revertlife's Avatar Private
    Reputation
    11
    Join Date
    Jun 2010
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do an external call to CreateProcess with the suspend flag and then I inject the DLL and it hooks LoadLibraryA and GetProcAddress and then the host process resumes the main WoW thread so it's hooked before it is even executed for the first time

Similar Threads

  1. Request for Glider
    By hackxor in forum World of Warcraft General
    Replies: 12
    Last Post: 02-14-2007, 03:30 PM
  2. Tauren male to Orc male request for patch 2.0.1 plz :(
    By marshymallow in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 01-03-2007, 10:19 PM
  3. Few Requests for Tauren Hunter
    By Zacharisjosepi in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 12-24-2006, 05:57 PM
  4. continued requests for stuff add me to MSN
    By sudnrage111 in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 10-04-2006, 10:08 AM
  5. Model Editing Request for Race Conversion and Other
    By #ClumsyWizard in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 10-03-2006, 10:27 PM
All times are GMT -5. The time now is 06:47 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