diff --git a/demo/test.hpp b/demo/test.hpp index 5917f25..d7ebd68 100644 --- a/demo/test.hpp +++ b/demo/test.hpp @@ -140,7 +140,7 @@ namespace vm enum class calls : u32 { get_hello = 0xbffd6fa5, - get_world = 0xbffd6f4a, + get_world = 0xbffd6f49, }; inline _pair_t< u8, calls > call_map[ 2 ] = { @@ -8215,12 +8215,12 @@ namespace vm }; u8 __get_world_vinstrs[ 92 ] = { - 0x3a, 0x1, 0x9e, 0x72, 0x35, 0xdb, 0xd4, 0x3c, 0x7b, 0x95, 0x2a, 0xe6, 0xe1, 0x2f, 0xa0, 0x70, - 0x67, 0xa9, 0x36, 0xda, 0xd, 0x3, 0xec, 0x24, 0xd3, 0x3d, 0xc2, 0x4e, 0xb9, 0x57, 0xb8, 0x59, - 0xbf, 0x52, 0xce, 0x43, 0xe5, 0xc, 0x4, 0xed, 0x88, 0xeb, 0x8a, 0x8, 0x14, 0xff, 0xff, 0xff, - 0x9a, 0x73, 0x80, 0x67, 0x6e, 0xe4, 0x17, 0x5e, 0x35, 0x58, 0x3b, 0x4a, 0x49, 0x34, 0x5e, 0x16, - 0x7c, 0xf0, 0xa2, 0xc2, 0xd0, 0x8c, 0x6, 0x4e, 0x44, 0x8, 0x8a, 0xba, 0xd8, 0x64, 0x2e, 0x6, - 0x8c, 0xa0, 0xf2, 0x32, 0x60, 0xbc, 0xd6, 0x3e, 0x54, 0xb8, 0xda, 0x2a, + 0x39, 0x2, 0x9d, 0x73, 0x34, 0xdc, 0xd3, 0x3d, 0x7a, 0x96, 0x29, 0xe7, 0xe0, 0x30, 0x9f, 0x71, + 0x66, 0xaa, 0x35, 0xdb, 0xc, 0x4, 0xeb, 0x25, 0xd2, 0x3e, 0xc1, 0x4f, 0xb8, 0x58, 0xb7, 0x5a, + 0xbe, 0x53, 0xcd, 0x44, 0xe4, 0xd, 0x3, 0xee, 0x87, 0xec, 0x89, 0x9, 0x13, 0xff, 0xff, 0xff, + 0x9a, 0x73, 0x80, 0x67, 0x6f, 0xe5, 0x16, 0x5f, 0x34, 0x59, 0x3a, 0x4b, 0x48, 0x35, 0x5d, 0x17, + 0x7b, 0xf1, 0xa1, 0xc3, 0xcf, 0x8d, 0x5, 0x4f, 0x43, 0x9, 0x89, 0xbb, 0xd7, 0x65, 0x2d, 0x7, + 0x8b, 0xa1, 0xf1, 0x33, 0x5f, 0xbd, 0xd5, 0x3f, 0x53, 0xb9, 0xd9, 0x2b, }; u8 __vmcall_shell_code[ 2 ][ 15 ] = { @@ -8340,7 +8340,7 @@ namespace vm // signed rip relative rva to vm entry... *reinterpret_cast< u32 * >( &__vmcall_shell_code[ idx ][ 11 ] ) = reinterpret_cast< s32 >( - ( map_area - ( reinterpret_cast< u64 >( __vmcall_shell_code[ idx ] ) + 15 ) ) + entry_rva ); + ( map_area - ( reinterpret_cast< u64 >( &__vmcall_shell_code[ idx ] ) + 15 ) ) + entry_rva ); } return true; // only a bool so i can use static/call init only once... @@ -8351,17 +8351,12 @@ namespace vm template < calls e_call, class T, class... Ts > auto call( const Ts... args ) -> T { - auto __init_result = gen_data.init(); + static auto __init_result = gen_data.init(); __vmcall_t vmcall = nullptr; for ( auto idx = 0u; idx < sizeof( call_map ) / sizeof( _pair_t< u8, calls > ); ++idx ) - { if ( call_map[ idx ].second == e_call ) - { - vmcall = reinterpret_cast< __vmcall_t >( gen_data.__vmcall_shell_code[ idx ] ); - break; - } - } + vmcall = reinterpret_cast< __vmcall_t >( &gen_data.__vmcall_shell_code[ idx ] ); return reinterpret_cast< T >( vmcall( args... ) ); } diff --git a/src/compiler.cpp b/src/compiler.cpp index fd38006..799f6ab 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -106,12 +106,12 @@ namespace vm exit( 0 ); } - // sometimes there is a mov al, [rsi-1]... we want that disp... - if ( opcode_fetch->instr.operands[ 1 ].mem.disp.has_displacement ) - decrypt_key += std::abs( opcode_fetch->instr.operands[ 1 ].mem.disp.value ); - start_addr = decrypt_key - 1; // make it zero based... std::for_each( virt_labels.begin(), virt_labels.end(), [ & ]( vm::vlabel_data &label ) { + // sometimes there is a mov al, [rsi-1]... we want that disp... + if ( opcode_fetch->instr.operands[ 1 ].mem.disp.has_displacement ) + start_addr += std::abs( opcode_fetch->instr.operands[ 1 ].mem.disp.value ); + decrypt_key = start_addr; result.push_back( { label.label_name, start_addr } );