From 8e5e48337a6cf7a33ecbee7cf9c594fa18bd93ae Mon Sep 17 00:00:00 2001 From: auth Date: Fri, 17 Jul 2020 15:47:51 +0200 Subject: Refactoring. --- client/src/shellcode/shellcode.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 client/src/shellcode/shellcode.h (limited to 'client/src/shellcode/shellcode.h') diff --git a/client/src/shellcode/shellcode.h b/client/src/shellcode/shellcode.h new file mode 100644 index 0000000..5f0e135 --- /dev/null +++ b/client/src/shellcode/shellcode.h @@ -0,0 +1,35 @@ +#pragma once + +#include + +using namespace asmjit; + +namespace sc { + +class generator { + std::vector m_buf; + + CodeHolder m_code; + JitRuntime m_runtime; + x86::Assembler m_assembler; + + bool m_x64; + public: + generator(const bool x64 = false) : m_x64{x64} { + Environment env(x64 ? Environment::kArchX64 : Environment::kArchX86); + + m_code.init(env); + m_code.attach(&m_assembler); + } + + void start(); + void push(const std::vector &args); + void call(const uintptr_t addr); + void save_ret(const uintptr_t addr); + void end(); + + auto &operator()() const { return m_buf; } + auto &operator->() const { return m_assembler; } +}; + +}; \ No newline at end of file -- cgit v1.2.3