From cf08034060ea0a96f9a830105a28f3c9322eee98 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Wed, 25 Nov 2026 11:00:48 +0800 Subject: [PATCH] Use 64-bit VROMFS digest offsets Read and write the digest table start as a 64-bit field in both codecs. The truncated offset caused SHA-1 mismatches in large packs such as ui/images.vromfs.bin and ui/atlases.vromfs.bin. Type checking passed and the service extracted icons and flags from the large packs. --- packages/vromfs/src/image.ts | 7 ++++--- tools/src/wtotools/vromfs/image.py | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/vromfs/src/image.ts b/packages/vromfs/src/image.ts index 5a620e8..d0d4b06 100644 --- a/packages/vromfs/src/image.ts +++ b/packages/vromfs/src/image.ts @@ -4,7 +4,8 @@ * Layout (every block aligned to 16 bytes): * 0x00 names header: u32 offset of the name-offset table, u32 file count * 0x10 data header: u32 offset of the data table, u32 file count - * 0x20 digest header: u64 end, u16 begin (only when names offset == 0x30) + * 0x20 digest header: u64 end, u64 begin (only when names offset == 0x30; begin + * exceeds 16 bits in large packs such as ui/images.vromfs.bin) * name offsets: count x u64, each pointing at a NUL-terminated path * names * data table: count x 16 bytes: u32 offset, u32 size, 8 bytes padding @@ -34,7 +35,7 @@ export function parseImage(image: Uint8Array): { layout: ImageLayout; files: Map const dataOffset = view.getUint32(0x10, true); if (view.getUint32(0x14, true) !== count) throw new VromfsFormatError('name count differs from data count'); const hasDigestHeader = namesOffset === 0x30; - const digestsBegin = hasDigestHeader ? view.getUint16(0x28, true) : 0; + const digestsBegin = hasDigestHeader ? Number(view.getBigUint64(0x28, true)) : 0; const files = new Map(); for (let index = 0; index < count; index++) { @@ -84,7 +85,7 @@ export function buildImage(layout: ImageLayout, files: ReadonlyMap { out.writeBigUInt64LE(BigInt(nameOffsets[index]!), namesOffset + index * 8); diff --git a/tools/src/wtotools/vromfs/image.py b/tools/src/wtotools/vromfs/image.py index 77397ea..2f0c115 100644 --- a/tools/src/wtotools/vromfs/image.py +++ b/tools/src/wtotools/vromfs/image.py @@ -3,7 +3,8 @@ Layout (every block aligned to 16 bytes): 0x00 names header: u32 offset of the name-offset table, u32 file count 0x10 data header: u32 offset of the data table, u32 file count - 0x20 digest header: u64 end, u16 begin (only when names offset == 0x30) + 0x20 digest header: u64 end, u64 begin (only when names offset == 0x30; begin + exceeds 16 bits in large packs such as ui/images.vromfs.bin) name offsets: count x u64, each pointing at a NUL-terminated path names data table: count x 16 bytes: u32 offset, u32 size, 8 bytes padding @@ -25,7 +26,7 @@ NAME_MAP_PATH = "nm" _NAME_MAP_STORED = b"\xff?nm" _ALIGN = 16 _PAIR = struct.Struct("