aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser/bruisercapstone.h
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-03-01 14:37:53 +0000
committerbloodstalker <thabogre@gmail.com>2018-03-01 14:37:53 +0000
commitb72238e4056bc8f28c53f42f186bd385cc81ba12 (patch)
tree5821add9b2d785f09b4f4e1c8b62a17e6a713769 /bruiser/bruisercapstone.h
parentbruiser will now run a lua script before startup so now you can easily use yo... (diff)
downloadmutator-b72238e4056bc8f28c53f42f186bd385cc81ba12.tar.gz
mutator-b72238e4056bc8f28c53f42f186bd385cc81ba12.zip
wip-the asm rewriter module plus the assembly jump table lua module implementation
Diffstat (limited to 'bruiser/bruisercapstone.h')
-rw-r--r--bruiser/bruisercapstone.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/bruiser/bruisercapstone.h b/bruiser/bruisercapstone.h
index 054eb19..d10db70 100644
--- a/bruiser/bruisercapstone.h
+++ b/bruiser/bruisercapstone.h
@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include <capstone/capstone.h>
#include <keystone/keystone.h>
#include <stdint.h>
+#include <inttypes.h>
/**********************************************************************************************************************/
#ifndef BRUISER_CAPSTONE_H
#define BRUISER_CAPSTONE_H
@@ -29,6 +30,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
extern "C" {
#endif
+enum jmp_type {NONE=0, JMP=1, JNE=2, JE=3};
+#define JMP_T enum jmp_type
+
+struct jmp_s_t {
+ JMP_T type;
+ uint64_t location;
+ uint8_t size;
+ struct jmp_s_t* next;
+ struct jmp_s_t* next_y;
+ struct jmp_s_t* next_n;
+ uint64_t address;
+ uint64_t address_y;
+ uint64_t address_n;
+ bool y;
+ bool n;
+ bool z;
+};
+#define JMP_S_T struct jmp_s_t
+JMP_S_T* iter_next(JMP_S_T* arg);
+JMP_S_T* iter_next_y(JMP_S_T* arg);
+JMP_S_T* iter_next_n(JMP_S_T* arg);
+extern JMP_S_T* head;
+extern JMP_S_T* tail;
+
uint32_t get_textsection_length(void);
uintptr_t get_symbol_rt_address(const char* symbol_name);
void int2byte(int value, uint8_t* ret_value, size_t size);
@@ -39,6 +64,12 @@ void leb128_decode_u(uint32_t value, uint8_t* ret_value, size_t size);
int ks_write(ks_arch arch, int mode, const char* assembly, int syntax, unsigned char* encode);
int global_rewriter(int offset, size_t size, uint8_t* asm_code, const char* obj);
int call_rewriter(int offset, size_t size, uint8_t* asm_code, const char* obj);
+JMP_S_T* makejmptable(size_t size, uint8_t* obj);
+int freejmptable(JMP_S_T* _head);
+int dumpjmptable(JMP_S_T* head);
+void jmprewriter_j(JMP_S_T* jmp, uint8_t* code, JMP_T type, uint8_t* rewritten);
+void jmprewriter_jne(JMP_S_T* jmp, uint8_t* code, JMP_T type, uint8_t* rewritten);
+void jmprewriter_je(JMP_S_T* jmp, uint8_t* code, JMP_T type, uint8_t* rewritten);
#ifdef __cplusplus
}