ffu_extract: store via PlatformId scan, mmap

This commit is contained in:
SashegDev
2026-09-11 08:15:25 +00:00
parent b9ad328a8e
commit ea661ee9ff
+11 -13
View File
@@ -18,27 +18,25 @@ CHUNK = 131072
def load(ffu): def load(ffu):
f = open(ffu, "rb") import mmap
raw = open(ffu, "rb")
f = mmap.mmap(raw.fileno(), 0, access=mmap.ACCESS_READ)
sec = f.read(32) sec = f.read(32)
_, _, chunk_kb, _, cat, hsh = struct.unpack("<I12sIIII", sec) _, _, chunk_kb, _, cat, hsh = struct.unpack("<I12sIIII", sec)
assert chunk_kb * 1024 == CHUNK assert chunk_kb * 1024 == CHUNK
off = 32 + cat + hsh # store header: ASCII PlatformId inside it; header starts 12B before
off += (CHUNK - off % CHUNK) % CHUNK st = f.find(b"Microsoft.MSM") - 12
f.seek(off) assert st > 0
ih = f.read(24) vals = struct.unpack("<11I", f[st + 204:st + 248])
mlen = struct.unpack("<I", ih[16:20])[0] assert vals[0] == CHUNK, vals # blkSize sanity
man = f.read(mlen)
st = off + 24 + mlen
f.seek(st + 204)
vals = struct.unpack("<11I", f.read(44))
wcnt = vals[1] wcnt = vals[1]
pos = st + 248 pos = st + 248
disk = {} # diskchunk -> datachunk disk = {} # diskchunk -> datachunk
dc = 0 dc = 0
for _ in range(wcnt): for _ in range(wcnt):
f.seek(pos) a, _ = struct.unpack("<II", f[pos:pos + 8])
a, _ = struct.unpack("<II", f.read(8)) locs = [struct.unpack("<II", f[pos + 8 + k * 8:pos + 16 + k * 8])
locs = [struct.unpack("<II", f.read(8)) for _ in range(a)] for k in range(a)]
pos += 8 + 8 * a pos += 8 + 8 * a
for m, idx in locs: for m, idx in locs:
if m == 0: if m == 0: