|
|
|
@ -12,25 +12,26 @@ 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(),
|
|
|
|
|
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 );
|
|
|
|
|
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(),
|
|
|
|
|
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 );
|
|
|
|
|
return block_data.first == vm_code_block.jcc.block_addr[ 1 ];
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
assert( bb2 != rtn->llvm_code_blocks.end(),
|
|
|
|
@ -41,10 +42,10 @@ namespace vm
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto rva = rtn->pop( 8 );
|
|
|
|
|
auto bb_data = std::find_if(
|
|
|
|
|
rtn->llvm_code_blocks.begin(), rtn->llvm_code_blocks.end(),
|
|
|
|
|
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;
|
|
|
|
|
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" );
|
|
|
|
|