From 664e9b52e1c85a8248822fac899bf9889b91f93f Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Thu, 21 Dec 2023 21:47:29 +0100 Subject: [PATCH 1/7] EndianBinaryReader - fix string reading regex --- UnityPy/streams/EndianBinaryReader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/streams/EndianBinaryReader.py b/UnityPy/streams/EndianBinaryReader.py index 2435846c..4fea9761 100644 --- a/UnityPy/streams/EndianBinaryReader.py +++ b/UnityPy/streams/EndianBinaryReader.py @@ -4,7 +4,7 @@ from typing import List, Union from io import BytesIO, BufferedIOBase, IOBase, BufferedReader -reNot0 = re.compile(b"(.*?)\x00") +reNot0 = re.compile(b"(.*?)\x00", re.S) SYS_ENDIAN = "<" if sys.byteorder == "little" else ">" From 83d736cfc5ad417480787a09ba91060d8a514cfa Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Thu, 21 Dec 2023 21:53:28 +0100 Subject: [PATCH 2/7] SerializedFile - hotfix version parsing for custom versions --- UnityPy/files/SerializedFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/files/SerializedFile.py b/UnityPy/files/SerializedFile.py index d26efbba..050c22d3 100644 --- a/UnityPy/files/SerializedFile.py +++ b/UnityPy/files/SerializedFile.py @@ -328,7 +328,7 @@ def set_version(self, string_version): build_type = re.findall(r"([^\d.])", string_version) self.build_type = BuildType(build_type[0] if build_type else "") version_split = re.split(r"\D", string_version) - self.version = tuple(int(x) for x in version_split) + self.version = tuple(int(x) for x in version_split[:4]) def read_type_tree(self): type_tree = [] From 46e05c557cf695cb63d23bc8f1ba24328729f112 Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Thu, 21 Dec 2023 21:55:01 +0100 Subject: [PATCH 3/7] Tpk - UnityVersion - set default values for fromList --- UnityPy/helpers/Tpk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/helpers/Tpk.py b/UnityPy/helpers/Tpk.py index 84b65d42..f523a794 100644 --- a/UnityPy/helpers/Tpk.py +++ b/UnityPy/helpers/Tpk.py @@ -292,7 +292,7 @@ def fromString(version: str) -> UnityVersion: return UnityVersion(version.split(".")) @staticmethod - def fromList(major: int, minor: int, patch: int, build: int) -> UnityVersion: + def fromList(major: int = 0, minor: int = 0, patch: int = 0, build: int = 0) -> UnityVersion: return UnityVersion(major << 48 | minor << 32 | patch << 16 | build) @property From cb7ae496abbb9dff67967a8b9691928863335787 Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Thu, 21 Dec 2023 22:08:56 +0100 Subject: [PATCH 4/7] AudioClipConverter - hotfix pyfmodex --- UnityPy/export/AudioClipConverter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UnityPy/export/AudioClipConverter.py b/UnityPy/export/AudioClipConverter.py index 16d2a02d..85ee15bd 100644 --- a/UnityPy/export/AudioClipConverter.py +++ b/UnityPy/export/AudioClipConverter.py @@ -73,6 +73,9 @@ def cdll_hook(name, *args, **kwargs): return CDLL(name, *args, **kwargs) ctypes.CDLL = cdll_hook + + # hotfix ctypes for pyfmodex for non windows + ctypes.windll = getattr(ctypes, "windll", None) import pyfmodex ctypes.CDLL = CDLL From 50fcaf1ee64773fcc63ed10c95b98480e478fdbf Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Thu, 21 Dec 2023 22:36:20 +0100 Subject: [PATCH 5/7] AudioClipConverter - pyfmodex 0.7.1 --- UnityPy/export/AudioClipConverter.py | 29 ++++++++-------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/UnityPy/export/AudioClipConverter.py b/UnityPy/export/AudioClipConverter.py index 85ee15bd..8709fe28 100644 --- a/UnityPy/export/AudioClipConverter.py +++ b/UnityPy/export/AudioClipConverter.py @@ -57,28 +57,15 @@ def import_pyfmodex(): # prepare the environment for pyfmodex if system == "Windows": - # register fmod.dll, so that windll.fmod in pyfmodex can find it - ctypes.WinDLL(os.path.join(LIB_PATH, "fmod.dll")) - import pyfmodex + os.environ["PYFMODEX_DLL_PATH"] = os.path.join(LIB_PATH, "fmod.dll") else: - # It's a bit more complicated on Linux and Mac - # as CDLL doesn't cache the loaded libraries. - # So our only option is to hook into the ctypes loader - # and add the path to the library there. - CDLL = ctypes.CDLL - - def cdll_hook(name, *args, **kwargs): - if name.startswith("libfmod"): - name = os.path.join(LIB_PATH, name) - return CDLL(name, *args, **kwargs) - - ctypes.CDLL = cdll_hook - + ext = "dylib" if system == "Darwin" else "so" + os.environ["PYFMODEX_DLL_PATH"] = os.path.join(LIB_PATH, f"libfmod.{ext}") + # hotfix ctypes for pyfmodex for non windows ctypes.windll = getattr(ctypes, "windll", None) - import pyfmodex - - ctypes.CDLL = CDLL + + import pyfmodex def extract_audioclip_samples(audio) -> dict: @@ -112,7 +99,7 @@ def dump_samples(clip): sound = system.create_sound( bytes(clip.m_AudioData), pyfmodex.flags.MODE.OPENMEMORY, - exinfo=pyfmodex.system.CREATESOUNDEXINFO( + exinfo=pyfmodex.structure_declarations.CREATESOUNDEXINFO( length=clip.m_Size, numchannels=clip.m_Channels, defaultfrequency=clip.m_Frequency, @@ -137,7 +124,7 @@ def dump_samples(clip): def subsound_to_wav(subsound): # get sound settings - length = subsound.get_length(0x00000004) # TIMEUNIT.PCMBYTES + length = subsound.get_length(pyfmodex.enums.TIMEUNIT.PCMBYTES) channels = subsound.format.channels bits = subsound.format.bits sample_rate = int(subsound.default_frequency) From eff8260047bda1a0dbb243c07337f6e1f7ff0110 Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Thu, 21 Dec 2023 22:37:04 +0100 Subject: [PATCH 6/7] pyproject.toml - enforce pyfmodex >= 0.7.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6e27f3a5..d38992e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ # raw typetree dumping "tabulate", # audio extraction - "pyfmodex", + "pyfmodex >= 0.7.1", # filesystem handling "fsspec", ] From 765b84cb7f57ca8e4c23b3c32a60538668d48c9f Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Thu, 21 Dec 2023 22:45:40 +0100 Subject: [PATCH 7/7] bump version to 1.10.7 --- UnityPy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/__init__.py b/UnityPy/__init__.py index 78dc97a3..fe5f4fc5 100644 --- a/UnityPy/__init__.py +++ b/UnityPy/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.10.6" +__version__ = "1.10.7" from .environment import Environment from .helpers.ArchiveStorageManager import set_assetbundle_decrypt_key