Posted about 1 year ago, by Specific

This tutorial on how to hook process functions via dll injection is not for the beginning programmer.  I assume that you have knowledge of creating DLL (Dynamic Link Libraries) files in C++, as I do not cover this.  If you do not know how to inject a dll into a process, please read my tutorial "Inject DLL into running process with CPP."

Some of you may remember a release I had for MSN Gaming Zone called ZoneHook, this very code was used to hook the functions inside it's inner workings.  We start out planning how we will implement this code. Because ZoneHook was reasonably complex, I made a class so that implementing was easy as possible.

What we want to accomplish here is overwrite the address of the function to either jmp, or call our own function in the dll file.  Sounds really complicated, but it's not and with little knowledge of pointers and how programs work we can do this.

How do we accomplish what was just said?  We create a function that will render an instruction to jmp or call a specified offset.  With this instruction we then assign appropriate permissions to access and write to the original function call, we then write our new instruction in place of the original. 

Here is the basic structure (Redirect.h):


The class consists of one constructor and four methods. 

With the structure there, there is nothing more to do but code what we wanted to do.

Redirecting the function is simple:

Not done yet though, we still have to create the OnZoneSend function.  This is where people can run into problems if they don't know instruction flow in applications, it may require a little knowledge of assembly.

We now call a naked function which will jmp to the original function entry point.

Thats it!  Enjoy.

Author Info Comment
XtC
Posted about 1 year ago.
User Avatar

This is exactly what I was searching for!  I had to check it out seeing zonehacks.com in the title and being an old zone sysop.  lol i remember using zonehook too, I had used it when another sysop sent it to me with a plugin he paid you to make.  It would auto ban people by their ip so when they went and made a new account it would ban when they joined your lobby.   lol brings back many memories. I miss those days.  How did your plugin system work anyway?  

I am working on a game hack for modern warfare and I think this wil help me do what I need to.  Thanks  and great tut spec.