Files
ddidderr 8b99e9607c feat(reconstruction): complete binary-backed C recovery
Replace the partial mechanics transcriptions with a separate, readable C11
reconstruction of the complete Win16 image while preserving the original raw
Ghidra export as immutable evidence. Cover all ordinary and overlapping entry
points, Borland runtime behavior, Win16 imports, segmented data, callbacks,
resources, indirect control flow, physics, rendering, persistence, and
startup/shutdown lifecycles.

Add deterministic extraction and audit tooling plus address-linked ledgers for
functions, imports, DGROUP ranges and objects, relocations, resources, and
callbacks. The final gate records zero raw, partial, restored, unknown,
blocked, or unclassified required units. Keep the semantic-fidelity boundary
explicit: the portable C is not claimed to reproduce a byte-identical Borland
NE build.

Add strict focused harnesses for every reconstructed C unit, exact resource
round-trip checks, and a 16-bit Borland Real48 reference probe. No Rust source
or Cargo metadata is changed in this phase.

Test Plan:
- `bash original/tools/test_reconstructed_c.sh` -- passed
- `bash original/tools/probe_real48_reference.sh` -- passed bit-for-bit
- `python3 original/tools/audit_reconstruction.py --require-complete` -- passed
- `git diff --cached --check` -- passed
- `git diff HEAD -- '*.rs' Cargo.toml Cargo.lock` -- empty
2026-08-23 16:41:17 +02:00

44 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
workspace_dir=$(pwd -P)
ghidra_install_dir=${GHIDRA_INSTALL_DIR:-/opt/ghidra}
headless_analyzer="$ghidra_install_dir/support/analyzeHeadless"
script_dir="$workspace_dir/tools"
project_dir=$(mktemp -d /tmp/tdkpin-ghidra.XXXXXX)
if [[ ! -x "$headless_analyzer" ]]; then
echo "Ghidra headless analyzer not found at: $headless_analyzer" >&2
exit 1
fi
"$headless_analyzer" "$project_dir" tdkpin \
-import "$workspace_dir/TDKPIN.EXE" \
-analysisTimeoutPerFile 900 \
-max-cpu 8
"$headless_analyzer" "$project_dir" tdkpin \
-process TDKPIN.EXE \
-noanalysis \
-scriptPath "$script_dir" \
-preScript SeedMissingEntrypoints.java \
-preScript ApplyWin16ImportSignatures.java \
"$workspace_dir/IMPORT_RECONSTRUCTION.tsv" \
-postScript ExportDecompilation.java \
"$workspace_dir/TDKPIN_GHIDRA_COMPLETE_RAW.c" \
"$workspace_dir/COMPLETE_FUNCTIONS.tsv" \
-postScript AuditCoverage.java \
"$workspace_dir/COMPLETE_COVERAGE.tsv" \
-postScript ExportProgramEvidence.java \
"$workspace_dir/BINARY_FUNCTIONS.tsv" \
"$workspace_dir/REFERENCES.tsv" \
"$workspace_dir/DEFINED_DATA.tsv" \
"$workspace_dir/SYMBOLS.tsv" \
"$workspace_dir/UNEXPLAINED.tsv"
python3 "$script_dir/extract_ne_metadata.py" "$workspace_dir/TDKPIN.EXE" \
--output-dir "$workspace_dir"
python3 "$script_dir/build_data_coverage.py"
echo "Ghidra project retained at: $project_dir"