From a2b532cfffd9f23a35d625c596629abe46eef33a Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Sat, 28 Aug 2021 13:42:04 -0700 Subject: [PATCH] updated vmexit handler, updated vmprofiler dep... updated main.cpp --- dependencies/vmprofiler | 2 +- src/devirt_t.cpp | 17 ----------------- src/devirt_utils.cpp | 2 +- src/lifters/vmexit.cpp | 4 ++-- src/main.cpp | 1 + 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/dependencies/vmprofiler b/dependencies/vmprofiler index 90106b0..0511401 160000 --- a/dependencies/vmprofiler +++ b/dependencies/vmprofiler @@ -1 +1 @@ -Subproject commit 90106b0f5e748f1e67e108800ee0463bae5755e3 +Subproject commit 051140175db16b38acee882cfca714b4a1000a41 diff --git a/src/devirt_t.cpp b/src/devirt_t.cpp index 169536f..478f3e5 100644 --- a/src/devirt_t.cpp +++ b/src/devirt_t.cpp @@ -85,23 +85,6 @@ namespace vm bool devirt_t::compile( std::vector< std::uint8_t > &obj ) { - llvm::legacy::FunctionPassManager pass_mgr( llvm_module ); - pass_mgr.add( llvm::createPromoteMemoryToRegisterPass() ); - pass_mgr.add( llvm::createCFGSimplificationPass() ); - pass_mgr.add( llvm::createSROAPass() ); - pass_mgr.add( llvm::createLoopSimplifyCFGPass() ); - pass_mgr.add( llvm::createNewGVNPass() ); - pass_mgr.add( llvm::createReassociatePass() ); - pass_mgr.add( llvm::createPartiallyInlineLibCallsPass() ); - pass_mgr.add( llvm::createDeadCodeEliminationPass() ); - pass_mgr.add( llvm::createCFGSimplificationPass() ); - pass_mgr.add( llvm::createInstructionCombiningPass() ); - pass_mgr.add( llvm::createFlattenCFGPass() ); - - for ( auto vmp_rtn : vmp_rtns ) - pass_mgr.run( *vmp_rtn->llvm_fptr ); - - // compile to native x86_64.... llvm::TargetOptions opt; llvm::SmallVector< char, 128 > buff; llvm::raw_svector_ostream dest( buff ); diff --git a/src/devirt_utils.cpp b/src/devirt_utils.cpp index 8e7a62f..ff8d310 100644 --- a/src/devirt_utils.cpp +++ b/src/devirt_utils.cpp @@ -12,7 +12,7 @@ namespace devirt if ( file_header->version != vmp2::version_t::v4 ) { - std::printf( "[!] invalid vmp2 file version... this build uses v3...\n" ); + std::printf( "[!] invalid vmp2 file version... this build uses v4...\n" ); return false; } diff --git a/src/lifters/vmexit.cpp b/src/lifters/vmexit.cpp index 1d60373..795ad26 100644 --- a/src/lifters/vmexit.cpp +++ b/src/lifters/vmexit.cpp @@ -8,8 +8,8 @@ namespace vm llvm::IRBuilder<> *ir_builder ) { std::stringstream rtn_name; llvm::Function *exit_func = nullptr; - rtn_name << "vmexit_" << std::hex << vinstr.trace_data.vm_handler_rva + rtn->vmp2_file->image_base; + if ( !( exit_func = rtn->llvm_module->getFunction( rtn_name.str() ) ) ) { auto vmexit_func_type = llvm::FunctionType::get( @@ -58,4 +58,4 @@ namespace vm ir_builder->CreateCall( exit_func, stack_ptr ); ir_builder->CreateRet( stack_ptr ); }; -} +} // namespace vm diff --git a/src/main.cpp b/src/main.cpp index d7a4a7e..89f8f81 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,7 @@ int main( int argc, const char *argv[] ) { std::printf( "[!] failed to lift rtn_0x%p, please review the console...\n", vm_enter_offset + file_header->image_base ); + return -1; } }