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.
This commit is contained in:
N0VAN0M4LY committed 2026-11-24 00:35:13 +08:00
1 parent 0117c02677
commit 5421268fbf
44 files changed
+1986 -1

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
/**
* Write a verified plan into a copy of the executable's bytes. The expected original bytes
* are checked again right before each write, so a plan made against other bytes is refused
* instead of landing half applied. The input is never modified.
*/
import { VerifyError } from './errors.ts';
import type { PlannedWrite } from './plan.ts';
export function applyWrites(data: Uint8Array, writes: readonly PlannedWrite[]): Uint8Array {
const patched = Uint8Array.from(data);
for (const write of [...writes].sort((left, right) => left.fileOffset - right.fileOffset)) {
const end = write.fileOffset + write.payload.length;
const actual = Buffer.from(patched.subarray(write.fileOffset, end));
if (!actual.equals(write.expectOriginal)) {
throw new VerifyError(`${write.patchId}: bytes at file offset 0x${write.fileOffset.toString(16)} are ${actual.toString('hex')}, ` +
`expected ${Buffer.from(write.expectOriginal).toString('hex')}; nothing was written`);
}
patched.set(write.payload, write.fileOffset);
}
return patched;
}