[PR #702] [MERGED] feat(ghidra): admit explicit DOS COM analysis #2182

Closed
opened 2026-10-16 21:15:21 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/702
Author: @N0zoM1z0
Created: 10/6/2026
Status: ✅ Merged
Merged: 10/6/2026
Merged by: @N0zoM1z0

Base: main ← Head: feat/ghidra-dos-com-analysis


📝 Commits (2)

  • ad9739e feat(ghidra): admit explicit DOS COM analysis
  • 8c5e3b5 fix(verification): validate COM package selection before allocating fixtures

📊 Changes

45 files changed (+1104 additions, -75 deletions)

View changed files

📝 bridge/ghidra/ReaGhidraBridge.java (+23 -0)
➕ bridge/ghidra/ReaGhidraPrepareCom.java (+32 -0)
📝 docs/ghidra-dos.md (+40 -3)
📝 docs/product-catalog.json (+3 -3)
📝 docs/testing.md (+7 -0)
📝 docs/verification/managed-conformance-manifest.json (+2 -2)
📝 package.json (+2 -0)
➕ scripts/verify-real-ghidra-com.mjs (+277 -0)
📝 skills/reverse-engineer-anything/SKILL.md (+2 -2)
📝 skills/reverse-engineer-anything/references/native-and-artifacts.md (+5 -0)
📝 src/application/BinarySessionOpen.ts (+3 -0)
📝 src/application/BinarySessionPort.ts (+2 -0)
📝 src/application/BinaryTargetResolver.ts (+27 -2)
📝 src/application/DirectAnalysis.ts (+20 -1)
📝 src/cli/coreAnalysisCommands.ts (+134 -21)
📝 src/cli/options.ts (+11 -0)
📝 src/contracts/officialToolContracts.ts (+1 -1)
📝 src/contracts/sessionLifecycleInputs.ts (+6 -0)
📝 src/contracts/sessionToolContracts.ts (+1 -1)
📝 src/contracts/toolOutputSchemaPrimitives.ts (+1 -0)

...and 25 more files

📄 Description

Changes

  • Admit headerless DOS COM only when the caller explicitly selects its interpretation: open_binary({path, format: "dos-com"}) or CLI --target-format dos-com. Omission preserves header detection; the hint intentionally selects a complete-file interpretation independently of its filename. Validate the 64 KiB segment / 256-byte PSP format extent and reject contradictory target kinds.
  • Import with BinaryLoader at 1000:0100, the x86 real-mode language and default compiler spec. A packaged pre-analysis script seeds the entry and CS/DS/ES/SS context. Failed preparation prevents bridge startup.
  • Extend independent load-image verification to complete COM bytes, source mappings, entry, register context and absence of fixups; return imposed context separately from unverified PSP, stack and runtime state. Include measured entry context in MZ/other observations and bind the new observation representation in the analysis profile to invalidate incompatible cached snapshots.
  • Preserve DOS identity through Evidence, snapshots, artifact graphs and CLI/MCP boundaries. Hopper explicitly rejects this format. Package the new Java adapter asset and document the workflow/verification lane.

Verification

  • 114 focused tests across COM format/boundary validation, MZ/COM independent comparisons and negative controls, launcher arguments, provider projection, CLI/catalog contracts and SDK MCP transport.
  • npm run check:fast; npm run docs:check.
  • Actual node scripts/verify-real-ghidra-com.mjs: Linux x64 / Ghidra 12.1.4, generated public fixture, CLI/MCP parity for load-image/whole-file bytes/source offsets, imposed entry context, unmapped PSP/partial read, function discovery/decompilation, unchanged original and no surviving owned descendants. Run b2d266c0-bcfb-4efc-874b-a1e57e1285aa.
  • Actual MZ load-image CLI regression on the source-built MZ fixture, with all checks passing and no surviving owned descendants. Run ec12a784-ea4f-4b57-a424-0acb251e0ba1.
  • Two private local COM analysis images (original and separately identified decoded derivative) also verified with actual Ghidra. No game data, paths, digests, projects or outputs are committed.
  • npm package manifest confirms the Java preparation asset is included and private reference/work directories are excluded. The COM lane also passed against an extracted npm tarball with the locked local dependencies, including actual CLI/MCP/decompilation and clean process lineage. Packaged run e975cc01-adb5-43af-8936-ea580bd05fa5.
  • Real Hopper, macOS and Windows verification was not performed. Windows P0 remains unchanged and excludes DOS.

Examples

rea inspect-native-load-image /absolute/path/to/legacy.com --target-format dos-com --provider ghidra --json
rea function /absolute/path/to/legacy.com 0x10100 --target-format dos-com --provider ghidra --json
{"name":"open_binary","arguments":{"path":"/absolute/path/to/legacy.com","format":"dos-com","provider_id":"ghidra"}}
{"name":"inspect_native_load_image","arguments":{}}

COM is an explicit interpretation, not magic-based format identification. Verified import and decompilation do not establish DOS/PC-98 execution or source reconstruction.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/702 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/6/2026 **Status:** ✅ Merged **Merged:** 10/6/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `feat/ghidra-dos-com-analysis` --- ### 📝 Commits (2) - [`ad9739e`](https://github.com/morluto/rea/commit/ad9739e0e9d8e1e09fb970acca5472bf8f32f7e5) feat(ghidra): admit explicit DOS COM analysis - [`8c5e3b5`](https://github.com/morluto/rea/commit/8c5e3b55442bd7515375a9d440d910cda1179762) fix(verification): validate COM package selection before allocating fixtures ### 📊 Changes **45 files changed** (+1104 additions, -75 deletions) <details> <summary>View changed files</summary> 📝 `bridge/ghidra/ReaGhidraBridge.java` (+23 -0) ➕ `bridge/ghidra/ReaGhidraPrepareCom.java` (+32 -0) 📝 `docs/ghidra-dos.md` (+40 -3) 📝 `docs/product-catalog.json` (+3 -3) 📝 `docs/testing.md` (+7 -0) 📝 `docs/verification/managed-conformance-manifest.json` (+2 -2) 📝 `package.json` (+2 -0) ➕ `scripts/verify-real-ghidra-com.mjs` (+277 -0) 📝 `skills/reverse-engineer-anything/SKILL.md` (+2 -2) 📝 `skills/reverse-engineer-anything/references/native-and-artifacts.md` (+5 -0) 📝 `src/application/BinarySessionOpen.ts` (+3 -0) 📝 `src/application/BinarySessionPort.ts` (+2 -0) 📝 `src/application/BinaryTargetResolver.ts` (+27 -2) 📝 `src/application/DirectAnalysis.ts` (+20 -1) 📝 `src/cli/coreAnalysisCommands.ts` (+134 -21) 📝 `src/cli/options.ts` (+11 -0) 📝 `src/contracts/officialToolContracts.ts` (+1 -1) 📝 `src/contracts/sessionLifecycleInputs.ts` (+6 -0) 📝 `src/contracts/sessionToolContracts.ts` (+1 -1) 📝 `src/contracts/toolOutputSchemaPrimitives.ts` (+1 -0) _...and 25 more files_ </details> ### 📄 Description ## Changes - Admit headerless DOS COM only when the caller explicitly selects its interpretation: `open_binary({path, format: "dos-com"})` or CLI `--target-format dos-com`. Omission preserves header detection; the hint intentionally selects a complete-file interpretation independently of its filename. Validate the 64 KiB segment / 256-byte PSP format extent and reject contradictory target kinds. - Import with BinaryLoader at `1000:0100`, the x86 real-mode language and default compiler spec. A packaged pre-analysis script seeds the entry and CS/DS/ES/SS context. Failed preparation prevents bridge startup. - Extend independent load-image verification to complete COM bytes, source mappings, entry, register context and absence of fixups; return imposed context separately from unverified PSP, stack and runtime state. Include measured entry context in MZ/other observations and bind the new observation representation in the analysis profile to invalidate incompatible cached snapshots. - Preserve DOS identity through Evidence, snapshots, artifact graphs and CLI/MCP boundaries. Hopper explicitly rejects this format. Package the new Java adapter asset and document the workflow/verification lane. ## Verification - 114 focused tests across COM format/boundary validation, MZ/COM independent comparisons and negative controls, launcher arguments, provider projection, CLI/catalog contracts and SDK MCP transport. - `npm run check:fast`; `npm run docs:check`. - Actual `node scripts/verify-real-ghidra-com.mjs`: Linux x64 / Ghidra 12.1.4, generated public fixture, CLI/MCP parity for load-image/whole-file bytes/source offsets, imposed entry context, unmapped PSP/partial read, function discovery/decompilation, unchanged original and no surviving owned descendants. Run `b2d266c0-bcfb-4efc-874b-a1e57e1285aa`. - Actual MZ load-image CLI regression on the source-built MZ fixture, with all checks passing and no surviving owned descendants. Run `ec12a784-ea4f-4b57-a424-0acb251e0ba1`. - Two private local COM analysis images (original and separately identified decoded derivative) also verified with actual Ghidra. No game data, paths, digests, projects or outputs are committed. - npm package manifest confirms the Java preparation asset is included and private reference/work directories are excluded. The COM lane also passed against an extracted npm tarball with the locked local dependencies, including actual CLI/MCP/decompilation and clean process lineage. Packaged run `e975cc01-adb5-43af-8936-ea580bd05fa5`. - Real Hopper, macOS and Windows verification was not performed. Windows P0 remains unchanged and excludes DOS. ## Examples ```bash rea inspect-native-load-image /absolute/path/to/legacy.com --target-format dos-com --provider ghidra --json rea function /absolute/path/to/legacy.com 0x10100 --target-format dos-com --provider ghidra --json ``` ```json {"name":"open_binary","arguments":{"path":"/absolute/path/to/legacy.com","format":"dos-com","provider_id":"ghidra"}} {"name":"inspect_native_load_image","arguments":{}} ``` COM is an explicit interpretation, not magic-based format identification. Verified import and decompilation do not establish DOS/PC-98 execution or source reconstruction. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:15:21 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2182
No description provided.