diff options
| author | VictorJulianiR <juliani_rodrigues@hotmail.com> | 2026-11-21 22:35:40 -0300 |
|---|---|---|
| committer | VictorJulianiR <juliani_rodrigues@hotmail.com> | 2026-11-21 22:35:59 -0300 |
| commit | ea2c6a91ad23a92a31c4273993aa4bb9a443efd2 (patch) | |
| tree | f225d749cc15a1657ff2f6e3b5bc6715d421e8fd /tools/rtti_scan.py | |
| parent | c432cdce127ed2d22a99aa6ef57d91db4a10b5bb (diff) | |
rtti_scan.py: an output it can't write is one line
The report was written outside the try that turns read and scan errors
into one ERROR line, so an --out in a missing folder (or the default
<image>.rtti.json next to a read-only image) ended in a traceback after
the whole scan. It now prints ERROR: <path>: <reason> and exits 1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/rtti_scan.py')
| -rw-r--r-- | tools/rtti_scan.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/rtti_scan.py b/tools/rtti_scan.py index 2a63adde2..03073dc16 100644 --- a/tools/rtti_scan.py +++ b/tools/rtti_scan.py | |||
| @@ -202,8 +202,12 @@ def main(): | |||
| 202 | 202 | ||
| 203 | out = {"image": a.image, **scanned} | 203 | out = {"image": a.image, **scanned} |
| 204 | path = a.out or re.sub(r"\.(exe|dll)$", "", a.image, flags=re.I) + ".rtti.json" | 204 | path = a.out or re.sub(r"\.(exe|dll)$", "", a.image, flags=re.I) + ".rtti.json" |
| 205 | with open(path, "w", encoding="utf-8") as f: | 205 | try: |
| 206 | json.dump(out, f, indent=1) | 206 | with open(path, "w", encoding="utf-8") as f: |
| 207 | json.dump(out, f, indent=1) | ||
| 208 | except OSError as exc: | ||
| 209 | print(f"ERROR: {path}: {exc.strerror or exc}", file=sys.stderr) | ||
| 210 | return 1 | ||
| 207 | print(f"{a.image}: {out['type_descriptors']} type descriptors, {len(out['classes'])} classes with RTTI, {len(out['vtables'])} vtables -> {path}") | 211 | print(f"{a.image}: {out['type_descriptors']} type descriptors, {len(out['classes'])} classes with RTTI, {len(out['vtables'])} vtables -> {path}") |
| 208 | for c in out["classes"][:5]: | 212 | for c in out["classes"][:5]: |
| 209 | print(" ", c["name"], "<-", ", ".join(c["bases"][:4])) | 213 | print(" ", c["name"], "<-", ", ".join(c["bases"][:4])) |