Skip to content

Commit 01d26b0

Browse files
committed
1.7.11 improved apk handling and fixed apk/zip detection
1 parent 5b0a688 commit 01d26b0

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

‎UnityPy/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.7.10"
1+
__version__ = "1.7.11"
22

33
from .environment import Environment
44

‎UnityPy/environment.py‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,21 @@ def load_zip_file(self, value):
8181
if isinstance(value, str) and os.path.exists(value):
8282
buffer = open(value, "rb")
8383
elif isinstance(value, (bytes, bytearray)):
84-
buffer = ZipFile(io.BytesIO(value))
84+
buffer = io.BytesIO(value)
8585
elif isinstance(value, (io.BufferedReader, io.BufferedIOBase)):
8686
buffer = value
8787

8888
z = ZipFile(buffer)
89+
splits = {}
8990
for path in z.namelist():
91+
92+
if path[-7:-1] == ".split":
93+
name = path[:-7]
94+
if name not in splits:
95+
splits[name] = []
96+
splits[name].append(path)
97+
continue
98+
9099
stream = z.open(path)
91100
if stream._orig_file_size == 0:
92101
continue
@@ -97,6 +106,22 @@ def load_zip_file(self, value):
97106
cur.files[d] = files.File(self)
98107
cur = cur.files[d]
99108
cur.files[name] = self.load_file(stream, cur)
109+
110+
# merge splits
111+
for path, items in splits.items():
112+
# merge data
113+
data = io.BytesIO()
114+
for item in items:
115+
with z.open(item) as f:
116+
data.write(f.read())
117+
*path, name = path.split("/")
118+
cur = self
119+
for d in path:
120+
if d not in cur.files:
121+
cur.files[d] = files.File(self)
122+
cur = cur.files[d]
123+
cur.files[name] = self.load_file(data, cur)
124+
100125
z.close()
101126

102127
@property

‎UnityPy/helpers/ImportHelper.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def check_file_type(input_) -> (FileType, EndianBinaryReader):
9696
return FileType.BundleFile, reader
9797
elif signature == "UnityWebData1.0":
9898
return FileType.WebFile, reader
99-
elif signature == "PK\x03\x04\x14":
99+
elif signature == "PK\x03\x04":
100100
return FileType.ZIP, reader
101101
else:
102102
if reader.Length < 128:

0 commit comments

Comments
 (0)