aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoni <toni@devlap.local>2015-05-21 13:02:04 +0200
committertoni <toni@devlap.local>2015-05-21 13:02:04 +0200
commitf187f832b297045d85635ddbb1285ba0b83fb403 (patch)
treef7d65eb9e9716e4f2db97db4d348402962bd4850
parent75bdb5991d637aa4726ae1f03454b85d53ddb37f (diff)
simple 'inner function jmp' ..
-rw-r--r--.gitignore1
-rw-r--r--funcjmp_simple.c39
2 files changed, 40 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 2815720..f691adf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ overflow_tcp
overflow_tcp_x64
sc-test
sc-test_x64
+funcjmp_simple
diff --git a/funcjmp_simple.c b/funcjmp_simple.c
new file mode 100644
index 0000000..9e756cf
--- /dev/null
+++ b/funcjmp_simple.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#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: \
+ ");
+
+JUMPABLE_FUNC(testfkt);
+JMP_FUNC_DECL(testfkt);
+
+JUMPABLE_FUNC(testfkt)
+{
+ int var0 = 0x1, var1 = 0x2, var2 = 0x3;
+ var0 += var1 + var2;
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ JMP_TO_FUNC;
+ return 66;
+}