From fd3e44fb9db73055d6d180ed4a5d135f4fe6cb0a Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Mon, 2 Aug 2021 00:40:17 -0700 Subject: [PATCH] preparing for vmemu re-write --- include/vmemu_t.hpp | 1 + src/main.cpp | 4 ++-- src/vmemu_t.cpp | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/vmemu_t.hpp b/include/vmemu_t.hpp index 42fc34f..7b4ddd4 100644 --- a/include/vmemu_t.hpp +++ b/include/vmemu_t.hpp @@ -15,5 +15,6 @@ namespace vm private: uc_engine *uc_ctx; + vm::ctx_t *vm_ctx; }; } // namespace vm \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index a0eb184..53e2079 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,13 +31,13 @@ int __cdecl main( int argc, const char *argv[] ) auto umtils = xtils::um_t::get_instance(); - if ( !parser.exists( "unpack" ) ) + if ( !parser.exists( "unpack" ) && parser.exists( "vmentry" ) && parser.exists( "bin" ) ) { const auto module_base = reinterpret_cast< std::uintptr_t >( LoadLibraryExA( parser.get< std::string >( "bin" ).c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES ) ); const auto vm_entry_rva = std::strtoull( parser.get< std::string >( "vmentry" ).c_str(), nullptr, 16 ); - const auto image_base = umtils->image_base( parser.get< std::string >( "vmpbin" ).c_str() ); + const auto image_base = umtils->image_base( parser.get< std::string >( "bin" ).c_str() ); const auto image_size = NT_HEADER( module_base )->OptionalHeader.SizeOfImage; std::printf( "> image base = %p, image size = %p, module base = %p\n", image_base, image_size, module_base ); diff --git a/src/vmemu_t.cpp b/src/vmemu_t.cpp index b6570f1..59399d1 100644 --- a/src/vmemu_t.cpp +++ b/src/vmemu_t.cpp @@ -2,12 +2,14 @@ namespace vm { - emu_t::emu_t( vm::ctx_t *vmctx ) + emu_t::emu_t( vm::ctx_t *vm_ctx ) : vm_ctx( vm_ctx ), uc_ctx( nullptr ) { } emu_t::~emu_t() { + if ( uc_ctx ) + uc_close( uc_ctx ); } bool emu_t::init()