diff options
| author | blasty <blasty@local> | 2026-07-10 14:53:20 +0200 |
|---|---|---|
| committer | blasty <blasty@local> | 2026-07-10 14:53:20 +0200 |
| commit | b8d0335682758ef51eab1c6dea6435b11d4e0bd2 (patch) | |
| tree | b37fdb91e74dbe136f2d0d757c2062937be82b1c /server/patch_server.py | |
| parent | hex view: raw image bytes (VA-addressed), synced to the code cursor (diff) | |
| download | ida-tui-b8d0335682758ef51eab1c6dea6435b11d4e0bd2.tar.gz ida-tui-b8d0335682758ef51eab1c6dea6435b11d4e0bd2.tar.xz ida-tui-b8d0335682758ef51eab1c6dea6435b11d4e0bd2.zip | |
hex view: file offsets + 'g' goto (dedicated input)
Add a file_regions server tool (get_fileregion_offset per segment) and
Program.file_regions/file_offset so a virtual address maps to its raw
on-disk offset without a format-specific header parser. The hex view now
shows a VA column and a file-offset column side by side, and the status
line reports file+off.
Goto moves to its own top-level #goto Input instead of overloading the
function-filter box (which is hidden with the names pane, so goto was
unreachable there). In the hex view 'g' jumps the cursor to an address
(bounds-checked against the image); elsewhere it navigates as before.
Diffstat (limited to 'server/patch_server.py')
| -rw-r--r-- | server/patch_server.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/patch_server.py b/server/patch_server.py index eeebfae..f42cc3a 100644 --- a/server/patch_server.py +++ b/server/patch_server.py @@ -154,6 +154,30 @@ def set_lvar_type( ok = bool(ida_hexrays.modify_user_lvar_info( f.start_ea, ida_hexrays.MLI_TYPE, lsi)) return {"addr": hex(f.start_ea), "variable": variable, "type": type, "ok": ok} + + +@tool +@idasync +def file_regions() -> dict: + """Loaded segments mapped to their raw file offsets (get_fileregion_offset), + so clients can convert a virtual address to an on-disk file offset without a + format-specific header parser. file_off is -1 for non-file-backed segments + (e.g. .bss).""" + import ida_segment + import idaapi + + out = [] + seg = ida_segment.get_first_seg() + while seg is not None: + try: + fo = int(idaapi.get_fileregion_offset(seg.start_ea)) + except Exception: + fo = -1 + if fo < 0 or fo >= (1 << 48): + fo = -1 + out.append({"start": hex(seg.start_ea), "end": hex(seg.end_ea), "file_off": fo}) + seg = ida_segment.get_next_seg(seg.start_ea) + return {"regions": out} ''' SNIPPET = f"{BEGIN}\n{BODY.strip()}\n{END}\n" |
