/** * 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) }; }