So, you've heard about what people use to write cheats: hooks. But what are they?
A hook (Or "detour") is called when a function is called, and they're used to change how the function works.
Think of this like a detour in the road: if you're driving to your mall, and there's a construction site going on, you'll usually be taken down a detour. However, you'll still arrive at the mall, just through a different means.
Okay, so you understand how detours work. But what's a function? A function is simply a number of steps that alter what the program is doing while it runs. In math, if you've completed Algebra I, you may have seen a function such as:
f(x) = x^2 + 1
The above, function x, takes x, squares it, and then adds one to it. In programming, we have functions which can change numbers, print messages, do all sorts of things.
Putting them together
In a computer game, you might have a function which sets the HP of your player. If every time you take damage, the game calls the function, telling it to subtract 5 from your HP, you'll eventually have an HP of zero, and your character may "die". Using a detour, you could change this so the function doesn't change your HP at all.
Player is hit -> function named "SetHP" is called, telling program to subtract 5 -> SetHP subtracts 5
But, with our detour:
Player is hit -> function named "SetHP" is called, telling program to subtract 5 -> detour is called and changes what SetHP is being told, so it does nothing -> detour allows SetHP to run, and the game will continue working as normal, oblivious to what just happened
Okay, so now you understand detours. But are detours detectable? The answer to that is yes, they are. What most anti-hacks do are check if the program code is modified (Something that simply shouldn't happen). There's a number of ways you can do hooks, and a lot of them are undetectable. To name a few:
- - Import Address Table hooking
- Export Address Table hooking
- Virtual table hooking
- Code segment hooking (e.g. Software breakpoints, or just inline hooking)
- Hardware breakpoints
- Page exception hooking with single step exceptions (This one I haven't seen detected by any anti-hack yet)
However, before you can use any of these to write a hack, you'll need three basic skills:
- - Understanding of the x86 architecture, which means assembly.
- Understanding of the operating system you'll be working with; for most of you, this is Windows, and you need to know the executable format (That would be PE, which is the most common on Windows) and many functions from the Windows API.
- Understanding of a programming language in which to write your cheats (Most people say you can only do this with C++, but really, almost any language is suitable).
The above three take time to learn - I'll be releasing tutorials that will walk you through learning each skill piece-by-piece, but, at the end of the day, it's up for you to learn it all.
After reading this guide in its entirety you should now know:
- - What detours and functions are
- How detours work
- How it all ties in with writing hacksAuthor: ThatOneBoy