/** * Patch a copy of aces.exe with every definition under the exe patch folder. A patch that cannot * be applied (site missing or ambiguous, original bytes differ, or a patch it requires failed) is * left out and listed with the features it covers; whether a copy with * patches missing may be installed is the caller's decision (essential-features.ts). */ import { applyWrites, describePlan, loadPatches, PeImage, planPatches, type PatchPlan } from '@wto/exepatch'; export interface ExecutableResult { /** The executable with every available patch written. */ readonly executable: Uint8Array; readonly plan: PatchPlan; readonly description: string; } export function patchExecutable(stockExecutable: Uint8Array, patchesRoot: string): ExecutableResult { const plan = planPatches(new PeImage(stockExecutable), loadPatches(patchesRoot)); return { executable: applyWrites(stockExecutable, plan.writes), plan, description: describePlan(plan) }; }