From 667285403f1a0c1b5ce82295e744b511632aaf73 Mon Sep 17 00:00:00 2001 From: Wawax007 <108287745+Wawax007@users.noreply.github.com> Date: Fri, 24 Jul 2026 18:31:57 +0200 Subject: [PATCH] Fix read_resource returning empty bytes for uncompressed resources When sizeField's low 30 bits are 0 the resource is stored uncompressed (dsz bytes on disk, still XOR-scrambled when bit31 is set), but read_resource passed comp=0 to f.read() and returned 0 bytes. TEXT/TEXD resources are stored this way in both retail chunks. --- glacier/rpkg.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glacier/rpkg.py b/glacier/rpkg.py index a263082..e52a38c 100644 --- a/glacier/rpkg.py +++ b/glacier/rpkg.py @@ -172,7 +172,9 @@ def read_resource(chunk_path, t1, t2, index, roff=None): type_str, dbs, dsz = t2_record_info(t2, rec_off) with open(chunk_path, "rb") as f: f.seek(off) - blob = f.read(comp) + # comp == 0 means the resource is stored uncompressed (dsz bytes on disk), + # possibly still XOR-scrambled (e.g. TEXT resources). + blob = f.read(comp if comp else dsz) if is_xor: blob = xor_scramble(blob) if comp == 0 or comp == dsz: