mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
cab78de506
* feat(domain): parse and validate GameCube/Wii DOL headers Add a pure parser for the 0x100-byte DOL header (7 text and 11 data slots, BSS, entry point). Used slots must lie after the header and inside the file and the 0x80000000..0x81800000 load window; text slots are 4-byte aligned; sections may not overlap in memory or in the file; the entry point must be inside a text section. BSS may overlap data sections, as .sdata/.sdata2 do in shipped DOLs. Refs #1741 * feat(binary): admit caller-selected GameCube/Wii DOL targets * feat(ghidra): import GameCube/Wii DOL targets through a section-map pre-script * test(ghidra): cover DOL launcher arguments, attestation and raw profile digests * test(ghidra): add the real verify:ghidra:dol lane and DOL docs * fix(ghidra): read only the DOL header and section ranges instead of the whole file * test(ghidra): derive DOL lane addresses from readelf and admit Gekko from the install catalog * fix(ghidra): attest DOL block permissions, space, overlay and load state * fix(ghidra): keep load-image permissions optional for older inspections * fix(contracts): accept DOL targets in binary_session output * fix(ghidra): adapt the DOL lane to the current upstream address schema Validate DOL load-image coordinates with the upstream observed-address schema, drop a duplicate import left by the rebase, and re-pin the raw profile digests to the unmodified upstream resolver. * fix(ghidra): preserve bridge inventory symbol provenance * fix(ghidra): align DOL verification with shared workflow contracts * feat(domain): parse and validate GameCube/Wii DOL headers Add a pure parser for the 0x100-byte DOL header (7 text and 11 data slots, BSS, entry point). Used slots must lie after the header and inside the file and the 0x80000000..0x81800000 load window; text slots are 4-byte aligned; sections may not overlap in memory or in the file; the entry point must be inside a text section. BSS may overlap data sections, as .sdata/.sdata2 do in shipped DOLs. Refs #1741 * feat(binary): admit caller-selected GameCube/Wii DOL targets * feat(ghidra): import GameCube/Wii DOL targets through a section-map pre-script * test(ghidra): cover DOL launcher arguments, attestation and raw profile digests * test(ghidra): add the real verify:ghidra:dol lane and DOL docs * fix(ghidra): read only the DOL header and section ranges instead of the whole file * test(ghidra): derive DOL lane addresses from readelf and admit Gekko from the install catalog * fix(ghidra): attest DOL block permissions, space, overlay and load state * fix(ghidra): keep load-image permissions optional for older inspections * fix(contracts): accept DOL targets in binary_session output * fix(ghidra): adapt the DOL lane to the current upstream address schema Validate DOL load-image coordinates with the upstream observed-address schema, drop a duplicate import left by the rebase, and re-pin the raw profile digests to the unmodified upstream resolver. * docs(ghidra): qualify the DOL memory window * refactor(ghidra): own DOL BSS ranges in the parsed header * docs(ghidra): record real DOL workflows and task costs * docs(ghidra): record final DOL integration verification * fix(mcp): share the native procedure search row contract * docs(ghidra): record public procedure search verification --------- Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
90 lines
3.2 KiB
TypeScript
90 lines
3.2 KiB
TypeScript
import { z } from "incur";
|
|
|
|
import {
|
|
executableFormatHintSchema,
|
|
type ExecutableFormatHint,
|
|
} from "../domain/dosCom.js";
|
|
import type { BinaryArchitecture } from "../domain/binaryTargetTypes.js";
|
|
import {
|
|
binaryArchitectureSchema,
|
|
rawBinaryEntryPointSchema,
|
|
} from "../domain/rawBinary.js";
|
|
import { analysisProviderSelectorSchema } from "../contracts/providerSelection.js";
|
|
import type { AnalysisProviderSelector } from "../contracts/providerSelection.js";
|
|
import type { Logger } from "pino";
|
|
|
|
/** Parse decimal integer tokens before Number coercion can erase their syntax. */
|
|
export const cliIntegerArgument = (min: number) =>
|
|
z
|
|
.string()
|
|
.regex(/^[0-9]+$/u, "Expected a decimal integer")
|
|
.pipe(z.coerce.number<string>().safe().min(min));
|
|
|
|
export const providerSelectionOption = analysisProviderSelectorSchema
|
|
.optional()
|
|
.describe(
|
|
"Bind deep analysis to a provider ID or use deterministic auto selection",
|
|
);
|
|
|
|
/** Optional path to the local analysis snapshot loaded or updated by a command. */
|
|
export const snapshotSelectionOption = z
|
|
.string()
|
|
.min(1)
|
|
.optional()
|
|
.describe("Load and update a local analysis snapshot");
|
|
|
|
/** Explicit interpretation for headerless native executable formats. */
|
|
export const formatSelectionOption = executableFormatHintSchema
|
|
.optional()
|
|
.describe(
|
|
"Explicit interpretation: dos-com or raw-binary (headerless), or gamecube-dol (GameCube/Wii DOL, never auto-detected); omission preserves header-based detection",
|
|
);
|
|
|
|
export const architectureSelectionOption = binaryArchitectureSchema
|
|
.optional()
|
|
.describe(
|
|
"Caller-supplied CPU family; required with --target-format raw-binary, must be omitted with gamecube-dol",
|
|
);
|
|
|
|
export const entryPointSelectionOption = rawBinaryEntryPointSchema
|
|
.optional()
|
|
.describe(
|
|
"Caller-supplied load and entry address (0xhex); required with --target-format raw-binary, optional with gamecube-dol (must equal the DOL header entry)",
|
|
);
|
|
|
|
/** Shared CLI flags that bind a native target interpretation. */
|
|
export const nativeOpenOptionFields = {
|
|
"target-format": formatSelectionOption,
|
|
architecture: architectureSelectionOption,
|
|
"entry-point": entryPointSelectionOption,
|
|
provider: providerSelectionOption,
|
|
};
|
|
|
|
/** Native CLI flags consumed when opening a target for one-shot analysis. */
|
|
export interface NativeOpenCliFlags {
|
|
readonly snapshot?: string | undefined;
|
|
readonly provider?: AnalysisProviderSelector | undefined;
|
|
readonly "target-format"?: ExecutableFormatHint | undefined;
|
|
readonly architecture?: BinaryArchitecture | undefined;
|
|
readonly "entry-point"?: string | undefined;
|
|
}
|
|
|
|
/** Map native CLI flags onto the shared one-shot analysis options. */
|
|
export const directAnalysisOptionsFromCli = (
|
|
logger: Logger,
|
|
options: NativeOpenCliFlags,
|
|
) => ({
|
|
logger,
|
|
snapshotPath: options.snapshot,
|
|
...(options["target-format"] === undefined
|
|
? {}
|
|
: { formatHint: options["target-format"] }),
|
|
...(options.architecture === undefined
|
|
? {}
|
|
: { architecture: options.architecture }),
|
|
...(options["entry-point"] === undefined
|
|
? {}
|
|
: { entryPoint: options["entry-point"] }),
|
|
...(options.provider === undefined ? {} : { providerId: options.provider }),
|
|
});
|