mirror of
https://github.com/morluto/rea.git
synced 2026-11-08 15:56:35 +00:00
feat(il2cpp): link native methods and export Ghidra seeds
Link IL2CPP metadata names to native addresses and types through shared CLI/MCP workflows, with bounded queries and atomic Ghidra seed export. Preserve the original implementation by 8rulerstar and follow-up correctness, resource, provenance, and CI dependency repairs. Verified against real Windows/Android artifacts, independent references, actual Ghidra, and focused CLI/MCP tests. Fixes #5112.
This commit is contained in:
1 parent
e50a271c72
commit
52d1a72af0
43 files changed
+5060
-368
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import { absoluteCallerPath } from "../filesystem/callerPath.js";
|
||||
import { z } from "incur";
|
||||
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
||||
import { err } from "../domain/result.js";
|
||||
import { createIl2cppMetadataService } from "../composition/il2cpp.js";
|
||||
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
||||
import { logCliCommand } from "../cliLogging.js";
|
||||
@@ -18,23 +20,83 @@ export const registerIl2cppCommands = (
|
||||
): void => {
|
||||
cli.command(CLI_COMMANDS.inspectIl2cppMetadata, {
|
||||
description:
|
||||
"Inventory IL2CPP global-metadata.dat names, owners and string literals",
|
||||
"Inventory IL2CPP global-metadata.dat names, owners and string literals, optionally linking method addresses from the native binary",
|
||||
args: z.object({
|
||||
path: z
|
||||
.string()
|
||||
.describe("Local global-metadata.dat (version 24, 27, 29, 31 or 39)"),
|
||||
}),
|
||||
options: z.object(analysisEvidenceDeliveryOptions),
|
||||
options: z.object({
|
||||
...analysisEvidenceDeliveryOptions,
|
||||
binary: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Matching native binary (Mach-O GameAssembly.dylib, PE GameAssembly.dll or ELF libil2cpp.so) to link method addresses; read only",
|
||||
),
|
||||
architecture: z
|
||||
.enum(["arm64", "amd64"])
|
||||
.optional()
|
||||
.describe("Slice of a universal Mach-O binary"),
|
||||
ghidraSeeds: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Also write REA_GHIDRA_SEED_FILE function seeds named Type$$Method for every linked method; needs --binary",
|
||||
),
|
||||
seedBase: z
|
||||
.string()
|
||||
.regex(/^0x[0-9a-fA-F]{1,16}$/u)
|
||||
.optional()
|
||||
.describe(
|
||||
"Address Ghidra loads the binary at; seeds are seed-base + RVA (default: Ghidra's loader default, 0x100000 for an ELF linked at 0, else the link base)",
|
||||
),
|
||||
}),
|
||||
run: ({ args, options }) =>
|
||||
withCommandCancellation((signal) =>
|
||||
logCliCommand(logger, CLI_COMMANDS.inspectIl2cppMetadata, async () => {
|
||||
const service = createIl2cppMetadataService();
|
||||
return deliverCliAnalysisEvidence({
|
||||
run: () =>
|
||||
service.inspect(
|
||||
{ path: absoluteCallerPath(args.path), detail: "complete" },
|
||||
{ signal },
|
||||
),
|
||||
run: () => {
|
||||
const input = {
|
||||
path: absoluteCallerPath(args.path),
|
||||
detail: "complete" as const,
|
||||
...(options.binary === undefined
|
||||
? {}
|
||||
: { binary_path: absoluteCallerPath(options.binary) }),
|
||||
...(options.architecture === undefined
|
||||
? {}
|
||||
: { binary_architecture: options.architecture }),
|
||||
};
|
||||
if (options.ghidraSeeds !== undefined)
|
||||
return service.inspectWithGhidraSeeds(
|
||||
input,
|
||||
{
|
||||
path: absoluteCallerPath(options.ghidraSeeds),
|
||||
...(options.seedBase === undefined
|
||||
? {}
|
||||
: { base: options.seedBase }),
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
if (options.seedBase !== undefined)
|
||||
return Promise.resolve(
|
||||
err(
|
||||
new AnalysisInputError(
|
||||
"inspect_il2cpp_metadata",
|
||||
undefined,
|
||||
[
|
||||
{
|
||||
path: ["seed_base"],
|
||||
reason: "invalid_value",
|
||||
message: "--seed-base requires --ghidra-seeds.",
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
return service.inspect(input, { signal });
|
||||
},
|
||||
service,
|
||||
providerId: "il2cpp-metadata",
|
||||
operation: "inspect_il2cpp_metadata",
|
||||
|
||||
Reference in new issue
Block a user