From 2295658e5d222f61dc370df871cb92dd7a226e8f Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Tue, 8 Jun 2021 00:59:27 -0700 Subject: [PATCH] fixed an issue with flattening code with legit branchs... --- src/vmutils.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vmutils.cpp b/src/vmutils.cpp index 147b5f4..432bbbc 100644 --- a/src/vmutils.cpp +++ b/src/vmutils.cpp @@ -83,6 +83,13 @@ namespace vm while ( ZYAN_SUCCESS( ZydisDecoderDecodeBuffer( &decoder, reinterpret_cast< void * >( routine_addr ), 0x1000, &instr ) ) ) { + // detect if we have already been at this instruction... if so that means there is a loop and we are going + // to just return... + if (std::find_if( routine.begin(), routine.end(), [ & ]( const zydis_instr_t &zydis_instr ) -> bool { + return zydis_instr.addr == routine_addr; + } ) != routine.end() ) + return true; + std::vector< u8 > raw_instr; raw_instr.insert( raw_instr.begin(), ( u8 * )routine_addr, ( u8 * )routine_addr + instr.length );