Skip to content

Commit

Permalink
uEmu: fixes and improvements
Browse files Browse the repository at this point in the history
- add `Dump To File` option to popup menu in mapped memory view
- fix typos in readme
  • Loading branch information
alexhude committed Aug 8, 2017
1 parent 7f9322f commit f3d65a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Supports following architectures out of the box: **x86**, **x64**, **ARM**, **AR

### Start

When emulation is started, it is necessary to provide initial CPU context (see _Update CPU Context_)
Start emulation from cursor. It is necessary to provide initial CPU context first (see _Update CPU Context_)
After that all segments from IDA database will be mapped to emulator (initialized data will be copied as well).

### Run
Expand Down Expand Up @@ -124,8 +124,8 @@ Every time emulation stops, changed memory blocks will be highlighted.

### Update CPU Context

Register Values can be changes individually or all at once with JSON file via popup menu.
Current context can also be saved in JSON fine for future use.
Register Values can be changed individually or all at once with JSON file via popup menu.
Current context can also be saved in JSON file for future use.

![](./Resources/screenshots/doc_changectx.png)

Expand All @@ -139,7 +139,7 @@ Apart from all the functions listed in Popup Menu, there are couple of new comma

#### Show Mapped Memory

Display all mapped regions. Use popup menu to display memory for particular region.
Display all mapped regions. Use popup menu to display memory for particular region or dump it to a file.

![](./Resources/screenshots/doc_mappedmem.png)

Expand Down
Binary file modified Resources/screenshots/doc_mappedmem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion uEmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,23 @@ def __init__(self, owner, memory, flags=0, width=None, height=None, embedded=Fal
self.items = memory
self.icon = -1
self.selcount = 0
self.popup_names = [ "", "", "Show", "" ]
self.popup_names = [ "", "Dump To File", "Show", "" ]
self.owner = owner

def OnClose(self):
pass

def OnDeleteLine(self, n): # Save JSON
filePath = AskFile(1, "*.bin", "Dump memory")
if filePath is not None:
with open(filePath, 'w') as outfile:
address = self.items[n][0]
size = self.items[n][1] - self.items[n][0] + 1
outfile.seek(0, 0)
outfile.write(self.owner.unicornEngine.get_mapped_bytes(address, size))
outfile.close()
return n

def OnEditLine(self, n):
address = self.items[n][0]
size = self.items[n][1] - self.items[n][0] + 1
Expand Down Expand Up @@ -783,6 +794,9 @@ def fetch_segments(self):
def get_mapped_memory(self):
return [ [ memStart, memEnd, memPerm ] for (memStart, memEnd, memPerm) in self.mu.mem_regions() ]

def get_mapped_bytes(self, address, size):
return self.mu.mem_read(address, size)

def hook_mem_access(self, uc, access, address, size, value, user_data):
if self.is_breakpoint_reached(address):
# vvv Workaround to fix issue when register are still updated even if emu_stop is called
Expand Down

0 comments on commit f3d65a1

Please sign in to comment.