Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving files bigger than 4GB #229

Open
ev1313 opened this issue Feb 9, 2024 · 2 comments
Open

Saving files bigger than 4GB #229

ev1313 opened this issue Feb 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ev1313
Copy link

ev1313 commented Feb 9, 2024

Code

    env = UnityPy.load(datafile)

    for obj in env.objects:
        if obj.type.name == "MonoBehaviour":
            if not obj.serialized_type.nodes:
                data = obj.read()
                if data.name == "DataBaseCompiled":
                    data = obj.read()
                    with open(inputfile, "rb") as f:
                        data.save(raw_data = f.read())

    with open("data.unity3d", "wb") as f:
        f.write(env.file.save())

Error

Traceback (most recent call last):
  File "replace_database.py", line 24, in <module>
    unpack_monobehaviour(sys.argv[1], sys.argv[2])
  File "replace_database.py", line 21, in unpack_monobehaviour
    f.write(env.file.save())
            ^^^^^^^^^^^^^^^
  File "/python3.11/site-packages/UnityPy/files/BundleFile.py", line 224, in save
    self.save_fs(writer, 64, 64)
  File "/python3.11/site-packages/UnityPy/files/BundleFile.py", line 325, in save_fs
    block_writer.write_u_int(uncompressed_data_size)
  File "/python3.11/site-packages/UnityPy/streams/EndianBinaryWriter.py", line 70, in write_u_int
    self.write(pack(self.endian + "I", value))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: 'I' format requires 0 <= number <= 4294967295

Bug
The file gets saved without an error.

To Reproduce
I think the problem is saving a unity3d file that is uncompressed bigger than 4GB, considering the file size overflows?

If I print the size, it is 0x21b5da210.

  • Python 3.11
  • UnityPy 1.10.7
@ev1313 ev1313 added the bug Something isn't working label Feb 9, 2024
@ev1313
Copy link
Author

ev1313 commented Feb 9, 2024

I cannot upload the file for copyright reasons, however it is from the game "Broken Arrow" https://store.steampowered.com/app/1604270/Broken_Arrow/

@K0lb3
Copy link
Owner

K0lb3 commented Feb 9, 2024

A possible fix for this is pretty straight forward - replicating what Unity does, splitting the data into blocks and compressing these.
As this would require some testing I'm not sure when I will come around to implementing it tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants