Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 21:41

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Direct 3D Hooking

Discussion on Direct 3D Hooking within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1




 
gotstyle's Avatar
 
elite*gold: 71
Join Date: Apr 2004
Posts: 7,164
Received Thanks: 3,096
DIRECT3D8 HOOKING:


Required Skills:

BASIC ASM programming - Necessary for making the hook code.
CODE Injection - Necessary for setting the hook code.
Debugging skill - Necessary for finding the Method Calls. Or
Hooking of Exports ? Necessary unless you plan to use a debugger.

Desired Skills:

C++ programming - if you want to exploit the hook, you'll have to be able to code for D3D.
DLL Injection - makes Code Injection a walk in the park.


If you can Program (if not you will have a hard time) then you can do this pretty much without anything except your target program, your skill and your compiler. If you are unsure of your programming skills then you can use a Debugger to do all the preliminary work. Here is a basic Over-View of the process.

1.) Hook the call to Direct3DCreate8 - BPX it or make a program to hook it
1.)Keep a record of where this is called from, you will need that info later
2.)Find out what it happens to the return value from this call

The purpose of hooking Direct3DCreate8 is ONLY so that you are able to hook CreateDevice, you want to hook CreateDevice so that you get the Device Interface, Necessary if you plan to DO anything with your Hook, and you want to hook EndScene because this is most likely the place that you will be DOING things at.



2.) IF the return value is stored in a hard-coded location then there is no need to hook this call to keep track of this important value, if however it is stored in moving location, you will have to.

3.)Once you have access to the return value you will need to calculate from it Where CreateDevice is at

4.)Hook CreateDevice again either BPX or hook it with your program?

5.)Grab the Pointer to your Device Interface and from that Calculate the address of EndScene (or any other function you want to hook)

6.)Hook EndScene .. you know 

After you do The Steps Listed above you have enough Information to take over the screen. You simple keep a pointer to the Device Interface, and Hook EndScene, you don?t need to worry about Direct3DCreate8 once you have the addies that call CreateDevice and EndScene in most cases.

Since I am only covering the Hooking of Direct3D here and not the use of the Hooks once Installed That is as far as I will go here. Now for a more thorough explanation of each step.

Hook the call to Direct3DCreate8.
If you are using a debugger to do this part by hand then I expect you to know how to use it, I am not going to tell you how to set breakpoints. If you are Hooking this with a program then a required skill Is knowledge of how to set hooks.
Your main objective here is retrieving the Return Value from this call since you have to have it to calculate Where CreateDevice is
Once you have the return Value from that call, then you need to go from Pointer to Com Object, to Pointer to Structure of Pointers, to Pointer to CreateDevice, this would take many words to explain something simple, so ill show you what I Mean in ASM (BASIC ASM = REQUIRED SKILL), Assuming you have the Return Value in EAX then

MOV EBX, DWORD PTR [EAX]
MOV ECX, DWORD PTR [EBX]

Now EAX, holds PTR to COM, EBX holds PTR to STRUCT, and ECX Points to first BYTE of CreateDevice

This is because the first member of the COM OBJECT is a pointer to The Structure, and the Fist member of the Structure is a pointer to CreateDevice.

At this Point you Should Hook CreateDevice, so that you can find out where it gets called from. AND grab the Pointer to your Device Interface. When your hook catches a call to CreateDevice DWORD PTR [esp]= Where it was called from and DWORD PTR [esp+24]=Where the pointer to Device Interface will be stored so grab those values.
(man I get headaches from all these Pointers to Pointers to Pointers?..)

After CreateDevice returns, you will want to hook EndScene. Soooo?
Have In EAX the value you grabbed from [ESP+24] above
MOV EAX, DWORD PTR [EAX]
MOV EBX, DWORD PTR [EAX]
MOV ECX, DWORD PTR [EBX+8Ch]

Now ECX points to the first Byte of EndScene, Hook This to Find Where It gets Called From.

Congratulations, now you have all the information you need to fiddle around with the screen while the game is running
gotstyle is offline  
Old 12/24/2006, 17:13   #2
 
elite*gold: 0
Join Date: Sep 2006
Posts: 774
Received Thanks: 8,580
good tutorial for beginners.. i am new to d3d tho, but i am going to try this later
phize is offline  
Old 12/24/2006, 17:14   #3
 
elite*gold: 0
Join Date: Sep 2006
Posts: 774
Received Thanks: 8,580
i dont see why asm is required here btw, i can do this in c/c++
phize is offline  
Old 12/25/2006, 23:59   #4
 
elite*gold: 0
Join Date: May 2005
Posts: 232
Received Thanks: 52
well first of all that is not for beginner
this tutorial is based on reversing a game so you can hook a function (i.e DirectX calls,draw_endframe etc ) and dont need to callback/wrap/whatever the directxcall.
of course you can do this by hooking directx dlls also (that is what you mean :P)
emjay is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
C++ D3D Hooking
08/24/2009 - C/C++ - 12 Replies
Hallo zusammen, ich stehe gerade vor folgendem Problem: ich habe eine DLL und einen Loader gecoded, jedoch will ich anstelle des Loader einen Injecter haben, sprich: das spiel, in das injected werden soll, soll schon laufen. Natürlich hab ich das ganze schon probiert, jedoch werden die D3D-funktionen nicht wirklich gehookt, da die DLL auf ein Direct3DCreate9 wartet. Da diese Funktion aber wahrscheinlich direkt beim Starten des "Opfer-Spiels" ausgeführt wird, werden deswegen die anderen...
D3D9 Hooking
06/06/2009 - General Coding - 1 Replies
Guten Abend die Damen und Herren. Wie im Titel des Threads angegeben geht es um D3D9 Hooking. Die implementierung von den folgenden interfaces als Proxy habe ich bereits erstellt: IDirect3D9 -> D3D9Impl IDirect3DBaseTexture9 -> D3DBaseTex9Imp IDirect3DCubeTexture9 -> D3DCubeTex9Imp IDirect3DDevice9 -> D3DDevice9Imp
D3D Hooking [autoit]?
04/17/2009 - GW Bots - 11 Replies
edited
hooking lua_CFunctions
04/27/2008 - WoW Exploits, Hacks, Tools & Macros - 10 Replies
leute die damit was anfangen können ^^ hier schenk ich euch, ich danke kynox da er so freundlich war mir das mitzuteilen 2 parameters: eax = addresse von der CFunction, ecx = name das lua verwendet 00692440 > 55 PUSH EBP 00692441 8BEC MOV EBP,ESP 00692443 56 PUSH ESI 00692444 E8 A7FFFFFF CALL WoW.006923F0 ; mov eax, L ( the lua_State ) 00692449 8BF0 MOV ESI,EAX 0069244B 8B45 0C MOV...
Another way of Hooking -> PeterPan
03/21/2008 - General Coding - 6 Replies
Hi, i wanted to share some ideas and looking for ideas/comments. Some of you might already have read about Hooking code (Detours,etc). PeterPan tries to install the Hook in a more generic&easier way. The old approach It works like this: We take CreateFileA as an example. Looking at the disassembly you will see:



All times are GMT +1. The time now is 21:42.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.