From eea5c30e7c490fa928a410b44fa3a93534eae359 Mon Sep 17 00:00:00 2001 From: ohyeah521 <1449374+ohyeah521@users.noreply.github.com> Date: Fri, 18 Apr 2025 10:57:18 +0800 Subject: [PATCH] Update ida.py --- plugins/patching/util/ida.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/patching/util/ida.py b/plugins/patching/util/ida.py index 1e85978..b5c6cea 100644 --- a/plugins/patching/util/ida.py +++ b/plugins/patching/util/ida.py @@ -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)