nesrak1 / UABEA

c# uabe for newer versions of unity
MIT License
1.1k stars 143 forks source link

unable to repack properly #234

Open nijinekoyo opened 1 year ago

nijinekoyo commented 1 year ago

When I tried to repackage a data.unity3d file, I found that even if I didn’t modify anything, the file he packed still couldn’t run normally, and no matter whether I used L4Z or LZAM, he couldn’t make him pack the same file as before. File link: https://1drv.ms/u/s!Ah0MLfDa4AHqajuahlRKrWL2O7Q?e=h2iChD

nijinekoyo commented 1 year ago

Running with the repackaged resources gives the following error 81%1)6Y_J{ QPPEKSYU(XAP

nesrak1 commented 1 year ago

If this is one of these packed web files, UABEA can't handle it out of the box. We already had this conversation in a different issue, but some web files start with the standard bundle header so they look like just a bundle, but in reality there are many other files also packed after it as well. Whenever UABEA saves, it strips the rest of the data since it's not part of the bundle. I don't have an answer for how to handle it but I'm sure there's a separate listing file that shows which part of the packed file extracts to other files.

nijinekoyo commented 1 year ago

This is indeed one of the web package files. It comes from the ba2.data file. Is there any other way to modify it?

nesrak1 commented 1 year ago

The last time this was asked was issue #223. I don't have a solution right now.

nijinekoyo commented 1 year ago

Are you still interested in solving this, I can provide more details

nijinekoyo commented 1 year ago

I have successfully modified global-metadata.dat and encapsulated it back to achieve string replacement

nesrak1 commented 1 year ago

Did you do that by overwriting the original file in a hex editor? Or something else? What would be best is to find a way to automate how to extract and repack the files.

nijinekoyo commented 1 year ago

Almost, I achieved it by replacing the binary

nijinekoyo commented 1 year ago

https://1drv.ms/u/s!Ah0MLfDa4AHqebRTCXYTIhzbE2o?e=NfRTEW This is the complete game file, which can be run through Nginx

nijinekoyo commented 1 year ago

The millennium_quest\static_prod2\Build\ba2.data.br file is the data file of the game, don't care about the br suffix, it has been decompressed

nijinekoyo commented 1 year ago

The millennium_quest\static_prod2\Build\ba2.wasm.br file is the WASM of the game. It passed the Il2CppDumper test, and its function should be similar to libil2cpp.so

nijinekoyo commented 1 year ago

image The ba2.data.br file header contains the file type and packaged file path

nijinekoyo commented 1 year ago

The global-metadata.dat contained in the ba2.data.br file can be replaced by binary replacement, and it can run normally after testing

nijinekoyo commented 1 year ago

A simple binary replacement script

with open('./ba2.data', 'rb') as f:
    data = f.read()

with open('./global-metadata.dat', 'rb') as f:
    metadata = f.read()

with open('./global-metadata_new.dat', 'rb') as f:
    new_metadata = f.read()

# 替换二进制
new_data = data.replace(metadata, new_metadata)

with open('./ba2_new.data', 'wb') as f:
    f.write(new_data)
nijinekoyo commented 1 year ago

Everything was going fine until I tried to replace the data.unity3d repackaged by UABEA and I got an error no matter if I modified the file or not