From 97aab6d44feca6b7ad1800130ae691dc34abe49c Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Sun, 8 Aug 2021 14:13:30 -0700 Subject: [PATCH] fixed JMP lifter... branching is now working... --- dependencies/vmprofiler | 2 +- src/lifters/jmp.cpp | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/dependencies/vmprofiler b/dependencies/vmprofiler index 1f5fe9c..0d37ea8 160000 --- a/dependencies/vmprofiler +++ b/dependencies/vmprofiler @@ -1 +1 @@ -Subproject commit 1f5fe9cd7b16ad2edd17ee8e13c672b3feeb9c08 +Subproject commit 0d37ea80907e7264b23b2a2db0a697fe399792ca diff --git a/src/lifters/jmp.cpp b/src/lifters/jmp.cpp index 697d377..3ed5b33 100644 --- a/src/lifters/jmp.cpp +++ b/src/lifters/jmp.cpp @@ -12,26 +12,27 @@ namespace vm if ( vm_code_block.jcc.type == vm::instrs::jcc_type::branching ) { auto rva = rtn->pop( 8 ); - auto b1 = vm_code_block.jcc.block_addr[ 0 ] & ~std::numeric_limits< std::uint32_t >::max(); + auto b1 = vm_code_block.jcc.block_addr[ 0 ] & std::numeric_limits< std::uint32_t >::max(); + auto _const_b1 = llvm::ConstantInt::get( ir_builder->getInt64Ty(), b1 ); auto cmp = ir_builder->CreateCmp( llvm::CmpInst::ICMP_EQ, rva, _const_b1 ); // find the first branch basic block... - auto bb1 = std::find_if( - rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), - [ & ]( const std::pair< std::uintptr_t, llvm_basic_block_t * > &block_data ) -> bool { - return block_data.first == ( vm_code_block.jcc.block_addr[ 0 ] - vinstr.trace_data.regs.r13 ); - } ); + auto bb1 = + std::find_if( rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), + [ & ]( const std::pair< std::uintptr_t, llvm_basic_block_t * > &block_data ) -> bool { + return block_data.first == vm_code_block.jcc.block_addr[ 0 ]; + } ); assert( bb1 != rtn->llvm_code_blocks.end(), "[!] fatal error... unable to locate basic block for branching...\n" ); // find the second branch basic block... - auto bb2 = std::find_if( - rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), - [ & ]( const std::pair< std::uintptr_t, llvm_basic_block_t * > &block_data ) -> bool { - return block_data.first == ( vm_code_block.jcc.block_addr[ 1 ] - vinstr.trace_data.regs.r13 ); - } ); + auto bb2 = + std::find_if( rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), + [ & ]( const std::pair< std::uintptr_t, llvm_basic_block_t * > &block_data ) -> bool { + return block_data.first == vm_code_block.jcc.block_addr[ 1 ]; + } ); assert( bb2 != rtn->llvm_code_blocks.end(), "[!] fatal error... unable to locate basic block for branching...\n" ); @@ -41,11 +42,11 @@ namespace vm else { auto rva = rtn->pop( 8 ); - auto bb_data = std::find_if( - rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), - [ & ]( const std::pair< std::uintptr_t, llvm_basic_block_t * > &block_data ) -> bool { - return block_data.first == vm_code_block.jcc.block_addr[ 0 ] - vinstr.trace_data.regs.r13; - } ); + auto bb_data = + std::find_if( rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), + [ & ]( const std::pair< std::uintptr_t, llvm_basic_block_t * > &block_data ) -> bool { + return block_data.first == vm_code_block.jcc.block_addr[ 0 ]; + } ); assert( bb_data != rtn->llvm_code_blocks.end(), "[!] fatal error... unable to locate basic block...\n" ); ir_builder->CreateBr( bb_data->second );