fixed JMP lifter... branching is now working...

merge-requests/1/merge
_xeroxz 3 years ago
parent 856fa1815d
commit 97aab6d44f

@ -1 +1 @@
Subproject commit 1f5fe9cd7b16ad2edd17ee8e13c672b3feeb9c08 Subproject commit 0d37ea80907e7264b23b2a2db0a697fe399792ca

@ -12,25 +12,26 @@ namespace vm
if ( vm_code_block.jcc.type == vm::instrs::jcc_type::branching ) if ( vm_code_block.jcc.type == vm::instrs::jcc_type::branching )
{ {
auto rva = rtn->pop( 8 ); 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 _const_b1 = llvm::ConstantInt::get( ir_builder->getInt64Ty(), b1 );
auto cmp = ir_builder->CreateCmp( llvm::CmpInst::ICMP_EQ, rva, _const_b1 ); auto cmp = ir_builder->CreateCmp( llvm::CmpInst::ICMP_EQ, rva, _const_b1 );
// find the first branch basic block... // find the first branch basic block...
auto bb1 = std::find_if( auto bb1 =
rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), 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 { [ & ]( 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 ); return block_data.first == vm_code_block.jcc.block_addr[ 0 ];
} ); } );
assert( bb1 != rtn->llvm_code_blocks.end(), assert( bb1 != rtn->llvm_code_blocks.end(),
"[!] fatal error... unable to locate basic block for branching...\n" ); "[!] fatal error... unable to locate basic block for branching...\n" );
// find the second branch basic block... // find the second branch basic block...
auto bb2 = std::find_if( auto bb2 =
rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), 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 { [ & ]( 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 ); return block_data.first == vm_code_block.jcc.block_addr[ 1 ];
} ); } );
assert( bb2 != rtn->llvm_code_blocks.end(), assert( bb2 != rtn->llvm_code_blocks.end(),
@ -41,10 +42,10 @@ namespace vm
else else
{ {
auto rva = rtn->pop( 8 ); auto rva = rtn->pop( 8 );
auto bb_data = std::find_if( auto bb_data =
rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(), 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 { [ & ]( 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; 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" ); assert( bb_data != rtn->llvm_code_blocks.end(), "[!] fatal error... unable to locate basic block...\n" );

Loading…
Cancel
Save