You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
4 years ago
|
#pragma once
|
||
|
#include <Zydis/Utils.h>
|
||
4 years ago
|
#include <Zydis/Zydis.h>
|
||
3 years ago
|
|
||
|
#include <optional>
|
||
4 years ago
|
#include <vector>
|
||
4 years ago
|
#include <xmmintrin.h>
|
||
|
|
||
3 years ago
|
#define NOMINMAX
|
||
|
#include <Windows.h>
|
||
|
|
||
4 years ago
|
using u8 = unsigned char;
|
||
|
using u16 = unsigned short;
|
||
|
using u32 = unsigned int;
|
||
|
using u64 = unsigned long long;
|
||
|
using u128 = __m128;
|
||
|
|
||
4 years ago
|
using zydis_decoded_instr_t = ZydisDecodedInstruction;
|
||
|
using zydis_register_t = ZydisRegister;
|
||
4 years ago
|
using zydis_mnemonic_t = ZydisMnemonic;
|
||
4 years ago
|
|
||
4 years ago
|
struct zydis_instr_t
|
||
|
{
|
||
4 years ago
|
zydis_decoded_instr_t instr;
|
||
|
std::vector< u8 > raw;
|
||
|
std::uintptr_t addr;
|
||
4 years ago
|
};
|
||
|
|
||
4 years ago
|
using zydis_routine_t = std::vector< zydis_instr_t >;
|
||
4 years ago
|
|
||
|
namespace vm
|
||
|
{
|
||
4 years ago
|
namespace util
|
||
|
{
|
||
|
namespace reg
|
||
|
{
|
||
|
// converts say... AL to RAX...
|
||
|
zydis_register_t to64( zydis_register_t reg );
|
||
|
bool compare( zydis_register_t a, zydis_register_t b );
|
||
|
} // namespace reg
|
||
4 years ago
|
|
||
3 years ago
|
bool get_fetch_operand( const zydis_routine_t &routine, zydis_instr_t &fetch_instr );
|
||
|
std::optional< zydis_routine_t::iterator > get_fetch_operand( zydis_routine_t &routine );
|
||
|
|
||
4 years ago
|
void print( zydis_routine_t &routine );
|
||
|
void print( const zydis_decoded_instr_t &instr );
|
||
|
bool is_jmp( const zydis_decoded_instr_t &instr );
|
||
4 years ago
|
|
||
4 years ago
|
bool flatten( zydis_routine_t &routine, std::uintptr_t routine_addr, bool keep_jmps = false );
|
||
|
void deobfuscate( zydis_routine_t &routine );
|
||
|
} // namespace util
|
||
|
} // namespace vm
|