Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions plugins/patching/util/ida.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ def apply_patches(filepath):
def visitor(ea, file_offset, original_value, patched_value):

# the patched byte does not have a know file address
if file_offset == ida_idaapi.BADADDR:
print("%08X: has no file mapping (original: %02X patched: %02X)...skipping...\n" % (ea, original_value, patched_value))
return 0
if file_offset == -1:
fpos = ea - ida_nalt.get_imagebase()
if fpos > 0:
print(f"Manually calculated file_offset: {hex(fpos)}")
file_offset=fpos
else:
print("%08X: has no file mapping (original: %02X patched: %02X)...skipping...\n" % (ea, original_value, patched_value))
return 0

# seek to the patch location
f.seek(file_offset)
Expand Down