I'm trying to re-implement old-as-behemoth kernel intercept (described at this Phrack issue).
The code to replace 32-bit function call is like:
#define SYSMAPADDR 0x12345678
#define CODESIZE 7
static char acct_code[7] = "\xb8\x00\x00\x00\x00"/*movl $0, %eax*/
"\xff\xe0";/*jmp *%eax*/
*(long*)&acct_code[1] = (long)my_hijacking_function;
// here, use either set_pages_rw or trick CR0 to do this:
memcpy(SYSMAPADDR, acct_code, CODESIZE);
But 64-bit address of original function is 0xffffffff12345678 (kernel is located in low-memory).
So will the (long) new function pointer fit just 4 \x00 bytes of the movl instruction?
Btw, please link this to Can I replace a Linux kernel function with a module? and Overriding functionality with modules in Linux kernel, the hacky method described above is more flexible (can intercept non-extern functions => no need to recompile the kernel).