#pragma once #include #include #include #include #include #include #include #include #include namespace vm { class emu_t { using callback_t = std::function; public: explicit emu_t(std::uint32_t vm_entry_rva, std::uintptr_t image_base, std::uintptr_t module_base); ~emu_t(); bool init(); bool get_trace(std::vector& entries); private: uc_err create_entry(vmp2::entry_t* entry); static void hook_code(uc_engine* uc, uint64_t address, uint32_t size, vm::emu_t* obj); static bool hook_mem_invalid(uc_engine* uc, uc_mem_type type, uint64_t address, int size, int64_t value, vm::emu_t* obj); uc_engine* uc; uc_hook trace, trace1; std::uintptr_t image_base, module_base; std::uint32_t vm_entry_rva; zydis_routine_t vm_entry; std::uintptr_t* vm_handler_table; std::vector vm_handlers; std::vector* trace_entries; }; }