mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 09:48:21 +00:00
added regression test for fstcw not writing to memory
This commit is contained in:
parent
cc5d28e112
commit
91c9c89650
1 changed files with 32 additions and 0 deletions
32
regress/fpu_mem_write.py
Normal file
32
regress/fpu_mem_write.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
from unicorn import *
|
||||||
|
from unicorn.x86_const import *
|
||||||
|
|
||||||
|
ESP = 0x2000
|
||||||
|
PAGE_SIZE = 1 * 1024 * 1024
|
||||||
|
|
||||||
|
# fstcw [esp]
|
||||||
|
# pop ecx
|
||||||
|
CODE = b'\x9B\xD9\x3C\x24\x59'
|
||||||
|
|
||||||
|
def mem_reader(addr, size):
|
||||||
|
tmp = mu.mem_read(addr, size)
|
||||||
|
|
||||||
|
for i in tmp:
|
||||||
|
print(" 0x%x" % i),
|
||||||
|
print("")
|
||||||
|
|
||||||
|
def hook_mem_write(uc, access, address, size, value, user_data):
|
||||||
|
print("mem WRITE: 0x%x, data size = %u, data value = 0x%x" % (address, size, value))
|
||||||
|
return True
|
||||||
|
|
||||||
|
mu = Uc(UC_ARCH_X86, UC_MODE_32)
|
||||||
|
mu.mem_map(0, PAGE_SIZE)
|
||||||
|
mu.mem_write(0, CODE)
|
||||||
|
mu.reg_write(UC_X86_REG_ESP, ESP)
|
||||||
|
mu.hook_add(UC_HOOK_MEM_WRITE, hook_mem_write)
|
||||||
|
|
||||||
|
mu.emu_start(0x0, 0, 0, 2)
|
||||||
|
esp = mu.reg_read(UC_X86_REG_ESP)
|
||||||
|
print("value at ESP [0x%X]: " % esp)
|
||||||
|
mem_reader(esp, 10)
|
Loading…
Reference in a new issue