@@ -320,14 +320,8 @@ EXTERN_DLL_EXPORT VOID __stdcall DisassembleRemoteCode(HANDLE process, LPVOID ad
320
320
}
321
321
322
322
UIntPtr start = (UIntPtr)address;
323
- UIntPtr end = start + length;
324
- if (end <= start)
325
- {
326
- return ;
327
- }
328
323
329
- DISASM disasm;
330
- std::memset (&disasm, 0 , sizeof (DISASM));
324
+ DISASM disasm = { };
331
325
disasm.Options = NasmSyntax + PrefixedNumeral;
332
326
#ifdef _WIN64
333
327
disasm.Archi = 64 ;
@@ -338,12 +332,14 @@ EXTERN_DLL_EXPORT VOID __stdcall DisassembleRemoteCode(HANDLE process, LPVOID ad
338
332
std::vector<uint8_t > buffer (length);
339
333
readRemoteMemory (process, address, buffer.data (), buffer.size ());
340
334
335
+ UIntPtr end = (UIntPtr)buffer.data () + length;
336
+
341
337
disasm.EIP = (UIntPtr)buffer.data ();
342
338
disasm.VirtualAddr = start;
343
339
344
340
while (true )
345
341
{
346
- disasm.SecurityBlock = ((UIntPtr)buffer. data () + buffer. size ()) - disasm.EIP ;
342
+ disasm.SecurityBlock = end - disasm.EIP ;
347
343
348
344
auto disamLength = Disasm (&disasm);
349
345
if (disamLength == OUT_OF_BLOCK || disamLength == UNKNOWN_OPCODE)
@@ -354,7 +350,7 @@ EXTERN_DLL_EXPORT VOID __stdcall DisassembleRemoteCode(HANDLE process, LPVOID ad
354
350
callbackDisassembledCode ((LPVOID)disasm.VirtualAddr , disamLength, disasm.CompleteInstr );
355
351
356
352
disasm.EIP += disamLength;
357
- if (disasm.EIP >= end)
353
+ if (disasm.EIP >= end || buffer[disasm. EIP - (UIntPtr)buffer. data ()] == 0xCC )
358
354
{
359
355
break ;
360
356
}
0 commit comments