Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jul 18, 2020
1 parent e6b5932 commit 1b93d87
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pwn++/asm.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "asm.h"

#include <keystone/keystone.h>
#include <stdexcept>

using namespace pwn::log;

Expand Down Expand Up @@ -79,6 +80,14 @@ namespace pwn::assm
}


std::vector<BYTE> PWNAPI x86(_In_ const char* code, _In_ const size_t code_size)
{
std::vector<BYTE> res;
__assemble(KS_ARCH_X86, KS_MODE_32, code, code_size, res);
return res;
}



/*++
Description:
Expand All @@ -102,6 +111,14 @@ namespace pwn::assm
}


std::vector<BYTE> PWNAPI x64(_In_ const char* code, _In_ const size_t code_size)
{
std::vector<BYTE> res;
__assemble(KS_ARCH_X86, KS_MODE_64, code, code_size, res);
return res;
}


/*++
Description:
Expand Down Expand Up @@ -135,4 +152,21 @@ namespace pwn::assm

return FALSE;
}


std::vector<BYTE> 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;
}
}
}
4 changes: 4 additions & 0 deletions pwn++/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BYTE>& bytes);
_Success_(return) BOOL PWNAPI x64(_In_ const char* code, _In_ const size_t code_size, _Out_ std::vector<BYTE>& bytes);
_Success_(return) BOOL PWNAPI x86(_In_ const char* code, _In_ const size_t code_size, _Out_ std::vector<BYTE>& bytes);

_Success_(return) PWNAPI std::vector<BYTE> assemble(_In_ const char* code, _In_ const size_t code_size);
_Success_(return) PWNAPI std::vector<BYTE> x64(_In_ const char* code, _In_ const size_t code_size);
_Success_(return) PWNAPI std::vector<BYTE> x86(_In_ const char* code, _In_ const size_t code_size);
}
2 changes: 2 additions & 0 deletions pwn++/pwn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ const std::tuple<WORD, WORD> pwn::version_info()
const std::tuple<WORD, WORD> out(__PWNLIB_VERSION_MAJOR__, __PWNLIB_VERSION_MINOR__);
return out;
}


3 changes: 3 additions & 0 deletions pwn++/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,7 @@ namespace pwn::utils

return flat;
}



}
1 change: 1 addition & 0 deletions pwn++/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BYTE>& bytes);

}

0 comments on commit 1b93d87

Please sign in to comment.