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.
This commit is contained in:
1 parent
8012cf7954
commit
cf08034060
2 files changed
+7
-5
No files matched your search
@@ -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<string, Uint8Array>();
|
||||
for (let index = 0; index < count; index++) {
|
||||
@@ -84,7 +85,7 @@ export function buildImage(layout: ImageLayout, files: ReadonlyMap<string, Uint8
|
||||
if (layout.hasDigestHeader) {
|
||||
const [begin, end] = layout.hasDigests ? [digestsOffset, digestsOffset + DIGEST_SIZE * count] : [0, firstDataOffset];
|
||||
out.writeBigUInt64LE(BigInt(end), 0x20);
|
||||
out.writeUInt16LE(begin, 0x28);
|
||||
out.writeBigUInt64LE(BigInt(begin), 0x28);
|
||||
}
|
||||
paths.forEach((path, index) => {
|
||||
out.writeBigUInt64LE(BigInt(nameOffsets[index]!), namesOffset + index * 8);
|
||||
|
||||
@@ -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("<II")
|
||||
_DIGEST_HEADER = struct.Struct("<QH")
|
||||
_DIGEST_HEADER = struct.Struct("<QQ")
|
||||
_DIGEST_SIZE = 20
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user