diff --git a/pwn++/asm.cpp b/pwn++/asm.cpp index 07b6cf6..9c017ee 100644 --- a/pwn++/asm.cpp +++ b/pwn++/asm.cpp @@ -1,6 +1,7 @@ #include "asm.h" #include +#include using namespace pwn::log; @@ -79,6 +80,14 @@ namespace pwn::assm } + std::vector PWNAPI x86(_In_ const char* code, _In_ const size_t code_size) + { + std::vector res; + __assemble(KS_ARCH_X86, KS_MODE_32, code, code_size, res); + return res; + } + + /*++ Description: @@ -102,6 +111,14 @@ namespace pwn::assm } + std::vector PWNAPI x64(_In_ const char* code, _In_ const size_t code_size) + { + std::vector res; + __assemble(KS_ARCH_X86, KS_MODE_64, code, code_size, res); + return res; + } + + /*++ Description: @@ -135,4 +152,21 @@ namespace pwn::assm return FALSE; } + + + std::vector assemble(_In_ const char* code, _In_ const size_t code_size) + { + switch (pwn::context::arch) + { + case pwn::context::arch_t::x86: + return x86(code, code_size); + + case pwn::context::arch_t::x64: + return x64(code, code_size); + + default: + throw std::runtime_error("unsupported architecture"); + break; + } + } } \ No newline at end of file diff --git a/pwn++/asm.h b/pwn++/asm.h index 6634f67..4557fcc 100644 --- a/pwn++/asm.h +++ b/pwn++/asm.h @@ -10,4 +10,8 @@ namespace pwn::assm _Success_(return) BOOL PWNAPI assemble(_In_ const char* code, _In_ const size_t code_size, _Out_ std::vector& bytes); _Success_(return) BOOL PWNAPI x64(_In_ const char* code, _In_ const size_t code_size, _Out_ std::vector& bytes); _Success_(return) BOOL PWNAPI x86(_In_ const char* code, _In_ const size_t code_size, _Out_ std::vector& bytes); + + _Success_(return) PWNAPI std::vector assemble(_In_ const char* code, _In_ const size_t code_size); + _Success_(return) PWNAPI std::vector x64(_In_ const char* code, _In_ const size_t code_size); + _Success_(return) PWNAPI std::vector x86(_In_ const char* code, _In_ const size_t code_size); } \ No newline at end of file diff --git a/pwn++/pwn.cpp b/pwn++/pwn.cpp index 12cd0c3..61b3f0e 100644 --- a/pwn++/pwn.cpp +++ b/pwn++/pwn.cpp @@ -12,3 +12,5 @@ const std::tuple pwn::version_info() const std::tuple out(__PWNLIB_VERSION_MAJOR__, __PWNLIB_VERSION_MINOR__); return out; } + + diff --git a/pwn++/utils.cpp b/pwn++/utils.cpp index a78485e..42871f0 100644 --- a/pwn++/utils.cpp +++ b/pwn++/utils.cpp @@ -479,4 +479,7 @@ namespace pwn::utils return flat; } + + + } \ No newline at end of file diff --git a/pwn++/utils.h b/pwn++/utils.h index 73001ad..309aec3 100644 --- a/pwn++/utils.h +++ b/pwn++/utils.h @@ -53,4 +53,5 @@ namespace pwn::utils PWNAPI void hexdump(_In_ const PBYTE Buffer, _In_ SIZE_T BufferSize); PWNAPI void hexdump(_In_ const std::vector& bytes); + } \ No newline at end of file