6
void real (int a,int b,int c,int d) __attribute__((noinline));
8
// A function that is not mine but to which I have access and want to patch so that it calls a function of mine with its original arguments
9
void real (int a,int b,int c,int d)
14
// A function that I want to be called, receiving the original arguments
15
void receiver(int a,int b,int c,int d);
17
void patch(int a, int b, int c, int d)
20
__asm__("jmp dummy\n\t"
21
".ascii \"dummy\\0\"\n"
27
FlushInstructionCache(GetCurrentProcess(),(const void *) &real,5);
30
VirtualProtect((void *) &real,5,PAGE_EXECUTE_READWRITE,&oldProtection);
32
// Patching the real function to go to my patch
33
((unsigned char*)real)[0] = 0xE9;
34
*((long*)((long)(real) + sizeof(unsigned char))) = (char*)patch - (char*)real - 5;
42
"call __Z4realiiii \n\t"