Compare commits
4 commits
048af58296
...
b7b60c191a
| Author | SHA1 | Date | |
|---|---|---|---|
| b7b60c191a | |||
| ec236a2430 | |||
| 1b70294ef7 | |||
| 7586979838 |
41 changed files with 7681 additions and 19 deletions
1
.github/instructions/ghidra.instructions.md
vendored
1
.github/instructions/ghidra.instructions.md
vendored
|
|
@ -7,6 +7,7 @@ applyTo: "**"
|
|||
## Safety Guardrails
|
||||
|
||||
- Never create a git commit on your own.
|
||||
- Never save or explicitly persist Ghidra project/program changes yourself, including through MCP endpoints or scripts. Leave requested database edits pending in the live session and let the user handle saving them in Ghidra.
|
||||
- Never run a command that may delete files outside a temporary folder unless you first ask the user with `vscode_askQuestions` and get explicit confirmation.
|
||||
- If a request could remove or overwrite repository files, pause and confirm before proceeding.
|
||||
|
||||
|
|
|
|||
220
.github/skills/reverse-engineer-anything/SKILL.md
vendored
Normal file
220
.github/skills/reverse-engineer-anything/SKILL.md
vendored
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
---
|
||||
name: reverse-engineer-anything
|
||||
description: Reverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.
|
||||
metadata:
|
||||
version: "37"
|
||||
---
|
||||
|
||||
# REA
|
||||
|
||||
Use REA when a claim depends on a shipped binary or package, decompilation,
|
||||
passive application runtime evidence, or comparison with
|
||||
behavior not established by available source. For ordinary analysis of a
|
||||
complete source repository, use normal repository tools and do not run REA
|
||||
readiness or provider commands.
|
||||
|
||||
## Connect only when needed
|
||||
|
||||
Installing this skill supplies instructions; it does not register the REA MCP
|
||||
server, install analysis engines, or add tools to an already-running agent.
|
||||
|
||||
If REA tools are available and their registration is not known to be stale,
|
||||
proceed directly to the target. Do not run diagnostics or setup before every
|
||||
investigation. Use the connected server's actual tool list and input schemas;
|
||||
a skill installed from repository main may describe capabilities absent from
|
||||
an older npm release. Keep complete inline Evidence when that server does not
|
||||
advertise retained references.
|
||||
|
||||
If tools are absent, a call is blocked by the client, or a required provider is
|
||||
unavailable, read [connection and recovery](references/connection-and-recovery.md).
|
||||
Diagnose the observed blocker, continue useful supported work, and resume the
|
||||
original task after repair. Client approval, shell PATH, registration and engine
|
||||
availability have different remedies; avoid repeating setup for all of them.
|
||||
|
||||
Prefer an existing `rea` CLI. When none is installed and REA package acquisition
|
||||
is within the authorized scope, use `npx -y rea-agents@latest` in its place.
|
||||
Configuration repair starts with a read-only setup plan; show paths, backups and
|
||||
skill replacement before applying authorized changes. Preserve existing approval
|
||||
and target-execution boundaries. REA setup never installs or upgrades unrelated
|
||||
software, including Node.js, npm, Homebrew, Java, Ghidra, IDA, JADX, Binwalk or Unblob.
|
||||
|
||||
## Route the target first
|
||||
|
||||
Choose the first tool from the target the user supplied. Use `open_binary` for
|
||||
active-target native or archive workflows; target-free tools take their own
|
||||
explicit path or endpoint and do not need it.
|
||||
|
||||
- ASAR or extracted JavaScript/Electron tree:
|
||||
`analyze_javascript_application`.
|
||||
- Archive/package member inventory (ZIP/APK/IPA/MSIX/AppX or DMG):
|
||||
`open_binary` with the supplied local path; use `inspect_artifact` when its
|
||||
graph and findings help answer the question.
|
||||
- Android APK code, classes, methods, or incoming references:
|
||||
`inspect_android_package`, then focused Android tools when advertised.
|
||||
Archive member inventory still uses the archive route above.
|
||||
- Managed PE/CLI assembly: `inspect_managed_artifact`.
|
||||
- Firmware image: `inspect_firmware_regions` when advertised. Use
|
||||
`extract_firmware` when extraction is requested, with a caller-selected new
|
||||
absolute output directory. These tools use caller-supplied Binwalk/Unblob on
|
||||
Linux; see the [firmware guide](https://github.com/morluto/rea/blob/main/docs/firmware-analysis.md).
|
||||
- .NET NativeAOT PE/ELF: native Ghidra analysis. Native code can yield pseudocode;
|
||||
consult the NativeAOT workflow in `references/native-and-artifacts.md` for
|
||||
optional metadata recovery and its supported host/layout boundary.
|
||||
- User-owned browser page already open: `list_browser_targets`.
|
||||
- Retained HAR/native mitmproxy capture: `inspect_web_network_capture`. Select
|
||||
original record ordinals when useful; inspect producer fields and byte/number
|
||||
sidecars without fetching recorded URLs or claiming live attribution. See
|
||||
[historical captures](https://github.com/morluto/rea/blob/main/docs/web-network-captures.md) for the exact upstream
|
||||
profile and credential exclusions.
|
||||
- User-owned Electron runtime already open: `list_electron_targets`.
|
||||
- Explicit local EVM bytecode carrier: `inspect_evm_interface` with caller-selected
|
||||
`raw` or `hex` encoding. Preserve carrier/decoded digests and treat selectors,
|
||||
argument strings and mutability as inferred candidates; this performs no chain
|
||||
lookup or target execution. See the
|
||||
[EVM bytecode guide](https://github.com/morluto/rea/blob/main/docs/evm-bytecode.md).
|
||||
- Explicit Linux ELF file for offline layout, symbols, relocations or static
|
||||
mitigation evidence: `inspect_binary_layout`. This target-free operation uses
|
||||
caller-supplied pwntools without opening a disassembler database. Preserve its
|
||||
raw locations and inference/coverage limits; see the
|
||||
[offline binary guide](https://github.com/morluto/rea/blob/main/docs/binary-diagnostics.md).
|
||||
- Supplied Linux x86-64 ELF core: `inspect_recorded_crash`. Read every recorded
|
||||
thread, raw note and source-bound register without opening a live target.
|
||||
Historical PIDs do not select live processes. Request `include_debugger_context`
|
||||
only when core-only mapping candidates help; see the
|
||||
[recorded crash guide](https://github.com/morluto/rea/blob/main/docs/recorded-crashes.md).
|
||||
- PE resource type/name/language trees and static icon group references:
|
||||
`inspect_pe_resources` with an explicit path. This portable operation requires
|
||||
no active target or engine; opaque payloads retain file ranges and SHA-256.
|
||||
- Native executable, library, or analysis database: `open_binary`, then
|
||||
use focused analysis tools directly; call `binary_overview` when metadata or
|
||||
inventory context is useful and available from the selected provider.
|
||||
|
||||
For an existing IDA MCP configuration, use `open_binary` with the original
|
||||
input binary and `provider_id: "ida"`; do not pass an `.idb` or `.i64` database.
|
||||
The legacy attached profile binds the already-open GUI input by SHA-256 and
|
||||
leaves its database open. The modern headless profile creates and closes an
|
||||
owned private database without saving. Installation and registration reuse
|
||||
[mrexodia/ida-pro-mcp](https://github.com/mrexodia/ida-pro-mcp); see the
|
||||
[IDA provider guide](https://github.com/morluto/rea/blob/main/docs/ida-provider.md).
|
||||
Proceed directly to `analyze_function`, pseudocode, or function/string searches
|
||||
after opening; IDA does not supply `binary_overview`. Consult session availability
|
||||
when composing broader workflows. Modern direct callers and unsupported dossier
|
||||
facets remain unknown; live IDA results are not replayed from snapshots.
|
||||
|
||||
If the user says only "my app" without a name, path, or target already selected
|
||||
for this task, ask which app before searching for artifacts. Paths in unrelated
|
||||
saved reports and nearby test fixtures do not select the user's target. Resolve
|
||||
an actual human-readable app name to one clear installed artifact when possible;
|
||||
ask when matches are ambiguous. Never choose an example app on the user's behalf.
|
||||
|
||||
In a target-free session, use `open_binary` to bind any archive/package or
|
||||
native target whose analysis tool operates on the active target. Do not call an
|
||||
unadvertised tool; inspect `binary_session` with `{}` and its
|
||||
`result.tool_availability` for availability reasons and remediation. The tool
|
||||
list stays complete; availability depends on the operation, target, and host.
|
||||
|
||||
## Work summary-first
|
||||
|
||||
Start with the default result and use its inline Evidence and graph context.
|
||||
For a JavaScript application or ELF layout whose size is unknown or large,
|
||||
call `analyze_javascript_application` or `inspect_binary_layout` with
|
||||
`"detail": "summary"`, then inspect the retained `parent_evidence_id` with
|
||||
`inspect_analysis_view`.
|
||||
Page module identities and select the returned `node_id` before requesting an
|
||||
item; a single file path can represent several graph roles. Do not repeat an
|
||||
identical analysis or rejected call without a changed input or resolved blocker.
|
||||
Recheck session state when a lifecycle change makes that status useful.
|
||||
Make a focused follow-up only when the
|
||||
returned result leaves a specific question unanswered.
|
||||
|
||||
If MCP reports `resource_constraint` with `details.resource: "transport"`, call
|
||||
`inspect_analysis_view` with its reported same-session Evidence reference for a
|
||||
summary, one section/module, or a stable page. Use `trace_application_feature`
|
||||
once a seed is known, or call `export_evidence_bundle` to write the complete
|
||||
session to a selected path. The analysis remains complete in the ledger; avoid
|
||||
repeating it merely to request the same oversized response. Complete CLI JSON
|
||||
output also streams without a single MCP frame.
|
||||
|
||||
When the retained parent ID is unknown, use `get_evidence_bundle` with
|
||||
`detail: "summary"` and exact filters for operation, target SHA-256,
|
||||
analysis-profile digest or canonical procedure address. Select its returned
|
||||
Evidence ID for the next view instead of requesting the complete bundle.
|
||||
`retention: "complete-record"` means the whole record is stored; native
|
||||
value-flow truncation and unknown metadata remain separate. For an exported
|
||||
portable bundle, use `rea inspect-evidence-bundle` with JSON containing `path`,
|
||||
`detail: "summary"` and the same `filters`. Reading that file still requires
|
||||
validating its full contents within the local memory budget.
|
||||
|
||||
A client can also truncate a successful tool result without a REA transport
|
||||
error. Treat that preview as incomplete; use the retained parent ID for smaller
|
||||
views or export when the full record is needed. Do not parse the preview as
|
||||
canonical JSON or repeat the producer. For JavaScript, read the
|
||||
[module-view and trace recipes](references/javascript-applications.md) before
|
||||
drilling into a large graph; a broad bidirectional trace can expand unrelated
|
||||
containment relationships even after summary analysis.
|
||||
|
||||
Every conclusion must distinguish observations, inferences, and unknowns. Cite
|
||||
Evidence IDs, preserve limitations and incomplete coverage, and never imply
|
||||
that static analysis observed execution. Runtime requests execute the declared
|
||||
target and lifecycle; do not broaden the target or action beyond those fields.
|
||||
|
||||
Within the user's requested investigation, call available analysis tools
|
||||
directly. REA does not require permission grants or per-call approval flags.
|
||||
The agent client can independently require approval. Follow the declared request
|
||||
scope and the host's actual access requirements; use the recovery guide for an
|
||||
observed client-policy rejection.
|
||||
|
||||
## Plan broader investigations
|
||||
|
||||
For requests that span multiple features or subsystems, use a staged workflow:
|
||||
|
||||
1. Turn the request into a checklist of questions and the evidence each answer
|
||||
needs. Resolve target identity and constraints from the conversation and
|
||||
workspace before asking for information again.
|
||||
2. Inspect the current REA session, artifact identity, saved analysis database,
|
||||
bookmarks, and prior evidence. Reuse matching state; do not open duplicate
|
||||
sessions or repeat identical analysis.
|
||||
3. Start with the smallest useful overview or inventory. Follow each question
|
||||
from its entry point through relevant data and state changes to its result.
|
||||
Batch related operations around a specific hypothesis, then expand only when
|
||||
the returned evidence leaves a concrete gap.
|
||||
4. Inspect relevant packaged resources and configuration alongside code when
|
||||
they affect the question. Use format-aware inventory and parsers; do not
|
||||
infer behavior from filenames, strings, or layout alone.
|
||||
5. Corroborate a conclusion with the evidence type it requires. Use runtime
|
||||
observation only when static evidence cannot answer the question and the
|
||||
required host runtime and OS access are available. For JavaScript behavior,
|
||||
run probes against the actual app through the available browser, Electron,
|
||||
or process capture workflow.
|
||||
6. Decompose work into independent questions. When parallel workers are
|
||||
available and the questions do not depend on one another, assign distinct
|
||||
scopes, point workers to existing evidence, and ask them to return sources,
|
||||
conclusions, and unresolved gaps. Otherwise, work sequentially.
|
||||
7. Keep a concise finding ledger linking each conclusion to Evidence IDs,
|
||||
confidence/evidence type, search boundary, and remaining unknowns. Update
|
||||
the shared index or investigation report so later passes can reuse results.
|
||||
|
||||
Before finishing, revisit the original checklist. Mark each question as
|
||||
answered, partially answered, or unresolved based on its evidence; keep
|
||||
bounded negative searches bounded, and do not describe a broad investigation
|
||||
as complete while required questions remain open.
|
||||
|
||||
## Read only the relevant guide
|
||||
|
||||
- Native binaries, managed assemblies, archives, and extraction:
|
||||
[references/native-and-artifacts.md](references/native-and-artifacts.md)
|
||||
- ASARs, extracted JavaScript, feature tracing, and version comparison:
|
||||
[references/javascript-applications.md](references/javascript-applications.md)
|
||||
- Android APK declarations, classes, methods, and static references:
|
||||
[references/android-applications.md](references/android-applications.md)
|
||||
- Passive browser/Electron observation and static/runtime reconciliation:
|
||||
[references/runtime-observation.md](references/runtime-observation.md)
|
||||
- Evidence paging, comparisons, residual unknowns, and verification:
|
||||
[references/evidence-workflows.md](references/evidence-workflows.md)
|
||||
|
||||
## Finish the task
|
||||
|
||||
Explain findings in plain language and tie them to returned evidence. When the
|
||||
user asks to build something, use normal coding tools and separate observed
|
||||
behavior from design choices. Close an opened native session with
|
||||
`close_binary` when the investigation is complete.
|
||||
34
.github/skills/reverse-engineer-anything/references/android-applications.md
vendored
Normal file
34
.github/skills/reverse-engineer-anything/references/android-applications.md
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Android application artifacts
|
||||
|
||||
Use the connected server's advertised Android tools. Repository main and npm
|
||||
4.1.0 include this family. A skill installation alone cannot add it to an
|
||||
older server.
|
||||
|
||||
Start with `inspect_android_package` on the caller's APK path for package
|
||||
identity, manifest declarations, coverage, and inline Evidence. Use
|
||||
`search_android_classes` to find candidates, `inspect_android_class` for one
|
||||
class's members, `inspect_android_method` for decompilation, and
|
||||
`trace_android_references` for incoming static references. Each call takes its
|
||||
own APK path and explicit selectors; do not open a native session first.
|
||||
Choose an `overload_index` from the class inventory when methods are ambiguous
|
||||
instead of guessing.
|
||||
|
||||
The provider requires a separately supplied headless JADX MCP JAR 0.7.1 and
|
||||
Java 17 or newer. `REA_JADX_MCP_JAR` selects the absolute JAR path; `JAVA_HOME`
|
||||
can select Java. REA setup does not install or configure that JAR, and doctor
|
||||
provider scopes cover Hopper/Ghidra rather than JADX. Use existing tools and
|
||||
report missing prerequisites for the Android task specifically.
|
||||
|
||||
Linux and macOS use the POSIX owned-process boundary. Windows x64 requires the
|
||||
matching bundled native controls and uses an owned Job Object with bidirectional
|
||||
stdio. A full JDK, including `jdk.compiler`, is required on every host; Windows
|
||||
`JAVA_HOME` selects `bin\java.exe`. Consult the Android guide for actual host
|
||||
verification coverage. Calls use one worker and provider deadlines; optional
|
||||
`REA_JADX_HEAP_MIB` selects the JVM heap. The APK is never launched,
|
||||
and no emulator is required.
|
||||
|
||||
Manifest entries and decompiled text are static observations, not execution or
|
||||
policy enforcement. Incoming references are recovered static relationships;
|
||||
reflection, dynamic loading, and unresolved calls remain unknown. Preserve
|
||||
artifact digests, locations, diagnostics, and incomplete coverage. For archive
|
||||
members rather than code analysis, use `open_binary` and `inspect_artifact`.
|
||||
127
.github/skills/reverse-engineer-anything/references/connection-and-recovery.md
vendored
Normal file
127
.github/skills/reverse-engineer-anything/references/connection-and-recovery.md
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# Connection and task recovery
|
||||
|
||||
Read this guide only for an observed connection, command, approval or provider
|
||||
blocker. Keep the user's target and question in view. Explain what prevented the
|
||||
operation and the next useful step; after repair, continue the investigation.
|
||||
|
||||
Commands below use an installed `rea`. If none is available, use the package
|
||||
invocation in `SKILL.md` when acquiring REA is authorized. Follow the connected
|
||||
server's schemas and the installed CLI's help rather than assuming repository
|
||||
main and an older release expose the same arguments.
|
||||
|
||||
## Choose the remedy from the observed failure
|
||||
|
||||
| Observation | Meaning and next step |
|
||||
| --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| No REA tools in the active session | Inspect registration with `rea doctor --client codex --json`. A skill installation alone does not register MCP. |
|
||||
| Missing, malformed or stale registration | Prepare a scoped setup plan; apply only authorized changes with backups. |
|
||||
| Aligned registration, but no connected tools | Restart/reconnect the client. Doctor checks registration; it cannot establish the current agent's connection. Inspect the client's launch error if reconnection fails. |
|
||||
| `MCP tool call requires approval, but approval policy is never` | Codex rejected the call before REA executed it. Do not install an engine or repeat setup to solve this client-policy decision. See the approval section below. |
|
||||
| REA returns `provider_unavailable` or an unavailable tool entry | Read that operation's provider diagnostics or `binary_session.result.tool_availability`. Resolve only the prerequisite needed for the task; a complete tool catalog does not imply every operation is available. |
|
||||
| `rea` is missing in a child shell, or Node is incompatible | Inspect the actual shell PATH and launcher/runtime. A prefix installation may be absent from a login shell's PATH; this does not establish a broken MCP registration. |
|
||||
|
||||
If the client cannot launch its shell/sandbox helper or read the installed skill,
|
||||
inspect its launch diagnostic. For example, Codex can refuse helper aliases when
|
||||
CODEX_HOME is under `/tmp`; use an authorized profile outside the OS temporary
|
||||
directory. REA setup cannot repair the client's executor. Preserve the sandbox
|
||||
instead of silently disabling it to make an analysis command work.
|
||||
|
||||
Static JavaScript and ordinary ZIP inventory need neither Hopper nor Ghidra.
|
||||
HAR inspection is offline and does not require a live browser. Native
|
||||
decompilation, Android analysis and firmware extraction have their own
|
||||
bring-your-own prerequisites. Use supported inventory/static evidence when it
|
||||
answers part of the question, and name the unavailable evidence separately.
|
||||
Do not substitute another target. Label observations from ordinary shell tools
|
||||
as such; only actual REA output supplies REA Evidence.
|
||||
|
||||
## Repair registration when needed
|
||||
|
||||
For Codex:
|
||||
|
||||
```bash
|
||||
rea doctor --client codex --json
|
||||
rea setup --client codex --dry-run --json
|
||||
```
|
||||
|
||||
Use the current supported client's ID: `claude_code`, `claude_desktop`, `codex`,
|
||||
`cursor`, `gemini_cli`, `windsurf`, `devin`, `opencode`, `antigravity`,
|
||||
`copilot_cli`, `commandcode`, `qwen_code`, `vscode`, `grok_build`, `omp`, `pi`,
|
||||
`hermes`, or `grok_bot`. If unknown, inspect `doctor --json` before choosing a
|
||||
scope. `grok_bot` uses a chat registration step rather than local `mcp.json`.
|
||||
For unsupported clients, use version-pinned manual stdio registration or CLI.
|
||||
|
||||
Show the plan's exact paths, backups, changes and bundled-skill replacement.
|
||||
Obtain approval for writes when that concrete scope is not already authorized,
|
||||
then apply the same scope with `rea setup --client codex --yes`. Add
|
||||
`--install-hopper` only when separately needed and explicitly approved. Do not
|
||||
install or upgrade unrelated prerequisites. Restart/reconnect, verify tools
|
||||
actually appear, and resume the original task. If they remain absent, inspect
|
||||
the launch failure rather than looping through setup.
|
||||
|
||||
## Codex tool approval is separate from REA readiness
|
||||
|
||||
REA tools have no permission-grant handshake. Codex can still require approval
|
||||
because an operation creates owned resources, launches a helper or has cleanup
|
||||
effects. An advertised tool or successful doctor result does not override that
|
||||
client policy. `workspace-write` alone does not resolve an MCP approval
|
||||
rejection, and `approval_policy = "never"` does not mean every MCP tool is
|
||||
preapproved.
|
||||
|
||||
When interactive approval is available, use the client's approval flow for the
|
||||
requested operation. In an unattended run, continue through an authorized CLI
|
||||
workflow if the execution environment permits it, or report the blocked
|
||||
operation and the approval needed to proceed. Do not retry the same rejected
|
||||
call, silently broaden approvals, or rewrite MCP effects as read-only.
|
||||
|
||||
For an operator who explicitly wants to preapprove named operations in a
|
||||
disposable Codex profile, current Codex supports per-tool configuration. For
|
||||
example, opening and closing an analysis session can be scoped independently:
|
||||
|
||||
```toml
|
||||
[mcp_servers.rea.tools.open_binary]
|
||||
approval_mode = "approve"
|
||||
|
||||
[mcp_servers.rea.tools.close_binary]
|
||||
approval_mode = "approve"
|
||||
```
|
||||
|
||||
Use the actual server ID and only the operations whose effects were approved;
|
||||
this example does not approve inspection, extraction or runtime execution.
|
||||
Show the proposed config edit and preserve unrelated entries and backups before
|
||||
writing. Managed policy can constrain client settings. Consult the
|
||||
[Codex configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
|
||||
for the installed client's supported settings. This is an optional recovery
|
||||
choice, not a prerequisite for every REA task.
|
||||
|
||||
## Continue through an installed CLI
|
||||
|
||||
Check the command environment only if the launcher fails:
|
||||
|
||||
```bash
|
||||
command -v rea
|
||||
command -v node
|
||||
node --version
|
||||
rea --version
|
||||
```
|
||||
|
||||
Use the public launcher at its known installation path with a supported existing
|
||||
Node on PATH when the child shell loses a prefix installation. Avoid internal
|
||||
`dist/cli.js` entrypoints or global toolchain changes. MCP may have its own valid
|
||||
launcher even when a shell cannot resolve `rea`.
|
||||
|
||||
For a user-supplied JavaScript tree or ASAR, select output files in the authorized
|
||||
workspace and save complete Evidence before reading a view:
|
||||
|
||||
```bash
|
||||
rea analyze-javascript-application /absolute/path/to/app --json > app-evidence.json
|
||||
jq -c '{source: {kind: "inline", evidence: .}, view: {kind: "summary"}}' app-evidence.json > app-view.json
|
||||
rea inspect-analysis-view app-view.json
|
||||
```
|
||||
|
||||
These commands do not register MCP or install an analysis engine. CLI JavaScript
|
||||
JSON is complete and can be very large; redirect it rather than loading it into
|
||||
context. Use an existing JSON processor if `jq` is absent, without installing
|
||||
one just for this recipe. Inspect a module page or item using the same inline
|
||||
source and the [JavaScript recipes](javascript-applications.md). Preserve graph
|
||||
coverage, limitations and unknowns. Native CLI analysis still requires its
|
||||
selected engine, and all CLI operations retain the host's execution permissions.
|
||||
48
.github/skills/reverse-engineer-anything/references/evidence-workflows.md
vendored
Normal file
48
.github/skills/reverse-engineer-anything/references/evidence-workflows.md
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Evidence, comparison, and verification workflows
|
||||
|
||||
Evidence-producing tools return the complete Evidence record directly in MCP
|
||||
`structuredContent` and CLI JSON. Read `normalized_result` for operation data,
|
||||
and cite `evidence_id` when another tool or your explanation needs a stable
|
||||
reference. Preserve authority, limitations, coverage, and residual unknowns. If a result
|
||||
is incomplete or paginated, continue only when the remaining data matters to
|
||||
the task; do not fetch a bundle or resource merely to read a result already
|
||||
returned inline. When complete `inspect_binary_layout` or
|
||||
`analyze_javascript_application` Evidence is already retained, call
|
||||
`inspect_analysis_view` for a summary, one section/symbol/module, or a stable
|
||||
page instead of repeating the producer.
|
||||
|
||||
Use `record_unknown` to track unresolved questions in the user's investigation
|
||||
and name the authority or environment still required. Supply supporting and
|
||||
contradicting evidence IDs. It updates the session registry directly.
|
||||
Use `update_unknown` with the current revision; reread after a stale revision
|
||||
instead of retrying blindly. Only qualifying observed evidence can verify a
|
||||
resolution.
|
||||
|
||||
Use comparisons with complete, compatible page sets when claiming equivalence
|
||||
or absence:
|
||||
|
||||
- `compare_artifacts` compares inventory pages by occurrence path, content,
|
||||
metadata, and graph relations.
|
||||
- `compare_functions` compares explicit function Evidence, not fuzzy
|
||||
whole-binary matches.
|
||||
- `compare_bundles` compares canonical bundle membership and unknown history.
|
||||
- `find_changed_behavior` combines existing comparisons; static differences
|
||||
remain candidates, not causal proof.
|
||||
- `build_call_path` needs explicit function dossiers from one artifact/provider;
|
||||
an incomplete frontier makes absence unknown.
|
||||
- `correlate_static_and_runtime` uses explicit mappings; matching patterns are
|
||||
hypotheses, not causality.
|
||||
- `verify_reconstruction` evaluates a finite typed specification. A pass covers
|
||||
only declared comparable claims, not global equivalence.
|
||||
|
||||
Process captures are opt-in behavioral evidence, not a security sandbox. V3
|
||||
captures cannot be upgraded to V4; rerun the original scenario. Distinguish root
|
||||
exit from descendant settlement and require freshness when the task needs it.
|
||||
A timed-out target that must write a final report needs `finalization_ms`: REA
|
||||
sends SIGTERM to the captured root, keeps observing, and sends SIGKILL once
|
||||
only if the target has not exited by the end of the interval.
|
||||
`exit.finalization.signals` lists each attempt with its delivery result; the
|
||||
observed exit signal stays in `exit.signal`, `exit.code` is null for every
|
||||
deadline exit, and the code of a finalizer that exited on its own is in
|
||||
`exit.finalization.exit_code` (null on a signal exit or when no exit was
|
||||
observed).
|
||||
149
.github/skills/reverse-engineer-anything/references/javascript-applications.md
vendored
Normal file
149
.github/skills/reverse-engineer-anything/references/javascript-applications.md
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
# JavaScript and Electron application artifacts
|
||||
|
||||
Use `analyze_javascript_application` directly on the operator-supplied ASAR or
|
||||
extracted tree. When size is unknown or large and the connected schema advertises
|
||||
`detail`, request `detail: "summary"`. This returns an `inspect_analysis_view`
|
||||
Evidence record with a distinct ID and a `normalized_result.parent_evidence_id`
|
||||
for the complete retained application analysis. Source-map contents are part of
|
||||
that static analysis. Read findings, coverage, limitations and unknowns, then
|
||||
follow a specific unanswered question. Older servers without `detail` return
|
||||
the complete application Evidence inline when it fits.
|
||||
|
||||
When the connected schema advertises `max_heap_mb` and `analysis_timeout_ms`,
|
||||
these select the isolated source analyzer's old-space heap and per-source
|
||||
deadline. Defaults are 1024 MiB and 300000 ms. They do not change the MCP
|
||||
process heap. Resource-limited analyses preserve completed static facts and
|
||||
report partial semantic coverage with specific unknown scopes; this does not
|
||||
mean the source is malformed. Inspect those limits before retrying a source.
|
||||
When expanded relationships exceed the parent's available memory, inspect the
|
||||
file's modules item view for retained `static_analysis` and
|
||||
`semantic_module_analysis`. Their facts remain available even when graph links
|
||||
are unknown. Cumulative result exhaustion can stop analysis before every file
|
||||
is examined; the inventory and remaining unknown scopes distinguish that case.
|
||||
Timeout or cancellation after source analysis begins retains partial Evidence
|
||||
in the same session. A returned `error.details.partial_observation` reference
|
||||
can be supplied directly to `inspect_analysis_view`. If the SDK cancels locally, retrieve its recorded ID from
|
||||
the Evidence bundle before inspecting the partial analysis.
|
||||
|
||||
## Read a module without repeating analysis
|
||||
|
||||
Use the actual returned parent ID, on the same connection, as `source.evidence_id`.
|
||||
The following IDs are placeholders to replace with returned values. When the
|
||||
module's node ID is not already known, page identities before selecting an item.
|
||||
Pages return only node IDs, paths and roles; choose a useful page size and follow
|
||||
`coverage.next_offset` when another page matters:
|
||||
|
||||
```json
|
||||
{
|
||||
"source": {
|
||||
"kind": "retained-evidence",
|
||||
"evidence_id": "ev_ACTUAL_PARENT_ID"
|
||||
},
|
||||
"view": { "kind": "page", "collection": "modules", "offset": 0, "limit": 16 }
|
||||
}
|
||||
```
|
||||
|
||||
Select the relevant page entry by its exact `node_id` and recorded role:
|
||||
|
||||
```json
|
||||
{
|
||||
"source": {
|
||||
"kind": "retained-evidence",
|
||||
"evidence_id": "ev_ACTUAL_PARENT_ID"
|
||||
},
|
||||
"view": {
|
||||
"kind": "item",
|
||||
"collection": "modules",
|
||||
"selector": { "node_id": "jag_node_ACTUAL_NODE_ID" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Module pages include asset, bundled and source module roles, so one path can
|
||||
identify several entries. Use `selector.path` only when uniqueness is established;
|
||||
the returned node ID avoids needing a complete inventory to prove uniqueness. On ambiguity,
|
||||
select the matching node ID from the page or the error's candidates. Follow
|
||||
`next_offset` when another page matters. An item exposes that module node's
|
||||
recorded observations, identity, hashes, exports and source ranges; it does not
|
||||
include every child syntax observation, related edge or original source file.
|
||||
An absent item fact is not evidence of absence from the whole application.
|
||||
|
||||
## Trace only the remaining question
|
||||
|
||||
Use `trace_application_feature` on the parent application Evidence for one
|
||||
literal node ID, route, string, API, IPC channel, module, or native export.
|
||||
Select `incoming` for relationships leading to the seed, `outgoing` for those
|
||||
leaving it, and `both` when the question needs both. Trace traversal includes
|
||||
containment relationships, so even a narrow seed can expand many nodes; a
|
||||
bidirectional trace can reach unrelated sibling modules. A module item or page
|
||||
is preferable when its observations already answer the question. Do not treat
|
||||
all reached nodes as participants in the feature.
|
||||
|
||||
Reuse retained parent Evidence when the server advertises it, or supply complete
|
||||
Evidence inline. Include Hopper or Ghidra Evidence only when its artifact digest
|
||||
matches exactly.
|
||||
|
||||
## Recover an oversized display
|
||||
|
||||
An oversized response reports `resource_constraint` and
|
||||
`details.resource: "transport"`. Reuse
|
||||
`details.reported_limits.evidence_reference` with `inspect_analysis_view` for a
|
||||
summary, one module, or a stable page of module identities.
|
||||
`export_evidence_bundle` writes the complete canonical session to a
|
||||
caller-selected file. These workflows keep the original Evidence and coverage;
|
||||
a broad follow-up can also exceed framing.
|
||||
|
||||
A client can truncate a successful result inside its text envelope without a
|
||||
REA `resource_constraint`. Treat a truncation notice or incomplete JSON as a
|
||||
display limitation; do not claim the full record was examined. Reuse the known
|
||||
parent ID for smaller views, or export complete Evidence to a selected file
|
||||
while the session remains open. If the parent ID was lost from the preview,
|
||||
use the prior analysis summary or explicit ledger entries to recover it; do
|
||||
not invent an ID or rerun analysis just to reproduce the same display.
|
||||
|
||||
BrowserWindow preferences, preload and contextBridge surfaces, IPC
|
||||
registrations, utility processes, and native binding requests are static syntax
|
||||
observations. Only a unique exact literal IPC channel match supports an inferred
|
||||
pairing. Dynamic or ambiguous channels remain unresolved. A requested `.node`
|
||||
member is not a verified native export. Never claim runtime reachability,
|
||||
registration, defaults, or policy enforcement from static analysis.
|
||||
|
||||
For version comparison, analyze each version once, then call
|
||||
`compare_application_versions`. Accept only its digest, source-map, structural
|
||||
fingerprint, or non-module semantic matches. Module ordinals and minified names
|
||||
are not persistent identity. Report added or removed only with complete
|
||||
opposite-side coverage; otherwise report unknown.
|
||||
|
||||
When the question asks how one exact exported callable's returned object shape
|
||||
changed, analyze each version once and then call
|
||||
`compare_javascript_export_shapes` with explicit module paths and export names.
|
||||
Use the returned IDs on the same connection, or complete inline Evidence
|
||||
records, from both analysis calls. Accept variant
|
||||
pairing only through the tool's unique exact literal discriminant. Read
|
||||
`property_inventories` and each change's `presence` before treating `unknown` as
|
||||
"the name was not observed": inventories list observed property names even when
|
||||
values stay unknown, with a `source_range` for each paired or unpaired variant.
|
||||
Array holes and mutation-invalidated slots are not observed properties.
|
||||
Complete parent coverage reports presence-only
|
||||
`added`/`removed` independently of unresolved values. Cite the
|
||||
comparison Evidence and report JSON Pointer changes; dynamic values, ambiguous
|
||||
variants, and incomplete parent-property coverage stay unknown. This is static
|
||||
inference, not runtime behavior. When runtime semantics are needed, run
|
||||
behavioral probes against the relevant application versions and capture them
|
||||
through the available browser, Electron, or process workflows.
|
||||
|
||||
## Reusing application Evidence
|
||||
|
||||
When advertised by the connected server, application trace and compare tools
|
||||
accept complete inline Evidence or
|
||||
`{"kind":"retained-evidence","evidence_id":"ev_<64 lowercase hex characters>"}`
|
||||
for their application input (`application`, or `left`/`right`). `inspect_analysis_view`
|
||||
uses the same retained-reference form in `source`, or portable inline Evidence,
|
||||
to project a summary, module page, or one module with its recorded observations. This notation is
|
||||
a template: replace it with the actual returned ID. Versions before 4.1.0 accept only full
|
||||
inline Evidence. Use the exact ID
|
||||
returned by the producer on the same MCP connection. Resolution does not run
|
||||
analysis or select a provider; findings remain inline. Native observation
|
||||
arrays still take full Evidence. `close_binary` clears retained references;
|
||||
export a bundle before closing, or supply portable inline Evidence in another
|
||||
connection. A missing reference includes its ID and recovery guidance.
|
||||
167
.github/skills/reverse-engineer-anything/references/native-and-artifacts.md
vendored
Normal file
167
.github/skills/reverse-engineer-anything/references/native-and-artifacts.md
vendored
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
# Native, managed, and packaged artifacts
|
||||
|
||||
## Recorded Linux crashes
|
||||
|
||||
Use `inspect_recorded_crash` with an explicit Linux x86-64 ELF core path to
|
||||
inspect historical thread registers, signals, raw notes and original file
|
||||
ranges. It is independent of the active disassembler target. Source-bound
|
||||
register values and note bytes are observations; missing notes, signal-thread
|
||||
association and current executable/library identity remain unknown. PIDs are
|
||||
historical metadata and never authorize live attach or control.
|
||||
|
||||
The optional `include_debugger_context` facet adds mapping candidates through
|
||||
caller-supplied GDB/pwndbg in an owned core-only session. Display names do not
|
||||
establish current file identity; zero reported flags leave permissions unknown.
|
||||
Requested unavailable context fails with setup guidance. See
|
||||
[recorded crashes](https://github.com/morluto/rea/blob/main/docs/recorded-crashes.md)
|
||||
for exact upstream profiles, bounds and verification coverage.
|
||||
|
||||
## Offline ELF layout
|
||||
|
||||
Use `inspect_binary_layout` with an explicit local ELF path for file-backed
|
||||
sections, symbols, relocations, linkage names, and static mitigation inferences
|
||||
without opening a disassembler target. When that complete record is already
|
||||
retained, call `inspect_analysis_view` for a summary, mitigations or linkage
|
||||
facet, one section or symbol, or a stable page. Do not re-run the decoder to
|
||||
read a single object.
|
||||
|
||||
## Native targets
|
||||
|
||||
After `open_binary`, use focused search, procedure, or function tools directly.
|
||||
Use `binary_overview` when target metadata or inventory context helps answer the
|
||||
question. Prefer literal search, names, decompilation, callers, callees, and
|
||||
cross-references. Addresses and recovered pseudocode are analysis observations,
|
||||
not original source. Provider unavailability and unsupported metadata remain
|
||||
unknown rather than false.
|
||||
|
||||
For a completed `analyze_function` dossier, use `inspect_analysis_view` with
|
||||
`view: {kind: "native", facet: "value_flow_operations", offset: 0, limit: 32}`
|
||||
and the exact retained Evidence ID to read selected facts without reanalysis.
|
||||
Native facets also include procedure, pseudocode, assembly, basic blocks,
|
||||
comments, callers/callees, references, unresolved calls, referenced strings and
|
||||
names, the native API record, and value-flow summaries. Pseudocode offsets and limits count UTF-16
|
||||
code units; use the returned `next_offset` for continuation. Provider limitations
|
||||
and unavailable facts remain explicit; the complete parent Evidence is retained.
|
||||
|
||||
To see which functions or Objective-C methods a Mach-O actually calls in one
|
||||
run, use `observe_native_calls` with explicit breakpoints and a bounded
|
||||
`duration_ms`/`max_events`. It launches a new process under LLDB, so the target
|
||||
runs and may change files or use the network. Hardened-runtime targets need the
|
||||
`get-task-allow` entitlement.
|
||||
|
||||
Use `binary_session` with no arguments to check the open target, selected
|
||||
provider, and alignment. Its default `result.tool_availability` includes the
|
||||
complete tool inventory with availability reasons and remediation. When choosing
|
||||
a tool, use its entry in that result; `tools/list` retains the complete catalog
|
||||
when the target or provider state changes.
|
||||
|
||||
## DOS MZ with Ghidra
|
||||
|
||||
For an admitted DOS MZ target, use `inspect_native_load_image` to check measured
|
||||
loaded bytes, file mappings, relocations and the entry against the immutable
|
||||
snapshot. Keep `mismatch` and `unsupported` explicit. Verified import covers the
|
||||
reported static image, not runtime DOS or PC-98 hardware behavior.
|
||||
|
||||
Use `read_bytes` for initialized analysis memory and `address_to_file_offset` to
|
||||
anchor one observed address to original file bytes. Loader fixups can change a
|
||||
word; a source offset does not imply byte equality. Complete function body ranges
|
||||
use inclusive ends and can contain gaps. Do not treat the enclosing span as code.
|
||||
For packed targets, retain the original and separately derived artifact identities;
|
||||
decompiling an unpacking stub does not recover the unpacked program.
|
||||
|
||||
When reading Objective-C dispatch metadata, distinguish class implementation
|
||||
methods from protocol requirements: class methods report null requirement
|
||||
flags, while decoded protocol declarations retain required and optional facts.
|
||||
Property attributes remain raw name/value tokens; use the property's
|
||||
`atomicity` field for the decoded `N` marker or the default atomic behavior.
|
||||
Null class/meta flags, ivar counts, atomicity, or read-only values mean the
|
||||
selected provider did not establish that fact. Symbol names alone do not prove
|
||||
that a class is a root class or has no ivars.
|
||||
|
||||
## Managed PE/CLI
|
||||
|
||||
Start with `inspect_managed_artifact`. REA's canonical managed inspection is
|
||||
execution-free: do not claim it loaded, reflected, executed, or resolved the
|
||||
assembly. Keep managed/native boundaries and unavailable reconstruction facts
|
||||
explicit. A bring-your-own reconstruction oracle is separate from the canonical
|
||||
parser and must not become an implicit setup dependency.
|
||||
|
||||
### .NET NativeAOT
|
||||
|
||||
NativeAOT binaries contain native machine code, so ordinary CIL decompilers
|
||||
cannot recover the original method bodies. When managed metadata/CIL is absent,
|
||||
classify that as a native-analysis route rather than claiming source recovery.
|
||||
Open the native image with the selected deep provider and inspect functions,
|
||||
strings, calls, and references; describe decompiler output as pseudocode and
|
||||
inference.
|
||||
|
||||
NativeAOT images can be PE/COFF, ELF, or Mach-O executables and shared
|
||||
libraries. Use file bytes and loader metadata rather than suffixes to identify
|
||||
them. For packaged apps, inventory/extract with REA's artifact tools and retain
|
||||
the exact contained image identity. PDB, ELF debug, or dSYM sidecars are
|
||||
additional evidence only when the provider accepts and matches them.
|
||||
|
||||
For deeper type recovery, the optional third-party
|
||||
[Ghidra NativeAOT analyzer](https://github.com/Washi1337/ghidra-nativeaot)
|
||||
rehydrates ReadyToRun metadata and can recover method tables, type relationships,
|
||||
frozen objects, and strings. This is a Ghidra extension with its own install and
|
||||
interactive workflow; it is not currently part of REA's managed parser or
|
||||
headless Ghidra bridge. Treat its annotations as analysis evidence, retain the
|
||||
binary identity, and do not present recovered types as original source. Header
|
||||
discovery may require a symbol or analyst identification of the ReadyToRun
|
||||
header, depending on the binary and analyzer version.
|
||||
|
||||
## Packages and extraction
|
||||
|
||||
Use `inspect_artifact` for application bundles, archives, ZIP/APK/IPA/MSIX/AppX,
|
||||
ASAR, or DMG inputs when the artifact graph and findings help answer the
|
||||
question. It returns the complete artifact graph inline. Cite graph manifest
|
||||
IDs when using them.
|
||||
|
||||
For an IPA or a macOS `.app`, ZIP, or DMG, pass the inventory Evidence to
|
||||
`project_apple_application_graph`. It reports application roots and nested
|
||||
bundles by path convention: app extensions, XPC services, frameworks, login
|
||||
items, system and driver extensions, and plug-ins. It also lists privileged
|
||||
helpers, launchd plists, symlinks, and each bundle's `info_plist_path` and
|
||||
executable candidates. Roles are path conventions, not parsed plists; read the
|
||||
listed plists with `inspect_plist`.
|
||||
|
||||
After `open_binary` on a `.app` or Mach-O, use `trace_dylib_resolution` to see
|
||||
which file each `@rpath`, `@loader_path` and `@executable_path` load reaches for
|
||||
every executable in the bundle. It also lists missing or weak loads and earlier
|
||||
`@rpath` candidates that are absent. Narrow large bundles with `roots` or
|
||||
`architecture`. System paths stay undetermined because the dyld shared cache
|
||||
provides them.
|
||||
|
||||
Use `extract_artifact` when materialized files are needed. It takes no arguments
|
||||
and materializes all regular files into a fresh temporary directory chosen by
|
||||
REA. Symlinks and encrypted entries are inventory facts, not extractable files.
|
||||
The result reports the materialized directory; callers do not choose the
|
||||
destination. No separate permission grant is needed.
|
||||
|
||||
Native DMG traversal automatically uses a read-only mount on supported macOS
|
||||
hosts, with an owned temporary mount directory and cleanup. It needs no approval
|
||||
flag. Unsupported hosts or mount failures remain explicit limitations; do not
|
||||
claim child inventory when only root identity is available. Extraction is a
|
||||
separate filesystem-writing operation.
|
||||
|
||||
For headerless DOS COM, explicitly open with `format: "dos-com"` (CLI
|
||||
`--target-format dos-com`). Inspect the load image before trusting function
|
||||
analysis: the entry is `0x10100`, file offset zero, with imposed real-mode segment
|
||||
context. PSP/stack/device state remains unmodeled. See [DOS guide](https://github.com/morluto/rea/blob/main/docs/ghidra-dos.md).
|
||||
|
||||
### Function annotations in Ghidra
|
||||
|
||||
Use `annotate_native_function` for one function name and/or entry comments, with at least one explicit change. Review its annotation readback and refreshed dossier inline. Changes are atomic and session-scoped; empty comments clear them, omitted fields preserve them. Later MCP calls observe edits until close. CLI `annotate-native-function` returns the updated analysis before discarding the session. Original executable bytes are unchanged; edits invalidate immutable snapshots. Windows P0 does not admit database mutations. For naming only, `set_address_name` / `set_addresses_names` also work with Ghidra: they name function entries or data addresses (primary labels) and return compact per-address success booleans instead of a dossier.
|
||||
|
||||
## Offline PE resource inventory
|
||||
|
||||
Use `inspect_pe_resources` with an absolute `path`, or
|
||||
`rea inspect-pe-resources ./selected.exe --json`, for portable PE32/PE32+
|
||||
resource inspection without opening a native target. Preserve returned Evidence:
|
||||
type/name/language IDs and UTF-16 names, original directory/data/payload ranges,
|
||||
code pages, payload hashes and static icon-group references. Same-language icon
|
||||
resolution is explicit; missing references and size mismatch remain visible.
|
||||
Other payloads are opaque, and this operation does not decode images or simulate
|
||||
Windows resource loading. Consult the budgets and supported tree profile in
|
||||
[offline binary diagnostics](https://github.com/morluto/rea/blob/main/docs/binary-diagnostics.md).
|
||||
28
.github/skills/reverse-engineer-anything/references/runtime-observation.md
vendored
Normal file
28
.github/skills/reverse-engineer-anything/references/runtime-observation.md
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Passive browser and Electron observation
|
||||
|
||||
Supply the existing browser or Electron instance's literal-port loopback CDP
|
||||
endpoint in the request. No separate permission configuration or per-call
|
||||
approval flag is needed. Browser discovery lists eligible HTTP(S) pages;
|
||||
`allowed_origins` optionally filters them. An individual capture defaults to the
|
||||
selected page's current origin. Electron discovery lists eligible local
|
||||
`file://` targets without a configured file-root allowlist.
|
||||
|
||||
Start browser work with `list_browser_targets`; start Electron runtime work with
|
||||
`list_electron_targets`. Inspect the target selected for the user's task. Observation
|
||||
is passive: never claim REA clicked, navigated, evaluated page JavaScript,
|
||||
invoked IPC, captured prior activity, or contained the page's network.
|
||||
|
||||
Credentials, cookies, authorization headers, storage values, and raw
|
||||
WebSocket/JSON bodies are deliberately absent. Local URLs retain ordinary query
|
||||
values and fragments; userinfo credentials are removed. Browser accessibility
|
||||
text, console primitives, value-free shapes, script sources, source maps, and
|
||||
storage key names have request-specific capture options. Electron script
|
||||
sources are also optional. Use `capture_web_screenshot` when pixels are needed.
|
||||
Treat scope filtering, truncation, and attach-window coverage as limitations.
|
||||
Page-declared WebMCP tools are untrusted inventory and are never invoked by REA.
|
||||
|
||||
Use `reconcile_javascript_runtime` only after static application Evidence and
|
||||
passive browser/Electron Evidence exist. Prefer captured-source digest identity;
|
||||
report path/digest disagreement as a mismatch and preserve ambiguity. Explicit
|
||||
path mappings are inference inputs and never broaden filesystem or CDP authority.
|
||||
A bundle observed at runtime does not prove every contained module executed.
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -54,3 +54,4 @@ rebuild/**/imported/**
|
|||
**/dist/**
|
||||
**/.vite/**
|
||||
*.log
|
||||
JP/**
|
||||
Binary file not shown.
Binary file not shown.
BIN
Crusader.rep/idata/00/~0000000e.db/tmp8053461288306487346.ps
Normal file
BIN
Crusader.rep/idata/00/~0000000e.db/tmp8053461288306487346.ps
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -9,7 +9,314 @@
|
|||
</SAVE_STATE>
|
||||
</PROJECT_DATA_XML_NAME>
|
||||
<TOOL_MANAGER ACTIVE_WORKSPACE="Workspace">
|
||||
<WORKSPACE NAME="Workspace" ACTIVE="true" />
|
||||
<WORKSPACE NAME="Workspace" ACTIVE="true">
|
||||
<RUNNING_TOOL TOOL_NAME="CodeBrowser">
|
||||
<ROOT_NODE X_POS="10" Y_POS="170" WIDTH="1720" HEIGHT="931" EX_STATE="0">
|
||||
<SPLIT_NODE WIDTH="100" HEIGHT="100" DIVIDER_LOCATION="0" ORIENTATION="VERTICAL">
|
||||
<SPLIT_NODE WIDTH="1621" HEIGHT="816" DIVIDER_LOCATION="148" ORIENTATION="VERTICAL">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Entropy" OWNER="EntropyPlugin" TITLE="Entropy" ACTIVE="false" GROUP="Header" INSTANCE_ID="3207819926581772885" />
|
||||
<COMPONENT_INFO NAME="Overview" OWNER="OverviewPlugin" TITLE="Overview" ACTIVE="false" GROUP="Header" INSTANCE_ID="3207819926581772883" />
|
||||
</COMPONENT_NODE>
|
||||
<SPLIT_NODE WIDTH="1706" HEIGHT="835" DIVIDER_LOCATION="143" ORIENTATION="HORIZONTAL">
|
||||
<SPLIT_NODE WIDTH="243" HEIGHT="835" DIVIDER_LOCATION="640" ORIENTATION="VERTICAL">
|
||||
<SPLIT_NODE WIDTH="243" HEIGHT="532" DIVIDER_LOCATION="502" ORIENTATION="VERTICAL">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Program Tree" OWNER="ProgramTreePlugin" TITLE="Program Trees" ACTIVE="true" GROUP="Default" INSTANCE_ID="3757545580951314007" />
|
||||
</COMPONENT_NODE>
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Symbol Tree" OWNER="SymbolTreePlugin" TITLE="Symbol Tree" ACTIVE="true" GROUP="Default" INSTANCE_ID="3757545580951314002" />
|
||||
</COMPONENT_NODE>
|
||||
</SPLIT_NODE>
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="DataTypes Provider" OWNER="DataTypeManagerPlugin" TITLE="Data Type Manager" ACTIVE="true" GROUP="Default" INSTANCE_ID="3757545670340320835" />
|
||||
</COMPONENT_NODE>
|
||||
</SPLIT_NODE>
|
||||
<SPLIT_NODE WIDTH="1459" HEIGHT="835" DIVIDER_LOCATION="785" ORIENTATION="VERTICAL">
|
||||
<SPLIT_NODE WIDTH="1386" HEIGHT="638" DIVIDER_LOCATION="705" ORIENTATION="VERTICAL">
|
||||
<SPLIT_NODE WIDTH="1459" HEIGHT="652" DIVIDER_LOCATION="500" ORIENTATION="HORIZONTAL">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Listing" OWNER="CodeBrowserPlugin" TITLE="Listing: CRUSADER.EXE" ACTIVE="true" GROUP="Core" INSTANCE_ID="3757545580951314015" />
|
||||
</COMPONENT_NODE>
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Decompiler" OWNER="DecompilePlugin" TITLE="Decompile: static_resource_cache_construct" ACTIVE="true" GROUP="Default" INSTANCE_ID="3757476628342578776" />
|
||||
<COMPONENT_INFO NAME="Bytes" OWNER="ByteViewerPlugin" TITLE="Bytes: CRUSADER.EXE" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545580951314010" />
|
||||
<COMPONENT_INFO NAME="Data Window" OWNER="DataWindowPlugin" TITLE="Defined Data" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670340320839" />
|
||||
<COMPONENT_INFO NAME="Defined Strings" OWNER="ViewStringsPlugin" TITLE="Defined Strings" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757200037297742990" />
|
||||
<COMPONENT_INFO NAME="Equates Table" OWNER="EquateTablePlugin" TITLE="Equates Table" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545580951314013" />
|
||||
<COMPONENT_INFO NAME="External Programs" OWNER="ReferencesPlugin" TITLE="External Programs" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670231268929" />
|
||||
<COMPONENT_INFO NAME="Functions Window" OWNER="FunctionWindowPlugin" TITLE="Functions" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670231268932" />
|
||||
<COMPONENT_INFO NAME="Relocation Table" OWNER="RelocationTablePlugin" TITLE="Relocation Table" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670340320843" />
|
||||
</COMPONENT_NODE>
|
||||
</SPLIT_NODE>
|
||||
<SPLIT_NODE WIDTH="1386" HEIGHT="189" DIVIDER_LOCATION="495" ORIENTATION="HORIZONTAL">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Data Type Preview" OWNER="DataTypePreviewPlugin" TITLE="Data Type Preview" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670340320833" />
|
||||
</COMPONENT_NODE>
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Virtual Disassembler - Current Instruction" OWNER="DisassembledViewPlugin" TITLE="Disassembled View" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545580951314012" />
|
||||
</COMPONENT_NODE>
|
||||
</SPLIT_NODE>
|
||||
</SPLIT_NODE>
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Console" OWNER="ConsolePlugin" TITLE="Console" ACTIVE="true" GROUP="Default" INSTANCE_ID="3757545580951314009" />
|
||||
<COMPONENT_INFO NAME="Bookmarks" OWNER="BookmarkPlugin" TITLE="Bookmarks" ACTIVE="false" GROUP="Core.Bookmarks" INSTANCE_ID="3757545580951314006" />
|
||||
</COMPONENT_NODE>
|
||||
</SPLIT_NODE>
|
||||
</SPLIT_NODE>
|
||||
</SPLIT_NODE>
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Function Call Trees" OWNER="CallTreePlugin" TITLE="Function Call Trees" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545580951314003" />
|
||||
</COMPONENT_NODE>
|
||||
</SPLIT_NODE>
|
||||
<WINDOW_NODE X_POS="426" Y_POS="178" WIDTH="1033" HEIGHT="689">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Script Manager" OWNER="GhidraScriptMgrPlugin" TITLE="Script Manager" ACTIVE="false" GROUP="Script Group" INSTANCE_ID="3757545580951314004" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="423" Y_POS="144" WIDTH="927" HEIGHT="370">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Memory Map" OWNER="MemoryMapPlugin" TITLE="Memory Map" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545580951314000" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="383" Y_POS="7" WIDTH="1020" HEIGHT="1038">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Function Graph" OWNER="FunctionGraphPlugin" TITLE="Function Graph" ACTIVE="false" GROUP="Function Graph" INSTANCE_ID="3757545670340320845" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="550" Y_POS="206" WIDTH="655" HEIGHT="509">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Register Manager" OWNER="RegisterPlugin" TITLE="Register Manager" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670231268931" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="287" Y_POS="186" WIDTH="1424" HEIGHT="666">
|
||||
<SPLIT_NODE WIDTH="1408" HEIGHT="559" DIVIDER_LOCATION="573" ORIENTATION="HORIZONTAL">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Symbol Table" OWNER="SymbolTablePlugin" TITLE="Symbol Table" ACTIVE="false" GROUP="symbolTable" INSTANCE_ID="3757545670340320840" />
|
||||
</COMPONENT_NODE>
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Symbol References" OWNER="SymbolTablePlugin" TITLE="Symbol References" ACTIVE="false" GROUP="symbolTable" INSTANCE_ID="3757545670340320841" />
|
||||
</COMPONENT_NODE>
|
||||
</SPLIT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="-1" Y_POS="-1" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Checksum Generator" OWNER="ComputeChecksumsPlugin" TITLE="Checksum Generator" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545580951314014" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="-1" Y_POS="-1" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Function Tags" OWNER="FunctionTagPlugin" TITLE="Function Tags" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670340320836" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="-1" Y_POS="-1" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Comment Window" OWNER="CommentWindowPlugin" TITLE="Comments" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670340320838" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="-1" Y_POS="-1" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Python" OWNER="InterpreterPanelPlugin" TITLE="Python" ACTIVE="false" GROUP="Default" INSTANCE_ID="3207819978370941531" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="0" Y_POS="0" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="PyGhidra" OWNER="PyGhidra" TITLE="PyGhidra" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670340320837" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="0" Y_POS="0" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Source Files and Transforms" OWNER="SourceFilesTablePlugin" TITLE="Source Files and Transforms" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670231268930" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="0" Y_POS="0" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Bundle Manager" OWNER="GhidraScriptMgrPlugin" TITLE="Bundle Manager" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545580951314005" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="0" Y_POS="0" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Jython" OWNER="Jython" TITLE="Jython" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757200037004141725" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="0" Y_POS="0" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Function Call Graph" OWNER="FunctionCallGraphPlugin" TITLE="Function Call Graph" ACTIVE="false" GROUP="Function Call Graph" INSTANCE_ID="3757545670340320834" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
<WINDOW_NODE X_POS="0" Y_POS="0" WIDTH="0" HEIGHT="0">
|
||||
<COMPONENT_NODE TOP_INFO="0">
|
||||
<COMPONENT_INFO NAME="Defined Strings" OWNER="DefinedStringsPlugin" TITLE="Defined Strings" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757545670340320842" />
|
||||
</COMPONENT_NODE>
|
||||
</WINDOW_NODE>
|
||||
</ROOT_NODE>
|
||||
<DATA_STATE>
|
||||
<PLUGIN NAME="NavigationHistoryPlugin">
|
||||
<XML NAME="HISTORY_LIST_0">
|
||||
<SAVE_STATE>
|
||||
<STATE NAME="CURRENT_LOC_INDEX" TYPE="int" VALUE="1" />
|
||||
<STATE NAME="LOCATION_COUNT" TYPE="int" VALUE="2" />
|
||||
<STATE NAME="MEMENTO_CLASS0" TYPE="string" VALUE="ghidra.app.plugin.core.gotoquery.DefaultNavigatableLocationMemento" />
|
||||
<STATE NAME="MEMENTO_CLASS1" TYPE="string" VALUE="ghidra.app.plugin.core.gotoquery.DefaultNavigatableLocationMemento" />
|
||||
<XML NAME="MEMENTO_DATA0">
|
||||
<SAVE_STATE>
|
||||
<XML NAME="MEMENTO0">
|
||||
<SAVE_STATE>
|
||||
<STATE NAME="CURSOR_OFFSET" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="MEMENTO_CLASS" TYPE="string" VALUE="ghidra.app.plugin.core.codebrowser.CodeViewerLocationMemento" />
|
||||
<STATE NAME="NAV_ID" TYPE="long" VALUE="3757476628342578783" />
|
||||
<STATE NAME="PROGRAM_ID" TYPE="long" VALUE="3721129048497902276" />
|
||||
<STATE NAME="PROGRAM_PATH_" TYPE="string" VALUE="Crusader:/ja/CRUSADER.EXE" />
|
||||
<STATE NAME="_ADDRESS" TYPE="string" VALUE="00400000" />
|
||||
<STATE NAME="_BYTE_ADDR" TYPE="string" VALUE="00400000" />
|
||||
<STATE NAME="_CHAR_OFFSET" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_CLASSNAME" TYPE="string" VALUE="ghidra.program.util.MemoryBlockStartFieldLocation" />
|
||||
<STATE NAME="_COLUMN" TYPE="int" VALUE="0" />
|
||||
<ARRAY NAME="_COMMENT" TYPE="string">
|
||||
<A VALUE="//" />
|
||||
<A VALUE="// Headers" />
|
||||
<A VALUE="// ram:00400000-ram:004003ff" />
|
||||
<A VALUE="//" />
|
||||
</ARRAY>
|
||||
<STATE NAME="_ROW" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_TYPE" TYPE="int" VALUE="-1" />
|
||||
</SAVE_STATE>
|
||||
</XML>
|
||||
<STATE NAME="MEMENTO_CLASS" TYPE="string" VALUE="ghidra.app.plugin.core.gotoquery.DefaultNavigatableLocationMemento" />
|
||||
<STATE NAME="NUM_MEMENTOS" TYPE="int" VALUE="1" />
|
||||
<STATE NAME="PROGRAM_ID" TYPE="long" VALUE="3721129048497902276" />
|
||||
<STATE NAME="PROGRAM_PATH_" TYPE="string" VALUE="Crusader:/ja/CRUSADER.EXE" />
|
||||
<STATE NAME="_ADDRESS" TYPE="string" VALUE="00400000" />
|
||||
<STATE NAME="_BYTE_ADDR" TYPE="string" VALUE="00400000" />
|
||||
<STATE NAME="_CHAR_OFFSET" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_CLASSNAME" TYPE="string" VALUE="ghidra.program.util.MemoryBlockStartFieldLocation" />
|
||||
<STATE NAME="_COLUMN" TYPE="int" VALUE="0" />
|
||||
<ARRAY NAME="_COMMENT" TYPE="string">
|
||||
<A VALUE="//" />
|
||||
<A VALUE="// Headers" />
|
||||
<A VALUE="// ram:00400000-ram:004003ff" />
|
||||
<A VALUE="//" />
|
||||
</ARRAY>
|
||||
<STATE NAME="_ROW" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_TYPE" TYPE="int" VALUE="-1" />
|
||||
</SAVE_STATE>
|
||||
</XML>
|
||||
<XML NAME="MEMENTO_DATA1">
|
||||
<SAVE_STATE>
|
||||
<XML NAME="MEMENTO0">
|
||||
<SAVE_STATE>
|
||||
<STATE NAME="CURSOR_OFFSET" TYPE="int" VALUE="311" />
|
||||
<STATE NAME="MEMENTO_CLASS" TYPE="string" VALUE="ghidra.app.plugin.core.codebrowser.CodeViewerLocationMemento" />
|
||||
<STATE NAME="NAV_ID" TYPE="long" VALUE="3757476628342578783" />
|
||||
<STATE NAME="PROGRAM_ID" TYPE="long" VALUE="3721129048497902276" />
|
||||
<STATE NAME="PROGRAM_PATH_" TYPE="string" VALUE="Crusader:/ja/CRUSADER.EXE" />
|
||||
<STATE NAME="_ADDRESS" TYPE="string" VALUE="004755c8" />
|
||||
<STATE NAME="_BYTE_ADDR" TYPE="string" VALUE="004755c8" />
|
||||
<STATE NAME="_CHAR_OFFSET" TYPE="int" VALUE="4" />
|
||||
<STATE NAME="_CLASSNAME" TYPE="string" VALUE="ghidra.program.util.MnemonicFieldLocation" />
|
||||
<STATE NAME="_COLUMN" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_MNEMONIC" TYPE="string" VALUE="PUSH" />
|
||||
<STATE NAME="_ROW" TYPE="int" VALUE="0" />
|
||||
</SAVE_STATE>
|
||||
</XML>
|
||||
<STATE NAME="MEMENTO_CLASS" TYPE="string" VALUE="ghidra.app.plugin.core.gotoquery.DefaultNavigatableLocationMemento" />
|
||||
<STATE NAME="NUM_MEMENTOS" TYPE="int" VALUE="1" />
|
||||
<STATE NAME="PROGRAM_ID" TYPE="long" VALUE="3721129048497902276" />
|
||||
<STATE NAME="PROGRAM_PATH_" TYPE="string" VALUE="Crusader:/ja/CRUSADER.EXE" />
|
||||
<STATE NAME="_ADDRESS" TYPE="string" VALUE="004755c8" />
|
||||
<STATE NAME="_BYTE_ADDR" TYPE="string" VALUE="004755c8" />
|
||||
<STATE NAME="_CHAR_OFFSET" TYPE="int" VALUE="4" />
|
||||
<STATE NAME="_CLASSNAME" TYPE="string" VALUE="ghidra.program.util.MnemonicFieldLocation" />
|
||||
<STATE NAME="_COLUMN" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_MNEMONIC" TYPE="string" VALUE="PUSH" />
|
||||
<STATE NAME="_ROW" TYPE="int" VALUE="0" />
|
||||
</SAVE_STATE>
|
||||
</XML>
|
||||
<STATE NAME="NAV_ID" TYPE="long" VALUE="-1" />
|
||||
</SAVE_STATE>
|
||||
</XML>
|
||||
<STATE NAME="LIST_COUNT" TYPE="int" VALUE="1" />
|
||||
</PLUGIN>
|
||||
<PLUGIN NAME="ProgramTreePlugin">
|
||||
<STATE NAME="Current Viewname" TYPE="string" VALUE="Program Tree" />
|
||||
<ARRAY NAME="GroupNameProgram Tree0" TYPE="string">
|
||||
<A VALUE="CRUSADER.EXE" />
|
||||
</ARRAY>
|
||||
<STATE NAME="NavigationToggleState" TYPE="boolean" VALUE="false" />
|
||||
<STATE NAME="NumberOfGroupsProgram Tree" TYPE="int" VALUE="1" />
|
||||
<STATE NAME="NumberOfViews" TYPE="int" VALUE="1" />
|
||||
<STATE NAME="TreeName-0" TYPE="string" VALUE="Program Tree" />
|
||||
</PLUGIN>
|
||||
<PLUGIN NAME="DecompilePlugin">
|
||||
<STATE NAME="INDEX" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="NAV_ID" TYPE="long" VALUE="3757476628342578776" />
|
||||
<STATE NAME="Num Disconnected" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="Y_OFFSET" TYPE="int" VALUE="-10" />
|
||||
<STATE NAME="_ADDRESS" TYPE="string" VALUE="0045c92b" />
|
||||
<STATE NAME="_BYTE_ADDR" TYPE="string" VALUE="0045c92b" />
|
||||
<STATE NAME="_CHAR_OFFSET" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_CLASSNAME" TYPE="string" VALUE="ghidra.program.util.OperandFieldLocation" />
|
||||
<STATE NAME="_COLUMN" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_REP" TYPE="string" VALUE="AL" />
|
||||
<STATE NAME="_ROW" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_SUBOPINDEX" TYPE="int" VALUE="0" />
|
||||
</PLUGIN>
|
||||
<PLUGIN NAME="ByteViewerPlugin">
|
||||
<STATE NAME="Block Column" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="Block Num" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="Block Offset" TYPE="string" VALUE="0" />
|
||||
<STATE NAME="Index" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="NAV_ID" TYPE="long" VALUE="3757476628342578778" />
|
||||
<STATE NAME="Num Disconnected" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="X Offset" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="Y Offset" TYPE="int" VALUE="0" />
|
||||
</PLUGIN>
|
||||
<PLUGIN NAME="ProgramManagerPlugin">
|
||||
<STATE NAME="CURRENT_FILE" TYPE="string" VALUE="CRUSADER.EXE" />
|
||||
<STATE NAME="LOCATION_0" TYPE="string" VALUE="/K:/ghidra/Crusader_Decomp/" />
|
||||
<STATE NAME="NUM_PROGRAMS" TYPE="int" VALUE="1" />
|
||||
<STATE NAME="PATHNAME_0" TYPE="string" VALUE="/ja/CRUSADER.EXE" />
|
||||
<STATE NAME="PROJECT_NAME_0" TYPE="string" VALUE="Crusader" />
|
||||
<STATE NAME="VERSION_0" TYPE="int" VALUE="-1" />
|
||||
<STATE NAME="_ADDRESS" TYPE="string" VALUE="0045c92b" />
|
||||
<STATE NAME="_BYTE_ADDR" TYPE="string" VALUE="0045c92b" />
|
||||
<STATE NAME="_CHAR_OFFSET" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_CLASSNAME" TYPE="string" VALUE="ghidra.program.util.OperandFieldLocation" />
|
||||
<STATE NAME="_COLUMN" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_REP" TYPE="string" VALUE="AL" />
|
||||
<STATE NAME="_ROW" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_SUBOPINDEX" TYPE="int" VALUE="0" />
|
||||
</PLUGIN>
|
||||
<PLUGIN NAME="FunctionGraphPlugin">
|
||||
<SAVE_STATE NAME="COMPLEX_LAYOUT_NAME" KEY="COMPLEX_LAYOUT_NAME" TYPE="SaveState">
|
||||
<STATE NAME="LAYOUT_CLASS_NAME" TYPE="string" VALUE="ghidra.app.plugin.core.functiongraph.graph.layout.DecompilerNestedLayoutProvider" />
|
||||
<STATE NAME="LAYOUT_NAME" TYPE="string" VALUE="Nested Code Layout" />
|
||||
</SAVE_STATE>
|
||||
<STATE NAME="DISPLAY_POPUPS" TYPE="boolean" VALUE="true" />
|
||||
<STATE NAME="DISPLAY_SATELLITE" TYPE="boolean" VALUE="true" />
|
||||
<STATE NAME="DOCK_SATELLITE" TYPE="boolean" VALUE="true" />
|
||||
<STATE NAME="DOCK_SATELLITE_POSITION" TYPE="string" VALUE="LOWER_RIGHT" />
|
||||
<STATE NAME="Disconnected Count" TYPE="int" VALUE="0" />
|
||||
<ENUM NAME="EDGE_HOVER_HIGHLIGHT" TYPE="enum" CLASS="ghidra.app.plugin.core.functiongraph.EdgeDisplayType" VALUE="ScopedFlowsFromVertex" />
|
||||
<ENUM NAME="EDGE_SELECTION_HIGHLIGHT" TYPE="enum" CLASS="ghidra.app.plugin.core.functiongraph.EdgeDisplayType" VALUE="AllCycles" />
|
||||
<STATE NAME="NAV_ID" TYPE="long" VALUE="3757480742898179661" />
|
||||
</PLUGIN>
|
||||
<PLUGIN NAME="CodeBrowserPlugin">
|
||||
<STATE NAME="INDEX" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="NAV_ID" TYPE="long" VALUE="3757476628342578783" />
|
||||
<STATE NAME="Num Disconnected" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="Y_OFFSET" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_ADDRESS" TYPE="string" VALUE="0045c92b" />
|
||||
<STATE NAME="_BYTE_ADDR" TYPE="string" VALUE="0045c92b" />
|
||||
<STATE NAME="_CHAR_OFFSET" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_CLASSNAME" TYPE="string" VALUE="ghidra.program.util.OperandFieldLocation" />
|
||||
<STATE NAME="_COLUMN" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_REP" TYPE="string" VALUE="AL" />
|
||||
<STATE NAME="_ROW" TYPE="int" VALUE="0" />
|
||||
<STATE NAME="_SUBOPINDEX" TYPE="int" VALUE="0" />
|
||||
</PLUGIN>
|
||||
</DATA_STATE>
|
||||
</RUNNING_TOOL>
|
||||
</WORKSPACE>
|
||||
</TOOL_MANAGER>
|
||||
</PROJECT>
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
BIN
Crusader.rep/user/00/~0000000c.db/db.15.gbf
Normal file
BIN
Crusader.rep/user/00/~0000000c.db/db.15.gbf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -10,10 +10,16 @@
|
|||
"path": "../Crusader-vscode"
|
||||
},
|
||||
{
|
||||
"path": "../GhidraMCP"
|
||||
"path": "../crusader_map_viewer"
|
||||
},
|
||||
{
|
||||
"path": "../crusader_map_viewer"
|
||||
"path": "../../mcp/GhidraMCP"
|
||||
},
|
||||
{
|
||||
"path": "C:/RE/CRUSADER_JP_ISO"
|
||||
},
|
||||
{
|
||||
"path": "G:/games/Crusader No Remorse"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
|
|
|
|||
BIN
JP/CRUSADER.EXE
Normal file
BIN
JP/CRUSADER.EXE
Normal file
Binary file not shown.
|
|
@ -1,15 +1,15 @@
|
|||
"Segment","Type","FileOffset","Length","CoverageStatus","KnownSubsystem","KeyNamedFunctions","Blockers","NotesSource"
|
||||
"1","code","0x37600","0x8400","Deep","Gameplay cursor/input/projectiles","cursor_update_hover; entity_fire_weapon; projectile_update_tick","Broader gameplay subsystem still spans adjacent segments","crusader_decompilation_notes.md; plan-mid.md"
|
||||
"2","code","0x40000","0x2B0","None","","","","crusader_ne_segments.csv"
|
||||
"3","code","0x40400","0x55A","None","","","","crusader_ne_segments.csv"
|
||||
"4","code","0x40A00","0x10B1","Foothold","Reset/cache entry path","runtime_cache_reset_sequence","ASYLUM.24 and downstream reset callers still need tighter classification","crusader_decompilation_notes.md; plan-mid.md"
|
||||
"2","code","0x40000","0x2B0","Partial","Resource image records, viewport row loading, and palette conversion","resource_image_record_allocate_and_load_1008_0032; resource_image_record_open_and_read_1008_0098; resource_image_read_rows_into_vport_1008_0167; resource_palette_rgb_to_vga6_1008_01eb; resource_palette_triplet_alloc_callback_1008_028c","All five functions in this short segment are identified; the complete resource-record schema and broader file-loader ownership remain partially characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"3","code","0x40400","0x55A","Partial","Tile area search and solid/damage overlap","AreaSearch_FindItemAtWorldPosition_1010_0032; AreaSearch_FindItemAtTilePosition_1010_0061; AreaSearch_FindItemInTileRect_1010_007d; Item_CheckSolidDamageOverlap_1010_02de","The four documented helpers have no exact auto-names remaining; broader area-search and overlap call paths are not fully characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"4","code","0x40A00","0x10B1","Partial","Configuration file loading and option persistence","LoadConfigFile; SaveOptionsToConfigFile","Loader validation and malformed/unknown-option behavior remain incompletely characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"5","code","0x41E00","0x8D7","Partial","Startup/display transition prepare/driver lane","startup_display_transition_prepare; startup_display_transition_driver","The two main seg005 bodies are now named and tied to caller-side validation through vtable +0x0c, the seg108 0x4f38 sprite/object helper lane, the shared active-dispatch hold byte at 0x6828, the seg049 watch/controller lane at 0x2bd8, and the seg126 follow-up path; the exact higher-level state label is still unresolved","crusader_decompilation_notes.md; plan-mid.md"
|
||||
"6","code","0x42C00","0x75E","Foothold","Gameplay-side masked materializer and local state/value selector lane","entity_vm_context_try_create_mask_0008_slot30_with_offset; entity_vm_context_try_create_mask_0010_slot08_with_offset_if_ready","Outer callers for the renamed seg006 helpers are still unresolved, and the higher-level gameplay subsystem owning the local state-selector and adjacent class-linked value family still needs caller-side recovery","plan-mid.md; docs/raw-0008-000c.md"
|
||||
"7","code","0x43600","0x484","None","","","","crusader_ne_segments.csv"
|
||||
"8","code","0x43C00","0x1386","None","","","","crusader_ne_segments.csv"
|
||||
"9","code","0x45400","0x495","None","","","","crusader_ne_segments.csv"
|
||||
"10","code","0x45A00","0xD92","None","","","","crusader_ne_segments.csv"
|
||||
"11","code","0x46E00","0x5B1","None","","","","crusader_ne_segments.csv"
|
||||
"6","code","0x42C00","0x75E","Partial","Gamepal Xformpal palette resources and greyscale fade processes","Gamepal_Init; Gamepal_InitXformpalDatStruct; Gamepal_LoadXformpalDat; Gamepal_ReadXformpal_1028_0348; Gamepal_ReleaseXformpalResources_1028_02dc; Palette_FadeToGreyscale; FadeProcess_Create_2; FadeProcess1_Run_PausesCycle; FadeProcess2_Run","Xformpal data parsing/resource ownership and fade-process scheduling are not fully traced in the active CRUSADER.EXE; prior gameplay-side helper evidence is from raw segment 0006, not this live selector","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md; docs/raw-0008-000c.md"
|
||||
"7","code","0x43600","0x484","Partial","Animation-process render-state publication","AnimProcess_BeginRenderStateUpdate_1030_02a5; AnimProcess_CommitRenderStateAndClearFlag_1030_02b2","The remaining process creation, dispatch, timer, and lifecycle routines need behavioral characterization","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"8","code","0x43C00","0x1386","Partial","Item collision masks and gravity-process movement","AreaSearch_CheckCollision (1038:0000 wrapper; 1038:0072 core); GravityProcess_CreateProcess; GravityProcess_Finish_1038_04bc; GravityProcess_Run; GravityProcess_CheckDownwardSweep_1038_1131; GravityProcess_FastAreaCleanup; Item_Hurl; Item_Fall","Full GravityProcess_Run state transitions and caller-side interpretation of the collision mask remain open","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"9","code","0x45400","0x495","Partial","DOS extender calls and gravity trajectory helpers","DosExtenderCallInterrupt_1040_0000; DosExtenderCallInterrupt_1040_0035; DosExtenderCallInterrupt_1040_0041; DosExtenderCallInterrupt_1040_005a; Runtime_InitializeCommandLineAndRunLoop_1040_0079; Item_BuildHurlTrajectoryParams_1040_00a6; Item_HurlWithParams; Ensure_GravityProcess; Filespec_CopyCandidateIfExists_1040_039e; dos_free_disk_space","INT 21h/2Fh service/register contracts and caller-side purpose of the gravity-proximity helper are unresolved","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"10","code","0x45A00","0xD92","Partial","Game initialization, teardown, and command-line handling","Init_Everything; Uninitialize; HandleCommandlineArgs; Runtime_InitializeAndHandleCommandLine_1048_01dc; Runtime_DrawStartupBanner_1048_025b","Subsystem initialization/teardown dependencies and the remaining helper/config-dispatch behavior need closer characterization","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"11","code","0x46E00","0x5B1","Partial","Savegame slot metadata, quick-save, and restore","Savegame_Init; Savegame_GetFilename; Savegame_QuickSave; Savegame_LoadProbably; SavegameSlot_GetLabelPtr; SavegameSlot_SetLabel; File_CloseAndMaybeFree","Save-file schema/versioning and malformed-file or partial-load behavior remain open","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"12","code","0x47600","0x94B","None","","","","crusader_ne_segments.csv"
|
||||
"13","code","0x48200","0x1F6C","None","","","","crusader_ne_segments.csv"
|
||||
"14","code","0x4AA00","0x526","None","","","","crusader_ne_segments.csv"
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
"27","code","0x5B400","0x57B","None","","","","crusader_ne_segments.csv"
|
||||
"28","code","0x5BA00","0x788","None","","","","crusader_ne_segments.csv"
|
||||
"29","code","0x5C400","0x190A","Partial","Area-search collision move and step-aware sweep helper lane","AreaSearch_CollideMove; AreaSearch_SweepShapeBetweenPoints; AreaSearch_SweepItemToPointWithStepUp; AreaSearch_SweepShapeBetweenPointsWithStepUp","Current direct callers are still all movement/collision-side and the remaining gap is the earlier policy layer deciding when those paths instantiate the 0x236 queue or whether any non-collision lane feeds it","plan-mid.md; docs/ne-hole-filling-priorities.md; docs/raw-0008-000c.md"
|
||||
"30","code","0x5E000","0x5071","None","","","","crusader_ne_segments.csv"
|
||||
"30","code","0x5E000","0x5071","Partial","Process embedded EntityDispatchEntry destructor-copy cluster","Process_DestroyEmbeddedDispatchEntries; Process_DestroyEmbeddedDispatchEntries_10e8_41e3; Process_DestroyEmbeddedDispatchEntries_10e8_4744","28 exact FUN_ candidates remain; owning Process class/role and callers unresolved","docs/crusader-exe-function-identification-map.md"
|
||||
"31","code","0x64000","0x6EE","Partial","StorageDataProcess queue create/run/release helpers","StorageDataProcess_Create; StorageDataProcess_Run; StorageDataProcess_Release; StorageDataProcess_RunAndTerminateProcs; storage_process_ref_list_create; storage_process_ref_list_append; storage_process_ref_list_terminate_item_matches; storage_process_ref_list_destroy","Still needs caller-side recovery beyond the verified collision producer and any stronger subsystem naming than the local hit/got-hit storage queue","plan-mid.md; docs/ne-hole-filling-priorities.md; docs/raw-0008-000c.md"
|
||||
"32","code","0x64800","0x56A","Foothold","Item type / typename.dat loader helpers","ItemType_Init; ItemType_LoadTypeflagDat; ItemType_Load_TypenameDat; ItemType_GetTypenameRecordPtrAtIndex; ItemType_FindTypenameRecordIndex; Item_GetShapeFamilyOfShape","The segment is now clearly an item-type helper lane. The remaining gap is not local contract recovery but broader caller-side integration and any later higher-level item-family helpers that still sit outside this small loader-focused window.","plan-mid.md; docs/function-knowledge-roadmap.md"
|
||||
"33","code","0x65000","0x10D7","Partial","NPC action / stand / pace / surrender / guard / loiter AI processes","NPCActionProcess_Create; NPCActionProcess_RunNoop; NPCActionProcess_Destroy; NPCActionProcess_VtableSlot10Noop; StandProcess_Run; StandProcess_Destroy; PaceProcess_CreateProcess; PaceProcess_Run; PaceProcess_Destroy; SurrenderProcess_CreateProcess; SurrenderProcess_Destroy; SurrenderProcess_Run; GuardProcess_CreateProcess; GuardProcess_Run; GuardProcess_Destroy; LoiterProcess_CreateProcess; LoiterProcess_Run; LoiterProcess_Destroy; LoiterProcess_VtableSlot10DispatchByShapeIfAlive; NPC_DoRandomIdleAnimTwiceIfNotBusy","The live AI-process lane now has owner-first Remorse class lifting in addition to run ownership, slot-1 destructor ownership, and the local slot-10 helper split. The remaining uncertainty in this immediate window is mostly higher-level behavior-policy meaning and whether the family is ready for a safe provisional datatype, especially what the slot-10/slot-11 transitions represent semantically beyond the now-named local function objects.","plan-mid.md; docs/function-knowledge-roadmap.md; docs/npc-action-process-class-layout.md"
|
||||
|
|
@ -137,10 +137,10 @@
|
|||
"136","code","0xD7600","0x5BD","Partial","Shared active dispatch-entry owner and hold-state controller","active_dispatch_entry_mark_enabled; active_dispatch_entry_mark_disabled; active_dispatch_entry_create_default","The shared active entry is now tied to the seg126 DS:0x6341 transition-animation path and to the shared 0x31a2 break/hold depth; current evidence also separates its borrowed +0x40 presentation hold token from the seg108-local 0x4f38 bit-0x40 lane, but the exact higher-level transition/callback subsystem name is still unresolved","crusader_decompilation_notes.md; plan-mid.md"
|
||||
"137","code","0xD7E00","0xFBB","Partial","Palette and dispatch-entry emission helper family","entity_dispatch_entry_init_runtime_state; entity_dispatch_entry_release_runtime_state; vga_palette_set_all_black; vga_palette_set_all_white; vga_palette_set_all_rgb; dispatch_entry_create_black_palette_state_active; dispatch_entry_create_grayscale_palette_state_active; dispatch_entry_create_solid_palette_state_active","Higher-level event/script meaning is still unresolved, especially the paired 0x68bf object and the exact role of the 0004:5ad4-5b6e caller sequence","crusader_decompilation_notes.md; plan-mid.md"
|
||||
"138","code","0xD9200","0x32E4","Partial","Entity cleanup/finalize with callback, watch-controller release, and dispatch-entry palette emission","entity_cleanup_resources_and_dispatch; sprite_redraw_global_if_active; FUN_000d_938c","Concrete callback-object subsystem naming is still unresolved, but this lane now has verified caller-side control of watch/controller state at 0x2bd8, uses the shared active-dispatch byte +0x40 as a borrowed presentation hold token rather than a local owner install, and emits two distinct 0x4588 payload pairs (entity +0x12d/+0x12f and +0x74f/+0x751) in addition to the palette-emission helpers","crusader_decompilation_notes.md; plan-mid.md"
|
||||
"139","code","0xDCC00","0x984","None","","","","crusader_ne_segments.csv"
|
||||
"140","code","0xDD800","0xC6F","None","","","","crusader_ne_segments.csv"
|
||||
"141","code","0xDE600","0x2B","None","","","Short stub-sized segment","crusader_ne_segments.csv"
|
||||
"142","code","0xDE800","0x4371","None","","","","crusader_ne_segments.csv"
|
||||
"143","code","0xE3400","0x6F5","None","","","","crusader_ne_segments.csv"
|
||||
"139","code","0xDCC00","0x984","Partial","Item SFX data cleanup and no-op method","Sound_FreeItemSfxData_1450_00ec; NoOpMethod_1450_074b","The global item-SFX data owner and the no-op method's higher-level role remain unverified","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"140","code","0xDD800","0xC6F","Partial","Viewport RLE bitmap drawing and callback forwarding","VPort_DrawRleBitmapRows_1458_04b0; VPort_DrawRleBitmapRowsWithSkip_1458_09d4; Callback_ForwardToSlot009d_1458_0b1c; Callback_ForwardToSlot00a5_1458_0bc1","No direct callers were recovered for these functions; the higher-level drawing and callback roles remain structural","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"141","code","0xDE600","0x2B","Partial","MSB-first packed-stream bit extraction","ExtractBitsMSBFirst_1460_0000","Used by the 1468 video decoders; the wider packed-video format remains only partially characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"142","code","0xDE800","0x4371","Partial","Video playback, packed-row decoding, palette, and display lifecycle","VideoPlayer_DecodePackedRowsToWords_1468_04f9; VideoPlayer_DecodePackedRowsToDwords_1468_0995; VideoPlayer_DecodePackedRowsToBytes_1468_0e51; VideoPlayer_DecodePackedRowsToWords_1468_12fe; VideoPlayer_UpdateTimedMessage_1468_1da1; VideoPlayer_BuildFadePalette_1468_354a; VideoPlayer_StopAndDestroy_1468_3d36; VideoPlayer_ReleasePlaybackResources_1468_3d7a","The compressed-frame format and some callback contracts remain partially inferred; no exact auto-names remain in this segment","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"143","code","0xE3400","0x6F5","Partial","Video subtitle file loading, parsing, and timed-record access","VideoSubtitle_InitAndLoad_1470_005e; VideoSubtitle_ParseFile_1470_0239; VideoSubtitle_GetNextTimedRecord_1470_01ef; VideoSubtitle_ParseFrameTag_1470_05cc","The subtitle record format is behaviorally traced but not fully documented; no exact auto-names remain in this segment","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md"
|
||||
"144","data","0xE3C00","0x8DBC","None","","","Large data segment not yet classified","crusader_ne_segments.csv"
|
||||
"145","data","0x0","0x0","None","","","Zero-length data segment placeholder","crusader_ne_segments.csv"
|
||||
|
217
docs/REA/ghidra-dos.md
Normal file
217
docs/REA/ghidra-dos.md
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
# DOS MZ and COM analysis with Ghidra
|
||||
|
||||
REA can analyze DOS MZ executables and explicitly selected COM images through the bring-your-own Ghidra adapter.
|
||||
The Linux x64 and macOS arm64 verification lanes exercise actual 16-bit disassembly and
|
||||
decompilation through the CLI and stdio MCP. Provider admission accepts Ghidra
|
||||
12.1.x and that installation's declared JDK range. The verification lane uses
|
||||
Ghidra 12.1.4 and JDK 21; no DOS emulator or cross-compiler is required.
|
||||
|
||||
## Open and inspect
|
||||
|
||||
```bash
|
||||
rea inspect /absolute/path/to/legacy.exe --provider ghidra --json
|
||||
rea search /absolute/path/to/legacy.exe entry --kind procedures --provider ghidra --json
|
||||
rea instructions /absolute/path/to/legacy.exe entry --provider ghidra --json
|
||||
rea function /absolute/path/to/legacy.exe entry --provider ghidra --json
|
||||
rea inspect-native-load-image /absolute/path/to/legacy.exe --provider ghidra --json
|
||||
rea read-bytes /absolute/path/to/legacy.exe 0x10000 --length 16 --provider ghidra --json
|
||||
rea address-to-file-offset /absolute/path/to/legacy.exe 0x10000 --provider ghidra --json
|
||||
```
|
||||
|
||||
Use an observed procedure name or address from discovery when the target does
|
||||
not name its entry function `entry`. MCP uses `open_binary`, `list_procedures`,
|
||||
`procedure_info`, `read_function_instructions`, and `analyze_function` with the
|
||||
same admitted target and provider semantics.
|
||||
|
||||
The classifier validates MZ page counts, initialized module length, header and
|
||||
relocation-table bounds, relocation destinations, and the initialized entry
|
||||
point. It distinguishes DOS load-module and relocation bytes from the Windows
|
||||
new-header field. PE remains PE; NE, LE, and LX declarations are explicitly
|
||||
unsupported. A damaged declared Windows header does not silently become DOS.
|
||||
Inventory classification returns `unknown` when its bounded prefix cannot
|
||||
establish the format; this is distinct from the complete target admission check.
|
||||
|
||||
Ghidra imports a private target snapshot with `MzLoader`, language
|
||||
`x86:LE:16:Real Mode`, and compiler specification `default`. These settings,
|
||||
the fixed Ghidra load segment `0x1000`, and the linear address convention are
|
||||
committed in the analysis profile. The handshake rejects language or compiler
|
||||
drift. Closing the session deletes the temporary project and snapshot.
|
||||
|
||||
The profile also commits `function_body_evidence: complete-inclusive-ranges-v1`,
|
||||
so snapshots from older length-only Ghidra results do not satisfy the current
|
||||
profile.
|
||||
|
||||
## Headerless COM images
|
||||
|
||||
COM has no identifying header. Select its interpretation explicitly; neither the
|
||||
`.com` suffix nor arbitrary unrecognized bytes are enough to admit it.
|
||||
|
||||
```bash
|
||||
rea inspect /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
|
||||
rea inspect-native-load-image /absolute/path/to/legacy.com --target-format dos-com --provider ghidra --json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "open_binary",
|
||||
"arguments": {
|
||||
"path": "/absolute/path/to/legacy.com",
|
||||
"format": "dos-com",
|
||||
"provider_id": "ghidra"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The caller's interpretation applies to the complete file, even if its filename
|
||||
suggests another format. Files must contain 1..65280 bytes: the 64 KiB COM segment
|
||||
minus the 256-byte PSP prefix. Ghidra uses `BinaryLoader` with real-mode language
|
||||
and maps file offset zero at `1000:0100` (linear `0x10100`). A packaged pre-analysis
|
||||
script seeds the entry function and CS/DS/ES/SS context `0x1000`. These settings
|
||||
and the preparation policy are committed in the analysis profile; a failed
|
||||
preparation prevents the resident bridge from serving results.
|
||||
|
||||
Load-image verification checks all original and modified file bytes, complete
|
||||
source mapping/memory digests, absence of relocations, entry and measured register
|
||||
context. The context is imposed for analysis, not observed from execution. PSP
|
||||
memory, initial stack contents/SP, DOS interrupts and PC-98 devices are not
|
||||
modeled. COM has no MZ header, relocation table or appended-overlay model; all
|
||||
selected bytes belong to its analysis module. The original file stays unchanged.
|
||||
|
||||
## Addresses and function extent
|
||||
|
||||
Returned default-space addresses are linear byte coordinates. A Ghidra
|
||||
segment:offset address has linear value `segment * 16 + offset`; multiple
|
||||
segment aliases can identify the same byte. REA accepts the returned linear
|
||||
address for subsequent lookups and leaves instruction decoding context with
|
||||
Ghidra. These coordinates are analysis load addresses, not file offsets or
|
||||
observations of a running DOS system.
|
||||
|
||||
Offsets that Ghidra would truncate to a different address are rejected before
|
||||
reading or annotating a function. This also applies to explicit or encoded
|
||||
address-space names; leading zeros preserve the numeric offset.
|
||||
|
||||
`procedure_info` and function dossiers include `body` evidence:
|
||||
|
||||
```json
|
||||
{
|
||||
"available": true,
|
||||
"provenance": "ghidra-function-body-address-set",
|
||||
"ranges": [
|
||||
{ "start": "0x10000", "end": "0x1000d" },
|
||||
{ "start": "0x10060", "end": "0x10065" }
|
||||
],
|
||||
"total_bytes": 20,
|
||||
"span_bytes": 102,
|
||||
"non_contiguous": true,
|
||||
"contains_entry": true
|
||||
}
|
||||
```
|
||||
|
||||
Each end is **inclusive**. `total_bytes` counts the complete observed
|
||||
AddressSet; `span_bytes` measures its enclosing span and is null across address
|
||||
spaces. Gaps and shared tails must not be treated as owned bytes. This is
|
||||
Ghidra's database observation, not a proof of original source ownership or
|
||||
exhaustive code discovery. Providers that do not report complete ranges return
|
||||
`available: false` and an explicit reason.
|
||||
|
||||
## Loaded-image evidence
|
||||
|
||||
`inspect_native_load_image` independently checks the immutable session snapshot
|
||||
against the loaded Ghidra Program. It measures complete original and modified
|
||||
FileBytes digests, every source mapping and its memory digest, relocation records
|
||||
(including multiplicity), and external entry points. It verifies MZ header and
|
||||
module partitions, relocation fixups and linear coordinates rather than relying
|
||||
on the imported executable SHA alone.
|
||||
|
||||
The result is `verified`, `mismatch`, or `unsupported`. Every check retains its
|
||||
expected and observed values. A memory-digest mismatch identifies the source
|
||||
range's file offset and analysis address; it does not locate the first differing
|
||||
byte inside that range. Mapping ends are **inclusive**, unlike the exclusive ends
|
||||
from `list_segments`. Appended overlays remain in source-file identity and are
|
||||
excluded from initialized module coverage. Uninitialized allocations are reported;
|
||||
their contents and DOS runtime semantics are not verified. Formats other than MZ and explicit COM return
|
||||
`unsupported` with measured observations, not a successful MZ verification.
|
||||
|
||||
`read_bytes` returns initialized provider memory, including loader fixups; an
|
||||
unmapped or uninitialized byte ends the read with an explicit returned length and
|
||||
`complete: false`. `address_to_file_offset` uses the provider's source mapping;
|
||||
unmapped, uninitialized and ambiguous mappings fail explicitly. A relocated word
|
||||
can differ from the original file word even when its source offset is known.
|
||||
|
||||
## Coverage boundaries
|
||||
|
||||
Static decompilation does not execute the target or emulate BIOS, DOS
|
||||
interrupts, device ports, or self-modifying code. PC-98 hardware behavior and
|
||||
recovered calling conventions can remain uncertain; provider pseudocode and
|
||||
diagnostics are retained for analyst review.
|
||||
|
||||
For a packed executable, importing the original can analyze its unpacking
|
||||
stub. Analyze a separately prepared unpacked copy to inspect the original
|
||||
program's recovered code. Retain both artifact digests and the transformation
|
||||
evidence; REA never silently replaces the admitted target. Appended overlays
|
||||
are separate from the initialized MZ module. Raw COM files and DOS extenders
|
||||
without an admitted MZ real-mode entry are outside this import boundary.
|
||||
|
||||
DOS MZ is available through Ghidra, with no Hopper support claim. It is outside
|
||||
the Windows native PE P0 boundary. macOS x64 DOS verification remains unverified.
|
||||
|
||||
## Real verification
|
||||
|
||||
```bash
|
||||
npm run verify:ghidra:dos
|
||||
```
|
||||
|
||||
The lane generates a small public fixture from source at runtime. It verifies
|
||||
16-bit instruction bytes, a near call, a segment-relocated far call, actual
|
||||
decompilation, disjoint function ranges, stable CLI/MCP observations, unchanged
|
||||
input bytes, and session/process cleanup. It does not require external
|
||||
executable fixtures, an emulator, or an existing analysis database.
|
||||
|
||||
Provider p-code representations can contain process-specific address-space selector
|
||||
tokens. The lane preserves those reported values and compares stable dossier
|
||||
observations rather than asserting cross-process identity of raw p-code.
|
||||
|
||||
## Local Verification (2026-10-10)
|
||||
|
||||
The connected VS Code MCP server identified itself as `rea-agents` 6.3.0, loaded
|
||||
from `C:\Users\Maddo\AppData\Local\npm-cache\_npx\ec0ab2283efe73f6\node_modules\rea-agents`.
|
||||
The session had no active binary when checked. The REA tool catalog exposed
|
||||
native binary opening, procedure listing, function analysis, and loaded-image
|
||||
inspection.
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| Requested Ghidra installation | `I:\Apps\ghidra_12.1.4_PUBLIC` exists and contains `ghidraRun.bat` and `support\analyzeHeadless.bat`. Its `Ghidra\application.properties` reports Ghidra 12.1.4 and Java minimum 21; the maximum is unspecified. |
|
||||
| Requested JDK | `C:\Program Files\Microsoft\jdk-25.0.3.9-hotspot\bin\java.exe` exists and reports Microsoft OpenJDK 25.0.3. |
|
||||
| Ghidra headless startup | With both `JAVA_HOME` and `GHIDRA_JAVA_HOME` set to that JDK, `analyzeHeadless.bat -help` printed usage, then exited with code 1. Startup also reported an invalid manifest in the user `GhidraMCP` extension (`GHIDRA_MODULE_NAME` and `GHIDRA_MODULE_DESC` were rejected). This is evidence of launcher startup, not a successful analysis run; whether that extension warning affects the REA provider is unknown. |
|
||||
| REA open of Crusader | `open_binary` with provider `ghidra` rejected `K:\ghidra\Crusader_Decomp\CRUSADER.EXE` as `unsupported NE executable in MZ image`. The file is 991,878 bytes. Rejection occurred before Ghidra analysis, so no Crusader functions, strings, or loaded-image checks were produced by REA. |
|
||||
| REA end-to-end Ghidra analysis | Not verified. The installed npm package lists a `verify:ghidra:dos` command but does not include its referenced `scripts/verify-real-ghidra-dos.mjs` test runner; no DOS MZ/COM fixture was found in the workspace search. Antivirus blocked generation of a temporary MZ smoke-test image. |
|
||||
|
||||
The installed Ghidra/JDK pair is present, and the Ghidra headless launcher reached
|
||||
its command-line usage path under JDK 25. That does **not** prove the REA provider
|
||||
is configured to use these exact installations or that it can analyze Crusader.
|
||||
The observed target-format rejection agrees with the provider boundary above:
|
||||
the DOS workflow accepts validated MZ and explicitly selected COM images, not
|
||||
NE. For the current Crusader executable, REA cannot replace the existing NE
|
||||
Ghidra workflow. A future REA NE provider or a separately justified conversion
|
||||
would be required before this MCP can analyze the game executable.
|
||||
|
||||
## Function annotations
|
||||
|
||||
`annotate_native_function` changes the name and/or comments at one exact local function entry, verifies readback, and returns a refreshed dossier. This is useful when recording recovered DOS function roles; it does not claim original-source names. Name writes preserve the existing namespace; readback returns the fully qualified name used by function inventories. Regular comments map to Ghidra PRE comments and inline comments to EOL comments. Empty text clears a comment; omitted fields preserve it. The whole edit rolls back if a setter, readback or analysis fails.
|
||||
|
||||
```json
|
||||
{
|
||||
"procedure": "0x10100",
|
||||
"name": "entry",
|
||||
"comment": "Recovered startup role",
|
||||
"inline_comment": "Inspect segment setup"
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
rea annotate-native-function /local/program.com 0x10100 --target-format dos-com --provider ghidra --name entry --comment 'Recovered startup role' --json
|
||||
```
|
||||
|
||||
The CLI returns the updated analysis before closing its isolated session. MCP edits remain visible to later reads until `close_binary`. Original bytes remain unchanged, database edits are discarded on close, and immutable analysis snapshots are invalidated after edits. This operation does not save a Ghidra project, change ABI/types/body ranges, patch instructions, or emulate a DOS runtime. Windows P0 does not admit it.
|
||||
92
docs/ROGUE/cheats-and-debug.md
Normal file
92
docs/ROGUE/cheats-and-debug.md
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# Rogue Squadron 3D: PC Cheats and Debug Features
|
||||
|
||||
## Summary
|
||||
|
||||
The correct gameplay target is `Rogue Squadron.EXE`, not the neighboring `ROGUE.EXE` launcher. Static analysis of the gameplay binary found a 35-slot passcode hash table, with 16 slots mapped to 29 spellings so far. The binary confirms which spellings match its table; published PC cheat lists supply most claimed effects, which were not runtime-tested here.
|
||||
|
||||
Editor-style debug UI survives in the executable, but the normal startup path disables its `Config` menu before construction. The `Alt+T` caption is therefore a conditional editor command, not an established retail gameplay shortcut. If the menu were enabled by another build or runtime state, it would open a `Debug Data` panel for switching among registered subsystem diagnostics, not a gameplay-cheat menu.
|
||||
|
||||
## Scope and Method
|
||||
|
||||
- Gameplay target: `C:\RE\Star Wars - Rogue Squadron 3D\ROGUE\Rogue Squadron.EXE`, PE32 x86, SHA-256 `0764709692e559e9de8ed125b9c59389cda2b594339dca5f47266deb10c2d43c`.
|
||||
- `ROGUE.EXE` is the InstallShield launcher, not the gameplay executable; its SHA-256 is `a10f271a9708fe17e107072fa81243ed003155ab47bdff8514d338d04b847563`.
|
||||
- Analysis used REA with Ghidra 12.1.4. The binary was loaded into an ephemeral analysis project; no executable bytes were changed, no project was saved, and neither executable was run.
|
||||
- Addresses below are virtual addresses in `Rogue Squadron.EXE`. Hash-table slot numbers are zero-based.
|
||||
- Binary observations establish code paths and passcode hash matches, not that a menu or cheat is reachable in a particular runtime state. External cheat effects are attributed to the linked guides and are not treated as binary-confirmed behavior.
|
||||
|
||||
## Passcode Recognition
|
||||
|
||||
`FUN_0042959e` constructs a 256-entry CRC table using polynomial `0xedb88320`. `FUN_00429549` hashes the requested byte count from seed `0xfac5fac5`; `FUN_004291e0` hashes ten bytes and compares the result against 35 dwords beginning at `0x5eb300`. Matching a slot updates its bit in `DAT_00704248`; slots 7 through 18 are made mutually exclusive. The surrounding lookup wrapper `FUN_004294eb` returns the matching slot or `35` when no table entry matches. These findings are from the executable's pseudocode, not from readable plaintext cheat strings. REA Evidence: CRC table `ev_35bb19672e88b04c20689b7020203e367784d26a151d31fc23632b0fe04cf53e`; hash routine `ev_e04a9605c1db82129bc4a0d7c605dc09786f53509ae9720e8bd872c5de8e7a85`; table matcher `ev_caf5048103c29b0dfee21f185db388b6310ef33cbdd828a601646237e0699bf6`.
|
||||
|
||||
The spellings below reproduce these table slots when represented in the ten-byte input consumed by the matcher. Shorter strings were tested with trailing NUL padding. A matching hash establishes recognition by this executable's table, not the reported gameplay effect.
|
||||
|
||||
| Slot | Accepted passcode spellings | Published effect (not runtime-tested) |
|
||||
| ---: | --- | --- |
|
||||
| 0 | `WIMPAMI` | Unlock bonus missions/levels. [1][4] |
|
||||
| 2 | `WOOKIEPELT`, `PKDWXE`, `CRBSIFA` | Unlock the Millennium Falcon. [1][2][3][4] |
|
||||
| 3 | `GOODGUYTIE`, `AAAAFNPDJY` | Unlock a TIE ship, described as the TIE Interceptor or TIE Fighter; some guides say the Falcon must be unlocked first. [1][2][3][4] |
|
||||
| 5 | `CNDDOBY` | Display a developer-team picture. [1] |
|
||||
| 11 | `CREDITS`, `ONCHHZU` | View the credits. [1][2][3][4] |
|
||||
| 14 | `WOOKIYRWMW`, `AAAABDBOHP` | Effect unresolved; GameFAQs groups these with other unknown codes. [1] |
|
||||
| 15 | `CHICKEN`, `OTOOJKH` | Control an AT-ST; one guide reports it unavailable on Taloraan. [1][2][3][4] |
|
||||
| 19 | `MAESTRO` | Open the Concert Hall / listen to the music themes. [1][2][3][4] |
|
||||
| 20 | `DIRECTOR`, `EAAAABUMFU` | View cutscenes; guides direct players to High Scores > At The Movies. [1][2][3][4] |
|
||||
| 22 | `IAMDOLLY` | Infinite lives. [1][2][3][4] |
|
||||
| 24 | `TOUGHGUY`, `NAKASGMQ`, `MLVBHF` | All power-ups or a technology upgrade, depending on the guide's wording. [1][2][3][4] |
|
||||
| 25 | `NDAAFXWSFQ`, `EAAAABYCBA` | Effect unresolved; GameFAQs lists these among unknown codes. [1] |
|
||||
| 28 | `OOMPAWAMPA`, `GCTHNME` | Conflicting reports: level select versus bonus-mission unlock. [1][2][3][4] |
|
||||
| 30 | `USEDAFORCE`, `FSSRNB`, `JKQCNMH` | Use any ship available in the current level. [1][2][3][4] |
|
||||
| 33 | `GUNDARK` | Change joystick force-feedback resistance based on velocity. The bundled README describes forces for varying stick resistance with velocity. [1][2][3][4][5] |
|
||||
| 34 | `LEIAWRKOUT` | Enable acceleration/deceleration force feedback. The bundled README documents these forces and the `-i` command-line option for desensitizing craft movement caused by them. [1][2][3][4][5] |
|
||||
|
||||
The 19 remaining table slots (`1`, `4`, `6`-`10`, `12`-`13`, `16`-`18`, `21`, `23`, `26`-`27`, `29`, `31`-`32`) are not mapped to passcode spellings in this pass. Tested guide-listed candidates `HIKEN`, `NEUC`, `ACE`, `LOKJOT`, and `RECUER` did not match a table hash under the tested ten-byte normalization. This is a bounded mismatch result for those candidates, not proof that all other published lists or game builds are wrong.
|
||||
|
||||
### Reported Entry Method and Source Disagreements
|
||||
|
||||
The PC guides describe entering passcodes from the main menu through **Settings > Passcodes**; the bundled README specifically places the two force-feedback codes in **General Settings**. This menu interaction was not tested in the game.
|
||||
|
||||
Guide wording is not fully consistent. `OOMPAWAMPA`/`GCTHNME` are called a level-select code by Cheat Code Central, GameRevolution, and Super Cheats, while GameFAQs calls them a bonus-mission unlock. Reports also vary between “TIE Fighter” and “TIE Interceptor” for `GOODGUYTIE`, and whether that ship requires the Millennium Falcon first. Treat these as guide claims, not resolved binary semantics. Codes such as `ACE` (Expert Mode), `RECUER` (Imperial Shuttle), `HIKEN` (bonus weapons), and `NEUC` (radar destruction) occur in guide material but did not match the tested hash table for this executable.
|
||||
|
||||
## Debug Features
|
||||
|
||||
### Reachability and Opening
|
||||
|
||||
- `FUN_005081d0` builds an editor-style menu containing `X`, `File`, `Object`, `Tools`, and `Config`. It creates the `Config` menu and its entries only when its second argument is nonzero. The startup routine `FUN_004ea9f0` writes zero to `DAT_00658df0` at `0x4eaa71` and later passes that value to the menu builder. Its two resolved callers are `FUN_004dd07c` and `FUN_004ea726`; both use this initialization path.
|
||||
- The only direct write found for `DAT_00658df0` is that startup write of zero. The menu callback `FUN_004eba88` also returns without handling events unless `DAT_00658df0 != 0` and the UI event phase is `5`. If enabled, callback item `0x11` (17) invokes `FUN_004f2beb(2)`, which toggles the separate panel-display flag `DAT_00669adc`.
|
||||
- The caption at `0x62d26c` is `Toggle Debug (Alt+t)`. Its menu-table slot is 17 and matches callback case `0x11`; this proves the intended command in the editor menu, not a working retail shortcut. The conditional route, if another build or state enables `Config`, is **Config > Toggle Debug** or the displayed **Alt+T** accelerator. No normal-play route that sets the gate nonzero was found. The matching menu builder, callback, and toggle are `FUN_005081d0`, `FUN_004eba88`, and `FUN_004f2beb`.
|
||||
|
||||
### Panel and Modules
|
||||
|
||||
- The `swe_debug` module registers the panel initializer and cleanup callbacks through its `LECMODULE=swe_debug` descriptor. `FUN_004f26f2` queries the `DEBUG` registry, stores each entry's display callback, and initializes its state to zero. It accepts at most 20 entries (indices 0-19); this executable contains seven `DEBUG=` registrations listed below. Missing entries or handlers take logged error paths.
|
||||
- When enabled, the panel is titled **Debug Data** and has a **Set...** control. Activating it opens **Choose module to modify** with the registered module names. The panel draws the available names as rows. Selecting one sends state `-1` to that module and `0` to every other module; closing the panel clears its display flag and sends state `0` to all handlers. This is a one-module-at-a-time diagnostic selector, not a multi-option cheat menu. REA Evidence: panel builder `ev_aff919a807c9db7b2ee6fc76459630541650ce05764b6c1097ad09318ad8d2e7`; event/draw handler `ev_b0cefbd060522a6ca5a55aec191d2db41b262790e3308fe975e7fb3133f9c213`; cleanup `ev_a8cd442e451cdeac0b07ab05b15f853a1129dee7f531072fd556e44ad318ba48`.
|
||||
|
||||
| Registry key | Chooser label | Embedded module description | Initializer |
|
||||
| --- | --- | --- | --- |
|
||||
| `DEBUG=swe_link_debug` | `Text Links` | `SWEET text hyperlink System`; debugging interface for the SWEET text-hyperlink module. | `FUN_004f1370` |
|
||||
| `DEBUG=swe_dirtyrect_debug` | `Dirty Rectangles` | `SWEET Dirty Rectangle System`; debugging interface for the SWEET dirty-rectangles module. | `FUN_00502ee0` |
|
||||
| `DEBUG=animframe` | `Insane AnimFrame` | `Insane AnimFrame Debug Interface`; debugging interface for the Insane Animation Frame module. | `FUN_00508d40` |
|
||||
| `DEBUG=insane_animplay` | `Insane AnimPlay` | `Insane AnimPlay Debug Interface`; debugging interface for the Insane Animation module. | `FUN_00509c60` |
|
||||
| `DEBUG=insane_clami_debug` | `Clami Script` | `Clami Script Debug.`; debugging interface for the Clami Scripting module. | `FUN_0050db50` |
|
||||
| `DEBUG=insane_bundle` | `File Bundler` | `Insane File-bundler Debug.`; description says “Insance file-bundling system” in the binary. | `FUN_0051e6d8` |
|
||||
| `DEBUG=insane_cache` | `File Cache` | `Insane File-caching Debug.`; description says “Insance file-caching system” in the binary. | `FUN_0051fbe0` |
|
||||
|
||||
The module callbacks' displayed names/descriptions and state setters are present, but this pass did not trace every subsystem's downstream rendering or diagnostic side effects. The names establish the areas covered, not a complete list of counters, overlays, or commands inside each module.
|
||||
|
||||
### Other Diagnostic Markers
|
||||
|
||||
The binary also contains two separate memory-registry identifiers, `MEMORY=rogue_debug` at `0x60b3c4`/`0x60b3d8` and `MEMORY=insane_debug` at `0x63908c`/`0x6390a0`. They are not entries in the `DEBUG` selector described above. These strings alone do not establish supported command-line switches or visible features. The literal string inventory is recorded in REA Evidence `ev_a5b5fafa357ab084dc9545fa066d67ecb6e8fcb38f74886efebf9410ca0c88c7`.
|
||||
|
||||
## Evidence and Confidence
|
||||
|
||||
- **High, binary-observed:** executable identity and digest; CRC table construction; ten-byte hash routine; 35-slot comparison table; the mapped spellings' hash matches; Config-menu gating and startup zeroing; the conditional Alt+T callback; Debug Data panel construction, module selection/state behavior, and seven registered diagnostic module labels. See the Evidence IDs attached above.
|
||||
- **Medium, source-reported:** gameplay effects and passcode entry steps. Multiple PC guides agree on many effects, but they are user-submitted or secondary references and were not tested against this executable.
|
||||
- **Unresolved:** meanings of the 19 unmapped hash slots; effects of the codes in slots 14 and 25; the `OOMPAWAMPA` effect conflict; exact TIE ship/prerequisite; whether another build/runtime state can set `DAT_00658df0` nonzero; what each diagnostic module renders or logs after activation; differences among regional or repackaged builds.
|
||||
- **Not performed:** launching the game, entering passcodes, observing the Debug Data panel at runtime, patching bytes, or saving a Ghidra project.
|
||||
|
||||
## External References
|
||||
|
||||
1. [GameFAQs: Rogue Squadron 3D (PC) cheats](https://gamefaqs.gamespot.com/pc/70612-star-wars-rogue-squadron-3d/cheats) — community-submitted code aliases and reported effects, including unresolved entries.
|
||||
2. [Cheat Code Central: Star Wars: Rogue Squadron cheats for PC](https://www.cheatcc.com/articles/star-wars-rogue-squadron-cheats-codes-cheat-codes-walkthrough-guide-faq-unlockables-for-pc-pc/) — PC code list and instructions.
|
||||
3. [GameRevolution: Star Wars: Rogue Squadron PC Cheats](https://www.gamerevolution.com/guides/29965-star-wars-rogue-squadron-pc-cheats) — PC code list.
|
||||
4. [Super Cheats: Cheat Mode for Rogue Squadron 3D](https://www.supercheats.com/pc/star-wars-rogue-squadron-3d/14926/cheat-mode/) — PC code list; the site notes submissions are not usually tested.
|
||||
5. `C:\RE\Star Wars - Rogue Squadron 3D\ROGUE\README.TXT`, “Force Feedback Support” — documents `LEIAWRKOUT`, `GUNDARK`, and the `-i` option.
|
||||
124
docs/SOTE/cheats-and-debug.md
Normal file
124
docs/SOTE/cheats-and-debug.md
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
# Shadows of the Empire: PC Cheats and Debug Menu
|
||||
|
||||
## Summary
|
||||
|
||||
Static analysis of the PC game executable confirms four embedded gameplay-secret instructions, several pilot-name hooks, and a functional hidden debug menu. The debug menu has a PC keyboard activation path; do not assume the N64 pause-screen sequence works on PC. The player-facing secrets overlap substantially with documented N64 unlocks, but that does not establish that every N64 input sequence or prerequisite is identical on PC.
|
||||
|
||||
## Scope and Method
|
||||
|
||||
- Target: `Sdata/Shadows.exe`, PE32 x86, SHA-256 `bb63e515b39467947adad5e7c94fce1b0d00f0a815ca5f8cd24d67b373b46175`.
|
||||
- Launcher: `SOTE.EXE`, SHA-256 `be596ee755afbd4f3a50de366a07866d8dfed032f3341b63f539e5f93773ff77`. Its WinMain path delegates to MFC startup; it is not the gameplay executable analyzed here.
|
||||
- Analysis: REA with Ghidra 12.1.4; static inspection plus the user's runtime confirmation that the debug menu appears only while the game is paused and the pause menu is visible. The agent did not launch either executable. Ghidra's imported program was ephemeral; no executable bytes or saved project data were changed.
|
||||
- Addresses below are virtual addresses in `Shadows.exe`.
|
||||
|
||||
## PC Findings
|
||||
|
||||
### Embedded Gameplay Secrets
|
||||
|
||||
The binary contains four secret-instruction strings in the `0x4c6c60`-`0x4c6d70` range. Their instructions describe these actions:
|
||||
|
||||
| Address | Instruction described | Reported effect / comparison |
|
||||
| --- | --- | --- |
|
||||
| `0x4c6c60` | Hold the camera button for five seconds while on foot. | Leebo scanner / overhead view. The N64 guides report this as the Leebo Scanner unlock. |
|
||||
| `0x4c6cb8` | Hold the camera button for five seconds during the Skyhook sequence. | Change ship, cycling through the X-Wing and TIE fighter. N64 guides report this unlock on Skyhook. |
|
||||
| `0x4c6d18` | Hold crouch for fifteen seconds while on foot. | Invincibility and weapon/ammo replenishment. N64 guides report this on-foot secret on Hard. |
|
||||
| `0x4c6d70` | Complete the Jedi-difficulty condition for friendly Wampas. | Matches the N64 friendly-Wampa reward at a high level; the N64 guide describes collecting all challenge points on Jedi, so the exact PC prerequisite should be verified in-game. |
|
||||
|
||||
These are confirmed as embedded PC instructions, not as runtime-tested behavior. Unlock prerequisites mentioned in the comparison column come from N64 documentation and may differ by platform or build.
|
||||
|
||||
### Pilot-Name Hooks
|
||||
|
||||
The profile-name checker at `FUN_0040d0c0` compares the current pilot name character by character against strings in the executable. The strings include:
|
||||
|
||||
| Address | Embedded name | Finding |
|
||||
| --- | --- | --- |
|
||||
| `0x4cae14` | `R Testers ROCK` | The checker accepts this name. PC references describe it as granting access to all levels; the same accepted name also passes the debug-menu eligibility check described below. |
|
||||
| `0x4cadf0` | ` Wampa Stompa` | Exact spacing, including the leading space and two spaces between the words, is present in the checker. Its flag is consumed elsewhere in gameplay; N64 references associate the similarly spaced name with enemy-control cheats. The precise PC effects were not fully traced. |
|
||||
| `0x4cade0` | ` WIPE ALL DATA` | The checker invokes a cleanup routine for this name. Treat it as destructive: do not enter it on a profile containing data you want to keep. |
|
||||
|
||||
The leading spaces shown above are part of the embedded strings. External guides use underscores to represent spaces in pilot names.
|
||||
|
||||
### Hidden Debug Menu
|
||||
|
||||
- **Dispatcher gates:** `FUN_00491f10` first checks `DAT_0073e668`. If it is already set, the routine calls `FUN_00492770` and returns; otherwise it calls `FUN_00493150` only when `FUN_00410be0()` returns `1` and `DAT_006ef1a8` is `0`. `FUN_00410be0()` is just a getter for `DAT_004caf40`; `FUN_0041088c` changes that global, but its deeper runtime meaning is not established. Modes other than `0` go through other input paths. **Runtime confirmation from the user:** the game must be paused with the pause menu visible for F12 to open the debug menu. The static global checks do not, by themselves, reveal that pause-menu requirement.
|
||||
- **Keyboard polling:** `FUN_0041d280` initializes the input-slot table, including slot `0x58`. `FUN_0041dfa0` scans populated input slots from `0` through `0x283` and returns the first currently pressed input via `FUN_004a95e0`. That helper returns no input when `DAT_00760e54` is `0`; this is a necessary input-ready gate, although the exact conditions that set it are not established here. The scan can also report another held key or controller input before it reaches F12.
|
||||
- **Press and release:** `FUN_00493150` skips the scan on certain competing input-transition/release paths (`FUN_0041ef30` / `FUN_0041eec0`). Otherwise, it stores the detected code in `DAT_0073e6fc` while an input is down. It dispatches the stored code only on a later poll that finds no input down, then clears the latch. The `0x58` case is the F12 path; holding F12 alone is not enough. The slot is present in the initialized input table, so no separate F12 key-binding requirement was found.
|
||||
- **Profile eligibility:** the F12 case calls `FUN_0040d0c0`, which compares the current in-memory pilot-name buffer at `DAT_008d6348` against `R Testers ROCK`. That exact, case- and space-sensitive name returns true unconditionally. Other names depend on `DAT_004cada0`. The profile file containing the string is not proof that this is the name currently loaded in memory.
|
||||
- **Activation result:** a successful check sets `DAT_0073e668`. On the next update, `FUN_00491f10` routes directly to `FUN_00492770`, before the ordinary input-mode checks. No additional campaign-completion, difficulty, or multi-key condition appears in this F12 path. Once active, F12 is no longer processed by `FUN_00493150`; use the menu's directional and confirm inputs instead.
|
||||
- **What is drawn:** `FUN_00426440` is the relevant display path. With the menu active it calls `FUN_0042b870`, formats the current selection as `~c~o%s`, and passes that text to `FUN_00427ae0`. The menu-specific text is one styled selection label, not a 20-row list or an explicit “F12 accepted” message. The selection index `DAT_0073e670` starts at `0` in the image, so the initial label should be **Get all stuff**. Static analysis establishes the text path, not its exact screen position or how noticeable it is at runtime.
|
||||
- **Menu navigation:** `FUN_00492770` wraps the selection over indices `0` to `19`. Its input masks decrement on `0x10500`, increment on `0x20200`, and confirm on `0x3800`. `FUN_0041c900` maps the executable's default keyboard bindings into the states consumed by those masks: Left Arrow or numpad 4 decrements; Right Arrow or numpad 6 increments. D and Space also feed the decrement group, and A feeds the increment group. Enter and numpad Enter confirm, but the same confirm mask also includes Escape, F1, X, and Z. Thus Escape is not a cancel/back command here: it confirms and executes the currently highlighted option. Confirmation clears `DAT_0073e668`; user-configured bindings may alter these defaults.
|
||||
- **Live adjustment input:** menu entries read a signed input axis (`DAT_008a5c64`), not the menu's Left/Right selection masks. The input update routine builds this value from configured control slots and has a keyboard fallback, but the default key mapping for that fallback has not been identified. The user's runtime test found that Up/Down did not change the selected values, so do not assume those keys work. A configured controller axis may supply the value directly. Changes are applied continuously when the axis magnitude exceeds a dead zone; live entries do not require Enter.
|
||||
|
||||
The table describes all 20 menu entries. `Enter` means the command is dispatched by the confirm input; `Input axis, live` means the highlighted value consumes the signed adjustment axis. Numeric ranges are the code's clamps, not recommendations.
|
||||
|
||||
| Index | Display label | Input | Command/effect |
|
||||
| --- | --- | --- | --- |
|
||||
| 0 | Get all stuff | Enter | Runs the inventory/resource grant helpers and sets a related counter to 1000; the exact resource represented by that counter was not identified. |
|
||||
| 1 | Invincibility | Enter | Toggles the invincibility state. |
|
||||
| 2 | Debug Display | Enter | Toggles the debug-display mode. |
|
||||
| 3 | 50 Lives | Enter | Sets the lives counter to 50. |
|
||||
| 4 | Villains aren't sleepy | Input axis, live | Changes the villain behavior's 0/1 state. The default keyboard binding is unresolved. |
|
||||
| 5 | Kill Dash | Enter | Runs the labeled Dash kill action through entity/action helpers. |
|
||||
| 6 | Teleport | Enter | Runs teleport helpers for available actor/vehicle candidates; exact target and destination were not resolved. |
|
||||
| 7 | Next Level | Enter | Calls the shared level-change handler for the next-level entry. |
|
||||
| 8 | This Level | Enter | Calls the shared level-change handler for the current-level entry. |
|
||||
| 9 | Prev Level | Enter | Calls the shared level-change handler for the previous-level entry. |
|
||||
| 10 | Wall Ghost OFF (dynamic) | Input axis, live | Changes the wall-ghost 0/1 state; the displayed label reflects its current state. The default keyboard binding is unresolved. |
|
||||
| 11 | Fog ON (dynamic) | Input axis, live | Changes the fog 0/1 state; the displayed label reflects its current state. The default keyboard binding is unresolved. |
|
||||
| 12 | vertFOV: xxxxxxxx | Input axis, live | Adjusts vertical field of view, clamped to 4-120 degrees. |
|
||||
| 13 | aspect: xxxxxxxx | Input axis, live | Adjusts aspect ratio, clamped to 0.1-10.0. |
|
||||
| 14 | Fog Max xxxxxxxx | Input axis, live | Adjusts fog maximum, clamped to 10-999. |
|
||||
| 15 | Fog Thick xxxxxxxx | Input axis, live | Adjusts fog thickness, clamped to 10-996. |
|
||||
| 16 | Fog Red xxxxxxxx | Input axis, live | Adjusts the red fog/light component, clamped to 0-255. |
|
||||
| 17 | Fog Green xxxxxxxx | Input axis, live | Adjusts the green fog/light component, clamped to 0-255. |
|
||||
| 18 | Fog Blue xxxxxxxx | Input axis, live | Adjusts the blue fog/light component, clamped to 0-255. |
|
||||
| 19 | Revert Fog and Lights | Enter | Resets vertical FOV to 67.5 and aspect ratio to 4:3, and clears the view override. The full fog/light reset effect was not separately resolved. |
|
||||
|
||||
Confirming a command closes the debug overlay after dispatch. Invincibility and Debug Display are confirm-based toggles; entries described as live consume the signed input axis. The default keyboard control for that axis remains unresolved, and the user's test found that Up/Down did not change the values. Avoid Escape unless you intend to execute the highlighted command; it shares the confirm mask rather than cancelling.
|
||||
|
||||
**Practical use:** pause the game and leave the pause menu visible, then press and release F12. The debug menu appears as one selected label, initially `Get all stuff`. Use Left/Right (or numpad 4/6) to cycle entries. Live value adjustment requires the signed input axis; its default keyboard binding is not yet established, and Up/Down did not work in the user's test. If a controller is configured, try its vertical axis while a live entry is selected. If F12 fails in the required pause state, check that the live pilot-name buffer is exactly `R Testers ROCK`, `DAT_004caf40` is `1`, the input mode is `0`, and the keyboard input-ready flag is nonzero. The meanings/runtime values of those flags were not observed.
|
||||
|
||||
The N64 GameFAQs debug-mode report instead describes a pilot name rendered `.Wampa..Stompa`, followed by a pause-screen button and analog-stick sequence. That sequence is not the PC activation path observed in this executable. IGN's PC cheats page does not document that N64 debug sequence.
|
||||
|
||||
### Enemy-Control Carryover
|
||||
|
||||
**Conclusion: enemy control survived at least in part on PC.** The clearest directly documented PC example is the Battle of Hoth AT-ST: IGN and GameFAQs report holding numpad `4+6+8` for about five seconds, then pressing `Tab` to cycle views until the AT-ST view appears. This is distinct from the N64 D-pad/C-Right sequence.
|
||||
|
||||
The PC executable also contains internal evidence for a broader Wampa-related actor/control mode:
|
||||
|
||||
- `FUN_0040d0c0` recognizes the exact pilot string ` Wampa Stompa` and sets `DAT_004cad98`.
|
||||
- The gameplay input/state routine `FUN_00471e90` checks that flag before enabling a second, level-mapped control chord; the chord tables are indexed by the current level/state. This sets the separate state `DAT_004caad8`.
|
||||
- `FUN_00497680` is a stateful input-sequence handler with multiple branches that set the Wampa flag. One branch also dispatches four-byte identifiers through `FUN_00410cf0`; their exact game-level meaning was not resolved, so they are not treated as proof of a specific enemy spawn.
|
||||
- `DAT_004caad8` is consumed by actor/update and rendering routines, including `FUN_0040a960` and `FUN_0040c060`; the latter changes the render scale under the special state. Other event paths also test it. This is consistent with a gameplay actor/control mode, not just an unused profile string, but static evidence does not identify every resulting player action.
|
||||
|
||||
The N64 guide describes the related ` Wampa Stompa` name as unlocking control of a Wampa, Snowtrooper, AT-ST, or Xizor guard using D-pad/C-Right inputs. The shared profile-name hook and PC control-state paths make it likely that some of this system carried over. The PC references directly confirm only the AT-ST method; they do not establish that the N64 enemy roster, capture sequence, or movement/attack controls work unchanged on PC.
|
||||
|
||||
## N64 Carryover Comparison
|
||||
|
||||
The PC binary's four embedded secret instructions closely match the following N64 guide entries:
|
||||
|
||||
- Camera hold for the Leebo Scanner.
|
||||
- Camera hold during the Skyhook battle to switch to X-Wing/TIE.
|
||||
- Crouch hold for invincibility and ammunition.
|
||||
- Friendly Wampas on Jedi difficulty.
|
||||
|
||||
The shared effects are strong evidence of gameplay-secret carryover. The PC strings themselves are direct evidence for the PC build; challenge-point requirements and exact controls in the external guides are N64-only evidence unless independently confirmed above.
|
||||
|
||||
Name-based behavior also overlaps: the PC binary contains `R Testers ROCK` and ` Wampa Stompa`, while N64 guides report `R_Testers_ROCK` and `_Wampa__Stompa` (underscores denote spaces). A matching name string alone does not prove identical effects.
|
||||
|
||||
## Evidence and Confidence
|
||||
|
||||
- **High, binary-observed:** target identity and hashes; secret string locations and described actions; profile-name strings and exact spacing; the F12 polling/latch/eligibility path; dispatcher gates; default navigation and confirm binding groups; all 20 menu labels and their selection indices; the single-label rendering path.
|
||||
- **Runtime-confirmed by the user:** the game must be paused with the pause menu visible for the debug menu to open, and its labels appear. Up/Down did not change the selected live values.
|
||||
- **Medium, external comparison:** exact gameplay effects and unlock prerequisites, because the pages below document N64 behavior and PC entries but are user-contributed guides, not tests of this specific executable.
|
||||
- **Unresolved:** the default keyboard binding for the live adjustment axis; the source of `DAT_004cada0`; the runtime meanings and values of `DAT_004caf40`, `DAT_006ef1a8`, and `DAT_00760e54`; the exact on-screen position of the menu label; whether all four secrets trigger under precisely the same requirements as N64; compatibility across PC releases.
|
||||
|
||||
The user confirmed F12 activation and label visibility at runtime. The agent did not independently test the keyboard navigation/confirmation, destructive pilot name, or full effects of `Wampa Stompa`.
|
||||
|
||||
## External References
|
||||
|
||||
- [IGN: PC Cheats](https://www.ign.com/wikis/star-wars-shadows-of-the-empire/PC_Cheats)
|
||||
- [IGN: N64 Cheats](https://www.ign.com/wikis/star-wars-shadows-of-the-empire/N64_Cheats)
|
||||
- [GameFAQs: N64 Cheats](https://gamefaqs.gamespot.com/n64/198789-star-wars-shadows-of-the-empire/cheats)
|
||||
|
||||
The GameFAQs debug-mode entry and other submitted codes should be treated as reported community instructions, not independently verified behavior.
|
||||
67
docs/SOTE/level-modules.md
Normal file
67
docs/SOTE/level-modules.md
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# Shadows of the Empire PC Level Modules
|
||||
|
||||
## Scope and Method
|
||||
|
||||
- Target: the installed PC v1.1 build in `C:\RE\Star Wars - Shadows of the Empire\Sdata`; `Shadows.exe` SHA-256 `bb63e515b39467947adad5e7c94fce1b0d00f0a815ca5f8cd24d67b373b46175`.
|
||||
- The installation contains `DATA00.DLL` through `DATA31.DLL`. They are PE32 modules, not loose `.map` files.
|
||||
- Static inspection of each export found `GetLevelStub` returning the module's numeric suffix (0 through 31; module 00 returns zero). Each module also has an embedded `EEEENNNNDDDD` title marker. No DLL was loaded or executed during this inspection.
|
||||
- In `Shadows.exe`, `FUN_00441540` builds `sdata\data%02d` and bounds the requested module ID to 0–31 (out-of-range values fall back to 2). `FUN_00441660` loads the DLL and resolves `GetTheDataStub` and `GetLevelStub`.
|
||||
|
||||
## Finding
|
||||
|
||||
No dedicated debug/test map was identified in the shipped 32-module set. Every module has a title identifying it as a menu, a campaign segment, or a cutscene. A static scan of printable strings found no explicit `debug`, `test level`, `unused level`, `prototype map`, `development map`, `training level`, or `sandbox` label.
|
||||
|
||||
This is a bounded negative finding, not proof that every module is played on every route. `FUN_0044f270` uses a next-level override, while `FUN_0044f570` remaps some requested IDs (`9 -> 10`, `11/13 -> 14`, `18/19 -> 20`, `23 -> 24`, `28 -> 29`). The remapper is used by gameplay and debug-menu paths, so those remaps alone do not establish reachability. Follow-up tracing found a separate state-4 path to module 12; its trigger and ordinary-campaign reachability remain unresolved. Chapter-number gaps in the titles are likewise not enough to call a map cut.
|
||||
|
||||
**Conclusion:** no clearly labeled leftover debug map is present among `DATA00.DLL`–`DATA31.DLL`. The installation does contain cutscene and special-flow modules in addition to playable mission segments; whether any particular one is unreachable in every normal route remains unresolved.
|
||||
|
||||
## DATA12: End Game (Cut 02)
|
||||
|
||||
`DATA12.DLL` is a 55,296-byte PE32 module. Its `GetLevelStub` returns 12, `GetTheDataStub` returns the module data table at `0x1000B768`, and its embedded title marker is `EEEENNNNDDDDEnd Game (Cut 02)` (file offset `0x9b0c`). The payload also contains the string `Where am I?` at file offset `0x9978`; its use is not established by this static inspection.
|
||||
|
||||
The executable has an explicit special-flow route to this module:
|
||||
|
||||
- `FUN_0041088c` calls `FUN_00411660(-2)` when the game-state value at `DAT_004caf34` is 4.
|
||||
- `FUN_00411660` translates `-2` to level ID 12 and passes it through `FUN_0044f570` as the next-level override.
|
||||
- `FUN_0044f570` does not remap 12, and the normal transition routine then loads module 12 through the common level loader.
|
||||
|
||||
This establishes that DATA12 is not merely a numbered DLL with an interesting title or a debug-selector option: the executable contains a distinct runtime path that requests it. The code examined here does not identify what sets state 4, so it does not prove which ending condition reaches the path or whether it is exercised in an ordinary campaign run. The debug `Select Level` option provides a separate direct way to request ID 12.
|
||||
|
||||
## Module Index
|
||||
|
||||
| Module ID | File | Embedded title | Classification |
|
||||
| ---: | --- | --- | --- |
|
||||
| 0 | `DATA00.DLL` | Cut 00 (Intro) | Cutscene |
|
||||
| 1 | `DATA01.DLL` | Cut 01 (Hoth) | Cutscene |
|
||||
| 2 | `DATA02.DLL` | Main Menu | Menu |
|
||||
| 3 | `DATA03.DLL` | 1. Battle on Hoth | Campaign segment |
|
||||
| 4 | `DATA04.DLL` | 2a. Hoth Base | Campaign segment |
|
||||
| 5 | `DATA05.DLL` | 2b. Hoth Base | Campaign segment |
|
||||
| 6 | `DATA06.DLL` | 3. Asteroid Chase | Campaign segment |
|
||||
| 7 | `DATA07.DLL` | Cut 03 (Train) | Cutscene |
|
||||
| 8 | `DATA08.DLL` | 4a. Train | Campaign segment |
|
||||
| 9 | `DATA09.DLL` | Cut 04 (IG 88) | Cutscene |
|
||||
| 10 | `DATA10.DLL` | 4b. Junk Heap | Campaign segment |
|
||||
| 11 | `DATA11.DLL` | Cut 05 (Gorge) | Cutscene |
|
||||
| 12 | `DATA12.DLL` | End Game (Cut 02) | Special end-game cutscene; state-4 route exists, trigger unresolved |
|
||||
| 13 | `DATA13.DLL` | Cut 06 (Gorge Trans) | Cutscene |
|
||||
| 14 | `DATA14.DLL` | 6a. Gall Cliff Base | Campaign segment |
|
||||
| 15 | `DATA15.DLL` | 6b. Gall Cliff Base | Campaign segment |
|
||||
| 16 | `DATA16.DLL` | Cut 07 (Bike Intro) | Cutscene |
|
||||
| 17 | `DATA17.DLL` | 7. Speeder Bike Chase | Campaign segment |
|
||||
| 18 | `DATA18.DLL` | Cut 08 (Bike End) | Cutscene |
|
||||
| 19 | `DATA19.DLL` | Cut 09 (Freighter) | Cutscene |
|
||||
| 20 | `DATA20.DLL` | 9a. Space Freighter | Campaign segment |
|
||||
| 21 | `DATA21.DLL` | 9b. Space Freighter | Campaign segment |
|
||||
| 22 | `DATA22.DLL` | 9c. Space Freighter | Campaign segment |
|
||||
| 23 | `DATA23.DLL` | Cut 10 (Throne) | Cutscene |
|
||||
| 24 | `DATA24.DLL` | Cut 11 (Sewer) | Cutscene |
|
||||
| 25 | `DATA25.DLL` | 10. Sewer | Campaign segment |
|
||||
| 26 | `DATA26.DLL` | 11a. Xizor Palace | Campaign segment |
|
||||
| 27 | `DATA27.DLL` | 11b. Xizor Palace | Campaign segment |
|
||||
| 28 | `DATA28.DLL` | Cut 12 (Battle) | Cutscene |
|
||||
| 29 | `DATA29.DLL` | 12. Station Chase | Campaign segment |
|
||||
| 30 | `DATA30.DLL` | 13. Skyhook Battle | Campaign segment |
|
||||
| 31 | `DATA31.DLL` | Cut 13 (Finale) | Cutscene |
|
||||
|
||||
Titles are extracted from the installed module files. “Campaign segment,” “cutscene,” and “menu” are classifications based on those titles, not independent runtime observations. The PC executable also contains a separate debug-menu level navigation path; its existence does not make the corresponding module a debug map.
|
||||
41
docs/Yoda/cheats-and-debug.md
Normal file
41
docs/Yoda/cheats-and-debug.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Yoda Stories: PC Cheats and Debug Artifacts
|
||||
|
||||
## Summary
|
||||
|
||||
Static REA/Ghidra analysis of `Yodesk.exe` found two exact-match strings handled by one game routine: `goyoda` and `gojedi`. The first produces an `Invincible!` message and sets a handler field; the actual invulnerability effect was not traced. The second produces `Super Jedi!` and routes seven fixed game-data entries through an item-list helper. Their record names and exact gameplay effects remain unresolved.
|
||||
|
||||
A hardcoded `c:\yodalog.txt` writer is also present. No debug menu, console command, or debug-named game procedure was confirmed in the searched strings/procedure names. The logger is a diagnostic artifact, not evidence of a user-facing debug interface.
|
||||
|
||||
## Scope and Method
|
||||
|
||||
- Target: `C:\RE\Yoda_Stories\Star Wars - Yoda Stories (1997)(LucasArts)\Yoda\Yodesk.exe`, PE x86, SHA-256 `4d9876339d494cab141c3f4178f37a2725d178e41c7785887c84d021a8e695e7`.
|
||||
- Analysis: REA with Ghidra 12.1.4. The executable was analyzed statically in an ephemeral project. The game was not launched, executable bytes were not changed, and the Ghidra project was not saved.
|
||||
- The selected image contains 2,051 analyzed procedures and 999 defined strings. Addresses below are virtual addresses in `Yodesk.exe`.
|
||||
- String and procedure searches were bounded to cheat/debug-related terms. A negative search does not exclude encoded checks, unnamed logic, or behavior supplied by external game data.
|
||||
|
||||
## Embedded Codes
|
||||
|
||||
`FUN_00418cb0` compares the byte string at `this + 0x17c` against two embedded lowercase strings. The comparison is exact and case-sensitive. The strings are at `0x457214` (`goyoda`) and `0x457200` (`gojedi`); each has one direct reference in this handler. REA Evidence: handler pseudocode `ev_004e22d593fd6345794a575f11a6992f6f482a02a1513377ba49ce4db56d641f`; string inventory/search `ev_ade26cfa241bee347b0fd23213ff40f18c6361e54fb63ee6554a7ed3acfbdf50`; string xrefs `ev_1165b25725959f7b15e6e778150ae6104ba146717c74db2272159e1ff7c72701` and `ev_e20e0aaa72523fcb0b1b24587335bb51a9417256dc69a88e6bcce3f99eea3bee`.
|
||||
|
||||
| Code | Binary-observed behavior | What remains unverified |
|
||||
| --- | --- | --- |
|
||||
| `goyoda` | Passes `Invincible!` to UI helper `FUN_0041a7b0` at coordinates derived from the current game position, then sets `this + 0x180` to `1`. The input field is reset afterward. | The handler does not itself show a health/damage update. Whether `this + 0x180` enables player invulnerability elsewhere was not traced; treat the label as a strong hint, not a fully established gameplay effect. |
|
||||
| `gojedi` | Looks up table indices `0x1ff`, `0x200`, `0x201`, and `0x202` (the last four times) through `FUN_00404a70`, then passes the returned objects to `FUN_0041c3f0`. It displays `Super Jedi!` through the same UI helper and resets the input field. | `FUN_0041c3f0` inserts object-backed entries into a list, but the object names and exact gameplay effects are not recoverable from these executable references alone. The `YODESK.DTA` data records were not analyzed. |
|
||||
|
||||
The call to `FUN_0041a7b0` changes UI state and presents the supplied text; its use here is evidence for confirmation messages, not by itself proof of the associated cheat effect. The `gojedi` sequence and list behavior are visible in `FUN_00418cb0` and `FUN_0041c3f0`. REA Evidence: UI helper `ev_490ffce462d90c42b84b82a6272592d0345486c9f34128a7aacfa5dd97fdc72c`; list helper `ev_2a7abff77116595fc5e73e592ce41f3756dfeffd35a7cde29f0ff51d0b54a865`.
|
||||
|
||||
### Input Reachability
|
||||
|
||||
REA decoded a direct `CALL 0x00418cb0` at `0x41a088`. However, that callsite is not assigned to an analyzed procedure, and the resolved procedure-caller list for `FUN_00418cb0` is empty. The field at `this + 0x17c` is clearly compared with the two code strings, but this pass did not establish where the field is populated, the user-facing entry method, or whether the call is reachable in ordinary play. Do not infer a keyboard sequence or menu path from the comparisons alone. REA Evidence: callsite instruction `ev_a56dae62e987e14da434113e153ae803dbe6f13047c68829b7f1ed8a2f91d5d4`; caller result `ev_2f0331f64092b877fcb0cec7167ab0e1e76e3c865cc80a074621d4be53db6ec8`.
|
||||
|
||||
## Debug and Logging Artifacts
|
||||
|
||||
- `FUN_00401d20` opens the hardcoded path `c:\yodalog.txt`, writes its string argument, flushes, and closes the file. Its one resolved caller is `FUN_00423ef0`; the logger's file mode and the caller's precise logging conditions were not established. This supports the presence of file-based diagnostics, not an interactive debug facility. REA Evidence: logger pseudocode `ev_abd833e0e171e35a25a50a8bfd99fe2b2f39a1d915aeb907727ae94e8e0aef83`; caller list `ev_40c9282abeabc1b563740c277d22cf7b288f7831b5950cb8e953688f892d706b`.
|
||||
- Searches of the defined strings for `debug`, `cheat`, `secret`, `console`, `developer`, `test`, and related terms returned the two code strings, `c:\yodalog.txt`, `Invincible!`, and an MFC `CTestCmdUI` type string, but no named debug menu or console. Procedure-name search produced no game-specific debug/cheat routine. REA Evidence: string searches `ev_71610c8b15e3236479e7db351c31d39c296e0b4d15d1fab5e45427aac7e8bf7d`, `ev_49ae904a90daa0b4f76e6d2c053de584e71502204f4036bb99b2b1873db7242c`, and `ev_ade26cfa241bee347b0fd23213ff40f18c6361e54fb63ee6554a7ed3acfbdf50`; procedure search `ev_ee150208cd3debdd877edf3d8436ffe202e335ce55dc8b3f10d0244544897512`.
|
||||
|
||||
## Evidence and Confidence
|
||||
|
||||
- **High, binary-observed:** target identity; the exact lowercase strings; the two comparison branches; the `Invincible!` and `Super Jedi!` messages; the fixed `gojedi` table-index sequence; the UI/list helper behavior; and the hardcoded log writer.
|
||||
- **Medium, inference:** `goyoda` is intended to signal an invincibility cheat, and `gojedi` is intended to provide a special item loadout. The code names/messages support these interpretations, but the actual game-state effects and item identities were not independently traced.
|
||||
- **Unresolved:** how the compared field is filled; whether either check is reachable in normal gameplay; whether `this + 0x180` affects damage handling; the object names behind indices `0x1ff`-`0x202`; logger mode/conditions; and any debug behavior not represented by searched plaintext strings or analyzed procedure names.
|
||||
- **Not performed:** launching the game, testing either code, analyzing `YODESK.DTA`, patching bytes, or saving a Ghidra project.
|
||||
1753
docs/crusader-exe-function-identification-map.md
Normal file
1753
docs/crusader-exe-function-identification-map.md
Normal file
File diff suppressed because it is too large
Load diff
2259
docs/jp-remorse-decompilation-progress.md
Normal file
2259
docs/jp-remorse-decompilation-progress.md
Normal file
File diff suppressed because it is too large
Load diff
47
docs/jp-remorse-handoff-2026-10-12.md
Normal file
47
docs/jp-remorse-handoff-2026-10-12.md
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# JP Semantic-Gap Investigation Handoff
|
||||
|
||||
Date: 2026-10-12
|
||||
|
||||
## Resume Context
|
||||
|
||||
- Workspace: `Crusader_Decomp`
|
||||
- Live Ghidra target: `/ja/CRUSADER.EXE`, image base `00400000`
|
||||
- Main ledger and active backlog: [JP decompilation progress](jp-remorse-decompilation-progress.md), under `Semantic-Gap Analysis Checkpoint` and `Next Work`
|
||||
- Coverage script: `tools/jp_executable_documentation_report.py`
|
||||
|
||||
The user asked to investigate five semantic-gap areas and add follow-up tasks to the JP ledger. That static pass is recorded in the progress document. The current investigation made no Ghidra database edits, saved no Ghidra state, and changed no executable bytes. Any pre-existing pending Ghidra changes were left untouched.
|
||||
|
||||
## Verified Baseline
|
||||
|
||||
The latest read-only coverage report for the active JP program reports:
|
||||
|
||||
- Function entries tracked: `1,493 / 1,493` (100%); untracked: `0`; generated names: `0`
|
||||
- Function-body coverage: `336,693 / 499,712` bytes (67.4%)
|
||||
- Defined-instruction coverage: `399,698 / 499,712` bytes (80.0%)
|
||||
- Executable bytes outside defined instructions: `100,014`; these may be data, padding, or unanalyzed code
|
||||
- Five ledger table addresses are not function entries: `004811f3`, `004811f9`, `00481200`, `00481208`, `0048120d`
|
||||
|
||||
Do not treat the remaining byte percentage or those five table addresses as proof of missing functions.
|
||||
|
||||
## Findings So Far
|
||||
|
||||
- Action dispatch: selectors `0`, `4`, `0x21`, `0x39`, and `0x3b` all construct a type-`0xf0` process through `process_0x0f0_construct_for_item`, then install distinct callback tables. The selector callbacks still need semantic names.
|
||||
- Attack process: type `0x259` is constructed by `AttackProcess_0040af20`. The `process_choose_direction_to_coords` `0xff` path checks a nonzero `+0x64` value, shape overlap, and a packed-position query before dispatching selector `0`; the meanings of `DAT_0047b1d6`, `+0x64`, and process byte `+0x7d` remain open.
|
||||
- Cache and records: the keyed cache has ten rotating key slots and 256 entry pointers per slot. The 16-bit key is looked up at file offset `key * 4`; descriptor low byte `+4` controls count and bit `0x40` at `+7` selects `0x40`/`0x80` bytes per entry. The pair reader copies two dwords. The separate 16-byte item snapshot layout is mapped in the progress ledger; the main item table has stride `0x79`.
|
||||
- Animation and spatial search: AnimationProcess uses type `0x230` and vtable `0047e7a8`; its constructor clears `+0x52`, and a helper sets it to one. Its sole caller, `00411fcd`, is code with no owning Ghidra function. The spatial grid uses 64 two-byte cells per `0x80`-byte row; selector coordinates step by `0x200` and use `>> 9` for grid indexing.
|
||||
- Input and presentation: joystick actions `4`-`8` emit `u/g/s/m/e`; action `9` maps directions to `q/w/i/o`; process byte `+0x62` selects distinct handling. Startup dialog resource `0x71` opens only for positive direction flags; a zero dialog result aborts startup. The DirectDraw lock helper has no restore branch. The debug timeline helper's sole caller is unowned code at `00455bb6`.
|
||||
- Boundaries/debug: `00411fcd` and `00455bb6` are confirmed call sites but have no containing function. The timeline consumer/fields and writer for `DAT_004955e8` remain unresolved.
|
||||
|
||||
No runtime test of the joystick dialog or presentation paths was performed, and no JP/Western semantic comparison was made.
|
||||
|
||||
## First Steps Tomorrow
|
||||
|
||||
1. Open or confirm the live `/ja/CRUSADER.EXE` target before using Ghidra MCP. Use MCP-only analysis; do not use the offline PyGhidra CLI.
|
||||
2. Read the `Semantic-Gap Analysis Checkpoint` and `Next Work` sections in the [JP decompilation progress ledger](jp-remorse-decompilation-progress.md).
|
||||
3. Start with boundary triage around `00411fcd` and `00455bb6`: inspect surrounding disassembly, control flow, and references to determine whether each belongs to a larger routine. Do not create or name a function until bounds are supported.
|
||||
4. Continue with the prioritized backlog in the ledger: action callback/type-`0x259` contracts, cache and field semantics, animation/spatial details, then joystick/dialog/DirectDraw/debug-timeline paths.
|
||||
5. Re-run the read-only coverage script when useful to confirm the exact-entry baseline. Leave Ghidra project saving to the user and never patch bytes in the reference executable.
|
||||
|
||||
## Worktree Note
|
||||
|
||||
`docs/jp-remorse-decompilation-progress.md` was already locally modified before this investigation. Those existing edits were preserved; this work updated the bottom checkpoint/backlog and corrected its heading structure. The current changes have not been committed.
|
||||
158
docs/jp-remorse-usecode-debugger-feasibility.md
Normal file
158
docs/jp-remorse-usecode-debugger-feasibility.md
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
# Japanese No Remorse USECODE Debugger Feasibility
|
||||
|
||||
**Status:** Static feasibility assessment; no executable bytes changed
|
||||
**Target:** Japanese Win32 `/ja/CRUSADER.EXE` in the active Ghidra project
|
||||
**Reviewed:** 2026-10-11
|
||||
|
||||
## Executive Assessment
|
||||
|
||||
Adding a useful USECODE debugger to the Japanese build is technically feasible, but it is a JP-specific port or extension, not a hidden feature that can be switched on by copying the No Regret bootstrapper. The Japanese executable has ordinary USECODE execution and some useful metadata, but the recovered image does not contain the classic debugger's break-state object, interpreter record lifecycle, UI, or debugger event handlers.
|
||||
|
||||
The practical ratings are:
|
||||
|
||||
| Approach | Feasibility | Assessment |
|
||||
|---|---|---|
|
||||
| Copy DOS No Remorse/No Regret debugger machine code into the JP PE | Very low | The sources are 16-bit DOS NE programs; JP is a flat 32-bit Win32 PE. Segmented pointers, calling conventions, allocators, file access, and the UI framework do not match. This is not a binary transplant. |
|
||||
| Use the existing Windows native debugger on the JP process | High for machine-code debugging | Ghidra/x32dbg can stop and inspect native instructions, including the USECODE interpreter. This does not provide USECODE line breakpoints, unit-aware frames, watches, or a game debugger UI. |
|
||||
| Build a small JP trace/break prototype | Feasible, moderate | Add or externally orchestrate hooks at interpreter boundaries; begin with current unit/event, bytecode offset, opcode, and stop/continue. This is the recommended first implementation target. |
|
||||
| Port the complete in-game debugger | Feasible in principle, high effort and risk | Requires a new JP runtime-state layer, validated source mapping, break/step integration, watch semantics, and a UI path. No plugin ABI or existing JP debugger frontend has been recovered. |
|
||||
|
||||
**Recommendation:** time-box a runtime instrumentation spike before writing a full debugger. Prove that a real JP interpreter invocation can be identified, paused at a stable bytecode boundary, resumed without state corruption, and associated with its live unit/event/frame. Use an external controller first; add an in-game UI only after that contract is demonstrated.
|
||||
|
||||
## What The JP Executable Has
|
||||
|
||||
The active Ghidra project reports the open domain file as `/ja/CRUSADER.EXE`; the image is the flat Win32 build, not either DOS NE executable. The existing JP investigation records its PE image base as `0x00400000` and its SHA-256 as `037b7d2be829048a1b305eae15e7f78be72329af80425cc32e2f5fcee0ba5231`. Keep any future patcher tied to that exact build fingerprint.
|
||||
|
||||
USECODE runs through `UsecodeProcess_Create` (`004671b0`), `UsecodeProcess_Run` (`00467304`), and the large opcode dispatcher `UsecodeProcess_NextOpcode` (`0042ddc8`). The process factory installs the ordinary process callback table; the recovered table does not expose a debugger callback or break-state global.
|
||||
|
||||
### Process Lifecycle And Spawn Paths (2026-10-11)
|
||||
|
||||
The primary process callback entries at `004803d4` cover ordinary scheduling and lifecycle work. `UsecodeProcess_Run` (`00467304`) is the run slot; `00458980` and `00458990` are termination callbacks. `004680f0` performs cleanup, `00467360` releases a value for an incomplete process, `00467448` restores process state, `00467380` serializes it, and `004672fc` is a thunk that returns the process resource at `+0x34`. The `00467448` and `00467380` callbacks use shared Windows file helpers `004262f8` (`ReadFile`) and `0042637c` (`WriteFile`), rebuilding runtime pointers around the instruction cursor and stack/frame fields. `004059d0` and `004059e0` are one-byte `RET` stubs.
|
||||
|
||||
The word at `004803fc` (`00466de0`) begins a resource-object vtable used by `FUN_00466d60`, which installs `004803fc` as that object's vptr; `00466de0` is its destructor/release path. The following pointer at `00480400` (`0046a940`) is not another confirmed process callback. It is referenced as adjacent type/registration data from `0046eb7b`, and `0046a940` itself is constructor-like: it allocates and initializes a separate `0x11e`-sized object. The exact descriptor format and object's role remain open. None of the confirmed process lifecycle paths tests a source line or breakpoint.
|
||||
|
||||
The dispatcher retains both process-spawn opcodes. Token-name pointer slots map `T_SPAWN` to opcode `0x57` and `T_SPAWN_INLINE` to `0x58`; their dispatcher cases at `0042feaf` and `0042ffce` each call `UsecodeProcess_Create` (`004671b0`). A third creation path, now named `usecode_start_event_process_if_enabled` (`004670b0`), resolves a unit/event, checks its event mask, and creates a process for eligible events. `item_create_from_shape_id` calls it for shape-dependent initialization events. This confirms that ordinary event dispatch and nested/child process creation survive, not debugger stepping or a debugger-owned child-context stack.
|
||||
|
||||
The JP dispatcher retains two USECODE metadata opcodes, but their recovered handlers do not implement debugger control:
|
||||
|
||||
- Opcode `0x5b` (`T_LINE_NUMBER`, token pointer at `0047b900`, name at `00480e94`) is handled at `0042dfaa`. It advances the USECODE cursor by two operand bytes and returns to dispatch; it does not retain the line value, update a current-line field, or test a breakpoint. A new hook could capture the operand, but its mapping to display rows is not verified.
|
||||
- Opcode `0x5c` (`T_SYMBOL_INFO`, token pointer at `0047b904`, name at `00480ea2`) is handled at `0042dfbd`. It skips a two-byte field and a nine-byte inline name record. When `DAT_00482ad0` is nonzero, it sends the name to the shared output helper (`00445520`) using `"<%s>\n"`; it does not push a debugger current-entry record or preserve a frame for inspection.
|
||||
- The same `DAT_00482ad0` condition gates generic opcode-name output at `0042dea3`, using the token-name table. The current data-use scan found these reads but no writer. This is trace-style output, not an interactive debugger surface.
|
||||
|
||||
These handlers are useful hook locations because they expose a line operand and symbol activity during normal interpretation. They do not establish a complete source map or retain the state needed for source-level stops, stepping, watches, or frame inspection. The separate `T_SUSPEND` runtime operation is not connected to the line-number handler in the recovered path.
|
||||
|
||||
### Line-Related String Matches That Are Not USECODE Debugging
|
||||
|
||||
The broad string search also found halt/error text, but its references lead to the media-player error path rather than the USECODE VM:
|
||||
|
||||
- `"Halted file %s\\nline %d"` (`00425230`) and `"Halted file %s\\nline %d\\n%s"` (`00425247`) are used by `00425050` and `00425084`. These are one-shot fatal-report handlers that call the message formatter and then `win32_shutdown_message_loop`.
|
||||
- `"player halted on line %d"` (`00457060`) is passed by `004562f8` with source label `player.h` and line `0x1e`. `"Error in %s, line %ld. %s\\n"` (`00457082`) is used by `00454f08`, whose surrounding code parses RIFF/AVI chunks. These are media-player diagnostics, not USECODE line stops.
|
||||
|
||||
They are recorded here to prevent interpreting a text match for “halted” or “line” as evidence of a USECODE debugger.
|
||||
|
||||
## What Is Missing
|
||||
|
||||
The JP function and string searches found no classic debugger function family or characteristic prompt bundle. In particular, the following pieces recovered in the DOS builds have no JP equivalent in the analyzed path:
|
||||
|
||||
- A break-state object with breakpoint slots, current line, step flags, and a current-entry stack.
|
||||
- Interpreter-side line update, current-entry push/copy, and return/unwind operations.
|
||||
- A debugger-owned UI/event subsystem for source display, breakpoints, watches, inspection, and global editing.
|
||||
- A bootstrap that allocates and publishes debugger state, and a callback that opens the UI when a break condition fires.
|
||||
|
||||
The absence is bounded evidence, not proof that no encoded or dynamically registered helper exists. The stronger finding is behavioral: the known JP process and opcode paths do not perform the classic break-state lifecycle.
|
||||
|
||||
### UI Surface Search (2026-10-11)
|
||||
|
||||
The active `/ja/CRUSADER.EXE` program was searched again for both debugger-specific UI and ordinary game UI markers. This separates two questions that should not be conflated:
|
||||
|
||||
- **Classic USECODE debugger/editor UI:** no debugger menus, source/watch panes, or debugger command surface were recovered.
|
||||
- **Ordinary game UI:** the JP executable still contains generic Gump and event-dispatch infrastructure. Its presence does not establish that a debugger UI survived.
|
||||
|
||||
The targeted function-name searches for `usecode`, `gump`, `NewGump`, `dialog`, `menu`, `conversation`, `speech`, and `intrinsic` returned only the known general USECODE functions for the `usecode` query (`UsecodeProcess_Create`, `UsecodeProcess_NextOpcode`, `UsecodeProcess_Run`, `Usecode_FreeList`, `Usecode_FreeVal`, and `usecode_reference_table_decrement_refcount`). The other queries returned no named functions. This is bounded by current Ghidra function names; it does not classify every unnamed function.
|
||||
|
||||
Targeted decoded-string searches returned no matches for the classic debugger vocabulary: `Watch what?`, `Inspect what?`, `Goto Line`, `Breakpoints`, `Global name`, `Search for`, `FILE NOT FOUND`, `step`, `break`, and `source`. The `debug` search returned only `Debugging mode ON.\n\r` at `00466af9`, `-debug` at `004811d2`, and the imported `DebugBreak` name at `00496734`. The `usecode` search returned `usecode` at `0047be40` and `eusecode.flx` at `0047be90`.
|
||||
|
||||
There is positive evidence for generic game UI, not for the debugger frontend:
|
||||
|
||||
- `GUMPS.FLX` occurs at `00466a9b`; `.\\gumpshap.c` and `.\\newgump.c` source markers and `Bad NewGumpId [%04X]` occur in the executable.
|
||||
- The `Bad NewGumpId` diagnostic is referenced by `FUN_0044cb44` and `FUN_0044d614`, called from the broader `FUN_0041ccc8` dispatch path. The recovered code traverses and validates generic Gump objects; it is not a debugger-owned menu or pane.
|
||||
- The only `dialog` string-filter hits were imported Windows APIs `DialogBoxParamA` and `EndDialog`, not debugger prompts. The presence of those imports alone does not identify a game debugger UI.
|
||||
|
||||
**Conclusion:** it is not accurate to say that the JP executable has no UI or no Gump code. It is accurate, with the current search coverage, to say that no classic USECODE debugger/editor UI has been found. This pass did not prove which JP USECODE intrinsics can invoke ordinary Gump/dialog UI, and it does not rule out encoded/localized or unnamed debugger remnants. The opcode `0x5b`/`0x5c` behavior remains the stronger functional evidence that the classic debugger lifecycle is absent from the recovered JP interpreter path.
|
||||
|
||||
### Source and support files
|
||||
|
||||
The inspected Japanese `USECODE` directory contains `JUSECODE.FLX` and `UNKDS.DAT`; the scan found no loose per-unit `.unk` files. `UNKDS.DAT` is 66 bytes in this installation. Its internal role remains unresolved, and the recovered older debugger path opens it separately from the source viewer. It is not the per-unit text listing expected by the classic debugger.
|
||||
|
||||
The classic source pane constructs `<unit>.unk`, loads it as line-oriented text, and indexes its lines. Even if a debugger frontend were ported, the JP build would need either authentic JP listings or generated JP-specific display files. Western Remorse/Regret generated listings cannot be assumed to match JP names, bytecode, or line semantics. A source file improves display and navigation; it does not create executable state or make `RUN` interpret that text.
|
||||
|
||||
## Why The No Regret Bootstrap Does Not Solve This
|
||||
|
||||
No Regret is a useful behavioral reference, not a plug-in component. Its recovered `usecode_debugger_bootstrap_init` (`1398:0000`) allocates support objects, creates a break-state object, stores it in `1480:712c/712e`, and replaces the base vtable with a frontend-aware vtable. Its interpreter hook also contains the line, current-entry, child-context, and unwind handlers.
|
||||
|
||||
However, the bootstrap has no recovered normal caller. In the tested ordinary session, the debugger global remained null. A statically present writer is not proof that startup executes it. Separately, forcing the modal UI or loading a generated `.unk` does not synthesize a valid current interpreter entry: the debugger's `RUN` command resumes the live interpreter rather than executing the displayed text, and an invalid/missing current-entry record can still crash the path.
|
||||
|
||||
That distinction is even more important for JP. The JP build is not just missing No Regret's bootstrap call; its recovered interpreter handlers do not implement the producer/consumer lifecycle that bootstrap expects. Porting only the constructor would create state that JP's VM never updates.
|
||||
|
||||
## Implementation Choices
|
||||
|
||||
### 1. Native process debugging
|
||||
|
||||
Use Ghidra's native debugger or x32dbg to break in `UsecodeProcess_NextOpcode`, inspect the process/context objects, and follow the `0x5b`/`0x5c` paths. This is the lowest-risk way to discover live unit, event, cursor, and frame fields. It provides machine-level debugging and is a prerequisite for the options below, not USECODE source-level parity.
|
||||
|
||||
### 2. JP trace and controlled break prototype
|
||||
|
||||
Add the smallest possible interpreter instrumentation, or drive equivalent breakpoints from an external controller. Record at least process identity, unit/class, event, bytecode offset, opcode, and the `0x5b` operand where present. Add stop/continue at an instruction boundary only after confirming register, stack, and scheduler behavior at that point.
|
||||
|
||||
Keep the first controller outside the game's UI. This avoids having to recreate the DOS Gump interface before the VM state contract is known. A later UI can present the trace and break controls over a local IPC or debugger-agent connection.
|
||||
|
||||
### 3. Full JP in-game debugger
|
||||
|
||||
A full port would need JP-native implementations for:
|
||||
|
||||
1. A debugger session object and safe lifecycle attached to each active USECODE process/context.
|
||||
2. Unit/event identity and a balanced frame stack across calls, child processes, returns, suspension, and resumption.
|
||||
3. Line/bytecode mapping, breakpoints, break-next, single-step, step-over, and resume semantics.
|
||||
4. A source/listing loader and JP-specific generated or authentic per-unit listings.
|
||||
5. Watch/inspect expression evaluation over JP values, frames, globals, and intrinsic results.
|
||||
6. A frontend built on the JP UI framework or an external debugger window, plus a safe bridge to the emulation/game thread.
|
||||
|
||||
Do not begin with watch/inspect or a full UI. Those features depend on runtime value ownership and descriptor semantics, which the current JP evidence does not close.
|
||||
|
||||
## Binary Modification Constraints
|
||||
|
||||
JP's flat PE layout is easier to reason about than the DOS NE segment/fixup model, but that does not make arbitrary injection safe. No general plugin ABI or JP-specific patcher is established. Existing DOS NE patch definitions and offsets are inapplicable.
|
||||
|
||||
Any actual code experiment should use a separate writable copy of the fingerprinted JP executable, preserve the original file, and be reversible. A detour must preserve the original instruction boundaries, registers, flags, stack state, and execution timing. Prefer an external debugger breakpoint for the initial runtime investigation. Do not patch or save changes into the currently loaded reference executable or Ghidra program.
|
||||
|
||||
## Recommended Spike And Gates
|
||||
|
||||
Start with a bounded 1-2 week investigation, not a full feature commitment:
|
||||
|
||||
1. Attach to an unmodified JP game and capture one real USECODE event through `UsecodeProcess_NextOpcode`; identify the active unit/event, process object, source cursor, and frame/value context.
|
||||
2. Trace the `0x5b` and `0x5c` cases on real data. Establish what their operands mean in JP and whether unit names and offsets can be associated with a class/event listing.
|
||||
3. Set an external native breakpoint at a chosen opcode boundary, resume the game, and verify that the same process continues correctly. Check nested calls and at least one return/yield transition before claiming reliable stepping.
|
||||
4. Generate a JP-specific listing only after source identity and line-offset rules are established. Label synthetic rows as synthetic; do not imply original source-line fidelity.
|
||||
5. Decide whether the first usable debugger is an external trace/break UI or a game-integrated frontend. Estimate the full port only after the runtime snapshot and mapping gates pass.
|
||||
|
||||
### Go/no-go criteria
|
||||
|
||||
Proceed toward a source-aware debugger if the spike can reliably recover a live unit/event/bytecode position, stop and resume without corrupting scheduler state, and maintain a coherent frame across nested execution. If the line operand or symbol metadata is not sufficient for source mapping, a bytecode-offset debugger is still viable, but should be scoped and named accordingly.
|
||||
|
||||
Treat watches, global editing, and source-line breakpoints as later milestones. They require validated JP frame/value semantics and should not be advertised based only on the DOS debugger's menu behavior.
|
||||
|
||||
## Evidence And Limits
|
||||
|
||||
This assessment combines the active Ghidra target check, a live disassembly of `0042df90..0042e020`, the 2026-10-11 targeted function-name/string/UI-resource search, and the existing JP debugger, dispatch, USECODE-resource, No Regret, and `.unk` investigations listed below. Program bytes were not changed. No live JP game session was captured for this assessment, so pause/resume behavior, runtime frame fields, loader behavior for generated JP listings, and the meaning of `UNKDS.DAT` remain open.
|
||||
|
||||
The negative function/string searches do not prove absolute absence. They do show that the currently recovered JP interpreter/runtime does not contain the classic debugger lifecycle. The feasibility conclusion is therefore: **a JP-specific debugger extension is possible; direct reuse of the DOS debugger is not; first prove the live VM state contract before committing to a complete UI or watch system.**
|
||||
|
||||
## Related Investigations
|
||||
|
||||
- [Japanese hidden debugger investigation](jp-remorse-hidden-debugger-investigation.md)
|
||||
- [Japanese USECODE dispatch analysis](usecode-jp-dispatch-analysis.md)
|
||||
- [Japanese Windows debugging](jp-remorse-windows-debugging.md)
|
||||
- [Japanese Windows modding feasibility](jp-remorse-windows-modding-feasibility.md)
|
||||
- [No Regret hidden debugger investigation](regret-hidden-debugger-investigation.md)
|
||||
- [USECODE `.unk` format](usecode-unk-format.md)
|
||||
- [Standalone USECODE debugger proposal](standalone-usecode-debugger.md)
|
||||
64
docs/jp-remorse-windows-debugging.md
Normal file
64
docs/jp-remorse-windows-debugging.md
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# Japanese No Remorse Windows Debugging
|
||||
|
||||
## Executive Summary
|
||||
|
||||
The JP executable can be debugged as a normal 32-bit Win32 process with an external debugger. Its own debug facilities are narrower: `-debug` enables a timeline-like diagnostic buffer, and the executable imports `DebugBreak` for selected invariant/error paths. No JP equivalent of the DOS `CRUDEBUG` environment switch, classic hidden USECODE debugger, or app-specific debugger-attach protocol was found.
|
||||
|
||||
Ghidra 12.1.4 includes live debugger agents for Microsoft `dbgeng` and x64dbg, including local attach launchers. Its Decompiler can be used as an address-oriented view while the native executable runs. The reconstructed C is not executable source: breakpoints and stepping operate on machine instructions, with pseudocode synchronized to those addresses where possible.
|
||||
|
||||
## JP Game-Side Facilities
|
||||
|
||||
### The `-debug` option
|
||||
|
||||
`handle_commandline_args_jp` at `00466774` maps `-debug` to the handler at `004668b4`. The handler prints `Debugging mode ON` and sets bytes at `004957d9` and `004957eb`. The latter gates `debug_mode_update_timeline_buffer` at `00455eac`; that helper builds and copies a 512-byte timeline-like marker buffer from object counters. Its exact visible consumer is unresolved. This is engine instrumentation, not a debugger connection, breakpoint UI, or recovered USECODE break-state system. The flag at `004957d9` has no recovered reader.
|
||||
|
||||
The separate [hidden debugger investigation](jp-remorse-hidden-debugger-investigation.md) found no classic JP USECODE debugger UI/bootstrap or break-state lifecycle. JP's metadata opcodes do not reproduce the DOS debugger's source-line and current-entry recording behavior.
|
||||
|
||||
### Environment variables
|
||||
|
||||
The DOS build's `Kernel_Init` reads `CRUDEBUG` through its environment lookup helper and sets a debug-enabled global. In the JP PE, an exact ASCII byte search for `CRUDEBUG` found no hit. `GetEnvironmentStrings` is in the import table, but Ghidra found no code call site to it beyond the import entry. No JP environment-variable equivalent was recovered.
|
||||
|
||||
The JP `-debug` command-line option is the nearest identified counterpart, but it is not behaviorally equivalent to DOS `CRUDEBUG`: it enables the timeline-buffer instrumentation described above. Absence of the literal and direct environment lookup is strong negative evidence, not proof that no encoded or dynamically constructed environment check exists.
|
||||
|
||||
### Breaks, assertions, and crashes
|
||||
|
||||
The PE imports `DebugBreak`. One confirmed use is in `usecode_reference_table_decrement_refcount` at the call site `00467da6`: if the reference lookup fails, the code shows the game window/cursor, calls `DebugBreak`, retries the lookup, and then continues using the result. An attached debugger can stop at this breakpoint exception. If the lookup still fails after continuing, an invalid access can follow; this is an invariant trap, not a crash-recovery handler.
|
||||
|
||||
Other `DebugBreak` references occur in `process_choose_direction_to_coords` at `00453c64`. The call at `00453985` belongs to the recovered `process_update_direction_toward_target` at `004538c0`: it reads its associated item's current X/Y from the global item tables and delegates 8-way direction selection to the helper. The helper tests direction candidates and updates direction/turn state; it can return `0x10` when a packed process-state flag is set or `0xff` through a separate special-action path. These breakpoints are gated by global `004955e8`. Static xrefs still show reads of this global but no in-image writes, so how it becomes nonzero and whether ordinary gameplay reaches the breaks remain unresolved. They are diagnostic traps, not evidence of a user-facing stepping or inspection facility.
|
||||
|
||||
The imports include CRT unwind support (`RtlUnwind`) and the image contains C++ exception-runtime messages. The inspected import table has no explicit `SetUnhandledExceptionFilter` or `UnhandledExceptionFilter` import, and no custom JP crash-reporting path was established. This does not mean crashes cannot be debugged: a native debugger can stop on an access violation or breakpoint exception, provided it is attached before the fault or launches the process under debugging. Exact first-chance/second-chance behavior depends on the debugger backend and its exception policy.
|
||||
|
||||
No imports or strings were found for common app-side attach/detection APIs such as `IsDebuggerPresent`, `CheckRemoteDebuggerPresent`, `DebugActiveProcess`, or `OutputDebugString`. Such APIs are not required for an external debugger to attach; process attachment is provided by Windows and the debugger backend.
|
||||
|
||||
## Debugging With Ghidra
|
||||
|
||||
### Live native debugging
|
||||
|
||||
The installed Ghidra 12.1.4 distribution contains:
|
||||
|
||||
- `Debugger-agent-dbgeng`, with local launch and attach launchers using `dbgeng.dll`.
|
||||
- `Debugger-agent-x64dbg`, with local launch and attach launchers using `x64dbg.dll` and x64dbg's automation interface. The agent has 32-bit register/context support; for this x86 game, use the x32 debugger variant where appropriate.
|
||||
|
||||
Ghidra's setup notes specify Python 3.9-3.14 for debugger agents; WinDbg/DbgEng support uses Pybag and protobuf. The bundled launcher F1 help describes the local setup and dependencies. The attach launchers accept a process ID, so the JP game can be started normally and attached, or launched from Ghidra under the selected backend.
|
||||
|
||||
With a live target, Ghidra can provide dynamic disassembly, registers, memory, stack/call-stack state, breakpoints, and trace snapshots, subject to what the backend reports. The bundled Debugger course documents setting an address breakpoint from a static or dynamic listing, including the Decompiler window. A breakpoint selected on pseudocode resolves to a machine address; it does not create a source-line breakpoint in original game source.
|
||||
|
||||
### What “debug the decompiled code” means
|
||||
|
||||
- **Supported:** stop the native process at an address represented in the Decompiler, inspect the synchronized instruction/pseudocode, and use value hovers to evaluate recovered locals, parameters, globals, or fields against live state when Ghidra can map them.
|
||||
- **Not source-level execution:** Ghidra cannot execute a decompiler C statement as C or step it independently of the binary. A pseudocode statement can correspond to several instructions, and recovered types, names, and variable lifetimes are hypotheses unless confirmed by runtime state. Without matching source/debug symbols, use the disassembly, registers, stack, and memory as the ground truth.
|
||||
- **Emulation is different:** Ghidra's emulator steps the instruction semantics represented as p-code, which is also used by the decompiler. It does not run the decompiled C and does not automatically reproduce the full Windows/DirectDraw/DirectSound environment. It is useful for bounded functions or paths, but unsupported p-code userops and external API behavior may require modeling or stubbing.
|
||||
|
||||
### Practical workflow
|
||||
|
||||
1. Open the JP `/ja/CRUSADER.EXE` program in the Ghidra Debugger tool and choose the local `dbgeng attach` or x64dbg attach launcher, or launch the game under that backend. Confirm the target module is mapped to the analyzed image before trusting static-address breakpoints.
|
||||
2. Set a breakpoint from the Decompiler/disassembly at the code of interest. For the known invariant trap, `00467da6` is a candidate; use a narrow breakpoint rather than breaking on every `DebugBreak` invocation.
|
||||
3. To investigate a crash, attach before reproducing it and configure the backend to stop on the relevant access violation/breakpoint exception. Capture the exception address, registers, stack, and nearby memory before resuming or terminating the process.
|
||||
4. To test `-debug`, launch with that argument and observe the `00455bac` gate and `00455eac` helper. Do not infer classic USECODE debugger behavior from the “Debugging mode ON” message.
|
||||
5. Keep the game executable and data unchanged during initial debugging. Static analysis and live debugging are read-only unless an explicit dynamic edit/patch action is chosen.
|
||||
|
||||
## Evidence Boundary
|
||||
|
||||
The JP findings above come from live Ghidra analysis of `/ja/CRUSADER.EXE`, including its import table, `-debug` handler, timeline-buffer consumer, and `DebugBreak` xrefs. The no-`CRUDEBUG` result is based on the absence of the ASCII byte pattern and the lack of a direct `GetEnvironmentStrings` code reference. The exception/crash discussion is static; no JP crash was reproduced in a live debugger during this investigation.
|
||||
|
||||
Ghidra capability claims were checked against the installed 12.1.4 distribution: `docs/GhidraClass/Debugger/A3-Breakpoints.md`, `A4-MachineState.md`, and `B2-Emulation.md`; the `Debugger-agent-dbgeng` and `Debugger-agent-x64dbg` launchers; and the Debugger notes in `docs/GettingStarted.md`. The attach integration is available in this installation, but an actual JP live-debugger session has not yet been tested.
|
||||
222
docs/jp-remorse-windows-modding-feasibility.md
Normal file
222
docs/jp-remorse-windows-modding-feasibility.md
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
# Japanese No Remorse Windows Modding Feasibility
|
||||
|
||||
## Executive Assessment
|
||||
|
||||
The Japanese No Remorse release is a credible base for a **separate Windows-native mod target**, especially for data and script experiments. It is not a drop-in replacement for Western DOS retail, and executable patches or data should not be shared across those builds without validation.
|
||||
|
||||
| Question | Assessment | Main boundary |
|
||||
|---|---|---|
|
||||
| Use JP as a modding base | **Feasible with a version-specific toolchain** | JP has a native Win32 executable and a substantial data set, but maps and scripts are not interchangeable with Western retail by default. Rebuilt assets have not yet been proven in-game. |
|
||||
| Launch natively on Windows 10/11 | **DxWrapper reaches Direct3D device setup; full game stability remains unverified** | The game is a Win32 PE and does not require DOSBox by architecture. A DDraw-to-D3D9 test creates a 1920x1440 device, but the earlier device-loss/lock failure and a later write access violation mean menu-to-game stability still needs testing. |
|
||||
| Reuse Western retail decompilation or patches | **Low without translation and validation** | JP is a flat Win32 implementation; Western retail is a Phar Lap protected-mode MZ/NE executable. Addresses, ABI, loader, and some runtime behavior differ. |
|
||||
| Rebuild the original or a very similar executable | **Not currently practical from available materials** | No source or build project was found on the extracted JP CD. Decompiled output is not compiler-ready, and there is no recovered JP build system or complete source-port implementation. |
|
||||
| Use JP as a cross-reference | **Useful selectively** | Shared data and behavior can corroborate hypotheses, but JP-specific interpreter/debugger behavior must be checked per build. |
|
||||
|
||||
Track JP as its own target profile: separate executable fingerprint, asset manifest, USECODE assumptions, patch format, and Windows launch tests. Keep Western DOS/NE retail as a separate target for existing patches and DOSBox workflows.
|
||||
|
||||
## Established Evidence
|
||||
|
||||
The prior [Win9x investigation](jp-remorse-windows9x-investigation.md) found that JP is a PE-style Win32 application loaded at `0x00400000`, with Windows startup/window creation, registry-backed configuration, DirectDraw/DirectSound initialization, and a `GetVersion`/TLS branch for Win9x behavior. This strongly supports an intended native Windows 9x path. It does not certify runtime behavior on Windows 95, nor Windows 10/11 compatibility.
|
||||
|
||||
The active `/ja/CRUSADER.EXE` Ghidra program was also queried for `004459b0` (`video_init_directdraw_and_directsound`). It calls `DirectDrawCreate`, sets the display mode to `0x280 x 0x1e0` (640x480), creates a palette and primary surface, and initializes DirectSound. Its decompilation is still imperfect: the flat Win32 function has a `ulonglong __fastcall` signature, `undefined4` parameters, synthetic `extraout_ECX` values, and calls through interface-vtable offsets. This is a useful concrete example of both the clearer Windows API boundary and the remaining decompiler cleanup.
|
||||
|
||||
An independent REA pass with Ghidra 12.1.4 analyzed the byte-identical JP PE (SHA-256 `037b7d2be829048a1b305eae15e7f78be72329af80425cc32e2f5fcee0ba5231`) and resolved `FUN_004459b0` to `0x004459B0–0x00445B6A` (443 bytes). It corroborates the DirectDraw/DirectSound setup and also shows `ShowCursor(0)`; this remains static evidence, not a Windows 10/11 runtime test. REA Evidence ID: `ev_14075934dbe400153ac7280118a67be1a31059251467a81b81a237b5a2c9f99b`.
|
||||
|
||||
The local JP assets and renderer evidence establish substantial shared format support, not drop-in data identity:
|
||||
|
||||
- Retail, 1.01, and JP expose the same 63 detected maps, and the map viewer exports JP scenes.
|
||||
- Every shared JP/Western-retail map differs in the normalized exported scene payload. Similar top-line counts in sampled maps do not make the payloads identical.
|
||||
- `COMBAT.DAT` is byte-identical across JP and the listed Western builds, showing that some gameplay data is exactly shared.
|
||||
|
||||
See [family export differences](versions/family-export-differences.md) and [COMBAT.DAT evidence](combat-dat.md). A successful map export proves the reader can inspect the format; it does not prove that a rebuilt archive loads in the original JP game.
|
||||
|
||||
## Feasibility As A Modding Base
|
||||
|
||||
### Good fits
|
||||
|
||||
- **JP-targeted map and asset work:** `STATIC_JP` contains a substantial game data set, including `FIXED.DAT` and major graphics/resource archives, and the viewer supports JP map exports. Keep JP inputs and outputs together and test edits in the JP executable.
|
||||
- **Shared data:** files confirmed byte-identical, such as `COMBAT.DAT`, are candidates for shared tooling and cross-build tests. Matching filenames alone are not evidence of compatibility.
|
||||
- **Windows-native experiments:** JP is a better host than DOS retail when the goal is to investigate the Windows API path or build a mod that avoids DOSBox.
|
||||
- **Behavioral cross-reference:** JP can help explain shared game concepts, data structures, and services, but each conclusion should be checked against its intended target.
|
||||
|
||||
### Boundaries and risks
|
||||
|
||||
- **Not a Western-retail replacement:** JP map payloads differ, the local JP archive is named `JUSECODE.FLX`, and executable behavior is version-specific. Do not mix JP and Western fixed data or scripts without format and in-game validation.
|
||||
- **USECODE compatibility is not established:** the JP interpreter dispatches opcodes `0x00..0x79`; `0x71` and `0x72` take an invalid-token path. Its `0x5b`/`0x5c` handlers also differ from the classic DOS hidden-debugger line/current-entry behavior. This is concrete reason not to assume Western compiled USECODE is a safe JP replacement. See [JP USECODE dispatch analysis](usecode-jp-dispatch-analysis.md) and [JP debugger investigation](jp-remorse-hidden-debugger-investigation.md).
|
||||
- **Archive naming needs closure:** the JP executable contains an `eusecode.flx` string associated with its `-u` startup override, while the local static folder contains `JUSECODE.FLX`. The override helper does not establish the default JP archive lookup. Trace or runtime-test the default loader before renaming files or designing an override package. See [JP launch parameters](jp-remorse-cheats-and-launch-params.md).
|
||||
- **Palette caveat:** the viewer currently falls back to Western `GAMEPAL.PAL` when the JP copy is absent. That is a renderer workaround, not proof the JP game expects or accepts that palette. See [version differences](versions/version-differences.md).
|
||||
- **No known general plugin ABI:** native code changes need build-specific PE patching or a separately validated shim/injection mechanism. Existing NE patch definitions and relocation logic target the DOS executable and cannot be reused as-is.
|
||||
- **Japanese integration matters:** the executable imports DBCS/code-page and IME APIs. Preserve the intended text/input environment during tests and distinguish localization failures from game logic failures.
|
||||
|
||||
**Modding verdict:** JP is reasonable for JP-targeted data mods and controlled binary experiments, provided executable and assets are fingerprinted as one profile. It is not yet a turnkey mod platform: the archive rebuild/load loop, JP USECODE round-trip/compiler path, and runtime acceptance of edited resources remain unproven. For Western retail mod support, retain the DOS/NE target and its existing [patch/data feasibility path](remorse-patching-mod-system-feasibility.md).
|
||||
|
||||
## Windows 10/11 Native Launch Feasibility
|
||||
|
||||
### Why direct launch is plausible
|
||||
|
||||
JP is already a Win32 executable, not a DOS program dependent on `RUN286`, Phar Lap, NE segment loading, or DOS interrupts. A 32-bit Win32 application can generally run on x64 Windows through WoW64, which is Windows' x86 compatibility layer, not DOSBox. The recovered imports include windowing, registry, file, timing, joystick, DirectDraw, and DirectSound APIs. The Win9x TLS branch handles a Win9x-specific allocation constraint; no blanket Windows NT rejection has been established.
|
||||
|
||||
This makes unmodified direct launch the right first experiment. It does not prove all legacy API behavior works on current Windows, or that the original installer runs on x64 Windows. The prior analysis did not identify the required DirectX/runtime prerequisites or test Windows 95 in a VM.
|
||||
|
||||
### Compatibility work, ordered by risk
|
||||
|
||||
1. **Test the unmodified executable first** on clean Windows 10 and 11 x64 systems with a complete JP data set, expected working directory, and writable game directory. Test the game separately from its installer. Record startup, menu/game entry, display mode, input, audio, config/save paths, and shutdown.
|
||||
2. **Add a launch wrapper only for environment setup** if needed: establish the working directory, pass supported arguments, and capture diagnostics. Do not silently rewrite data paths or mix asset versions.
|
||||
3. **Use compatibility settings or shims only for a reproduced failure.** Investigate legacy DirectDraw fullscreen/palette behavior, DirectSound initialization, display changes/Alt-Tab, registry assumptions, and writes beneath protected install directories. These are risks inferred from the API surface, not observed Windows 10/11 failures.
|
||||
4. **Patch the PE only for a localized, repeatable failure.** Identify the exact version check or failing call first. The Win9x `GetVersion` branch alone is not a reason to patch version detection. Tie changes to an exact executable fingerprint and retest ordinary startup.
|
||||
|
||||
Current claim: **the PE architecture supports running without DOSBox, but the observed DirectX startup failure means an unmodified Windows 10/11 launch is not currently demonstrated.** If "native" means no DOSBox, the architecture is favorable. If it means no WoW64 or compatibility behavior on x64 Windows, that is not a realistic requirement for a 32-bit game.
|
||||
|
||||
### Observed DirectX startup failure and likely boundary
|
||||
|
||||
The user reports that startup fails with a DirectX error on a modern Windows system. The exact dialog text and the stage label shown by the game have not been captured, so this does not yet identify a root cause. Static analysis provides a concrete first boundary to test: `video_init_directdraw_and_directsound` at `004459b0` initializes DirectDraw before DirectSound. It calls `DirectDrawCreate`, sets cooperative level, requests 640x480, creates a palette and primary surface, applies the palette, and then calls DirectSound. The failure handler includes labels for each DirectDraw stage. In this initializer, the DirectSound result appears not to be fatal; that is a static inference, not a runtime finding.
|
||||
|
||||
Therefore, if the displayed error comes from this initializer, DirectDraw mode/surface setup is the leading hypothesis. The exact dialog stage label (or a wrapper log showing the last successful API operation) is the cheap check that could disconfirm it. Other startup failures remain possible until that evidence is recorded.
|
||||
|
||||
### Local dxwrapper test on Windows 11
|
||||
|
||||
The writable test copy at `K:\ghidra\Crusader_Decomp\JP\CRUSADER_JP_ISO` uses the local dxwrapper 1.8.8600.25 payload and its `Stub\ddraw.dll`; the C:\ analysis copy was not modified. The log identifies Windows 11 x64 build 26100 and confirms that `DirectDrawCreate` is redirected to D3D9.
|
||||
|
||||
- With Dd7to9 and a 1920x1440 override but D3D9Ex disabled, device creation failed with `D3DERR_DEVICELOST`; the next logged operation was `m_IDirectDrawSurfaceX::Lock2: d3d9 device not setup`. The Windows error dialog then reported a write access violation at `00468e13`, targeting `0b4e8000`. The lock failure is the best-supported cause chain; the dialog alone does not prove which game data structure supplied that pointer.
|
||||
- Enabling `D3d9to9Ex` allowed the D3D9Ex device to initialize, but a later write access violation still occurred. Enabling `DdrawEmulateLock` did not prevent the same game instruction (`00468e13`) from faulting; the dxwrapper log recorded exception `0xC0000005` with bad address `0B1B6F4C`.
|
||||
- An earlier native-resolution comparison restored the game's 640x480 output while retaining `D3d9to9Ex=1`, `DdrawEmulateLock=1`, and a 60 FPS test cap. Its log confirmed a 640x480 D3D device and the process was responsive at the last check; the previously failing gameplay transition still needs to be exercised. The user reports that a 30 FPS cap made the fan animation extremely slow and prevented the initial teleport sequence from initializing, so 30 FPS is not a viable setting for this build.
|
||||
- The separate 1920x1440 test profile created a 1920x1440 D3D target and measured a top-level window of about 1101x849 at `(549,194)` with caption and thick-frame style bits. The draggable border was observed, but the visible output was not confirmed as a true 3x on-screen scale.
|
||||
- Decoding `README.TXT` as CP932 confirms a Pentium 90 MHz minimum and a requirement for DirectX 2-compatible graphics/audio; it gives no original FPS target. The 30 FPS cap proved too restrictive. In a later 60-versus-120 FPS comparison, the user reported that 120 FPS made gameplay feel normal; this is not a measured simulation rate or a historically verified target. The text symptom and wrapper tests are documented below.
|
||||
|
||||
### Frame pacing: why the wrapper cap appears half-rate
|
||||
|
||||
The reported result is approximately `gameplay rate = LimitPerFrameFPS / 2`: a 60 cap feels like 30, while a 120 cap feels like the expected 60. These are user-observed settings and gameplay impressions, not measured render or simulation rates.
|
||||
|
||||
The live JP Ghidra trace identifies why an uncapped run can go too fast:
|
||||
|
||||
- `00446250` initializes the window and DirectDraw. Immediately before entering `kernel_process_manager_run_loop` at `0043efe0`, it clears both EAX and EDX at `004462f0`: the loop receives interval `0` and a null optional callback.
|
||||
- The loop calls `kernel_process_manager_update` every iteration. Its wait target is `start_tick + interval`; with interval `0`, the target is already reached, so the busy-wait exits immediately. The null callback is skipped. The loop records elapsed scheduler units in `DAT_00484368`, but does not globally pace iterations.
|
||||
- `FUN_00464390` calls `timeGetTime`, converts elapsed milliseconds into 10 ms units, and accumulates those units. This clock quantum feeds some timed/catch-up behavior; it is not a global frame limiter or evidence of a 100 FPS render rate.
|
||||
- `kernel_process_manager_update` uses separate 16 ms and 66 ms deadlines for timed process events. `SpriteProcess_Run` always performs at least one base pass per invocation; `DAT_00484368` selects up to four additional catch-up passes. Thus animation can advance once on every fast loop iteration even when the elapsed-tick value is zero.
|
||||
- The inspected primary-surface path at `00445418`/`00445498` checks surface loss, then locks and unlocks the DirectDraw surface. The core scheduler loop itself contains no DirectDraw flip or vertical-blank wait. The two `Sleep` references found elsewhere are a `Sleep(0)` yield and a DirectSound buffer-position polling delay, not a global frame limiter.
|
||||
|
||||
The uncapped-speed cause is therefore in the game loop: its actual startup path supplies no interval, so process updates run as fast as the update body and host allow. The 10 ms clock does not prevent per-invocation behavior from accelerating, and the sprite runner's base pass is per invocation. This explains why removing the wrapper cap can produce speeds well above the intended rate; the exact uncapped multiplier depends on loop throughput and is not fixed at 2x.
|
||||
|
||||
The separate `60 cap -> 30` and `120 cap -> 60` observation still indicates a 2:1 mismatch between the wrapper's counted pacing events and perceived game updates. The inspected primary-surface Lock/Unlock path is relevant to Dd7to9, but static Ghidra analysis cannot establish how many D3D9 presents dxwrapper counts per update. Treat two wrapper-counted events per game update as a hypothesis, not a proven call count.
|
||||
|
||||
The discriminating runtime check is to count `kernel_process_manager_update`/`SpriteProcess_Run` iterations and primary-surface Unlock/D3D9 Present events with no cap, then at caps of 60 and 120. This will measure the uncapped loop throughput and determine whether a 2:1 wrapper-event-to-update ratio explains the capped results. Keep 120 as an empirical compatibility setting, not a verified original target.
|
||||
|
||||
#### Practical pacing and patch options
|
||||
|
||||
- **Keep the 120 FPS wrapper cap as the low-risk workaround.** It is the only setting currently reported to make gameplay feel normal; it is not a measured 60 Hz simulation rate or a historically established target. Keep it in a JP-specific wrapper profile.
|
||||
- **Test wrapper VSync or frame limiting at a completed-frame boundary.** DDrawCompat or dgVoodoo2 could provide a useful comparison if their wait applies once per completed game frame. The inspected JP path uses primary-surface Lock/Unlock and the core loop has no explicit Flip/vblank wait, so a limiter attached to a lower-level operation could preserve or worsen the observed 2:1 mismatch. These wrapper options are untested for frame pacing.
|
||||
- **Consider a local pacing shim if wrapper settings cannot identify one frame per update.** A shim that throttles a mapped update boundary is a better conceptual fit than limiting every surface/presentation event, but the correct hook point has not yet been established. Instrument first; do not assume each Unlock or D3D9 Present equals one simulation update.
|
||||
- **Prototype a version-specific PE interval patch.** Startup clears `EAX` at `004462f2` immediately before calling the main loop, making its interval zero. The existing clock advances in 10 ms units, so interval `1` is approximately a 10 ms/100 Hz wait and interval `2` approximately 20 ms/50 Hz. These are coarse probes, not exact 60 FPS fixes; a stable 60 Hz target would need fractional/accumulator pacing or finer timing and careful interaction with existing elapsed-time catch-up.
|
||||
|
||||
No PE patch or custom shim has been applied. For an executable experiment, use a separate copy, record the exact JP PE hash, resolve the call-site RVA/file offset for that build, and preserve the untouched executable. Compare fan animation, the initial teleport sequence, gameplay timers, input response, and transitions with no cap, interval probes, and the 120-cap baseline before treating any result as a fix.
|
||||
|
||||
#### Original DOS comparison
|
||||
|
||||
The original DOS NE build has the same important pacing property: its main process loop is also entered with a zero tick interval. `Runtime_InitializeCommandLineAndRunLoop_1040_0079` calls `Kernel_RunTimedSchedulerLoop_11d0_31cf` with interval zero and a far callback at `1040:0073`. That callback stub calls `Spanker_CollectProfileAddresses_1218_0953`; the target only records profiler data when profiling flags are enabled, and does not wait for retrace or pace frames.
|
||||
|
||||
`Kernel_RunTimedSchedulerLoop` snapshots the `SystemTimerProcess` counter, calls `Kernel_RunProcessSchedulerIteration_11d0_0255`, invokes the optional callback, then waits until `current_tick >= start_tick + interval`. With the startup interval at zero, that condition is already satisfied on every pass. It records the elapsed timer delta in `1478:3a00/3a02`, but the delta is not a global loop throttle. `Kernel_Init_11d0_000c` sets up the timer-interrupt path and creates/registers the BIOS and system timer processes; `SystemTimerProcess_Increment_11c0_00f8` increments the system timer's 32-bit counter.
|
||||
|
||||
The DOS `SpriteProcess_Run_1138_04e2` also performs one base animation pass on every process-manager iteration and uses elapsed timer ticks to select additional catch-up passes. This closely parallels the JP runner at `00461b50`. The key difference is the clock plumbing: DOS reads an interrupt-maintained `SystemTimerProcess` counter and dispatches DOS timer events, while JP polls WinMM `timeGetTime()` and quantizes elapsed time into 10 ms units. Neither startup path provides a nonzero global frame interval, so both can be host-throughput-sensitive; the DOS timer supports elapsed-time events/catch-up but does not, by itself, pace the main loop. This is static analysis, not a new DOS runtime test.
|
||||
|
||||
### JP text corruption and PE patch feasibility
|
||||
|
||||
The user-provided screenshot shows the game scene and message box rendered normally while the subtitle/menu glyphs appear as fragmented, multicolored pixels. This localizes the visible symptom to text, but does not by itself distinguish bad byte decoding from glyph rasterization or palette conversion.
|
||||
|
||||
On the test machine, `Get-WinSystemLocale` returned `it-IT`, the active ANSI code page (ACP) is 1252, and the OEM code page is 850. The Japanese executable is a 32-bit x86 PE with SHA-256 `037b7d2be829048a1b305eae15e7f78be72329af80425cc32e2f5fcee0ba5231`. These are separate facts: the locale values describe the Windows host, while the following API behavior comes from static analysis of the executable.
|
||||
|
||||
REA/Ghidra 12.1.4 found imports for `CreateFontA`, `GetTextMetricsA`, `TextOutA`, `IsDBCSLeadByte`, and `GetCPInfo`. The font initializer at `0x004100b4` creates a compatible DC and a 32x32 8-bit bitmap, selects a 256-entry palette whose red component is an intensity ramp, and creates a font with charset `0x80` (`SHIFTJIS_CHARSET`) before calling `GetTextMetricsA`. The character-width helper at `0x0040fae8` calls `GetCharWidthA` when it has an HDC. `TextOutA` and `GetCPInfo` are present in the import table, but REA found no resolved direct code callers for them; focused import/procedure searches also found no `GetACP`, `MultiByteToWideChar`, `WideCharToMultiByte`, or explicit locale setter. Dynamic or unresolved indirect calls are not ruled out. Evidence: `ev_de7bd0221ca25ca3a5a8aa606d4b4570686e040fcdccfdad1a063d5f8bcb0b1d`, `ev_9e0169945fe29f6e1a23f0c5d3621722adeb7c881d867dcfe4913dd91088f47f`, and `ev_f9e245025ef4d9c8dd3077053e91028c173b653feb3c5f17fbc73abb8bce8686`.
|
||||
|
||||
`IsDBCSLeadByte` is called at seven resolved sites across six functions: `0x00412d10` copies DBCS text, `0x00413188` walks and wraps text while measuring glyph widths, `0x00428ac8` measures strings, `0x00428be4` and `0x00428d40` combine byte pairs before dispatching them to a glyph/layout helper, and `0x004640b8` scans a tokenized string. For example, `0x00428ac8` combines a lead byte and its following byte before asking a font-like object for a width; `0x00413188` uses the same lead-byte test before calling the `GetCharWidthA` helper. Microsoft documents that `IsDBCSLeadByte` tests the system default ANSI code page (`CP_ACP`), while its `Ex` variant is needed for a specified code page. With ACP 1252, the Japanese CP932 lead-byte ranges are not recognized as DBCS leads. The executable therefore has a concrete dependency on running under a Japanese-compatible ACP, despite selecting a Shift-JIS font charset. Evidence: `ev_b12b18650a53d90c9efb8583e65b7e9939594730dbdb290130f4bbccc080c0f6`, `ev_8cc6c851948c5b1f081ef83f939319c7a5af0f1d06be7ce0bcfc6eb7007f2bf0`, `ev_d8c64f4077ccdbca248a7166bb4dbf5b3612fa979f9e58933996e236db1a06f8`, `ev_dcc900b2086b1da3c5de5eaf7431133f3b1c8a40f739b8d3cf0e24cf480544a6`, `ev_54e5a97e481666d25e6829f052231996050c77fc07566dfba7990ae7222147d9`, and `ev_d0e9fabd41de9d73a68c42250286f5e1d652928e035ffd63b7bbf963c7776ec5`.
|
||||
|
||||
The locale mismatch is a strong explanation for DBCS parsing and measurement errors, but it does not alone explain the rainbow pixel colors. The font path's 8-bit bitmap and custom palette leave a separate GDI/DirectDraw conversion hypothesis open. In the current writable test profile, `DdrawEmulateSurface=1` produced no reported visual improvement and was restored to `0`. Enabling both `DdrawReadFromGDI=1` and `DdrawWriteToGDI=1` produced a completely black game screen; the wrapper log recorded repeated invalid rectangles `{1283,643,640,480}`, then exception `0xC0000005` at address `0x00000000`. Both options were restored to `0`. The current profile keeps `LimitPerFrameFPS=120`; no game bytes or system locale settings have been changed.
|
||||
|
||||
**Executable-hack assessment:** a PE patch is technically possible, but a reliable fix is not yet established. A first, bounded patch could replace the seven `IsDBCSLeadByte` call sites with a fixed CP932 lead-byte predicate (`0x81-0x9f` or `0xe0-0xfc`). That would repair DBCS byte-boundary handling in copying, wrapping, measuring, glyph dispatch, and token scanning, but it would not change the ACP behavior of ANSI GDI calls such as `GetCharWidthA`, nor prove that the 8-bit palette is converted correctly. A complete executable fix may need a CP932-aware shim or conversion to Unicode GDI calls, plus a separate correction to the glyph-bitmap/palette path if the rainbow artifacts remain. This requires tracing the indirect glyph renderer and carefully modifying a version-fingerprinted writable PE; it is substantially more invasive than a one-byte patch. No executable patch has been applied.
|
||||
|
||||
The lowest-risk next discriminator is still a process-local Japanese ACP run, which the user deferred for now; no system-wide locale change is recommended. If CP932 fixes the text, prototype the narrow DBCS patch on a separate writable copy and verify subtitles, confirmation menus, ASCII text, and input. If the rainbow pixels persist under CP932, investigate the custom 8-bit glyph palette and indirect drawing helper before attempting a PE rendering patch. Do not reuse the Western DOS/NE patcher for this PE.
|
||||
|
||||
### English-language content from original game files
|
||||
|
||||
A read-only comparison of Western `STATIC` resources with the writable JP test installation found three likely presentation/data candidates are already byte-identical:
|
||||
|
||||
- `FONTS.FLX` (198,862 bytes)
|
||||
- `GUMPS.FLX` (501,404 bytes)
|
||||
- `FIXED.DAT` (3,735,392 bytes)
|
||||
|
||||
Their SHA-256 hashes match between the two compared installs. Replacing these copies with the Western versions would not introduce English text or change the font data. The Western workspace also has a 25,897-byte `FONTS.DAT` that is absent from the JP `STATIC` directory, but its role and JP loader path are not established; its presence alone is not evidence that copying it would help. The identical `FONTS.FLX` also means the observed glyph corruption is not explained by a different Japanese font archive in these installs; it does not rule out the ACP or bitmap/palette issues described above.
|
||||
|
||||
Movie subtitles are a more direct candidate. The JP `FLICS` directory contains `.TXT` sidecars paired with many `.AVI` files. In the sampled `01A.TXT`, each `@frame` marker is followed by an English line and then a Japanese line. The local ScummVM reference documents `.txt` and `.iff` subtitle sidecars for Crusader movies. This supports a low-risk, one-movie experiment: on a separate writable copy, preserve the frame markers and English lines while removing the Japanese lines, then check whether the JP game's movie player displays the English-only sidecar. This is a candidate, not a verified JP runtime behavior; it affects movie subtitles only, not menus or in-game dialogue.
|
||||
|
||||
The script route is possible but substantially less certain. Western `STATIC\\EUSECODE.FLX` is 556,613 bytes; JP `USECODE\\JUSECODE.FLX` is 554,522 bytes. A preliminary header/directory check found 3,074 entries in each and all directory rows pointed within their respective files. That is only coarse structural evidence: the local format extractor is validated against Western `EUSECODE.FLX`, not the JP archive, and matching entry counts do not establish compatible class records, event bodies, or opcodes. The JP interpreter has documented differences, and its `-u`/default archive naming path remains unresolved. Do not replace `JUSECODE.FLX` directly with `EUSECODE.FLX`; first establish the JP loader path and validate compatibility through an isolated override on a disposable copy. See [JP USECODE dispatch analysis](usecode-jp-dispatch-analysis.md) and [JP launch parameters](jp-remorse-cheats-and-launch-params.md).
|
||||
|
||||
The source of specific menu or confirmation strings, including the observed exit text, was not established by this resource comparison. Trace that string to its executable, script, or data source before choosing an English replacement; do not infer it from the movie subtitle mechanism.
|
||||
|
||||
### Established wrapper options
|
||||
|
||||
The options below are local compatibility layers, not proof that this particular game works with them. Test with a writable copy of the JP installation, one wrapper at a time, and preserve the original executable and data. The game requests 640x480 and uses a palette; the current Dd7to9 scaling experiment is a separate profile from the original-mode startup test.
|
||||
|
||||
| Wrapper | Role | Fit for this failure | Caveat |
|
||||
|---|---|---|---|
|
||||
| [DDrawCompat](https://github.com/narzoul/DDrawCompat) | Local `ddraw.dll` compatibility implementation for legacy DirectDraw | **First test.** It is the least transformative first probe: it can mediate DirectDraw mode, surface, and fullscreen behavior while keeping the game's DirectDraw API path. Its per-directory configuration and logs are useful for recording the failing stage. | It is a DirectDraw layer, not an automatic API rewrite. If the failure requires a different rendering backend rather than compatibility fixes, this may not be enough. |
|
||||
| [dxwrapper](https://github.com/elishacloud/dxwrapper), feature [Dd7to9](https://github.com/elishacloud/dxwrapper/wiki/DirectDraw-to-Direct3D9-Conversion) | Local proxy wrapper; Dd7to9 translates DirectDraw 1-7 calls to Direct3D 9 | **Tested locally; D3D9Ex creates the device and the bordered-window style is observed, but lock emulation did not prevent a later game access violation.** | The project notes that most DirectDraw APIs are implemented, not all. DirectSound handling is separate from Dd7to9; do not assume the graphics conversion fixes audio. Mixed GDI/DirectDraw, surface locks, and palette behavior may need per-game configuration. |
|
||||
| [dgVoodoo2](https://dege.freeweb.hu/dgVoodoo2/ReadmeDirectX/) | Local DirectDraw/Direct3D emulation with configurable virtual devices and output | **Third comparison.** It supports classic resolutions including 640x480 and can emulate old DirectDraw behavior through a different implementation. | Its documentation warns that some old GDI/DirectDraw interactions are incomplete and that forced-resolution upscaling is a poor first setting for 8-bit palettized DirectDraw content. Use its local game-folder setup; do not copy wrapper DLLs into Windows system directories. |
|
||||
|
||||
Suggested test sequence:
|
||||
|
||||
1. Record the exact DirectX dialog text, Windows version, executable hash, and whether the error names a DirectDraw stage. Start with no wrapper on an untouched test copy.
|
||||
2. Add only DDrawCompat beside the copied executable, enable its normal logging, and retry without changing the requested 640x480 mode. Save the log and note whether the dialog changes or startup advances.
|
||||
3. Remove/disable that wrapper before trying dxwrapper with only `Dd7to9` enabled; preserve its logs. If DirectDraw initializes but sound fails later, investigate the separate DirectSound path rather than changing the DDraw configuration blindly.
|
||||
4. Repeat as an independent dgVoodoo2 test. Do not combine wrappers, install the bundled DirectX 2/3 setup payloads on modern Windows, or change system DLLs/registry settings as part of this comparison.
|
||||
|
||||
DDrawCompat remains an untested comparison because it preserves the DirectDraw API path. Dd7to9 is the only wrapper tested so far; its current test reaches device creation and requests a bordered window, but the game transition and text rendering remain open. dgVoodoo2 is also untested. Do not treat any wrapper as a completed compatibility solution until gameplay, text, input, audio, and shutdown have been checked.
|
||||
|
||||
## Modding And Rebuild Practicality
|
||||
|
||||
### Modding relative to Western DOS retail
|
||||
|
||||
JP is a better target for understanding and patching Windows-facing behavior: it has a flat 32-bit PE image, Windows imports, and linear addresses, avoiding much of the DOS build's segmented pointer, far-call, and NE-fixup friction. A tightly scoped PE patch or local proxy is consequently more approachable than creating a new DOS NE segment. This does not give JP a supported plugin ABI, and data/archive rebuild-and-load remains unproven.
|
||||
|
||||
Western DOS retail has the opposite advantage: the repository already documents concrete `STATIC\\FIXED.DAT` and `-u` replacement paths plus a cautious NE patch workflow. Those mechanisms and patch definitions are build-specific and must not be carried over to JP. JP has its own `JUSECODE.FLX`/override uncertainty, differing map payloads and USECODE behavior, so treat its data and executable as a separate versioned mod target. For narrow data/script changes, the DOS path currently has better-established evidence; for Windows API experiments and a future native PE patch, JP has the simpler executable model.
|
||||
|
||||
### Can the JP executable be rebuilt?
|
||||
|
||||
The extracted CD tree at `C:\\RE\\CRUSADER_JP_ISO` contains the compiled executable, setup files, and game resources. A targeted search for common C/C++/assembly sources and native project/make files found none there. This only establishes that the supplied CD tree does not expose those build inputs; it cannot rule out separate archival source elsewhere.
|
||||
|
||||
Decompilation is not a substitute for that missing source. Even the much-studied Western executable's exports contain unresolved calling conventions, undefined-width values, synthetic temporaries, segmented-pointer reconstruction, and provisional data layouts. The JP PE removes the NE/far-call burden but still needs type and ABI recovery, correct resource and startup behavior, and a complete replacement for the original build and runtime environment. No complete JP function-equivalence map, recovered JP source tree, compiler/toolchain, or link/resource recipe is established here.
|
||||
|
||||
The realistic options are distinct:
|
||||
|
||||
- **Reproduce the original bytes:** not supported by current evidence and unlikely without original source, exact toolchain, build scripts, and assets in their original build form. Decompiled C cannot establish byte identity.
|
||||
- **Build a behaviorally similar native game:** possible in principle, but it is a large source-port/reimplementation effort. The existing [Windows rebuild roadmap](remorse-windows-rebuild-roadmap.md) describes an incomplete host implementation based primarily on Western DOS exports; it is not a JP rebuild pipeline or a near-term way to regenerate `CRUSADER.EXE`.
|
||||
- **Modify the existing JP game:** the pragmatic route for bounded changes. Prefer version-fingerprinted PE edits, established local wrappers, or validated JP-specific data replacement. Test each against a separate copy and preserve a clean baseline.
|
||||
|
||||
**Rebuild verdict:** a very similar executable is a research project, not a build step available from the CD or current decompilation. A localized mod/compatibility shim has a much better cost-to-result ratio; pursue a source port only if the goal justifies implementing and validating the whole runtime over time.
|
||||
|
||||
## Decompilation And Reverse-Engineering Differences
|
||||
|
||||
| Surface | Japanese Windows build | Western retail build |
|
||||
|---|---|---|
|
||||
| Executable model | Flat Win32 PE image, reported at `0x00400000` | DOS MZ containing an NE image, with Phar Lap protected-mode loading |
|
||||
| Addressing | Linear 32-bit addresses and PE imports/relocations | Segment:offset addresses, far calls, NE fixups, extender/runtime services |
|
||||
| Platform boundary | Windows windowing, registry, DirectDraw/DirectSound, WinMM | DOS/extender, segmented memory, hardware/service calls, DOS-oriented paths |
|
||||
| Decompiler friction | Win32 API behavior, flat pointers, Windows structures; still has ABI/type recovery work | 16-bit widths, near/far pointer provenance, segmented calls, loader fixups, uncertain conventions |
|
||||
| Reuse value | Native Windows implementation and semantic parallels | Canonical target for current Western exports, ABI work, and NE patches |
|
||||
|
||||
These are distinct implementations, not two load formats for an interchangeable binary. JP addresses do not map to NE addresses by a constant offset. PE and NE relocations, pointer widths, calling conventions, and data layouts require independent recovery. JP decompilation is not a source drop-in for `exports/src_remorse`, and the Western NE patcher cannot patch the JP PE.
|
||||
|
||||
There is meaningful overlap at the behavior and data level: JP retains USECODE execution, familiar launch/cheat concepts, and shared assets such as `COMBAT.DAT`. But the JP debugger and opcode analyses show implementation differences. Use function comparisons to test specific hypotheses; do not infer source identity from matching names, strings, or file formats.
|
||||
|
||||
No complete function-by-function JP-versus-Western diff is claimed. Existing evidence is strongest for executable format, Windows integration, selected USECODE behavior, and resource/export differences. A broader code-equivalence map needs a dedicated comparison pass.
|
||||
|
||||
## Recommended Next Work
|
||||
|
||||
1. **Runtime gate:** launch the unmodified JP game on Windows 10 and 11 x64 from a writable copy; establish startup, menu/game entry, resolution, input, audio, config/save paths, and shutdown.
|
||||
2. **Loader gate:** trace/test JP lookup for `FIXED.DAT`, `JUSECODE.FLX`, palette, and core assets. Resolve the `JUSECODE.FLX` versus `eusecode.flx` discrepancy before recommending overrides.
|
||||
3. **Data-mod gate:** make one reversible JP map or asset edit, rebuild it, and prove the original executable loads it. Renderer export success is not this gate.
|
||||
4. **USECODE gate:** establish a JP-compatible round-trip/compiler corpus and compare supported opcodes, intrinsics, class/event tables, and archive conventions before porting Western scripts.
|
||||
5. **Patch gate:** fingerprint the JP PE and prototype one low-risk reversible patch only after launch behavior is known. Define PE-specific RVA/file-offset and relocation handling; do not reuse NE patch records.
|
||||
6. **Cross-build gate:** maintain separate JP and Western retail test profiles, promoting only verified shared formats or behavior into common tooling.
|
||||
7. **English subtitle probe:** on a separate writable copy, create an English-only version of one paired JP movie subtitle file while preserving `@frame` markers, then verify that the JP movie player displays it. Keep the original sidecar unchanged and record the tested movie and result.
|
||||
|
||||
## Evidence Boundary
|
||||
|
||||
This assessment combines the existing live-Ghidra JP Win9x, launch-parameter, debugger, and USECODE investigations with local version/resource comparisons, a targeted scan of the supplied CD tree, direct inspection of JP `video_init_directdraw_and_directsound` at `004459b0`, the frame-pacing trace at `0043efe0`/`00464390`/`00461b50`, and the bounded Windows 11 dxwrapper tests above. The English-resource comparison used Western `STATIC` files and the writable K: JP test copy; it confirmed matching hashes for `FONTS.FLX`, `GUMPS.FLX`, and `FIXED.DAT`, sampled the bilingual JP `FLICS/01A.TXT`, and performed only a coarse USECODE directory-bounds check. No game resources were edited and no English-only subtitle or USECODE override was runtime-tested. The 1920x1440 run still faulted at `00468e13` with lock emulation enabled; the native-resolution comparison is awaiting the same gameplay transition. No runtime counter comparison of scheduler updates against D3D9 presents has been performed, so the wrapper-side 2:1 explanation remains an evidence-backed hypothesis. This note does not claim a complete Windows 10/11 runtime pass, successful JP asset rebuild-and-load, or complete function-level equivalence. Those remain explicit validation gates.
|
||||
120
docs/observer-npc-analysis.md
Normal file
120
docs/observer-npc-analysis.md
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
# No Remorse Observer NPC Investigation
|
||||
|
||||
## Executive Read
|
||||
|
||||
No Remorse has a real NPC definition named `Observer`: DTABLE row `6` selects actor shape `0x033c` (`828`). The strongest evidence does not support a unique Observer-specific AI script. Instead, row 6 configures the normal native NPC activity system with a pacing activity and two `Attack5` defaults. The resulting behavior is a mobile actor that can transition into the shared attack process when its visibility/alert path fires.
|
||||
|
||||
The unusual part is the mismatch between that ordinary combat-capable runtime profile and the sparse presentation/content evidence: the Observer class has only one short event body, its current renderer preview deliberately avoids lower frames because they are blank or broken, and map records that resolve to Observer are often paired controller records rather than unambiguous actor spawns. "Unused" is therefore a plausible description of its encounter role, not a proven description of its executable/data status.
|
||||
|
||||
## Identity And Data
|
||||
|
||||
No Remorse `STATIC/DTABLE.FLX` contains row `6`:
|
||||
|
||||
| Field | Value | Meaning / evidence |
|
||||
|---|---:|---|
|
||||
| Name | `Observer` | DTABLE name object 2, row 6 |
|
||||
| NPC row | `6` | Index used by the DTABLE-backed NPC creation path |
|
||||
| Shape | `0x033c` (`828`) | Actor shape stored at NPCDat offset `0x3e` |
|
||||
| HP range | `35-45` | Minimum/maximum HP at row offsets `0x00/0x02` |
|
||||
| Weapon selectors | `1 / 2` | Words at offsets `0x18/0x1a`; these are data selectors, not proof of two simultaneously equipped weapons |
|
||||
| Default activities | `3 / 5 / 5` | Words at offsets `0x1e`, `0x40`, and `0x42` |
|
||||
|
||||
The 142-byte NPCDat row and parallel 32-byte name row are loaded from FLEX objects 0 and 2. The layout is corroborated by the `NPCDat` reader and the local [NPC spawner investigation](map_renderer/npc-spawners.md). Native `NPC_SetDataFromDTable` (`10e8:0152`) reads a `0x8e`-byte row into a local buffer, equips a weapon using the row's `+0x18` selector when nonzero, and writes the three activity fields into the actor's `0x06/0x08/0x0a` activity slots.
|
||||
|
||||
Shape `0x033c` is an NPC because it is the shape in DTABLE row 6 and is referenced as Observer's actor shape by the spawn data. The map renderer's catalog currently labels it `Helper Geometry` and notes that its display name was derived from NPC self-shape comparison in USECODE; that catalog label is not evidence that the actor is scenery.
|
||||
|
||||
## Native AI
|
||||
|
||||
### Configured Activities
|
||||
|
||||
The activity values are named in the live No Remorse `CRUSADER.EXE` Ghidra database:
|
||||
|
||||
| DTABLE field | Value | Native activity | Effect when selected |
|
||||
|---|---:|---|---|
|
||||
| `0x06` / default activity 0 | `3` | `Pace` | Creates `PaceProcess` (`1100:0693`, run at `1100:0708`) |
|
||||
| `0x08` / default activity 1 | `5` | `Attack5` | Creates the shared `AttackProcess` |
|
||||
| `0x0a` / default activity 2 | `5` | `Attack5` | Same activity family; used by other callers that select activity field `0x0a` |
|
||||
|
||||
`NPC_StartNextNPCActivityBehaviorProcess` (`10e8:2cfa`) resolves special activity selectors for fields `0x06`, `0x08`, and `0x0a`, then applies common gates: the NPC must be alive, not the controlled actor, not suppressed by the relevant actor flag, and inside a fast area before an activity process is created. It records current/previous activity and avoids restarting an activity that is already current. `NPC_ResetForEgg` (`10d8:04b1`) is a confirmed creation path that loads/sets the three activity fields and starts the field-`0x06` activity. Exact authored `0x04d0` spawner pairs can also supply activity values through their paired records, so the DTABLE row is the baseline profile, not a guarantee that every map instance uses all three unmodified.
|
||||
|
||||
### Observer's Likely Runtime Loop
|
||||
|
||||
For an Observer whose initial field-`0x06` activity remains DTABLE value `3`, the expected loop is:
|
||||
|
||||
1. Start `PaceProcess`, rather than `GuardProcess` or `LoiterProcess`.
|
||||
2. Before pacing, `PaceProcess::Run` calls `NPC_StartBehaviorInField0x8IfCanSeeControlledNPC` (`1100:026e`). That helper checks that the actor is entirely on screen, field `0x08` is nonzero, the current activity is not already the field-`0x08` activity, and the controlled NPC is visible.
|
||||
3. If those checks pass, field `0x08` is selected. For Observer, that is `Attack5`, which creates the common attack process.
|
||||
4. Otherwise, when not busy, `PaceProcess::Run` tries a walk animation in the actor's current direction. A successful walk clears its local failed-step count and waits for the animation. After a failed walk, it performs a stand/turn-around response and waits 60 ticks; after more than one failed step it requests another activity.
|
||||
5. That blocked-movement fallback requests `Attack5` for ordinary shapes. The explicit surrender exceptions in the native branch are shapes `0x2f5`, `0x2f7`, `0x2f6`, `0x344`, and `0x597`; Observer shape `0x033c` is not in that list.
|
||||
|
||||
This makes Observer a pacing/roaming combat actor, not an inert lookout. However, this code does not prove that every Observer placement immediately sees or attacks the player: visibility, fast-area activation, busy state, and map-specific activity overrides all gate the transition.
|
||||
|
||||
`Attack5` is an activity/process selector, not a literal weapon or a complete behavior description. The resulting `AttackProcess` uses the actor's combat-tactic state and `COMBAT.DAT` machinery. The confirmed egg reset path initializes tactic number `0`; [the COMBAT.DAT analysis](combat-dat.md) records the shipped tactic 0 name `Dumb` and an unresolved compatibility detail around how tactic 0 is interpreted. Do not infer a precise firing pattern for every Observer spawn from the activity value alone. At difficulty level `4`, the native selector can randomly remap an `Attack5` request to `AttackA` (`10e8:2cfa`); this is shared NPC behavior, not an Observer-specific rule.
|
||||
|
||||
### No Bespoke Observer AI Script
|
||||
|
||||
The extracted `OBSERVER` class (`0x033c`) has no bodies for `setActivity`, `hit`, `gotHit`, `schedule`, `enterFastArea`, or the other common events. Its only non-empty common event is slot `0x0e`, `calledFromAnim`:
|
||||
|
||||
```text
|
||||
set_info(0x021A, *(arg_06));
|
||||
process_exclude();
|
||||
return;
|
||||
```
|
||||
|
||||
That is a short state/process callback, not a custom movement or combat routine. Compare the neighboring `GUARD` and `SCIENTIS` slot-`0x0e` bodies: both perform the same setup and additionally spawn `NPCDEATH.slot_20`. Observer's body does not. This is a real script difference, but it only proves that Observer omits that scripted callback; it does not prove that the engine has no native death handling.
|
||||
|
||||
The distinction between actor identity and controller identity matters here. Shape `0x04d0` uses the `MONSTER` class as a spawner/controller. Its `enterFastArea` body checks frame 0 and `mapNum & 8`, then launches `MONSTER.equip`; paired `ITEM.slot_2D` logic handles actor creation. Those `MONSTER` event bodies are not Observer's AI. See [the paired-spawner investigation](map_1_spawners_targeted_investigation.md) for the unresolved question of which member of some frame-0/frame-1 pairs supplies the final spawned NPC row.
|
||||
|
||||
## Comparison With Similar NPCs
|
||||
|
||||
All values below are from the No Remorse DTABLE rows; activity names are the native enum values.
|
||||
|
||||
| NPC row | Shape | HP | Weapon selectors `+0x18/+0x1a` | Activities `0x06/0x08/0x0a` | Main contrast |
|
||||
|---|---:|---:|---:|---|---|
|
||||
| Observer `6` | `0x033c` | `35-45` | `1 / 2` | `Pace / Attack5 / Attack5` | Baseline under investigation |
|
||||
| GUARD `4` | `0x02fd` | `20-35` | `1 / 2` | `Pace / Attack5 / Attack5` | Same activity profile and weapon selectors, lower HP; its animation callback adds `NPCDEATH` |
|
||||
| Thermatron `10` | `0x0338` | `250-250` | `7 / 5` | `Pace / Attack5 / Attack5` | Same activity profile, much higher HP and different weapon selectors |
|
||||
| RoamingSusan `11` | `0x02cb` | `35-45` | `1 / 2` | `Loiter / Attack5 / Attack5` | Same HP and weapon selectors; starts in `Loiter`, not `Pace` |
|
||||
| Scientist `7` | `0x0344` | `5-12` | `0 / 0` | `Loiter / Attack5 / Attack5` | Unarmed selectors and low HP; `PaceProcess` specifically treats this shape as a surrender exception after repeated blocked steps |
|
||||
| Vetron `19` | `0x04e6` | `425-625` | `9 / 10` | `Pace / Attack5 / AttackA` | Same initial activity family, much higher HP and a distinct third default |
|
||||
|
||||
The most useful comparison is not simply Observer versus the NPC named GUARD. Observer shares GUARD's and Thermatron's default activity tuple, but the activity value `3` starts `PaceProcess`; the named `GuardProcess` is selected by the separate activity value `8`. Observer therefore does not inherit the named Guard's stationary guard/idle loop just because the DTABLE contains an armed humanoid row or the character is called Observer.
|
||||
|
||||
At the process level, `GuardProcess::Run` (`1100:0a0e`) attacks when the player is visible and otherwise sleeps or chooses random idle animations. `LoiterProcess::Run` (`1100:0bfa`) plays idle animations or pathfinds to randomized points near its anchor. Observer's activity `3` chooses the distinct `PaceProcess`, which attempts a directional walk and can transition to field `0x08`'s attack behavior. These process differences are stronger evidence than visual resemblance or class names.
|
||||
|
||||
## Maps And Spawn Evidence
|
||||
|
||||
The current No Remorse map-export audit reports DTABLE row 6 on maps `6, 7, 9, 16, 23, 42, 47, 55, 56, 62, 69, 116, 170, 248`. The No Remorse demo audit reports no Observer map occurrence. This establishes map-data presence in retail exports, not that every listed map is an intended encounter or that every preview resolves to a live Observer. The audit is maintained in the [map-viewer NPC spawn audit](../../crusader_map_viewer/map_renderer/docs/npc-spawn-audit.md).
|
||||
|
||||
Examples that show why the distinction matters:
|
||||
|
||||
- Remorse map 69 has a frame-0 family-7 `0x024f` monster egg with `npcNum = 6`, which resolves directly to Observer in the current preview pipeline.
|
||||
- On map 1, a frame-0 `0x04d0` record with `npcNum = 6` is paired with a frame-1 record resolving to RoamingSusan, ChemSuitGuy, or GUARD. The `MONSTER` controller can be dormant or paired; those records are not equivalent proof of an Observer actor.
|
||||
- On map 248, some frame-1 `0x04d0` records resolve to Observer while their paired frame-0 controller records contain `npcNum` values such as `100` or `134`, which do not resolve in the current Remorse DTABLE preview. These are stronger Observer-spawn candidates, but the paired creation arguments still need a call-site-level close.
|
||||
|
||||
These examples and the broader pair scan are detailed in [the map-1 spawner investigation](map_1_spawners_targeted_investigation.md). The evidence supports calling Observer a shipped, spawnable NPC definition with map placements. It does not establish that maps 6, 7, or 248 are all "unused," nor does the label `Observer` by itself establish a surveillance-specific combat role.
|
||||
|
||||
## Sprite And Presentation State
|
||||
|
||||
The No Remorse reference data identifies shape `0x033c` as an NPC-derived shape, but the current map renderer has only indexed Observer sprite entries at frames `7` (`121 x 98`) and `15` (`48 x 35`). Its preview code explicitly chooses frame `0x0f` for Observer because lower-numbered preview frames are blank or broken. That is concrete evidence of incomplete usable preview art in the current pipeline and is consistent with the reported missing orientations.
|
||||
|
||||
The atlas is a curated set of scene/preview sprites, not a complete inventory of every frame in `SHAPES.FLX`. The code's `frames.length > 15` test establishes that frame 15 exists in the loaded shape, but the two indexed atlas entries do not establish that the full shape contains only two frames. Exact missing facings and animation sets remain unverified; do not treat frame numbers 7 and 15 as a complete orientation table.
|
||||
|
||||
## Open Questions And Next Checks
|
||||
|
||||
1. Enumerate shape `0x033c` directly from the full No Remorse `SHAPES.FLX`; classify blank frames, animation groups, and facing coverage instead of relying on the preview atlas.
|
||||
2. Trace every map-69 `0x024f` Observer egg through its trigger, difficulty gate, and field-`0x06` activity startup in the retail executable.
|
||||
3. Close the `0x04d0` paired-spawner call argument ownership so frame-0/frame-1 pairs can be classified as actual Observer spawns or controller-only records.
|
||||
4. Recover the initial activity and combat-tactic values for actors created through the `0x04d0` path, including whether map/partner fields override DTABLE row 6.
|
||||
5. Test the Observer `calledFromAnim` path in a live No Remorse session and determine whether native death handling replaces the absent `NPCDEATH.slot_20` callback.
|
||||
6. Compare retail `CRUSADER.EXE` handling of tactic 0 against shipped `COMBAT.DAT` entry `Dumb` to establish Observer's concrete weapon/fire loop on the egg-spawn path.
|
||||
7. Audit the listed map IDs against mission routing and editor-only/unreachable status before labeling any placement definitively unused.
|
||||
|
||||
## Evidence Pointers
|
||||
|
||||
- No Remorse DTABLE and NPC row layout: [NPC spawner data](map_renderer/npc-spawners.md), `STATIC/DTABLE.FLX`, and ScummVM's [NPCDat loader](https://raw.githubusercontent.com/scummvm/scummvm/master/engines/ultima/ultima8/world/actors/npc_dat.cpp).
|
||||
- Observer event body and class slots: `USECODE/EUSECODE_extracted/pseudocode/OBSERVER/slot_0E_calledFromAnim.txt` and `USECODE/EUSECODE_extracted/class_event_index.tsv`.
|
||||
- Native activity selection: `NPC_SetDataFromDTable` (`10e8:0152`), `NPC_StartNextNPCActivityBehaviorProcess` (`10e8:2cfa`), `NPC_StartBehaviorInField0x8IfCanSeeControlledNPC` (`1100:026e`), `PaceProcess::Run` (`1100:0708`), `GuardProcess::Run` (`1100:0a0e`), and `LoiterProcess::Run` (`1100:0bfa`) in live No Remorse `CRUSADER.EXE`.
|
||||
- Process family ownership: [NPC action process layout](npc-action-process-class-layout.md).
|
||||
- `0x04d0` controller and map pair evidence: [NPC spawners](map_renderer/npc-spawners.md) and [targeted map investigation](map_1_spawners_targeted_investigation.md).
|
||||
- Combat tactic data and tactic-0 caveat: [COMBAT.DAT](combat-dat.md).
|
||||
598
docs/spice86/README.md
Normal file
598
docs/spice86/README.md
Normal file
|
|
@ -0,0 +1,598 @@
|
|||
# Spice86 - A PC emulator for real mode reverse engineering
|
||||
|
||||

|
||||

|
||||

|
||||
[](https://github.com/OpenRakis/Spice86/actions/workflows/prerelease.yml)
|
||||
[](https://www.nuget.org/packages/Spice86)
|
||||

|
||||
[](https://www.nuget.org/packages/Spice86)
|
||||
|
||||
Spice86 is a tool to execute, reverse engineer and rewrite real mode DOS programs for which source code is not available.
|
||||
|
||||
Releases are available [on Nuget](https://www.nuget.org/packages/Spice86/).
|
||||
|
||||
Pre-releases are also available [on the Release page](https://github.com/OpenRakis/Spice86/releases/tag/latest)
|
||||
|
||||
NOTE: This is a port, and a continuation from the [original Java Spice86](https://github.com/kevinferrare/spice86).
|
||||
|
||||
It requires [.NET 10](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) and runs on Windows, macOS, and Linux.
|
||||
|
||||
## Approach
|
||||
|
||||
Rewriting a program from only the binary is a hard task.
|
||||
|
||||
Spice86 is a tool that helps you do so with a methodic divide and conquer approach.
|
||||
|
||||
General process:
|
||||
|
||||
- You start by emulating the program in the Spice86 emulator.
|
||||
- As the program runs, Spice86 builds a Control Flow Graph (CFG) of the executed code.
|
||||
- At the end of each run, the emulator dumps some runtime data (memory dump, execution flow and the CFG).
|
||||
- From that CFG, Spice86 **directly generates a self-contained, runnable C# project** that overrides the original assembly with equivalent C# code.
|
||||
- You then gradually rewrite the generated C# functions, replacing the mechanical translation with readable, intentful code (a task an LLM can help with).
|
||||
- This is helpful because:
|
||||
- Small sequences of assembly can be statically analyzed and are generally easy to translate to a higher level language.
|
||||
- You work all the time with a fully working version of the program so it is relatively easy to catch mistakes early.
|
||||
- Rewriting code function by function allows you to discover the intent of the author.
|
||||
|
||||
Spice86 also dumps Ghidra-compatible symbols, so you can **optionally** load the memory dump into [Ghidra](https://github.com/NationalSecurityAgency/ghidra) via the [spice86-ghidra-plugin](https://github.com/OpenRakis/spice86-ghidra-plugin) for deeper static analysis. This is no longer required to produce C# overrides; it is just an extra analysis aid.
|
||||
|
||||
## Running your exe
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `Spice86 -e file.exe` | Run the specified executable |
|
||||
| `Spice86 -e file.com` | Run a COM file |
|
||||
| `Spice86 -e file.bat` | Run a DOS batch file |
|
||||
| `Spice86 -e file.bin` | Run a BIOS file |
|
||||
|
||||
## Dumping data
|
||||
|
||||
| Setting | Description |
|
||||
|---------|-------------|
|
||||
| Environment Variable | `SPICE86_DUMPS_FOLDER` - Set this to control the base directory where data is dumped |
|
||||
| Command Line | Use `--RecordedDataDirectory` to specify the base dump location |
|
||||
| Default Location | Current directory if neither of the above is specified |
|
||||
|
||||
**Note:** Regardless of the base directory setting, dumps are always placed in a subdirectory named with the program's SHA-256 hash. This ensures that multiple executables from the same game (e.g., SETUP.EXE, GAME.EXE) have isolated dump folders.
|
||||
|
||||
The emulator dumps the following files:
|
||||
|
||||
- **spice86dumpMemoryDump.bin**: Snapshot of the real mode address space
|
||||
- **spice86dumpExecutionFlow.json**: Contains function addresses, labels, and executed instructions
|
||||
- **spice86dumpGhidraSymbols.txt**: Ghidra-compatible symbols (function and label addresses), for optional import into Ghidra
|
||||
- **spice86dumpCfgBlocks.json**: The explored CFG as basic blocks with execution-context metadata
|
||||
- **spice86dumpCfgPartitions.json**: The recovered function/helper partitions and inter-partition transfers, derived from the block graph
|
||||
- **spice86dumpCfgGeneratedOverrides.cs**: C# overrides generated from the explored CFG
|
||||
- **GeneratedProject/**: A self-contained, runnable C# override project (see [Generated C# override project](#generated-c-override-project))
|
||||
|
||||
When there is already data in the specified location, the emulator will load it first and complement it.
|
||||
|
||||
**CFG graph reload:** The CFG instruction graph is also dumped (**spice86dumpCfgReload.json**) and, by default, reloaded from the recorded data directory at startup so previously explored program structure is preserved across runs. Disable with `--ReloadCfgGraph false`. It is a no-op if the file is absent.
|
||||
|
||||
**Code overrides:** When code overrides are active (`--UseCodeOverride true` with an `--OverrideSupplierClassName`), the CFG and execution flow dumps (**spice86dumpExecutionFlow.json**, **spice86dumpCfgBlocks.json**, **spice86dumpCfgPartitions.json**, **spice86dumpCfgReload.json**) are not written. Overrides replace the emulated asm, so the recorded graph would jump between overrides and no longer reflect the program.
|
||||
|
||||
### CPU Heavy Logging
|
||||
|
||||
For detailed debugging, you can enable CPU heavy logging which records every executed instruction to a file.
|
||||
|
||||
**⚠️ Warning:** This feature has a significant performance impact and should only be used for debugging purposes.
|
||||
|
||||
| Setting | Description |
|
||||
|---------|-------------|
|
||||
| `--CpuHeavyLog` | Enables CPU heavy logging (default: false) |
|
||||
| `--CpuHeavyLogDumpFile` | Custom path for the log file (optional). If set, will enable CpuHeavyLog as well. Default Location: `{DumpDirectory}/cpu_heavy.log` |
|
||||
| `--CpuHeavyLogExpressions` | Named expressions appended to every CPU heavy log line. Repeat the option for each expression to append (for example: `--CpuHeavyLogExpressions "life=AX+1" --CpuHeavyLogExpressions "myvalue=word ptr DS:[0x456]"`). Only active when `--CpuHeavyLog` is true. |
|
||||
|
||||
**Log Format:** Each line contains: `SegmentedAddress InstructionString`
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
017D:0000 mov AX,0xDD1D
|
||||
017D:0003 call near 0xE4AD
|
||||
017D:E4AD mov SI,0x0080
|
||||
```
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Enable with default location
|
||||
Spice86 -e program.exe --CpuHeavyLog
|
||||
|
||||
# Use custom log file path
|
||||
Spice86 -e program.exe --CpuHeavyLog --CpuHeavyLogDumpFile "C:\logs\cpu.log"
|
||||
|
||||
# Append named expressions to each log line (example)
|
||||
Spice86 -e program.exe --CpuHeavyLog \
|
||||
--CpuHeavyLogExpressions "life=AX+1" \
|
||||
--CpuHeavyLogExpressions "myvalue=word ptr DS:[0x456]"
|
||||
```
|
||||
|
||||
|
||||
## Command line options
|
||||
|
||||
```
|
||||
--Debug (Default: false) Starts the program paused and pauses once again when stopping.
|
||||
--Cycles (Default: null) Target CPU cycles per ms, for the rare speed sensitive game. 3000 by default. Overrides Instructions per second option below if used.
|
||||
--Xms (Default: true) Enables 15 MB of XMS memory.
|
||||
--Ems (Default: true) Enables EMS memory. EMS adds 8 MB of memory accessible to DOS programs through the EMM Page Frame.
|
||||
--A20Gate (Default: false) Disables the 20th address line to support programs relying on the rollover of memory addresses above the HMA (slightly above 1 MB).
|
||||
-m, --Mt32RomsPath Zip file or directory containing the MT-32 ROM files
|
||||
-c, --CDrive Path to C drive, default is exe parent
|
||||
-r, --RecordedDataDirectory Directory to dump data to when not specified otherwise. If blank dumps to SPICE86_DUMPS_FOLDER, and if not defined dumps to a sub directory named with the program SHA 256 signature
|
||||
-e, --Exe Required. Path to executable
|
||||
-a, --ExeArgs List of parameters to give to the emulated program
|
||||
-x, --ExpectedChecksum Hexadecimal string representing the expected SHA256 checksum of the emulated program
|
||||
-f, --FailOnUnhandledPort (Default: false) If true, will fail when encountering an unhandled IO port. Useful to check for unimplemented hardware. false by default.
|
||||
-g, --GdbPort GDB port. If 0, GDB server will be disabled. Default is 10000.
|
||||
-o, --OverrideSupplierClassName Name of a class that will generate the initial function information. See documentation for more information.
|
||||
-p, --ProgramEntryPointSegment (Default: 4096) Segment where to load the program. DOS PSP and MCB will be created before it.
|
||||
-u, --UseCodeOverride (Default: true) <true or false> if false it will use the names provided by overrideSupplierClassName but not the code
|
||||
-i, --InstructionTimeScale <number of instructions that have to be executed by the emulator to consider a second passed> if blank will use time based timer.
|
||||
--ClockJitterSeed <CLOCKJITTERSEED> Optional integer seed enabling small deterministic clock jitter (±0.01 ms). Omit to disable.
|
||||
--ClockStartTime <CLOCKSTARTTIME> Optional UTC start date/time for the emulated clock (parseable by DateTime.Parse, e.g. 1993-06-01T00:00:00Z). When omitted defaults to the current UTC time.
|
||||
-t, --TimeMultiplier (Default: 1) <time multiplier> if >1 will go faster, if <1 will go slower.
|
||||
-h, --HeadlessMode [Mode] (Default: false) Headless mode. The mode 'Minimal' does not use any UI components, 'Avalonia' uses the full UI and consumes a bit more memory.
|
||||
-l, --VerboseLogs (Default: false) Enable verbose level logs
|
||||
-w, --WarningLogs (Default: false) Enable warning level logs
|
||||
-s, --SilencedLogs (Default: false) Disable all logs
|
||||
-i, --InitializeDOS (Default: true) Install DOS interrupt vectors or not.
|
||||
--CpuHeavyLog (Default: false) Enable CPU heavy logging. Logs every executed instruction to a file. Warning: significant performance impact.
|
||||
--CpuHeavyLogDumpFile Custom file path for CPU heavy log output. If not specified, defaults to {DumpDirectory}/cpu_heavy.log
|
||||
--CpuHeavyLogExpressions (Default: none) Named expressions appended to every CPU heavy log line. Repeat the option for each expression to append (for example: --CpuHeavyLogExpressions "life=AX+1"). Only active when --CpuHeavyLog is true.
|
||||
--ReloadCfgGraph (Default: true) Reload the previously dumped CFG instruction graph (spice86dumpCfgReload.json) at startup so explored program structure is preserved across runs. No-op if the file is absent.
|
||||
--AsmRenderingStyle Style of the ASM rendering. Spice86 or DosBox.
|
||||
--StructureFile Path to a C header file that describes the structures in the application. Works best with exports from IDA or Ghidra
|
||||
--mcp-http-port (Default: 8081) Port for the MCP HTTP server
|
||||
--RenderingMode (Default: Async) Selects the VGA rendering mode. Sync fires VGA events on the emulation thread for determinism; The default mode is for performance.
|
||||
--JitMode (Default: InterpretedThenCompiled) Controls how the JIT compiler handles instruction execution delegates.
|
||||
--AllowIvtAddress0 (Default: false) Controls whether an INT instruction whose IVT entry is 0:0 is treated as valid.
|
||||
--version Display version information.
|
||||
```
|
||||
|
||||
### Sound Blaster and OPL/Adlib Gold Options
|
||||
|
||||
- SbType: Sound Blaster card type. Values: None, SB1, SB2, SBPro1, SBPro2, Sb16, GameBlaster, AdlibGold.
|
||||
- SbIrq: Sound Blaster IRQ line. Default is 7. Common values: 5, 7, 9, 10.
|
||||
- SbDma: Sound Blaster 8-bit DMA channel. Default is 1. Common values: 0, 1, 3.
|
||||
- SbHdma: Sound Blaster 16-bit high DMA channel. Default is 5. Common values: 5, 6, 7.
|
||||
- SbBase: Sound Blaster base I/O address (hex). Default is 0x220. Common values: 0x220, 0x240, 0x260, 0x280.
|
||||
- OplMode: OPL synthesis mode. Values: None, Opl2, DualOpl2, Opl3, Opl3Gold. Default is Opl3.
|
||||
- SbMixer: Enable Sound Blaster mixer control of OPL voices. Default is true.
|
||||
|
||||
## Dynamic analysis
|
||||
|
||||
Spice86 speaks the [GDB](https://www.gnu.org/software/gdb/) remote protocol:
|
||||
|
||||
- it supports most of the commands you need to debug.
|
||||
- it also provides custom GDB commands to do dynamic analysis.
|
||||
|
||||
### Connecting to GDB
|
||||
|
||||
The GDB server is always started along with the program to execute unless option is set to 0.
|
||||
Default port is 10000.
|
||||
|
||||
If you want to pause before starting execution to setup breakpoints and so on, use the --Debug option.
|
||||
|
||||
Here is how to connect from GDB command line client and how to set the architecture:
|
||||
|
||||
```
|
||||
(gdb) target remote localhost:10000
|
||||
(gdb) set architecture i8086
|
||||
```
|
||||
|
||||
### Vanilla GDB
|
||||
|
||||
You can add breakpoints, step, view memory and so on.
|
||||
|
||||
Example with a breakpoint on VGA VRAM writes:
|
||||
|
||||
```
|
||||
(gdb) watch *0xA0000
|
||||
```
|
||||
|
||||
Viewing assembly:
|
||||
|
||||
```
|
||||
(gdb) layout asm
|
||||
```
|
||||
|
||||
Removing a breakpoint:
|
||||
|
||||
```
|
||||
(gdb) remove 1
|
||||
```
|
||||
|
||||
Searching for a sequence of bytes in memory (start address 0, length F0000, ascii bytes of 'Spice86' string):
|
||||
|
||||
```
|
||||
(gdb) find /b 0x0, 0xF0000, 0x53, 0x70, 0x69, 0x63, 0x65, 0x38, 0x36
|
||||
```
|
||||
|
||||
GDB does not support x86 real mode segmented addressing, so pointers need to refer to the actual physical address in memory. VRAM at address A000:0000 would be 0xA0000 in GDB.
|
||||
|
||||
Similarly, The $pc variable in GDB will be exposed by Spice86 as the physical address pointed by CS:IP.
|
||||
|
||||
### Custom GDB commands (where the magic happens)
|
||||
|
||||
The list of custom commands can be displayed like this:
|
||||
|
||||
```
|
||||
(gdb) monitor help
|
||||
```
|
||||
|
||||
#### Dump information about current run
|
||||
|
||||
```
|
||||
(gdb) monitor dumpall
|
||||
```
|
||||
|
||||
Dumps everything described below in one shot. Files are created in the dump folder as explained [here](https://github.com/OpenRakis/Spice86#dumping-data)
|
||||
Several files are produced:
|
||||
|
||||
- spice86dumpMemoryDump.bin: Snapshot of the real mode address space. Contains the instructions that are actually loaded and executed. They may differ from the exe you are running because DOS programs can rewrite some of their instructions / load additional modules in memory.
|
||||
- spice86dumpExecutionFlow.json: Contains information about the run such as addresses of the functions, the labels, and the instructions that have been executed. Also consumed by the optional [spice86-ghidra-plugin](https://github.com/OpenRakis/spice86-ghidra-plugin).
|
||||
- spice86dumpCfgBlocks.json and spice86dumpCfgPartitions.json: the explored CFG as basic blocks, and the function/helper partitions plus transfers derived from those blocks.
|
||||
- spice86dumpCfgGeneratedOverrides.cs and GeneratedProject/: the C# overrides and runnable project generated from the explored CFG (see [Generated C# override project](#generated-c-override-project)).
|
||||
|
||||
#### Special breakpoints
|
||||
|
||||
Break after x emulated CPU Cycles:
|
||||
|
||||
```
|
||||
(gdb) monitor breakCycles 1000
|
||||
```
|
||||
|
||||
Break at the end of the emulated program:
|
||||
|
||||
```
|
||||
(gdb) monitor breakStop
|
||||
```
|
||||
|
||||
## Seer
|
||||
|
||||
For a pleasing and productive experience with GDB, the
|
||||
[seerGDB](https://github.com/epasveer/seer) client is highly recommended.
|
||||
|
||||
At best, use the configuration file `spice86.seer` provided in the `doc` directory ([here](doc/spice86.seer)): run Seer with `seergdb --project spice86.seer`.
|
||||
|
||||
If you use a different port for gdb, adjust `spice86.seer` correspondingly.
|
||||
|
||||
Also, while in Seer, set Settings/Configuration/Assembly/Disassembly Mode to
|
||||
“Length”, otherwise the Assembly View won't work.
|
||||
|
||||
## Emulator features
|
||||
|
||||
| Component | Support Level |
|
||||
|-----------|--------------|
|
||||
| **CPU** | 8086/8088 fully implemented and tested |
|
||||
| | 80186 (BOUND instruction missing) |
|
||||
| | 80286 (protected mode not implemented) |
|
||||
| | 80386 (partial support, protected mode not implemented) |
|
||||
| | Only 16-bit instructions fully supported |
|
||||
| | Most 32-bit instructions implemented but not fully tested |
|
||||
| | No FPU except detection instructions |
|
||||
| **Memory** | 1MB address space with segmented addressing |
|
||||
| | A20 Gate support |
|
||||
| | EMS 3.2 implemented |
|
||||
| | XMS 4.0 is implemented |
|
||||
| | HMA is implemented |
|
||||
| | No paging support |
|
||||
| **Graphics** | Text modes, VGA, EGA, and CGA implemented |
|
||||
| | EGA and CGA modes are best effort (you may find bugs) |
|
||||
| | VESA VBE 1.2 is supported |
|
||||
| **DOS** | Largely complete DOS and INT 21h implementation (DOS 5.0) |
|
||||
| **Input** | Keyboard and mouse supported |
|
||||
| | No joystick support |
|
||||
| **CD-ROM** | MSCDEX and CDDA support is implemented, including CD images |
|
||||
| **Floppy** | Floppy disk emulation is implemented, including floppy images and booting on a floppy image |
|
||||
|
||||
## Sound support
|
||||
|
||||
| Sound Type | Support Level | Notes |
|
||||
|------------|---------------|-------|
|
||||
| PC Speaker | ✅ Full | Implemented |
|
||||
| Adlib/SB OPL | ✅ Full | Ported from DOSBox Staging |
|
||||
| SoundBlaster | ✅ Full | Ported from DOSBox Staging |
|
||||
| Adlib Gold | ✅ Full | Ported from DOSBox Staging |
|
||||
| MT-32 | ⚠️ Partial | Not available on macOS |
|
||||
| Gravis Ultrasound | ❌ None | Not implemented yet |
|
||||
| General MIDI | ✅ Full | Supported |
|
||||
|
||||
## Misc
|
||||
|
||||
| Feature | Details |
|
||||
|---------|---------|
|
||||
| **C Drive** | Configurable with `--CDrive`, defaults to current folder |
|
||||
| **Program Arguments** | Pass up to 127 chars with `--ExeArgs` |
|
||||
| **Time Handling** | Real elapsed time (adjustable with `--TimeMultiplier`) or instruction-based timing with `--InstructionTimeScale` |
|
||||
| **Screen Refresh** | 30 FPS and on VGA retrace wait detection |
|
||||
| **Structure Viewer** | Requires C header file (`--StructureFile`) to display memory structures |
|
||||
|
||||
## Reverse engineering process
|
||||
|
||||
Concrete example with Cryo Dune [here](https://github.com/OpenRakis/Cryogenic).
|
||||
|
||||
First run your program and make sure everything works fine in Spice86. If you encounter issues it could be due to unimplemented hardware / DOS / BIOS features.
|
||||
|
||||
When Spice86 exits, it dumps its data (memory dump, execution flow, CFG) and generates a C# override project in the dump folder (current folder, or the folder specified by the `SPICE86_DUMPS_FOLDER` env variable / `--RecordedDataDirectory`).
|
||||
|
||||
The generated project under `GeneratedProject/` is immediately runnable and already overrides the explored assembly with equivalent C#. From there you rewrite the generated functions, function by function, to discover and document the program's intent. This is well suited to LLM assistance.
|
||||
|
||||
See [Generated C# override project](#generated-c-override-project) for how to run it and [Overriding emulated code with C# code](#overriding-emulated-code-with-c-code) for the override API.
|
||||
|
||||
Optionally, you can also open the memory dump in [Ghidra](https://github.com/NationalSecurityAgency/ghidra) with the [spice86-ghidra-plugin](https://github.com/OpenRakis/spice86-ghidra-plugin) for additional static analysis (see [Ghidra plugin](#ghidra-plugin)).
|
||||
|
||||
## Generated C# override project
|
||||
|
||||
On every dump (when not already running with overrides), Spice86 turns the explored CFG into a ready-to-run C# project, so you do not need any external tool to start rewriting the program in C#.
|
||||
|
||||
Two artifacts are produced in the dump folder:
|
||||
|
||||
- **spice86dumpCfgGeneratedOverrides.cs**: the generated overrides on their own (a `CfgGeneratedOverrideSupplier` plus a `CfgGeneratedOverrides : CSharpOverrideHelper` mapping every discovered function via `DefineFunction`).
|
||||
- **GeneratedProject/**: a self-contained, runnable project wrapping those overrides:
|
||||
- `Spice86.Generated.csproj` references the Spice86 GUI project, so the build always matches the running emulator.
|
||||
- `Program.cs` forwards all your arguments to Spice86 and defaults in `--OverrideSupplierClassName`, `--UseCodeOverride true`, and the program's `--ExpectedChecksum` (so the overrides cannot run against a different binary).
|
||||
- `CfgGeneratedOverrides.cs` contains the generated overrides.
|
||||
|
||||
Run it like a normal .NET project, passing the path to your executable:
|
||||
|
||||
```bash
|
||||
cd <dump folder>/GeneratedProject
|
||||
dotnet run -- -e /path/to/PROGRAM.EXE
|
||||
```
|
||||
|
||||
Then progressively replace the mechanically generated function bodies with your own readable C# implementations.
|
||||
|
||||
> **Note:** while running with overrides active (`--UseCodeOverride true`), the CFG and execution-flow dumps are not rewritten, so regenerating from scratch should be done from a plain (non-override) run.
|
||||
|
||||
## Overriding emulated code with C# code
|
||||
|
||||
You can provide your own C# code to override the program original assembly code. This is exactly what the [generated project](#generated-c-override-project) does for you automatically; the section below explains the API so you (or an LLM) can write or refine overrides.
|
||||
|
||||
### Defining overrides
|
||||
|
||||
Spice86 can take in input an instance of Spice86.Core.Emulator.Function.IOverrideSupplier that builds a mapping between the memory address of functions and their C# overrides.
|
||||
|
||||
For a complete example you can check the source code of [Cryogenic](https://github.com/OpenRakis/Cryogenic).
|
||||
|
||||
Here is a simple example of how it would look like:
|
||||
|
||||
```csharp
|
||||
namespace My.Program;
|
||||
|
||||
// This class is responsible for providing the overrides to spice86.
|
||||
// There is only one per program you reimplement.
|
||||
public class MyProgramOverrideSupplier : IOverrideSupplier {
|
||||
public IDictionary<SegmentedAddress, FunctionInformation> GenerateFunctionInformations(
|
||||
ILoggerService loggerService, Configuration configuration, ushort programStartSegment, Machine machine) {
|
||||
return new MyOverrides(new Dictionary<SegmentedAddress, FunctionInformation>(),
|
||||
machine, loggerService, configuration).FunctionInformations;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "Overrides My program exe. class is " + GetType().FullName;
|
||||
}
|
||||
}
|
||||
|
||||
// This class contains the actual overrides. As the project grows, you will probably need to split the reverse engineered code in several classes.
|
||||
public class MyOverrides : CSharpOverrideHelper {
|
||||
private readonly MyOverridesGlobalsOnDs globalsOnDs;
|
||||
|
||||
public MyOverrides(IDictionary<SegmentedAddress, FunctionInformation> functionInformations,
|
||||
Machine machine, ILoggerService loggerService, Configuration configuration)
|
||||
: base(functionInformations, machine, loggerService, configuration) {
|
||||
globalsOnDs = new MyOverridesGlobalsOnDs(Memory, State.SegmentRegisters);
|
||||
// IncDialogueCount47A8 will get executed instead of the assembly code when a call to 017D:A1E8 is performed.
|
||||
// The override method receives the load offset (segment where the program was loaded) as parameter.
|
||||
DefineFunction(0x017D, 0xA1E8, IncDialogueCount47A8_017D_A1E8_0C0B8);
|
||||
DefineFunction(0x017D, 0x0100, AddOneToAX_017D_0100_01FD0);
|
||||
}
|
||||
|
||||
public Action IncDialogueCount47A8_017D_A1E8_0C0B8(int loadOffset) {
|
||||
// Accessing the memory via accessors
|
||||
globalsOnDs.SetDialogueCount47A8(globalsOnDs.GetDialogueCount47A8() + 1);
|
||||
// Depends on the actual return instruction performed by the function, needed to be called from the emulated code as
|
||||
// some programs like to mess with the stack ...
|
||||
return NearRet();
|
||||
}
|
||||
|
||||
public Action AddOneToAX_017D_0100_01FD0(int loadOffset) {
|
||||
// Assembly for this would be
|
||||
// INC AX
|
||||
// RETN
|
||||
// Note that you can access the whole emulator to change the state in the overrides.
|
||||
State.AX++;
|
||||
return NearRet();
|
||||
}
|
||||
}
|
||||
|
||||
// Memory accesses can be encapsulated into classes like this to give names to addresses and make the code shorter.
|
||||
public class GlobalsOnDs : MemoryBasedDataStructureWithDsBaseAddress {
|
||||
public GlobalsOnDs(IByteReaderWriter memory, SegmentRegisters segmentRegisters) : base(memory, segmentRegisters) {
|
||||
}
|
||||
|
||||
// Getters and Setters for address 0x1DD:0x2/0x1DD2.
|
||||
// Was accessed via the following registers: DS
|
||||
public int Get01DD_0002_Word16() {
|
||||
return UInt16[0x2];
|
||||
}
|
||||
|
||||
public void Set01DD_0002_Word16(ushort value) {
|
||||
UInt16[0x2] = value;
|
||||
}
|
||||
|
||||
// Getters and Setters for address 0x1138:0x0/0x11380.
|
||||
public int Get1138_0000_Word16() {
|
||||
return UInt16[0x0];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The override method name encodes the address (`Name_<segment>_<offset>_<linear>`) so it can be parsed back into a `FunctionInformation`; pass an explicit `name` argument to `DefineFunction` if you prefer not to follow that convention.
|
||||
|
||||
*Remember*: You must tell Spice86 to use your C# code overrides with the command line argument "--UseCodeOverride true" when debugging your project, along with the mandatory path to your DOS program passed with the "-e" / "--Exe" argument.
|
||||
|
||||
## Debugger
|
||||
|
||||
Spice86 comes with a [built-in debugger](https://github.com/OpenRakis/Spice86/wiki/Spice86-internal-debugger). that can be used to debug the emulated program. It is a simple debugger that allows you to inspect the memory, the disassembly, the registers, and the stack.
|
||||
|
||||
### Structure viewer
|
||||
|
||||
The structure viewer allows you to inspect the memory in a structured way. It is useful to inspect the memory as a structure, like the DOS PSP, the DOS MCB, the VGA registers, etc.
|
||||
|
||||
First you need a C header file that describes the structures in the application. You can generate one with Ghidra or IDA. Then you can load it with the `--StructureFile` commandline argument.
|
||||
This will enable the "Structure view" button in the Memory tab of the debugger.
|
||||
|
||||
There you enter a segment:offset address and choose the structure you want to view. The structure will be displayed in a tree view and the memory in a hex view.
|
||||
|
||||
The display updates whenever the application is paused, so you can step through the program and see how the structure changes.
|
||||
Exporting a new C header file from Ghidra or IDA will also update the structure viewer with the new information real-time.
|
||||
|
||||
You can also enter the Structure view by selecting a range of bytes in the Memory tab and right-clicking on it.
|
||||
|
||||
## HTTP server
|
||||
|
||||
Spice86 includes a built-in HTTP server for quick runtime inspection and memory access.
|
||||
|
||||
- The HTTP server is **disabled by default**. Enable it by specifying a port with `--HttpApiPort`.
|
||||
|
||||
Available endpoints:
|
||||
|
||||
| Method | Route | Description |
|
||||
|--------|-------|-------------|
|
||||
| `GET` | `/api` | API metadata and endpoint list |
|
||||
| `GET` | `/api/status` | Current emulator status (pause state, CPU state, CS:IP, cycles, memory size) |
|
||||
| `GET` | `/api/memory/{address}/byte` | Read one byte at address |
|
||||
| `PUT` | `/api/memory/{address}/byte` | Write one byte at address |
|
||||
| `GET` | `/api/memory/{address}/range/{length}` | Read a memory range |
|
||||
|
||||
## Misc details
|
||||
|
||||
### C Drive
|
||||
|
||||
It is possible to provide a C: Drive for emulated DOS functions with the option **--CDrive**. Default is executed program folder. For some games you may need to set the C drive to the parent folder.
|
||||
|
||||
### Emulated program arguments
|
||||
|
||||
You can pass arguments (max 127 chars!) to the emulated program with the option **--ExeArgs**. Default is empty.
|
||||
|
||||
### Time
|
||||
|
||||
The emulated Timer hardware of the PC (Intel 8259) supports measuring time from either:
|
||||
|
||||
- The real elapsed time. Speed can be altered with parameter **--TimeMultiplier**.
|
||||
- The number of instructions the emulated CPU executed. This is the behaviour that is activated with parameter **--InstructionTimeScale** and is forced when in GDB mode so that you can debug with peace of mind without the timer triggering.
|
||||
|
||||
Compatibility list available [here](COMPATIBILITY.md).
|
||||
|
||||
### How to build on your machine
|
||||
|
||||
- Install the [.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) (once)
|
||||
- clone the repo
|
||||
- run this where Spice86.sln is located:
|
||||
|
||||
```bash
|
||||
dotnet build
|
||||
```
|
||||
|
||||
### How to run
|
||||
|
||||
```bash
|
||||
Spice86 -e <path to executable>
|
||||
```
|
||||
|
||||
or use this where Spice86.csproj is located:
|
||||
|
||||
```bash
|
||||
dotnet run -e <path to executable>
|
||||
```
|
||||
|
||||
if you don't want to manually build and run separately, use the helper script at the root of the repository which builds and runs the app, passing all arguments through:
|
||||
|
||||
```bash
|
||||
./run.sh -e <path to executable>
|
||||
```
|
||||
|
||||
### Ghidra plugin
|
||||
|
||||
Importing the dump into Ghidra is **optional**. Spice86 already generates a runnable C# override project on its own (see [Generated C# override project](#generated-c-override-project)); the Ghidra plugin is only useful if you additionally want to explore the dump inside Ghidra (static analysis, labeling, or producing a `--StructureFile` C header for the [structure viewer](#structure-viewer)).
|
||||
|
||||
This uses Ghidra and Java 17.
|
||||
|
||||
Before using it, define an environnement variable named SPICE86_DUMPS_FOLDER pointing to a folder where the Spice86 dumps are located.
|
||||
They are generated on exit.
|
||||
|
||||
General procedure, in order:
|
||||
|
||||
1.Ghidra's own script 'ImportSymbolScript.py' (input used is "spice86dumpGhidraSymbols.txt")
|
||||
|
||||
2.Ghidra's Auto-Analyze (only enable 'Dissasemble Entry Points')
|
||||
|
||||
3.Now, you can use the plugin.
|
||||
|
||||
Remember: if Ghidra displays SUBROUTINES, use the 'f' key to convert them into functions.
|
||||
|
||||
Also, if you have any weird behaviour, make sure you have Java 17 and ONLY Java 17. That's how Ghidra likes it.
|
||||
|
||||
### Cfg Cpu
|
||||
|
||||
Doc [here](doc/cfgcpuReadme.md)
|
||||
|
||||
### MCP
|
||||
|
||||
MCP server documentation is available in [doc/mcp.md](doc/mcp.md).
|
||||
|
||||
### Some screenshots
|
||||
|
||||
Cryo dune:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Prince of persia:
|
||||

|
||||
|
||||
Stunts:
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Betrayal at Krondor:
|
||||
|
||||

|
||||
|
||||
## Credits
|
||||
|
||||
The SoundBlaster and Adlib Gold implementations are fully ported from [dosbox-staging](https://github.com/dosbox-staging/dosbox-staging), replacing the previous one which was modified from the Aeon emulator. This includes PCM and OPL sound quality improvements, far greater emulation accuracy, SB/OPL compatibility, mixer thread logic, audio events, audio hardware delays, and a complete audio re-architecture.
|
||||
|
||||
The NukedOpl3 port to C# was done by codeEngine. It is bit-accurate. Thanks a lot!
|
||||
|
||||
The DOS implementation is heavily inspired by the clean code from FreeDOS, and DOSBox Staging.
|
||||
|
||||
The implementations of MSCDEX, CDDA, Floppy emulation, CD images support, CD drive emulation all used DOSBox Staging as a model (even if the architecture is different), escpecially for conformance about expected behavior (ie. IOCTL).
|
||||
|
||||
The BIOS implementation draws heavily from SeaBIOS, IBM PC BIOS reconstructionns, and sometimes DOSBox Staging.
|
||||
|
||||
EMS was written with the help of the specs.
|
||||
XMS was written with the help of the specs, but a lot had to be rewritten by looking at [the real HIMEM driver](https://github.com/neozeed/himem.sys-2.06), and by reproducing the XMS tests from Microsoft.
|
||||
|
||||
Additionally, the project no longer relies on PortAudio. Instead, it uses a fully cross-platform C# port of the SDL2 audio APIs.
|
||||
We only depend on WASAPI (Windows), ALSA (Linux), or CoreAudio (macOS).
|
||||
|
||||
This project uses JetBrains Rider licenses, thanks to JetBrains' [Open Source Community Support](https://www.jetbrains.com/community/opensource/#support).
|
||||
|
||||

|
||||
|
||||
The UI is powered by [Avalonia UI](https://avaloniaui.net/).
|
||||
|
||||

|
||||
402
docs/spice86/mcp.md
Normal file
402
docs/spice86/mcp.md
Normal file
|
|
@ -0,0 +1,402 @@
|
|||
# Spice86 MCP HTTP Server
|
||||
|
||||
## Overview
|
||||
|
||||
Spice86 exposes a **Model Context Protocol (MCP) server** over HTTP, enabling structured programmatic control of the emulator. AI clients, automation scripts, and external tooling can use MCP to inspect, manipulate, and drive execution of DOS programs running in Spice86.
|
||||
|
||||
This server provides **65+ built-in tools** covering:
|
||||
- CPU state inspection (registers, flags, instruction pointer)
|
||||
- Memory read/write/search/disassembly
|
||||
- I/O port read/write
|
||||
- Execution control (pause, resume, step, step-over)
|
||||
- Breakpoint management (execution, memory read/write)
|
||||
- Function discovery and CFG (Control Flow Graph) traversal
|
||||
- Video state inspection and screenshot capture
|
||||
- Sound device state (SoundBlaster, OPL, MIDI, PC Speaker)
|
||||
- DOS structures (PSP, MCB, File handle table)
|
||||
- EMS and XMS memory management
|
||||
|
||||
The HTTP transport is **stateless** by default to maximize compatibility with real-world AI clients that may skip session negotiation or reuse connection state unpredictably.
|
||||
|
||||
---
|
||||
|
||||
## Endpoints
|
||||
|
||||
Video inspection and PNG captures use the last completed logical framebuffer.
|
||||
Mode 13h produces 320x200 pixels; a program can change VGA registers without
|
||||
changing the BIOS mode record (for example, 256x224 unchained graphics).
|
||||
Pixel and scanline doubling are presentation concerns, not duplicate pixels
|
||||
in the returned framebuffer. GUI graphics retain 4:3 aspect correction.
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `http://localhost:<port>/mcp` | MCP protocol endpoint (JSON-RPC over HTTP) |
|
||||
| `http://localhost:<port>/health` | Health check endpoint returning `{"status":"ok"}` |
|
||||
|
||||
**Default port:** `8081`
|
||||
|
||||
**CLI option:** `--mcp-http-port <port>`
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Start Spice86 with MCP enabled (enabled by default)
|
||||
|
||||
```bash
|
||||
Spice86 -e program.exe --mcp-http-port 8081
|
||||
```
|
||||
|
||||
### 2. Connect your MCP client
|
||||
|
||||
Point your MCP client to:
|
||||
```
|
||||
http://localhost:8081/mcp
|
||||
```
|
||||
|
||||
### 3. Discover available tools
|
||||
|
||||
```json
|
||||
POST /mcp
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "initialize",
|
||||
"params": {
|
||||
"protocolVersion": "2024-11-05",
|
||||
"capabilities": {},
|
||||
"clientInfo": { "name": "MyClient", "version": "1.0" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then call `tools/list` to enumerate all available tools, or call `mcp_about` for high-level capability metadata.
|
||||
|
||||
---
|
||||
|
||||
## Protocol Behavior
|
||||
|
||||
- **Transport:** HTTP (stateless by default)
|
||||
- **Protocol:** JSON-RPC 2.0
|
||||
- **Session management:** The server does **not** issue `Mcp-Session-Id` headers by default (`options.Stateless = true`). This prevents 404 errors when AI clients reuse session IDs from fresh TCP connections or skip the `notifications/initialized` handshake.
|
||||
- **Standard MCP flow:** `initialize` → `tools/list` → `tools/call`
|
||||
|
||||
**Stateless mode** is recommended for AI agents and automated workflows. If you need stateful sessions (e.g., for long-lived interactive clients), you can modify `McpHttpHost.cs` to set `options.Stateless = false`.
|
||||
|
||||
---
|
||||
|
||||
## Built-in Tool Categories
|
||||
|
||||
Spice86 ships with **65+ MCP tools** organized into these capability scopes:
|
||||
|
||||
### CPU State & Execution Control
|
||||
- `read_cpu_state`: Read all general-purpose registers, segment registers, IP, flags, and cycle count
|
||||
- `pause`: Pause emulation
|
||||
- `resume`: Resume emulation
|
||||
- `step`: Execute one instruction and pause
|
||||
- `step_over`: Step over CALL instructions (run until RET)
|
||||
- `get_pause_status`: Check if emulator is paused
|
||||
|
||||
### Memory Operations
|
||||
- `read_memory`: Read a memory range (segment, offset, length) as hex bytes
|
||||
- `write_memory`: Write hex bytes to memory
|
||||
- `search_memory`: Search for a hex pattern in conventional RAM
|
||||
- `read_disassembly`: Disassemble instructions at a given address
|
||||
|
||||
### I/O Ports
|
||||
- `read_io_port`: Read from an I/O port
|
||||
- `write_io_port`: Write to an I/O port
|
||||
|
||||
### Breakpoints
|
||||
- `add_execution_breakpoint`: Break when CS:IP reaches an address
|
||||
- `add_memory_read_breakpoint`: Break on memory read
|
||||
- `add_memory_write_breakpoint`: Break on memory write
|
||||
- `remove_execution_breakpoint`
|
||||
- `remove_memory_read_breakpoint`
|
||||
- `remove_memory_write_breakpoint`
|
||||
- `list_execution_breakpoints`
|
||||
- `list_memory_breakpoints`
|
||||
|
||||
### Functions & CFG
|
||||
- `list_functions`: List discovered functions sorted by call count
|
||||
- `read_cfg_cpu_graph`: Dump the Control Flow Graph (CFG) built by `CfgCpu`
|
||||
|
||||
### Video
|
||||
- `read_video_state`: Current video mode, resolution, text/graphics flag, cursor position
|
||||
- `read_video_state_detailed`: Full VGA register dump
|
||||
- `video_set_mode`: Change video mode
|
||||
- `read_vga_memory`: Read VGA VRAM
|
||||
- `write_vga_memory`: Write VGA VRAM
|
||||
- `vga_set_palette_entry`: Set VGA palette color
|
||||
- `capture_screenshot`: Save a screenshot to disk and return the path
|
||||
|
||||
### Sound Devices
|
||||
- **SoundBlaster:** `read_sound_blaster_state`, `sound_blaster_set_speaker`, `read_sound_blaster_dsp_version`, `sound_blaster_write_mixer_register`, etc.
|
||||
- **OPL (Adlib/SB OPL2/OPL3):** `read_opl_state`, `opl_write_register`
|
||||
- **PC Speaker:** `read_pc_speaker_state`, `pc_speaker_set_control`
|
||||
- **MIDI:** `read_midi_state`, `midi_reset`, `midi_enter_uart_mode`, `midi_send_bytes`
|
||||
|
||||
### Input Automation
|
||||
- `send_keyboard_key`: Send a keystroke (press + release or hold)
|
||||
- `send_mouse_packet`: Send raw mouse data packet
|
||||
- `send_mouse_move`: Move mouse cursor
|
||||
- `send_mouse_button`: Press/release mouse button
|
||||
|
||||
### DOS & BIOS Structures
|
||||
- `read_dos_psp`: Read the DOS Program Segment Prefix
|
||||
- `read_dos_mcb_chain`: Dump the DOS Memory Control Block chain
|
||||
- `read_dos_file_handle_table`: List open file handles
|
||||
- `read_dos_current_directory`: Get current drive and directory path
|
||||
- `read_bios_equipment_word`: Read BIOS equipment flags
|
||||
|
||||
### EMS & XMS
|
||||
- `read_ems_state`: EMS handle allocation, page frame mapping
|
||||
- `read_xms_state`: XMS handle allocation, HMA usage
|
||||
- `read_ems_page_frame`: Dump EMS page frame content
|
||||
- `read_xms_block`: Read an XMS memory block
|
||||
|
||||
### Metadata & Diagnostics
|
||||
- `mcp_about`: High-level server metadata, capability scopes, extension points, tool count
|
||||
|
||||
For a complete tool list with parameter details, call `tools/list` via the MCP endpoint.
|
||||
|
||||
---
|
||||
|
||||
## Tool Invocation & Auto-Pause
|
||||
|
||||
Most tools automatically **pause** the emulator before execution and **resume** after. This ensures consistent state during inspection and prevents race conditions. A few tools (marked with `[McpManualControl]`) skip auto-pause and require the client to explicitly call `pause` if needed.
|
||||
|
||||
**Example: Reading CPU state**
|
||||
|
||||
```json
|
||||
POST /mcp
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 2,
|
||||
"method": "tools/call",
|
||||
"params": {
|
||||
"name": "read_cpu_state",
|
||||
"arguments": {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 2,
|
||||
"result": {
|
||||
"content": [
|
||||
{
|
||||
"type": "resource",
|
||||
"resource": {
|
||||
"uri": "data:application/json;base64,eyJFQVgiOjEyMywgIkVCWCI6NDU2LCAuLi59"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The structured content (JSON) is base64-encoded in the resource field.
|
||||
|
||||
**Example: Writing memory**
|
||||
|
||||
```json
|
||||
POST /mcp
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 3,
|
||||
"method": "tools/call",
|
||||
"params": {
|
||||
"name": "write_memory",
|
||||
"arguments": {
|
||||
"segment": 4096,
|
||||
"offset": 256,
|
||||
"data": "B80200CD21"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Extending MCP from User Projects
|
||||
|
||||
Spice86 supports **external MCP tool registration**. You can add project-specific tools for game-specific operations (e.g., reading player stats, manipulating inventory, triggering events).
|
||||
|
||||
### Extension Model
|
||||
|
||||
1. **Implement `IMcpToolSupplier`** in your project to provide custom tool assemblies and injectable services.
|
||||
2. **Mark your tool classes with `[McpServerToolType]`** and individual methods with `[McpServerTool(Name = "...")]`.
|
||||
3. **Register your tools at startup** by passing additional assemblies and services to `McpHttpHost.Start`.
|
||||
|
||||
### Extension Entry Points
|
||||
|
||||
| Method | Purpose |
|
||||
|--------|---------|
|
||||
| `IMcpToolSupplier.GetMcpToolAssemblies()` | Return additional assemblies containing `[McpServerToolType]` classes |
|
||||
| `IMcpToolSupplier.GetMcpServices()` | Return injectable services used by custom tools |
|
||||
| `McpHttpHost.Start(additionalToolAssemblies, additionalServices)` | Register external tools at server start |
|
||||
|
||||
### Minimal Extension Example
|
||||
|
||||
```csharp
|
||||
using Spice86.Core.Emulator.Mcp;
|
||||
using ModelContextProtocol.Server;
|
||||
|
||||
// 1. Implement IMcpToolSupplier in your override project
|
||||
public class MyGameMcpToolSupplier : IMcpToolSupplier {
|
||||
public IEnumerable<Assembly> GetMcpToolAssemblies() {
|
||||
return [typeof(MyGameMcpTools).Assembly];
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetMcpServices() {
|
||||
return [new MyGameContext(...)];
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Define your custom tools
|
||||
[McpServerToolType]
|
||||
public sealed class MyGameMcpTools {
|
||||
private readonly MyGameContext _context;
|
||||
|
||||
public MyGameMcpTools(MyGameContext context, EmulatorMcpServices emulatorServices) {
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[McpServerTool(Name = "read_player_health", UseStructuredContent = true)]
|
||||
public object ReadPlayerHealth() {
|
||||
// Read from memory via _context or emulatorServices
|
||||
int health = _context.GetPlayerHealth();
|
||||
return new { Health = health, MaxHealth = 100 };
|
||||
}
|
||||
|
||||
[McpServerTool(Name = "set_player_gold", UseStructuredContent = true)]
|
||||
public object SetPlayerGold(int amount) {
|
||||
_context.SetPlayerGold(amount);
|
||||
return new { Success = true, Gold = amount };
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Registering Custom Tools at Startup
|
||||
|
||||
Modify your startup wiring (typically in `Spice86DependencyInjection.cs` or a custom entry point):
|
||||
|
||||
```csharp
|
||||
IMcpToolSupplier supplier = new MyGameMcpToolSupplier();
|
||||
McpHttpHost host = new(loggerService);
|
||||
host.Start(
|
||||
services: emulatorMcpServices,
|
||||
port: configuration.McpHttpPort,
|
||||
additionalToolAssemblies: supplier.GetMcpToolAssemblies(),
|
||||
additionalServices: supplier.GetMcpServices()
|
||||
);
|
||||
```
|
||||
|
||||
**Note:** The default `Spice86` startup does **not** load external tool assemblies. You must wire them explicitly if you want project-specific tools.
|
||||
|
||||
---
|
||||
|
||||
## Practical Guidance for Extension Authors
|
||||
|
||||
### Tool Design Best Practices
|
||||
|
||||
1. **Keep tools deterministic:** Avoid relying on global mutable state outside the emulator.
|
||||
2. **Prefer semantic tools:** Expose high-level operations (e.g., `read_player_inventory`) instead of raw memory offsets.
|
||||
3. **Keep low-level tools available:** Also provide `read_memory_at_player_inventory_address` for diagnostics when the semantic tool breaks.
|
||||
4. **Return compact structured payloads:** Avoid dumping large arrays unless necessary. Use pagination or limits.
|
||||
5. **Add integration tests:** Write real MCP `tools/call` tests that verify your tools work end-to-end.
|
||||
|
||||
### Debugging Extension Tools
|
||||
|
||||
- **Check the MCP log:** `logs/mcp.log` contains startup and invocation errors.
|
||||
- **Verify tool registration:** Call `tools/list` and ensure your custom tools appear.
|
||||
- **Test auto-pause behavior:** If your tool accesses emulator state, ensure it pauses correctly or mark it with `[McpManualControl]`.
|
||||
|
||||
---
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
### AI-Driven Reverse Engineering
|
||||
|
||||
An AI agent can:
|
||||
1. Call `read_cpu_state` to see where the program is stuck.
|
||||
2. Call `read_disassembly` to inspect the next 10 instructions.
|
||||
3. Call `search_memory` to find a string or data pattern.
|
||||
4. Call `add_execution_breakpoint` to pause at a suspect function.
|
||||
5. Call `list_functions` to see which functions are called most often.
|
||||
6. Call `capture_screenshot` to see the current video output.
|
||||
|
||||
### Automated Testing
|
||||
|
||||
A test script can:
|
||||
1. Call `pause` to halt execution.
|
||||
2. Call `write_memory` to inject test data.
|
||||
3. Call `resume` and wait for a breakpoint.
|
||||
4. Call `read_dos_file_handle_table` to verify the program opened the expected file.
|
||||
5. Call `capture_screenshot` and compare against a baseline image.
|
||||
|
||||
### Game Trainer / Cheat Tool
|
||||
|
||||
A trainer tool can:
|
||||
1. Call `read_dos_psp` to locate the game's data segment.
|
||||
2. Call `search_memory` to find the player's health value.
|
||||
3. Call `write_memory` to set health to max.
|
||||
4. Call `add_memory_write_breakpoint` to detect when the game decrements health.
|
||||
|
||||
### Live Debugging Dashboard
|
||||
|
||||
A web dashboard can:
|
||||
1. Poll `read_cpu_state` every 500ms to display registers.
|
||||
2. Call `read_video_state` to show current video mode.
|
||||
3. Call `read_sound_blaster_state` to visualize audio channels.
|
||||
4. Call `list_functions` to show a live call-count heatmap.
|
||||
|
||||
---
|
||||
|
||||
## Logs & Troubleshooting
|
||||
|
||||
- **MCP server log:** `logs/mcp.log` (warning level by default)
|
||||
- **Emulator logs:** Console or file (controlled by `--VerboseLogs`, `--WarningLogs`, `--SilencedLogs`)
|
||||
- **Health check:** `GET http://localhost:8081/health` should return `{"status":"ok","service":"Spice86 MCP Server"}`
|
||||
|
||||
**Common issues:**
|
||||
|
||||
| Problem | Solution |
|
||||
|---------|----------|
|
||||
| Client gets 404 on `/mcp` | Check that `--mcp-http-port` is set and the server started successfully |
|
||||
| Tools return "Tool disabled" error | Some tools may be disabled if the emulator is not in the expected state (e.g., video tools when no VGA card is initialized) |
|
||||
| Tools time out | If emulator is not responding to pause requests, ensure the emulation loop is running and not deadlocked |
|
||||
| Client skips session ID and gets 404 | Ensure stateless mode is enabled (default); if using stateful mode, ensure client sends `Mcp-Session-Id` header |
|
||||
|
||||
---
|
||||
|
||||
## Reference
|
||||
|
||||
### Related Files
|
||||
|
||||
- `Spice86.Core/Emulator/Mcp/McpHttpHost.cs` - HTTP server setup and lifecycle
|
||||
- `Spice86.Core/Emulator/Mcp/EmulatorMcpTools.cs` - Built-in tool implementations
|
||||
- `Spice86.Core/Emulator/Mcp/EmulatorMcpServices.cs` - Injected services for built-in tools
|
||||
- `Spice86.Core/Emulator/Mcp/IMcpToolSupplier.cs` - Extension interface for custom tools
|
||||
- `Spice86.Core/Emulator/Mcp/Response/McpAboutResponse.cs` - Metadata response structure
|
||||
|
||||
### Further Reading
|
||||
|
||||
- [Model Context Protocol Specification](https://modelcontextprotocol.io/)
|
||||
- [Spice86 CFG CPU Documentation](cfgcpuReadme.md)
|
||||
- [Spice86 Internal Debugger Wiki](https://github.com/OpenRakis/Spice86/wiki/Spice86-internal-debugger)
|
||||
- [Cryogenic Project (MCP Extension Example)](https://github.com/OpenRakis/Cryogenic)
|
||||
|
||||
**Quick links:**
|
||||
- Health check: `http://localhost:8081/health`
|
||||
- MCP endpoint: `http://localhost:8081/mcp`
|
||||
- Tool discovery: Call `tools/list` or `mcp_about`
|
||||
99
docs/spice86/spice86.md
Normal file
99
docs/spice86/spice86.md
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
## Setup
|
||||
|
||||
- Spice86 executable: `I:\Apps\Spice86\win-x64\Spice86.exe`
|
||||
- Test installation: `G:\games\Crusader No Remorse`
|
||||
- MCP endpoint: `http://localhost:8281/mcp`
|
||||
- Spice86 HTTP API: `http://127.0.0.1:20000` (started by the tested launch)
|
||||
- GDB server: `localhost:10000` (started by the tested launch)
|
||||
- Recorded-data root: `K:\ghidra\Crusader_Decomp\spice86`
|
||||
|
||||
Use the installed GOG game directory as the emulated C: drive. The standalone
|
||||
repository executable is not a substitute for this installation when testing
|
||||
game startup.
|
||||
|
||||
## Launch
|
||||
|
||||
Run from PowerShell:
|
||||
|
||||
```powershell
|
||||
& 'I:\Apps\Spice86\win-x64\Spice86.exe' `
|
||||
-c 'G:\games\Crusader No Remorse' `
|
||||
-e 'G:\games\Crusader No Remorse\CRUSADER.EXE' `
|
||||
-a '-warp 0 23807 25343 0 -mapoff 13' `
|
||||
-r 'K:\ghidra\Crusader_Decomp\spice86' `
|
||||
--McpHttpPort 8281
|
||||
```
|
||||
|
||||
The arguments match `dosboxCRUSADER_single.conf`. Spice86 creates a
|
||||
program-SHA-256 subdirectory beneath the `-r` root. Dumps are written on a
|
||||
completed emulator run; a directory by itself is not evidence that a dump was
|
||||
produced.
|
||||
|
||||
## First Debug
|
||||
|
||||
1. Start the command above and confirm the log says the MCP HTTP server is
|
||||
listening on port `8281`.
|
||||
2. Check `http://localhost:8281/health`; the tested response was
|
||||
`{"status":"ok"}`.
|
||||
3. Send MCP JSON-RPC requests to `/mcp` with both
|
||||
`Content-Type: application/json` and
|
||||
`Accept: application/json, text/event-stream`. Without the `Accept` header,
|
||||
the initialize request returned HTTP 406. Use the documented sequence:
|
||||
`initialize`, then `tools/list`.
|
||||
4. For the first guest stop, call `read_cpu_state` and
|
||||
`read_disassembly` at the reported `CS:IP`. Check `get_pause_status` before
|
||||
trying execution controls. Use `read_video_state` or `capture_screenshot`
|
||||
only if the guest reaches a useful screen.
|
||||
5. Save the terminal error and MCP state with the run notes. Do not interpret a
|
||||
healthy MCP endpoint as proof that the game started.
|
||||
|
||||
## Test Log
|
||||
|
||||
- Spice86 and its HTTP API, MCP endpoint, and GDB server all started with the
|
||||
installed game. MCP health, initialization, tool discovery, CPU-state reads,
|
||||
and disassembly reads worked on port `8281`.
|
||||
- Both the default CPU model and `--CpuModel INTEL_80386` halted before the
|
||||
game screen at `0257:23D4` with `Invalid opcode 0xF01`. The startup log also
|
||||
reports an unsuccessful open of `386MAX$$` at `0257:C6F0`; its relationship
|
||||
to the opcode fault is not confirmed.
|
||||
- The Spice86 README says 80286 protected mode is not implemented and 80386
|
||||
support is partial, with protected mode not implemented. This is a likely
|
||||
compatibility barrier for the game's Phar Lap DOS extender, not yet a
|
||||
proven explanation for this exact fault.
|
||||
- A diagnostic retry with `--FailOnInvalidOpcode false` moved the fault to an
|
||||
uninitialized interrupt vector at `0:0`. Adding `--AllowIvtAddress0` did
|
||||
not recover: execution repeatedly reported `CALL STACK DEPTH EXCEEDED 1000`
|
||||
at `0000:002F`. That run was stopped. Do not use these flags as a startup
|
||||
workaround.
|
||||
- `--CpuModel INTEL_80386 --Ems false --Xms false` also halted at
|
||||
`0257:23D4` with the same invalid opcode. It additionally logged an
|
||||
unhandled `INT 2Fh` subfunction `1687` (DPMI host detection) and missing
|
||||
`EMMXXXX0`, `EMMQXXX0`, and `$MMXXXX0` names. The memory toggles do not
|
||||
resolve the CPU/DPMI startup barrier.
|
||||
- `--CpuModel INTEL_80286 --Ems false --Xms false` produced the same DPMI
|
||||
probe and opcode halt. Together with the default-memory runs, both CPU
|
||||
models have now been tested with EMS/XMS on and off; none booted the game.
|
||||
- A read-only hash check found the installed `CRUSADER.EXE.BAK` has the same
|
||||
SHA-256 as the standalone executable tried earlier, so it is not a new
|
||||
binary variant to test.
|
||||
- The DOSBox profile mounts `GAME.GOG` as D:, while the tested Spice86 command
|
||||
provides only C:. CD-drive parity remains untested, but it is separate from
|
||||
the current early CPU/DPMI halt.
|
||||
- The recorded-data directory
|
||||
`spice86\97317993EFFE2FAB37C4C10105B3388E5948ECB8001E3340DF87FA0E743214C9`
|
||||
was created, but was empty when checked. No generated CFG, memory dump, or
|
||||
C# project has been verified yet.
|
||||
|
||||
## Next Run
|
||||
|
||||
1. Keep the default invalid-opcode behavior; the ignored-fault path loops at
|
||||
`0000:002F` rather than booting the game.
|
||||
2. Further progress with Spice86 likely requires DPMI/protected-mode support;
|
||||
both CPU models, with EMS/XMS enabled and disabled, stop at the same
|
||||
instruction. Do not attribute the exact opcode fault to protected mode
|
||||
without confirming the instruction semantics in a compatible emulator.
|
||||
3. If the CPU/DPMI barrier is resolved, next test the profile's `GAME.GOG` as
|
||||
D: because the current Spice86 launch maps only the installed C: directory.
|
||||
4. Only record generated output as successful after verifying files appear in
|
||||
the hash subdirectory. The current confirmed success is MCP-based runtime
|
||||
inspection, not Crusader gameplay or dump generation.
|
||||
311
tools/jp_executable_documentation_report.py
Normal file
311
tools/jp_executable_documentation_report.py
Normal file
|
|
@ -0,0 +1,311 @@
|
|||
"""Report JP executable documentation and Ghidra analysis coverage.
|
||||
|
||||
Run with /ja/CRUSADER.EXE active in Ghidra, using Script Manager or the live
|
||||
Ghidra MCP read-only script endpoint. The script does not modify the program.
|
||||
|
||||
The primary progress proxy is exact function-entry addresses listed in
|
||||
JP-address tables in docs/jp-remorse-decompilation-progress.md. This measures
|
||||
address tracking, not semantic completeness; naming, comments, and byte
|
||||
coverage are reported separately.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
from ghidra.program.model.address import AddressSet
|
||||
|
||||
|
||||
DOCUMENT_NAME = "jp-remorse-decompilation-progress.md"
|
||||
GENERATED_NAME_PREFIXES = ("FUN_", "thunk_FUN_", "LAB_", "SUB_")
|
||||
REPORT_LIST_LIMIT = 20
|
||||
ADDRESS_BUCKET_SIZE = 0x10000
|
||||
|
||||
|
||||
def find_progress_document():
|
||||
candidate_paths = []
|
||||
configured_root = os.environ.get("CRUSADER_DECOMP_ROOT")
|
||||
if configured_root:
|
||||
candidate_paths.append(
|
||||
os.path.join(configured_root, "docs", DOCUMENT_NAME)
|
||||
)
|
||||
|
||||
possible_roots = []
|
||||
script_path = globals().get("__file__")
|
||||
if script_path:
|
||||
possible_roots.append(os.path.dirname(os.path.abspath(script_path)))
|
||||
possible_roots.append(os.getcwd())
|
||||
|
||||
for possible_root in possible_roots:
|
||||
current_path = os.path.abspath(possible_root)
|
||||
for unused_level in range(8):
|
||||
candidate_paths.append(
|
||||
os.path.join(current_path, "docs", DOCUMENT_NAME)
|
||||
)
|
||||
parent_path = os.path.dirname(current_path)
|
||||
if parent_path == current_path:
|
||||
break
|
||||
current_path = parent_path
|
||||
|
||||
candidate_paths.append(
|
||||
os.path.join(
|
||||
r"K:\ghidra\Crusader_Decomp", "docs", DOCUMENT_NAME
|
||||
)
|
||||
)
|
||||
|
||||
checked_paths = set()
|
||||
for candidate_path in candidate_paths:
|
||||
normalized_path = os.path.abspath(candidate_path)
|
||||
if normalized_path in checked_paths:
|
||||
continue
|
||||
checked_paths.add(normalized_path)
|
||||
if os.path.isfile(normalized_path):
|
||||
return normalized_path
|
||||
|
||||
raise RuntimeError(
|
||||
"Could not locate docs/" + DOCUMENT_NAME
|
||||
+ ". Set CRUSADER_DECOMP_ROOT to the repository root."
|
||||
)
|
||||
|
||||
|
||||
def collect_progress_addresses(document_text):
|
||||
addresses = set()
|
||||
in_address_table = False
|
||||
|
||||
for line in document_text.splitlines():
|
||||
stripped_line = line.strip()
|
||||
if re.match(r"^\|\s*JP address\s*\|", stripped_line):
|
||||
in_address_table = True
|
||||
continue
|
||||
if not stripped_line.startswith("|"):
|
||||
in_address_table = False
|
||||
continue
|
||||
if not in_address_table:
|
||||
continue
|
||||
|
||||
cells = stripped_line.split("|")
|
||||
if len(cells) < 3:
|
||||
continue
|
||||
first_cell = cells[1]
|
||||
for address_part in first_cell.split(","):
|
||||
token = address_part.replace("`", "").strip()
|
||||
match = re.fullmatch(r"(?:0[xX])?([0-9a-fA-F]{8})", token)
|
||||
if match:
|
||||
addresses.add(match.group(1).upper())
|
||||
|
||||
return addresses
|
||||
|
||||
|
||||
def is_generated_function_name(name):
|
||||
return name.startswith(GENERATED_NAME_PREFIXES)
|
||||
|
||||
|
||||
def format_percent(numerator, denominator):
|
||||
if denominator == 0:
|
||||
return "n/a"
|
||||
return "{:.1f}%".format(100.0 * numerator / denominator)
|
||||
|
||||
|
||||
def build_report(program):
|
||||
progress_path = find_progress_document()
|
||||
with open(progress_path, "r", encoding="utf-8") as progress_file:
|
||||
progress_text = progress_file.read()
|
||||
progress_addresses = collect_progress_addresses(progress_text)
|
||||
|
||||
memory = program.getMemory()
|
||||
executable_addresses = AddressSet()
|
||||
executable_bytes = 0
|
||||
executable_block_count = 0
|
||||
for memory_block in memory.getBlocks():
|
||||
if memory_block.isExecute():
|
||||
executable_addresses.add(
|
||||
memory_block.getStart(), memory_block.getEnd()
|
||||
)
|
||||
executable_bytes += int(memory_block.getSize())
|
||||
executable_block_count += 1
|
||||
|
||||
function_manager = program.getFunctionManager()
|
||||
all_function_count = int(function_manager.getFunctionCount())
|
||||
functions_by_entry = {}
|
||||
function_body_union = AddressSet()
|
||||
function_body_bytes_sum = 0
|
||||
generated_name_count = 0
|
||||
function_comment_count = 0
|
||||
thunk_count = 0
|
||||
|
||||
function_iterator = function_manager.getFunctions(True)
|
||||
while function_iterator.hasNext():
|
||||
function = function_iterator.next()
|
||||
entry = function.getEntryPoint()
|
||||
memory_block = memory.getBlock(entry)
|
||||
if memory_block is None or not memory_block.isExecute():
|
||||
continue
|
||||
|
||||
entry_text = str(entry).upper()
|
||||
functions_by_entry[entry_text] = function
|
||||
clipped_body = function.getBody().intersect(executable_addresses)
|
||||
function_body_bytes_sum += int(clipped_body.getNumAddresses())
|
||||
function_body_union.add(clipped_body)
|
||||
|
||||
if is_generated_function_name(function.getName()):
|
||||
generated_name_count += 1
|
||||
if function.getComment() and str(function.getComment()).strip():
|
||||
function_comment_count += 1
|
||||
if function.isThunk():
|
||||
thunk_count += 1
|
||||
|
||||
function_count = len(functions_by_entry)
|
||||
function_body_unique_bytes = int(function_body_union.getNumAddresses())
|
||||
tracked_entries = set(functions_by_entry).intersection(progress_addresses)
|
||||
untracked_functions = [
|
||||
function
|
||||
for entry_text, function in functions_by_entry.items()
|
||||
if entry_text not in tracked_entries
|
||||
]
|
||||
untracked_functions.sort(key=lambda function: function.getEntryPoint().getOffset())
|
||||
|
||||
tracked_generated_count = sum(
|
||||
1
|
||||
for entry_text in tracked_entries
|
||||
if is_generated_function_name(functions_by_entry[entry_text].getName())
|
||||
)
|
||||
tracked_named_count = len(tracked_entries) - tracked_generated_count
|
||||
untracked_named_count = sum(
|
||||
1
|
||||
for function in untracked_functions
|
||||
if not is_generated_function_name(function.getName())
|
||||
)
|
||||
unmatched_document_addresses = sorted(
|
||||
progress_addresses.difference(functions_by_entry)
|
||||
)
|
||||
|
||||
instruction_count = 0
|
||||
instruction_bytes = 0
|
||||
instruction_iterator = program.getListing().getInstructions(
|
||||
executable_addresses, True
|
||||
)
|
||||
while instruction_iterator.hasNext():
|
||||
instruction = instruction_iterator.next()
|
||||
instruction_count += 1
|
||||
instruction_bytes += int(instruction.getLength())
|
||||
|
||||
untracked_by_bucket = {}
|
||||
for function in untracked_functions:
|
||||
offset = int(function.getEntryPoint().getOffset())
|
||||
bucket_start = (offset // ADDRESS_BUCKET_SIZE) * ADDRESS_BUCKET_SIZE
|
||||
untracked_by_bucket[bucket_start] = (
|
||||
untracked_by_bucket.get(bucket_start, 0) + 1
|
||||
)
|
||||
|
||||
report_lines = [
|
||||
"# JP Executable Documentation Coverage",
|
||||
"",
|
||||
"- Target: `{}` (`{}`), image base `{}`".format(
|
||||
program.getName(), program.getDomainFile().getPathname(),
|
||||
program.getImageBase()
|
||||
),
|
||||
"- Progress source: `{}`".format(progress_path),
|
||||
"- Metric: exact function-entry addresses in `JP address` tables; this is address tracking, not a semantic-completeness score.",
|
||||
"",
|
||||
"## Documentation and Names",
|
||||
"",
|
||||
"- Ghidra functions across all address spaces: **{}**".format(
|
||||
all_function_count
|
||||
),
|
||||
"- Executable functions: **{}**".format(function_count),
|
||||
"- Ledger-tracked function entries: **{} / {} ({})**".format(
|
||||
len(tracked_entries), function_count,
|
||||
format_percent(len(tracked_entries), function_count)
|
||||
),
|
||||
"- Not yet listed in the primary progress tables: **{} ({})**".format(
|
||||
len(untracked_functions),
|
||||
format_percent(len(untracked_functions), function_count)
|
||||
),
|
||||
"- Tracked entries with descriptive Ghidra names: **{}**".format(
|
||||
tracked_named_count
|
||||
),
|
||||
"- Tracked entries still using generated names: **{}**".format(
|
||||
tracked_generated_count
|
||||
),
|
||||
"- Descriptive Ghidra names outside the progress tables: **{}**".format(
|
||||
untracked_named_count
|
||||
),
|
||||
"- Functions with a Ghidra function comment: **{} / {} ({})**".format(
|
||||
function_comment_count, function_count,
|
||||
format_percent(function_comment_count, function_count)
|
||||
),
|
||||
"- Thunk functions: **{}**".format(thunk_count),
|
||||
"- Progress-table addresses that are not executable function entries: **{}**".format(
|
||||
len(unmatched_document_addresses)
|
||||
),
|
||||
"",
|
||||
"## Executable Byte Coverage",
|
||||
"",
|
||||
"- Executable memory blocks: **{}**".format(executable_block_count),
|
||||
"- Executable memory bytes: **{}**".format(executable_bytes),
|
||||
"- Bytes covered by at least one defined function body: **{} / {} ({})**".format(
|
||||
function_body_unique_bytes, executable_bytes,
|
||||
format_percent(function_body_unique_bytes, executable_bytes)
|
||||
),
|
||||
"- Sum of function-body byte sizes (overlaps can count more than once): **{}**".format(
|
||||
function_body_bytes_sum
|
||||
),
|
||||
"- Defined instruction bytes: **{} / {} ({})** across **{} instructions**".format(
|
||||
instruction_bytes, executable_bytes,
|
||||
format_percent(instruction_bytes, executable_bytes),
|
||||
instruction_count
|
||||
),
|
||||
"- Executable bytes outside defined instructions: **{}** (may include data, padding, or unanalyzed code)".format(
|
||||
executable_bytes - instruction_bytes
|
||||
),
|
||||
"",
|
||||
"## Untracked Functions by 64 KiB Address Bucket",
|
||||
"",
|
||||
]
|
||||
|
||||
if untracked_by_bucket:
|
||||
for bucket_start in sorted(untracked_by_bucket):
|
||||
bucket_end = bucket_start + ADDRESS_BUCKET_SIZE - 1
|
||||
report_lines.append(
|
||||
"- `{:08X}-{:08X}`: {} untracked functions".format(
|
||||
bucket_start, bucket_end,
|
||||
untracked_by_bucket[bucket_start]
|
||||
)
|
||||
)
|
||||
else:
|
||||
report_lines.append("- None")
|
||||
|
||||
report_lines.extend(["", "## Next Untracked Entries", ""])
|
||||
for function in untracked_functions[:REPORT_LIST_LIMIT]:
|
||||
report_lines.append(
|
||||
"- `{}` `{}`".format(
|
||||
function.getEntryPoint(), function.getName()
|
||||
)
|
||||
)
|
||||
if not untracked_functions:
|
||||
report_lines.append("- None")
|
||||
elif len(untracked_functions) > REPORT_LIST_LIMIT:
|
||||
report_lines.append(
|
||||
"- Showing first {} of {} untracked functions.".format(
|
||||
REPORT_LIST_LIMIT, len(untracked_functions)
|
||||
)
|
||||
)
|
||||
|
||||
if unmatched_document_addresses:
|
||||
report_lines.extend(["", "## Unmatched Table Addresses", ""])
|
||||
for address_text in unmatched_document_addresses[:REPORT_LIST_LIMIT]:
|
||||
report_lines.append("- `{}`".format(address_text))
|
||||
if len(unmatched_document_addresses) > REPORT_LIST_LIMIT:
|
||||
report_lines.append(
|
||||
"- Showing first {} of {} unmatched addresses.".format(
|
||||
REPORT_LIST_LIMIT, len(unmatched_document_addresses)
|
||||
)
|
||||
)
|
||||
|
||||
report_lines.extend([
|
||||
"",
|
||||
"Generated from the active Ghidra program. Ghidra project state and executable bytes were not modified.",
|
||||
])
|
||||
return "\n".join(report_lines)
|
||||
|
||||
|
||||
print(build_report(currentProgram))
|
||||
Loading…
Add table
Add a link
Reference in a new issue