Problem with DirectX CreateDevice Hooking menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with DirectX CreateDevice Hooking

    Hi,

    I'm trying to Hook CreateDevice (using Dll Injection), but it didn't got called.
    Direct3DCreate is called twice, here's the log:

    [22:40:54]: Direct3DCreate9( 32 ) got called, result: 0x00DC2280
    [22:40:54]: Adding a detour at 0x6DBFF52D(0x6CF718A, name: CreateDevice
    [22:40:54]: Direct3DCreate9( 32 ) got called, result: 0x00DC2280

    The code below is executed after my own dll is loaded (HookD3D), any idea??

    Code:
    typedef long ( WINAPI * tCreateDevice )( IDirect3D9 * pThis, UINT Adapter, DWORD DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, void * pPresentationParameters, IDirect3DDevice9 ** ppReturnedDeviceInterface );
    tCreateDevice oCreateDevice = 0;
    
    long WINAPI hook_CreateDevice( IDirect3D9 * pThis, UINT Adapter, DWORD DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, void * pPresentationParameters, IDirect3DDevice9 ** ppReturnedDeviceInterface )
    {
    	HRESULT hResult = oCreateDevice( pThis, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface );
    	DBGLOG( "oCreateDevice got called, window handle: 0x%08X\n", hResult, hFocusWindow );
    	IDirect3DDevice9 * pDevice = *ppReturnedDeviceInterface;
    
    	gpWoWX->SetWindowHandle( hFocusWindow );
    	
    	return hResult;
    }
    
    typedef void * ( __stdcall * tDirect3DCreate9 )( UINT SDKVersion );
    tDirect3DCreate9 oDirect3DCreate9 = 0;
    
    void * WINAPI hook_Direct3DCreate9( UINT SDKVersion )
    {
    	void * pDirect3D = oDirect3DCreate9( SDKVersion );
    	
    	DBGLOG( "Direct3DCreate9( %i ) got called, result: 0x%08X\n", SDKVersion, pDirect3D );
    
    	if( !gpWoWX->GetPatcher()->GetPatchByName( "CreateDevice" ) )
    	{
    		/*
    			012D747D   8B0E             MOV ECX,DWORD PTR DS:[ESI]               ; d3d9.6DE906D0
    			012D747F   8B51 40          MOV EDX,DWORD PTR DS:[ECX+40]
    		*/
    		oCreateDevice = *(tCreateDevice*)( *(DWORD*)pDirect3D + 0x40 );
    		gpWoWX->GetPatcher()->AddDetour( &(PVOID&)oCreateDevice, (PBYTE)hook_CreateDevice, "CreateDevice" );
    	}
    
    	return pDirect3D;
    }
    
    void HookD3D()
    {
    
    	HMODULE hD3d9 = LoadLibraryA( "d3d9.dll" );
    
    	if( !hD3d9 )
    	{
    		MessageBoxA( 0, "d3d9.dll couldn't be loaded.", "Fatal error", 0 );
    		ExitProcess( 0 );
    		return;
    	}
    
    	oDirect3DCreate9 = (tDirect3DCreate9)GetProcAddress( hD3d9, "Direct3DCreate9" );
    	gpWoWX->GetPatcher()->AddDetour( &(PVOID&)oDirect3DCreate9, (PBYTE)hook_Direct3DCreate9, "Direct3DCreate9" );
    
    	DBGLOG( "D3D initialized\n" );
    }

    Problem with DirectX CreateDevice Hooking
  2. #2
    boredevil's Avatar Active Member
    Reputation
    46
    Join Date
    Feb 2008
    Posts
    166
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could try to igore the first call and apply your detour when it gets hit the second time. don´t ask why i don´t know. but that did the trick for a friend of mine

  3. #3
    DarkLinux's Avatar Former Staff
    CoreCoins Purchaser Authenticator enabled
    Reputation
    1627
    Join Date
    May 2010
    Posts
    1,846
    Thanks G/R
    193/539
    Trade Feedback
    16 (100%)
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Set a breakpoint and go line by line and see if your detour is working... I'm lazy and use Microsoft Detours Take a look how I do it if you want http://www.ownedcore.com/forums/worl...n-scanner.html (EverScan - An Open Source Warden Scanner)


    Also I cant really tell but are you detouring it from the vtable? Sounds like your detouring it on a specific call...
    Last edited by DarkLinux; 11-28-2012 at 11:37 AM.

  4. #4
    Master674's Avatar Elite User
    Reputation
    487
    Join Date
    May 2008
    Posts
    578
    Thanks G/R
    2/23
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved, Thank you all!
    I made a stupid mistake, I'm hooking Direct3DCreate9, but the game is using DirectX 11 by default

Similar Threads

  1. [Bot] Problems with the hook during loading screen
    By Xzord in forum WoW Memory Editing
    Replies: 7
    Last Post: 01-15-2015, 03:45 PM
  2. Hooking DirectX CreateDevice
    By nitrogrlie in forum WoW Memory Editing
    Replies: 13
    Last Post: 01-22-2010, 02:46 PM
  3. Problem with BWH 1.11.2
    By gwl15 in forum World of Warcraft General
    Replies: 3
    Last Post: 08-11-2006, 05:37 PM
  4. Problem with CE.
    By Eldretch in forum World of Warcraft General
    Replies: 1
    Last Post: 08-08-2006, 06:49 PM
  5. I have problem with BHW 3.0
    By sunrize1 in forum World of Warcraft General
    Replies: 1
    Last Post: 07-17-2006, 08:49 AM
All times are GMT -5. The time now is 05:06 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