You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Injecting data at multiple addresses that lie within the same memory page causes any data but the last to be discarded.
Consider the following IDAPython demo code:
from idaemu import *
import binascii
e = Emu(UC_ARCH_X86, UC_MODE_32)
# write two bytes into the same page
e.setData(0x0FFFFF, b"\xAA") # new page
e.setData(0x100000, b"\xAA") # new page
e.setData(0x100010, b"\xAA") # same page as above, will overwrite data at 0x10000
e.eUntilAddress(0x401000, 0x401000) # run the emulator once to init data
print "0x0FFFFF:", binascii.hexlify(e.curUC.mem_read(0x0FFFFF, 1))
print "0x100000:", binascii.hexlify(e.curUC.mem_read(0x100000, 1)) # this results in 0x00, not 0xAA as expected
print "0x100010:", binascii.hexlify(e.curUC.mem_read(0x100010, 1))
This seems to be occurring because the loop that injects the data into the emulator memory calls uc.mem_map for every data element in the list. If the memory region that is mapped already contains data from a previous call, this data will now be disregarded.
Quick workaround:
def _initData(self, uc):
# DIRTY FIX: first loop maps memory
for address, data, init in self.data:
addr = self._alignAddr(address)
size = PAGE_ALIGN
while addr + size < len(data): size += PAGE_ALIGN
uc.mem_map(addr, size)
# second loop actually writes
for address, data, init in self.data:
addr = self._alignAddr(address)
size = PAGE_ALIGN
if init:
uc.mem_write(addr, self._getOriginData(addr, size))
uc.mem_write(address, data)
The text was updated successfully, but these errors were encountered:
Injecting data at multiple addresses that lie within the same memory page causes any data but the last to be discarded.
Consider the following IDAPython demo code:
This seems to be occurring because the loop that injects the data into the emulator memory calls uc.mem_map for every data element in the list. If the memory region that is mapped already contains data from a previous call, this data will now be disregarded.
Quick workaround:
The text was updated successfully, but these errors were encountered: