ffu_extract: pick store by blkSize sanity
This commit is contained in:
+14
-5
@@ -24,11 +24,20 @@ def load(ffu):
|
|||||||
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
|
||||||
# store header: ASCII PlatformId inside it; header starts 12B before
|
# store header: ASCII PlatformId inside it; header starts 12B before.
|
||||||
st = f.find(b"Microsoft.MSM") - 12
|
# (manifest has one too — pick the occurrence with sane blkSize)
|
||||||
assert st > 0
|
st = -1
|
||||||
vals = struct.unpack("<11I", f[st + 204:st + 248])
|
i = 0
|
||||||
assert vals[0] == CHUNK, vals # blkSize sanity
|
while True:
|
||||||
|
i = f.find(b"Microsoft.MSM", i)
|
||||||
|
if i < 0:
|
||||||
|
break
|
||||||
|
vals = struct.unpack("<11I", f[i - 12 + 204:i - 12 + 248])
|
||||||
|
if vals[0] == CHUNK:
|
||||||
|
st = i - 12
|
||||||
|
break
|
||||||
|
i += 1
|
||||||
|
assert st > 0, "store header not found"
|
||||||
wcnt = vals[1]
|
wcnt = vals[1]
|
||||||
pos = st + 248
|
pos = st + 248
|
||||||
disk = {} # diskchunk -> datachunk
|
disk = {} # diskchunk -> datachunk
|
||||||
|
|||||||
Reference in New Issue
Block a user