Files
reverse-engineering-anything/src/domain/desktopApplicationProjection.test.ts
T
JANG BYUNGKUNandgensokyo-dev abc647bf6c feat(desktop): suggest managed members for Unity script assemblies (#5511)
* feat(desktop): suggest managed members for Unity predefined script assemblies

Unity Mono triage listed only inspect_managed_artifact probes, mostly for
engine and framework assemblies. Assembly-CSharp.dll and
Assembly-CSharp-firstpass.dll directly in a managed directory with a
UnityEngine reference witness now get an inspect_managed_members probe,
ordered before every managed artifact probe.

* docs(desktop): describe Unity Mono managed member probes

* refactor(desktop): read Unity managed directory from the witness fact

* refactor(desktop): reuse the managed directory index for predefined assemblies

* feat(desktop): point Unity member probes at summary delivery first

* test(desktop): no member probes without a Unity reference witness

* docs(desktop): trim Unity member probe note

* feat(desktop): suggest managed members in Unity IL2CPP backup folders

Unity IL2CPP builds write <Product>_BackUpThisFolder_ButDontShipItWithYourGame
next to the player. When shipped, its Managed/ holds pre-IL2CPP assemblies.
A path convention now records the folder on Assembly-CSharp*.dll directly in
its Managed/, including when the admitted root is the folder itself, and
triage offers inspect_managed_members for those files. Correspondence to
the shipped native code stays unknown.

* docs(desktop): note IL2CPP backup folder member probes

* docs(desktop): list IL2CPP metadata versions 24 and 27 for the metadata probe

* style(desktop): merge stacked doc comments on desktopPathConventions

* test(desktop): cover member probes in a macOS bundle managed directory

* docs(desktop): note that member probes need the game folder as root

* test(desktop): no member probe when the root is the Unity data folder

* test(desktop): check the data-folder root still gets managed probes

* test(desktop): check the IL2CPP backup convention against the probe bound

---------

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-04 19:53:00 +08:00

92 lines
2.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { DesktopFact, DesktopFile } from "./desktopApplication.js";
import {
DESKTOP_PROBES_PER_FACT,
projectDesktopApplication,
} from "./desktopApplicationProjection.js";
const row = (path: string, facts: DesktopFact[]): DesktopFile => ({
file_id: `dsf_${"a".repeat(64)}`,
path,
local_path: `/fixture/${path}`,
kind: "file",
bytes: 1,
identity: null,
read_status: "examined",
ranges: [],
facts,
issues: [],
});
// Every fact kind, including the IL2CPP pair that offers a native probe.
const facts: DesktopFact[] = [
{ kind: "pe-cli-directory", offset: 0, value: { rva: 1, bytes: 72 } },
{
kind: "unity-assembly-reference",
offset: 0,
value: { name: "UnityEngine", token: "0x23000001", managed_directory: "M" },
},
{
kind: "native-image-header",
offset: 0,
value: { format: "mach-o", signature: "cffaedfe" },
},
{
kind: "il2cpp-metadata-header",
offset: 0,
value: { magic: "0xfab11baf", raw_version: 29 },
},
{
kind: "godot-pck-header",
offset: 0,
value: {
pack_version: 2,
engine_version: [4, 2, 0],
placement: "standalone",
},
},
{
kind: "unityfs-header",
offset: 0,
value: {
format_version: 8,
engine_version: "2022.3.0f1",
flags: 0,
declared_size: 1,
},
},
{
kind: "gamemaker-form-header",
offset: 0,
value: { container: "FORM", first_chunk: "GEN8" },
},
{ kind: "il2cpp-library-convention", offset: null, value: "p" },
{
kind: "unity-il2cpp-backup-convention",
offset: null,
value: { backup_directory: "B" },
},
{ kind: "electron-asar-convention", offset: null, value: "p" },
{ kind: "unreal-container-convention", offset: null, value: "p" },
];
describe("desktop next probe fan-out", () => {
it.each(facts)("derives at most the reserved probes from $kind", (fact) => {
const { next_probes } = projectDesktopApplication([
row("resources/app.asar", [fact]),
]);
expect(next_probes.length).toBeLessThanOrEqual(DESKTOP_PROBES_PER_FACT);
});
it("derives at most the reserved probes per fact on one file", () => {
const { next_probes } = projectDesktopApplication([
row("resources/app.asar", facts),
]);
expect(next_probes.length).toBeGreaterThan(0);
expect(next_probes.length).toBeLessThanOrEqual(
DESKTOP_PROBES_PER_FACT * facts.length,
);
});
});