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("