Skip to content

Commit 798cf95

Browse files
authored
Merge branch 'praydog:master' into master
2 parents 004a436 + 1d11dc6 commit 798cf95

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

reversing/rsz/emulation-dumper.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def hook_code(emu, address, size, frame):
301301
list_size = cur_hist[lex] - 1
302302

303303
# Loop count matches the integer we filled the whole buffer with
304-
if list_size == FILL_BYTE:
304+
if list_size == FILL_BYTE and len(frame["layout"]) > FILL_BYTE:
305305
try:
306306
element_layout = frame["layout"][-1]
307307
except IndexError as e:
@@ -320,7 +320,20 @@ def hook_code(emu, address, size, frame):
320320
frame["layout"] = frame["layout"][0:len(frame["layout"]) - FILL_BYTE]
321321
frame["was_string"] = False
322322

323-
list_layout = frame["layout"][-1]
323+
try:
324+
list_layout = frame["layout"][-1]
325+
except IndexError as e:
326+
cs.detail = True
327+
dis_g = cs.disasm(emu.mem_read(lex, 0x100), address, 1)
328+
dis = next(dis_g)
329+
330+
print("LEX: 0x%x" % lex)
331+
print("0x%x: %s %s" % (address, dis.mnemonic, dis.op_str))
332+
333+
print("Instruction at %X didn't read bytes from stream? (2)" % address)
334+
os.system("pause")
335+
return
336+
324337
list_layout["list"] = True
325338
list_layout["element"] = element_layout
326339
list_layout["element_size"] = int((element_layout["offset"] - list_layout["offset"]) / FILL_BYTE)

0 commit comments

Comments
 (0)