mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-25 19:16:13 +00:00
32 lines
640 B
Python
Executable file
32 lines
640 B
Python
Executable file
#!/usr/bin/python
|
|
|
|
from unicorn import *
|
|
from unicorn.x86_const import *
|
|
|
|
binary1 = b'\x40\x01\xc1\x31\xf6\x90\x90\x90' # inc eax; add ecx, eax; xor esi, esi
|
|
|
|
mu = Uc(UC_ARCH_X86, UC_MODE_32)
|
|
|
|
mu.mem_map(0, 2 * 1024 * 1024)
|
|
|
|
# write machine code to be emulated to memory
|
|
mu.mem_write(0, binary1)
|
|
|
|
pos = 0
|
|
# emu for maximum 1 instruction.
|
|
mu.emu_start(pos, len(binary1), 0, 1)
|
|
|
|
print("EAX = %u" %mu.reg_read(UC_X86_REG_EAX))
|
|
|
|
pos = mu.reg_read(UC_X86_REG_EIP)
|
|
|
|
print("EIP = %x" %pos)
|
|
|
|
# emu to the end
|
|
mu.emu_start(pos, len(binary1))
|
|
|
|
print("EAX = %u" %mu.reg_read(UC_X86_REG_EAX))
|
|
|
|
pos = mu.reg_read(UC_X86_REG_EIP)
|
|
|
|
print("EIP = %x" %pos)
|