[C++] D3D9 Hooking via Detours
Chapter 1
DirectX9.0 - 11 Hooking via C++
Ok, so beings that this was requested, I decided to write this up. I hope this helps someone and if not, sorry First and for most, this tutorial is strictly for DirectX9 and I guarantee you it will not work for other versions without some major editing in the wrapper. At the end of this I will also include some instructions on how to turn this injected hook into a wrapper to the point where you can just compile it as d3d9.dll and drop it into your games directory and run it via that method too.
(I suggest the "wrapper" method as most cheat detections don't find it as a hack due to some machines needing the d3d9.dll in that folder to work.)
I am writing this tutorial to be used with C++ but you can translate it to what ever language you wish to program in as it's pretty basic and not too major. The wrapper is where the most work comes to play so you will need to do that on your own. Sorry, I don't know other languages outside of C++, MASM, and VB2010 so you are on your own when translating.
Part 1. Introduction and Such
Before we begin, let me go over what this does and how it works. Firstly, this main tutorial method is via injection. What this does is creates a remote thread in the process as its starting up and injects your hook and calls its DllMain (or main function of the DLL) and hooks the Direct3D9Create function. From there, when the game, or DX app you are using calls Direct3D9Create, it will call your hooked function instead of the original. When that happens, instead of using the default DirectX functions, it will use your wrapper "proxy" functions that are modified to your need and such. This allows you to add to the game, or app, such as wireframe, colored primitives, etc. Such things you see in hacks and so on.
Along with that, it opens up the window for any other extra feature(s) you can come up with on your own. The boundaries are small, just what you are able to do and such.
This tutorial is going to explain how to do the basics, create the hook, show an example wrapper, and explain a few small things along with the hook. I will include a full example as well that I will find some random free program to show you how it works and such in as well. I will add wireframe mode to a toggle key to show you how to add some of your own code into the hook as well
Part 2. Tools Needed
This is a small list of the things you will need to be able to use this tutorial.
Microsoft Visual Studio 2010
You do not need the full version to create things, you can use the express edition as far as I know to compile things as long as they are non-commercial (from what I was told). If not, find the full version on a warez site or be nice and purchase it
Microsoft Detours Library 1.5
Download from MS
Due to some unknown reason, the makers of the Detours library have removed the functions used in this tutorial from the new version. So you will need to download a precompiled version here
Microsoft DirectX 9.0c SDK
And again, another free download from Microsoft for developers. (Aren't they so nice to programmers)
Note: You need to have a real version of Windows for this download so if you don't, just google around for it. I don't think the version matters.
I used the July 2005 update for most of my old projects, but have installed the Mai 2009 version and my stuff still compiles fine so either should be ok.
Misc Tools
HERE For LINK to stage a more in-depth : https://www.mpgh.net/forum/31-c-c-pro...ml#post5191014A brain, patience, the willing to read and learn, coffee.
Last edited by Qmo; 09-21-2011 at 01:43 AM.
اَللّهُ اَكْبَرُ
.:If u can respect other people work, then u will get what u want:.