diff --git a/native_exec/simple_x64.py b/native_exec/simple_x64.py index b2fc56c..d3c2188 100644 --- a/native_exec/simple_x64.py +++ b/native_exec/simple_x64.py @@ -770,7 +770,7 @@ class MultipleInstr(object): # Change DelayedJump to LabeledJump ? if isinstance(instruction, DelayedJump): return self.add_delayed_jump(instruction) - if isinstance(instruction, Instruction): + if isinstance(instruction, (Instruction, Prefix)): self.instrs[self.size] = instruction self.size += len(instruction.get_code()) return diff --git a/native_exec/simple_x86.py b/native_exec/simple_x86.py index ac2292f..51e9c83 100644 --- a/native_exec/simple_x86.py +++ b/native_exec/simple_x86.py @@ -660,7 +660,7 @@ class MultipleInstr(object): # Change DelayedJump to LabeledJump ? if isinstance(instruction, DelayedJump): return self.add_delayed_jump(instruction) - if isinstance(instruction, Instruction): + if isinstance(instruction, (Instruction, Prefix)): self.instrs[self.size] = instruction self.size += len(instruction.get_code()) return diff --git a/native_exec/test_simple_x64.py b/native_exec/test_simple_x64.py index 1be0236..e1e55c3 100644 --- a/native_exec/test_simple_x64.py +++ b/native_exec/test_simple_x64.py @@ -111,4 +111,11 @@ TestInstr(Cpuid)() TestInstr(Xchg)('RAX', 'RSP') -assert Xchg('RAX', 'RCX').get_code() == Xchg('RCX', 'RAX').get_code() \ No newline at end of file +assert Xchg('RAX', 'RCX').get_code() == Xchg('RCX', 'RAX').get_code() + +code = MultipleInstr() +code += Nop() +code += Rep + Nop() +code += Ret() +print(repr(code.get_code())) +assert code.get_code() == "\x90\xf3\x90\xc3" \ No newline at end of file diff --git a/native_exec/test_simple_x86.py b/native_exec/test_simple_x86.py index 90f87e7..beb1c7d 100644 --- a/native_exec/test_simple_x86.py +++ b/native_exec/test_simple_x86.py @@ -117,3 +117,11 @@ TestInstr(Movsd, expected_result='movsd dword ptr es:[edi], dword ptr [esi]')() TestInstr(Xchg)('EAX', 'ESP') assert Xchg('EAX', 'ECX').get_code() == Xchg('ECX', 'EAX').get_code() + + +code = MultipleInstr() +code += Nop() +code += Rep + Nop() +code += Ret() +print(repr(code.get_code())) +assert code.get_code() == "\x90\xf3\x90\xc3"