diff --git a/src/main.cpp b/src/main.cpp index a8188c6..842489c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -219,7 +219,7 @@ int __cdecl main( int argc, const char *argv[] ) } } - if ( parser.exists( "showbvirtinstrs" ) && parser.exists( "rtnaddr" ) ) + if ( parser.exists( "showvirtinstrs" ) && parser.exists( "rtnaddr" ) ) { auto rtn_addr = std::stoull( parser.get< std::string >( "rtnaddr" ).c_str(), nullptr, 16 ); for ( auto [ rtn_block, rtn_idx ] = std::pair{ first_rtn, 0ull }; rtn_idx < file_header->rtn_count; @@ -234,15 +234,20 @@ int __cdecl main( int argc, const char *argv[] ) reinterpret_cast< std::uintptr_t >( code_block ) + code_block->next_block_offset ) ) { - std::printf( " [blk_0x%p] number of virtual instructions = %d\n", code_block->vip_begin, + std::printf( "[blk_0x%p] number of virtual instructions = %d\n", code_block->vip_begin, code_block->vinstr_count ); std::printf( "> -----------------------------------------------------------------------\n" ); std::printf( "> opcode | virtual instructions | virtual instruction pointer\n" ); std::printf( "> -----------------------------------------------------------------------\n" ); + + auto block_vinstrs = reinterpret_cast< vm::instrs::virt_instr_t * >( + reinterpret_cast< std::uintptr_t >( code_block ) + sizeof vmp2::v4::code_block_t + + ( code_block->num_block_addrs * 8 ) ); + for ( auto idx = 0u; idx < code_block->vinstr_count; ++idx ) { - const auto vinstr = &code_block->vinstr[ idx ]; + const auto vinstr = &block_vinstrs[ idx ]; const auto vm_profile = vm::handler::get_profile( vinstr->mnemonic_t ); if ( vinstr->operand.has_imm ) {