def searchUnpackAndroidSparse(filename, tempdir=None, blacklist=[], offsets={}, scanenv={}, debug=False):
hints = {}
if not 'android-sparse' in offsets:
return ([], blacklist, [], hints)
if offsets['android-sparse'] == []:
return ([], blacklist, [], hints)
diroffsets = []
counter = 1
tags = []
for offset in offsets['android-sparse']:
blacklistoffset = extractor.inblacklist(offset, blacklist)
if blacklistoffset != None:
continue
## first see if the major version is correct
sparsefile = open(filename, 'rb')
sparsefile.seek(offset+4)
sparsedata = sparsefile.read(2)
sparsefile.close()
if len(sparsedata) != 2:
break
majorversion = struct.unpack('<H', sparsedata)[0]
if not majorversion == 1:
continue
tmpdir = dirsetup(tempdir, filename, "android-sparse", counter)
res = unpackAndroidSparse(filename, offset, tmpdir)
if res != None:
(sparsesize, sparsedir) = res
diroffsets.append((sparsedir, offset, sparsesize))
blacklist.append((offset, offset + sparsesize))
counter = counter + 1
else:
## cleanup
os.rmdir(tmpdir)
return (diroffsets, blacklist, tags, hints)
评论列表
文章目录