This commit is contained in:
Maddo 2026-10-11 18:49:46 +02:00
commit ec236a2430
27 changed files with 3796 additions and 4 deletions

View 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.

View 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`.

View 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.

View 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).

View 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.

View 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).

View 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
View file

@ -54,3 +54,4 @@ rebuild/**/imported/**
**/dist/**
**/.vite/**
*.log
JP/**

View file

@ -10,6 +10,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="3757476628342578775" />
</COMPONENT_NODE>
<COMPONENT_NODE TOP_INFO="0">
<COMPONENT_INFO NAME="Symbol Tree" OWNER="SymbolTreePlugin" TITLE="Symbol Tree" ACTIVE="true" GROUP="Default" INSTANCE_ID="3757476628342578770" />
</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="3757480742898179651" />
</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="3757476628342578783" />
</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="3757476628342578778" />
<COMPONENT_INFO NAME="Data Window" OWNER="DataWindowPlugin" TITLE="Defined Data" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757480742898179655" />
<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="3757476628342578781" />
<COMPONENT_INFO NAME="External Programs" OWNER="ReferencesPlugin" TITLE="External Programs" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757480742866722369" />
<COMPONENT_INFO NAME="Functions Window" OWNER="FunctionWindowPlugin" TITLE="Functions" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757480742866722372" />
<COMPONENT_INFO NAME="Relocation Table" OWNER="RelocationTablePlugin" TITLE="Relocation Table" ACTIVE="false" GROUP="Default" INSTANCE_ID="3757480742898179659" />
</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="3757480742898179649" />
</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="3757476628342578780" />
</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="3757476628342578777" />
<COMPONENT_INFO NAME="Bookmarks" OWNER="BookmarkPlugin" TITLE="Bookmarks" ACTIVE="false" GROUP="Core.Bookmarks" INSTANCE_ID="3757476628342578774" />
</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="3757476628342578771" />
</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="3757476628342578772" />
</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="3757476628342578768" />
</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="3757480742898179661" />
</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="3757480742866722371" />
</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="3757480742898179656" />
</COMPONENT_NODE>
<COMPONENT_NODE TOP_INFO="0">
<COMPONENT_INFO NAME="Symbol References" OWNER="SymbolTablePlugin" TITLE="Symbol References" ACTIVE="false" GROUP="symbolTable" INSTANCE_ID="3757480742898179657" />
</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="3757476628342578782" />
</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="3757480742898179652" />
</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="3757480742898179654" />
</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="3757480742898179653" />
</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="3757480742866722370" />
</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="3757476628342578773" />
</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="3757480742898179650" />
</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="3757480742898179658" />
</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="84" />
<STATE NAME="NAV_ID" TYPE="long" VALUE="3757476628342578776" />
<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>
<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="376076" />
<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>

View file

@ -17,6 +17,12 @@
},
{
"path": "I:/Apps/ghidra_12.1.4_PUBLIC"
},
{
"path": "C:/RE/CRUSADER_JP_ISO"
},
{
"path": "C:/RE/Star Wars - Shadows of the Empire"
}
],
"settings": {

View 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.

View 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.

View 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.

View 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.

File diff suppressed because it is too large Load diff

View 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)

View 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.

View file

@ -7,8 +7,9 @@ The Japanese No Remorse release is a credible base for a **separate Windows-nati
| 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 | **Plausible; runtime proof needed** | The game is a Win32 PE and does not require DOSBox by architecture. DirectDraw, DirectSound, display, and configuration behavior still need testing on current Windows. |
| 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.
@ -19,6 +20,8 @@ The prior [Win9x investigation](jp-remorse-windows9x-investigation.md) found tha
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.
@ -62,7 +65,131 @@ This makes unmodified direct launch the right first experiment. It does not prov
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: **native Windows 10/11 support looks attainable and may work without a code patch, but is unverified.** If "native" means no DOSBox, the PE 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.
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
@ -88,7 +215,8 @@ No complete function-by-function JP-versus-Western diff is claimed. Existing evi
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, and directly inspected JP `video_init_directdraw_and_directsound` at `004459b0`. It does not claim a Windows 95/10/11 runtime pass, successful JP asset rebuild-and-load, or complete function-level equivalence. Those remain explicit validation gates.
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.

View 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))