Closed captainGeech42 closed 1 year ago
This works:
import binascii
from unicorn import *
from unicorn.x86_const import *
# popcnt bx, word ptr [esp - 0x4c]
code = binascii.unhexlify("66f30fb85c24b4")
mu = Uc(UC_ARCH_X86, UC_MODE_32)
mu.ctl_set_cpu_model(UC_CPU_X86_EPYC_ROME) # <-- This line
# stack
mu.mem_map(0x1000, 0x1000)
mu.reg_write(UC_X86_REG_ESP, 0x1080)
# code
mu.mem_map(0x3000,0x1000)
mu.mem_write(0x3000, code)
def hook(mu, addr, size, user_data):
print(f"addr={hex(addr)}, size={hex(size)}")
mu.hook_add(UC_HOOK_CODE, hook)
mu.emu_start(0x3000, 0x3000+len(code), count=1)
thank you for the code+reference @wtdcode , that works on my end as well!
I'm getting an invalid instruction exception when executing the below code. Capstone properly recognizes and disassembles those opcodes, so I'm not sure why Unicorn doesn't recognize it.
Output:
I'm running the latest pypi version on macOS