Files
WT-Offline/packages/build/src/executable.ts
T
N0VAN0M4LY 5421268fbf Build a loopback client copy with TypeScript
Add the shared BLK, VROMFS, executable patch, and build packages. Preserve
typed fields and shared name tables when reading BLK data. Rewrite the
service endpoints in place so the original environment names remain
available to the client, then build the client copy.
2026-11-24 00:35:13 +08:00

20 lines
887 B
TypeScript

/**
* Patch a copy of aces.exe with every definition under exe-patches/. When any patch cannot be
* applied, no executable is produced; the result lists the unavailable patches and the
* features they cover.
*/
import { applyWrites, describePlan, loadPatches, PeImage, planPatches, type PatchPlan } from '@wto/exepatch';
export interface ExecutableResult {
/** The patched executable, or null when some patch was unavailable. */
readonly executable: Uint8Array | null;
readonly plan: PatchPlan;
readonly description: string;
}
export function patchExecutable(stockExecutable: Uint8Array, patchesRoot: string): ExecutableResult {
const plan = planPatches(new PeImage(stockExecutable), loadPatches(patchesRoot));
const executable = plan.failures.length ? null : applyWrites(stockExecutable, plan.writes);
return { executable, plan, description: describePlan(plan) };
}