Detection is done via signature automatically gathered\or manually gathered, such as certain blocks of native assembly that would prove to be unique to the hack in question.
Thus, depending on the project's size (the hack) leaving the creator with the job of finding out what parts of code he needs to revamp\change.
Most of the time, a simple change in addition\subtraction does the trick, granted you turn off code optimization, to prevent it from taking the shortest way around.
ex 1:
ex 2:
Code:
int a = 0;
for(a = 0; a < 6; a++);
Tedious? Yes. But assembly output, without compiler optimizations would not be the same.
ex1:
ex2:
Code:
mov [reg], 0
__step:
cmp [reg], 5
je __finish;
inc [reg]
jmp __step;
__finish: