So I am trying to make my own now and I was wondering, what is the goal of a detour function/what does it do? If anyone wants to help that would be cool but I dont think anyone will. Also don't flame me for trying.
So I am trying to make my own now and I was wondering, what is the goal of a detour function/what does it do? If anyone wants to help that would be cool but I dont think anyone will. Also don't flame me for trying.
Basically, a detour is used to intercept a function. It takes the first instructions of the target you are detouring, and replaces it with a jmp to your function. The original function is saved, and then executed after your function has been executed. This is known as a trampoline.
[MPGH]AVGN (11-28-2011)
fakeness (11-28-2011)
Before you find out what a detour is, you'll need to know that programs run code, which runs serially. This means that code is executed one "instruction" at a time (going in one direction). These instructions tell your processor what to do - print out a character on the screen, change the colour of a pixel on your screen, add 1 and 2 together and save it somewhere or perhaps printing out a document through a printing port.
Like a real-world detour, a detour in computer engineering is altering path that the instructions take. For hacking purposes, we alter the path to our own instructions, so that we can get to the code instructions that draws a menu on the screen or activates a hack whenever the detoured code runs.
A more life-like example would be to run X whenever Y happens. Coming back to our real-world car example, the police would want a speed camera to be set off whenever a car goes past it. Fortunately, in the real world, we can use light detectors or other mechanisms to do this. In everyday computers, you don't have detection mechanisms like the above, so you use instruction detours instead. The end result is the same - when your targeted instructions are run, your own code/instructions are run too.
EDIT: Yet another (better) example would be the person inside the car. He is the processing unit. He processes instructions. He's driving the car, executing the instructions to make the car go forward. However, we set a detour to activate the speed camera. So, every time he reaches the speed camera, he will take a detour, get out of the car, activate the speed camera, return and continue driving the car.
Coming back to Combat Arms, you can use detours to get the code that draws a menu inside Combat Arms to run when Combat Arms is drawing the environment - the world, map and players. You can also use detours for a variety of other purposes, perhaps detouring calls to "SetPlayerPosition()" so you can filter out which positions should or shouldn't be set. You can even use detours to detour a game closing, to prevent people from closing the game and keep them inside the game for whatever reason (make them suffer or force them to click an ad)
Of course, this is a convoluted thing to explain and I've only summarized it. There are issues like how the speed camera takes the speed of the vehicle if he gets out of it (parameter passing), and so on. This is only an example to help you understand detouring and so it isn't as detailed or as accurate as a computer scientist might tell another computer scientist.
Last edited by freedompeace; 11-28-2011 at 10:56 PM.
Deuce. (11-28-2011),fakeness (11-30-2011),flameswor10 (11-28-2011),[MPGH]Flengo (11-30-2011),nbss (05-11-2012),OBrozz (11-30-2011),Saltine (11-29-2011)