Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There is hack. For example like combat arms.
And with this hacks you can load your own directx code.
And adding a simple menu.
I want to know if we can do that with all the games.
I want to try to add dirctx code. With injected dll.
What I need for this ? Any offsets ?
Any way to do that !?
Any tutorial for that ?
Posted

see here how can you intercept functions and inject modules
 
Share this answer
 
There are many solutions to do the job. If the functions you want to intercept are in a DLL that is statically linked (so that the DLL is loaded by the os when the exe or dll that needs it is loaded) then you can use api redirection to hook the function calls of one module to another module. This technique works all the time if the situation allows the use of this. For example if you have an x.exe and it imports y.dll with its DLL import table in its header then you use api redirection to intercept the f() function call that comes from x.exe to y.dll.
If x.exe uses another dll too, for example z.dll, and z.dll also uses the f() function of y.dll, then you have make a separate hooking to intercept f() function calls coming from z.dll to y.dll. The reason for this is that api redirection rewrites the address in the import table of x.exe and y.dll. This technique can not be used if someone loads the library explicitly with LoadLibrary() and queries func addresses with GetProcAddress(). API Hooking (LoadLibrary)[^]

Another technique is what armagedescu already posted, placing a hook at the beginning of the code of the hookable function. Unfortunately this isn't always possible, but because most pograms are written in modern languages and compiled with modern compilers the gereated code usually makes it possible quite easily. I never used code like the one armagedescu posted (A C++ Style of Intercepting Functions[^]), I solved such situations with assembly patches in my target process. But armagedescu's code works, its 1000x times clearner that patching in with assembly.

The last technique I used is a DLL proxy. Lest say your game uses a function from whatever library, lets say x.dll. This .dll is either in the directory of your game or is in some system directories. If the game is in your game directory, then move it somewhere else, because the next step is creating a dll in your game directory (in the directory where its user module resides) with the same name and with the same exported functions. Then this dll will be loaded instead of the original dll. Since dlls export functions by ordinal number or name, you dont have to know its parameter list, and you dll can load the other dll and just forward all calls to the original dll with a jmp instruction. when this is done, you just write the interceptor code in the proxy dll for the functions you wanna intercept. I used my own tool to automatically generate the source code of the proxy dll by copying the export interface of the target dll, you might find some similar tool on the net by searching for "proxy dll" with google. Here is one generator, but I havent tried it, check this out: Create your Proxy DLLs automatically[^]

EDIT: The first two solutions must be used from your DLL that you injected into the process of the game. The third solution does not require messing with injection because the game itself loads your proxy dll into its process.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900