From 91d928cf38eaa83cf74119c74aeda0b23a043489 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sat, 13 Apr 2019 19:38:53 +0200 Subject: funccrypt MAXSIZ macro, gitlab-ci integration Signed-off-by: Toni Uhlig --- funccrypt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/funccrypt.c b/funccrypt.c index 9235b0f..7f13c78 100644 --- a/funccrypt.c +++ b/funccrypt.c @@ -19,11 +19,16 @@ typedef struct crypt_header { uint64_t func_body[0]; } GCC_PACKED crypt_header; +#define CRYPT_FUNC_MAXSIZ 0x100 #define CRYPT_FUNC(fn) \ crypt_func((void *)fn) #define CRYPT_PROLOGUE(fn) \ + crypt_return __cr; \ { \ - CRYPT_FUNC(fn); \ + __cr = CRYPT_FUNC(fn); \ + if (__cr != CRET_OK) \ + asm volatile goto("jmp %l0 \n" \ + : : : : cr_epilogue); \ asm volatile goto("jmp %l0 \n" \ : : : : cr_prologue); \ asm volatile( \ @@ -113,7 +118,7 @@ static crypt_return crypt_func(void *fn_start) size_t crypt_size; printf("Fn: %p\n", fnbuf); - for (i = 0; i < 0x100; ++i) { + for (i = 0; i < CRYPT_FUNC_MAXSIZ; ++i) { if (cret == CRET_ERROR && *(uint32_t *) &fnbuf[i] == prologue_marker) { -- cgit v1.2.3