From 16faa81d6f5e18669fce4cfb71fa771e8d80bf90 Mon Sep 17 00:00:00 2001 From: toni Date: Tue, 19 Jul 2016 16:22:36 +0200 Subject: funcjmp --- funcjmp_ext.c | 52 ---------------------------------------------------- funcjmp_ext_x86.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 funcjmp_ext.c create mode 100644 funcjmp_ext_x86.c diff --git a/funcjmp_ext.c b/funcjmp_ext.c deleted file mode 100644 index 6174bec..0000000 --- a/funcjmp_ext.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include - - -#define INTEL_ASM(_asm_str) asm volatile(".intel_syntax noprefix"); \ - asm volatile(_asm_str); \ - asm volatile(".att_syntax prefix"); -#define JUMPABLE_FUNC(fname) __attribute__ ((__cdecl__)) int fname(void) -#define JMP_FUNC_DECL(func) void *fptr = (void *)( &func ); -#define JMP_TO_FUNC \ - INTEL_ASM(" \ - call getip; \ - jmp short donext; \ - cfunc: \ - mov eax,[fptr]; \ - add eax,0x0; \ - jmp eax; \ - ret; \ - getip: \ - nop; \ - jmp short cfunc; \ - donext: \ - "); - -#define PRE_JUMP(arg) - - -int hookable(char *arg0, int arg1, int arg2) -{ - asm("label:"); - INTEL_ASM("nop; nop; nop; pop eax; pop eax"); - asm("jmp end"); - return 0; -} - -int testfkt(void *param) -{ - printf("Subroutine ..\n"); -} - -int main(int argc, char **argv) -{ - asm("push %0" : : "m" (hookable)); - asm("push %0" : : "g" (hookable)); - asm("jmp label; \ - end:"); - //hookable(NULL, 0x8, 0x9); - printf("Hello World!\n"); - testfkt(NULL); - return 66; -} - diff --git a/funcjmp_ext_x86.c b/funcjmp_ext_x86.c new file mode 100644 index 0000000..6174bec --- /dev/null +++ b/funcjmp_ext_x86.c @@ -0,0 +1,52 @@ +#include +#include + + +#define INTEL_ASM(_asm_str) asm volatile(".intel_syntax noprefix"); \ + asm volatile(_asm_str); \ + asm volatile(".att_syntax prefix"); +#define JUMPABLE_FUNC(fname) __attribute__ ((__cdecl__)) int fname(void) +#define JMP_FUNC_DECL(func) void *fptr = (void *)( &func ); +#define JMP_TO_FUNC \ + INTEL_ASM(" \ + call getip; \ + jmp short donext; \ + cfunc: \ + mov eax,[fptr]; \ + add eax,0x0; \ + jmp eax; \ + ret; \ + getip: \ + nop; \ + jmp short cfunc; \ + donext: \ + "); + +#define PRE_JUMP(arg) + + +int hookable(char *arg0, int arg1, int arg2) +{ + asm("label:"); + INTEL_ASM("nop; nop; nop; pop eax; pop eax"); + asm("jmp end"); + return 0; +} + +int testfkt(void *param) +{ + printf("Subroutine ..\n"); +} + +int main(int argc, char **argv) +{ + asm("push %0" : : "m" (hookable)); + asm("push %0" : : "g" (hookable)); + asm("jmp label; \ + end:"); + //hookable(NULL, 0x8, 0x9); + printf("Hello World!\n"); + testfkt(NULL); + return 66; +} + -- cgit v1.2.3