disunity icon indicating copy to clipboard operation
disunity copied to clipboard

but how to pack the file again?

Open jy03344894 opened this issue 11 years ago • 45 comments

this unpack works great, but how to pack the file again?

jy03344894 avatar Jan 22 '14 03:01 jy03344894

I think you're referring to asset bundle repacking, right? That should be relatively easy to implement. However, there still are a few unknown fields in the file format that I need to figure out, just to make sure the resulting files won't end up corrupt. I think it will be possible in relatively near future.

ata4 avatar Jan 23 '14 17:01 ata4

Just wanted to second my interest in repacking functionality.

Thanks for this excellent tool!

jaqenn avatar Jan 31 '14 01:01 jaqenn

Repacking would be incredibly, incredibly useful. Is there any update on that? I'd be willing to donate if need be :)

flipperbw avatar Apr 05 '14 18:04 flipperbw

Im also interested in repacking assets.

Scrivener07 avatar Apr 05 '14 19:04 Scrivener07

I'd be interested too.

tux3 avatar Apr 05 '14 21:04 tux3

I think I can start working on that, soon. However, I have some concerns about that feature and wonder what the repacking would be used for? I hope it's just for harmless mods, but I assume it could also be used to embed malware or to cheat in multiplayer games.

ata4 avatar Apr 06 '14 09:04 ata4

Game modding is an example. If I had that feature I could finish a pet project for endless space http://forums.amplitude-studios.com/showthread.php?20961-ES-Eve-Online

Scrivener07 avatar Apr 06 '14 10:04 Scrivener07

I'm mainly interested in doing localizations, which is impossible to achieve without being able to repack the assets, so I'd definitely be interested in this, too.

dibas avatar Apr 06 '14 11:04 dibas

That would be phenomenal. Though I understand your concern. Personally, I've wanted this for so long to be able to play with and adjust aesthetic sounds and images in some of the games I play (some of the sounds are particularly annoying). Absolutely no malicious intent, and all client side.

I suspect that if someone really wanted to cheat online, they'd find other ways.

On Apr 6, 2014, at 5:43 AM, ata4 [email protected] wrote:

I think I can start working on that, soon. However, I have some concerns about that feature and wonder what the repacking would be used for? I hope it's just for harmless mods, but I assume it could also be used to embed malware or to cheat in multiplayer games.

— Reply to this email directly or view it on GitHub.

flipperbw avatar Apr 06 '14 16:04 flipperbw

I'm trying to protect my game by obfuscating dll's in webbuild your tool helped me a lot with unpacking,thank you! but is there a way to pack my files back to build? unity 3d obfucator isnt a solution

GreagDeay avatar May 29 '14 06:05 GreagDeay

If you're using 0.3.1, you can use the command "bundle-inject". The extracted folder needs to be in the same folder as the .unity3d for it to work. And it's also not guaranteed to work, so better test it extensively after repacking.

ata4 avatar May 29 '14 22:05 ata4

Can you help me to import *.tga file to assets file as TEX file ??? Thanks

hackspeedok avatar May 30 '14 01:05 hackspeedok

Has anyone gotten bundle-inject to work?

I've tried many different methods (extract, extract-raw), but if I'm even able to get it to inject anything, when I try to re-extract to test if it worked properly, I get an error about invalid arguments. Most of the time I get an error on the inject step itself, with IOExceptions. Any idea why this might be the case? The folder and .unity3d file are in the same place.

flipperbw avatar May 31 '14 20:05 flipperbw

Can you post the full exception message, please?

ata4 avatar Jun 01 '14 03:06 ata4

tried now it works JUST FINE! A LOT OF THANKS TO YOU, ata4!!!

here is my command line, if anyone has problems:

C:\Users\greag_000\Desktop\work\disunity-master\disunity>disunity.bat bundle-ext ract testSecurity.unity3d [info] DisUnity v0.3.1 [info] Processing testSecurity.unity3d [info] Uncompressing asset bundle, this may take a while [info] Extracting Assembly-CSharp.dll [info] Extracting sharedassets0.assets [info] Extracting resources/unity_builtin_extra [info] Extracting mainData [info] Extracting Assembly-CSharp.dll.mdb

C:\Users\greag_000\Desktop\work\disunity-master\disunity>disunity.bat bundle-inj ect testSecurity.unity3d [info] DisUnity v0.3.1 [info] Processing testSecurity.unity3d [info] Uncompressing asset bundle, this may take a while [info] Injecting Assembly-CSharp.dll [info] Injecting sharedassets0.assets [info] Injecting resources/unity_builtin_extra [info] Injecting mainData [info] Injecting Assembly-CSharp.dll.mdb [info] Compressing asset bundle, this may take a while

GreagDeay avatar Jun 01 '14 11:06 GreagDeay

Here's my output:

Windows:

$ ../../disunity_v0.3.1/disunity.bat extract sounds0.unity3d [info] DisUnity v0.3.1 [info] Processing sounds0.unity3d [info] Processing sounds0.unity3d:CAB-sounds0 [info] Writing AudioClip ....

$ ../../disunity_v0.3.1/disunity.bat bundle-inject sounds0.unity3d [info] DisUnity v0.3.1 [info] Processing sounds0.unity3d [info] Injecting CAB-sounds0 [error] DisUnityProcessor: Can't process sounds0.unity3d, caused by java.nio.file.AccessDeniedException: sounds0\CAB-sounds0 at sun.nio.fs.WindowsException.translateToIOException(Unknown Source) at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) at sun.nio.fs.WindowsFileSystemProvider.newFileChannel(Unknown Source) at java.nio.channels.FileChannel.open(Unknown Source) at java.nio.channels.FileChannel.open(Unknown Source) at info.ata4.io.buffer.ByteBufferUtils.openReadOnly(ByteBufferUtils.java:155) at info.ata4.io.buffer.ByteBufferUtils.openReadOnly(ByteBufferUtils.java:170) at info.ata4.unity.cli.action.BundleInjectAction.processAssetBundle(BundleInjectAction.java:63) at info.ata4.unity.cli.DisUnityProcessor.processAssetBundle(DisUnityProcessor.java:162) at info.ata4.unity.cli.DisUnityProcessor.run(DisUnityProcessor.java:116) at info.ata4.unity.cli.DisUnityCli.run(DisUnityCli.java:119) at info.ata4.unity.cli.DisUnityCli.main(DisUnityCli.java:55)

If I remove the CAB folder, and take everything inside it and put it into the immediate folder:

$ mv CAB-sounds0/* . $ rm -rf CAB-sounds0/ $ ../../disunity_v0.3.1/disunity.bat bundle-inject sounds0.unity3d [info] DisUnity v0.3.1 [info] Processing sounds0.unity3d

$ rm -rf sounds0 $ ../../disunity_v0.3.1/disunity.bat extract sounds0.unity3d [info] DisUnity v0.3.1 [info] Processing sounds0.unity3d [error] DisUnityProcessor: Can't process sounds0.unity3d, caused by java.lang.IllegalArgumentException at java.nio.Buffer.limit(Unknown Source) at info.ata4.io.buffer.ByteBufferUtils.getSlice(ByteBufferUtils.java:230) at info.ata4.unity.asset.bundle.AssetBundle.load(AssetBundle.java:96) at info.ata4.io.file.FileHandler.open(FileHandler.java:28) at info.ata4.unity.cli.DisUnityProcessor.processAssetBundle(DisUnityProcessor.java:157) at info.ata4.unity.cli.DisUnityProcessor.run(DisUnityProcessor.java:116) at info.ata4.unity.cli.DisUnityCli.run(DisUnityCli.java:119) at info.ata4.unity.cli.DisUnityCli.main(DisUnityCli.java:55)

flipperbw avatar Jun 01 '14 17:06 flipperbw

And on Linux it's the same thing. If I try to use "extract-raw" to make sure I get everything, I get this:

$ disunity.sh bundle-inject sounds0.unity3d [info] DisUnity v0.3.1 [info] Processing sounds0.unity3d [info] Injecting CAB-sounds0 [error] DisUnityProcessor: Can't process sounds0.unity3d, caused by java.io.IOException: No such device at sun.nio.ch.FileChannelImpl.map0(Native Method) at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:874) at info.ata4.io.buffer.ByteBufferUtils.openReadOnly(ByteBufferUtils.java:156) at info.ata4.io.buffer.ByteBufferUtils.openReadOnly(ByteBufferUtils.java:170) at info.ata4.unity.cli.action.BundleInjectAction.processAssetBundle(BundleInjectAction.java:63) at info.ata4.unity.cli.DisUnityProcessor.processAssetBundle(DisUnityProcessor.java:162) at info.ata4.unity.cli.DisUnityProcessor.run(DisUnityProcessor.java:116) at info.ata4.unity.cli.DisUnityCli.run(DisUnityCli.java:119) at info.ata4.unity.cli.DisUnityCli.main(DisUnityCli.java:55)

flipperbw avatar Jun 01 '14 17:06 flipperbw

You need to use bundle-extract first, not extract. Extracted asset content can't be injected yet, you need to edit the .assets file with the Unity editor.

ata4 avatar Jun 02 '14 08:06 ata4

Sorry, a bit confused. When I do that, I get another file of the same exact size, entitled CAB-(name of unity file). I see that that is an assets file ([warning] DisUnityProcessor: Command "bundle-extract" doesn't support asset files, skipping CAB-(file)).

I don't get a .assets file in particular though. Running extract on that extracted bundle nets me the AudioClip files, but are you saying I can't edit those?

flipperbw avatar Jun 02 '14 18:06 flipperbw

The CAB file is the actual .assets file, it just doesn't have the extension. You seem to have asset bundles for a standalone game, they're uncompressed and contain just that one file, that's why the .unity3d and CAB files have nearly the same size.

However, the CAB can't be edited with the Unity editor right now, because it doesn't contain the required structure metadata.

ata4 avatar Jun 03 '14 02:06 ata4

So even though I can obtain the underlying files from that .assets file, I can't use any injection methods?

flipperbw avatar Jun 03 '14 23:06 flipperbw

No, that requires advanced file editing support for asset files. The extracted files can't be put back into the asset file like in zip files, for example. Asset bundles are more like zip files, that's why I recently added the inject command.

ata4 avatar Jun 04 '14 11:06 ata4

There is an asset file repacker available somewhere, will post it later because I'm currently on mobile, but unfortunately it's closed-source and it only allows to replace files that have the same file size as the original one, at least for me, which makes it essentially useless for localization work :/

Am 04.06.2014 um 13:25 schrieb "ata4" [email protected]:

No, that requires advanced file editing support for asset files.


Reply to this email directly or view it on GitHub.

dibas avatar Jun 04 '14 12:06 dibas

Hmm, alright. That's a shame, but thanks guys.

flipperbw avatar Jun 04 '14 17:06 flipperbw

So here's the tool I was talking about, if anyone was interested: http://forum.xentax.com/viewtopic.php?f=10&t=10085

dibas avatar Jun 04 '14 17:06 dibas

I think the best would be an ASCII interchange format, maybe even the YAML format available in Unity Pro. Then you could switch between binary and human-readable formats, which opens the possibility for third-party editors. Even if it's just a simple text editor.

ata4 avatar Jun 05 '14 10:06 ata4

First of all, thank you a lot for your effort! I am trying to manipulate some specific, already existing files in a file (just for some visual modification in the client side) and i dont succed at repacking. Is it currently possible to do that?

Migano avatar Jun 30 '14 02:06 Migano

Migano, show your output. It is possible, to extract bundle, modify specific files and inject back to bundle.

GreagDeay avatar Jul 01 '14 08:07 GreagDeay

I cannot produce output, since i dont know the syntax to inject correctly. My readme file does not contain information about any commands related to injecting. I have the .unity3d file and a folder containing the original content from the unity3d file (created with "extract") and a folder with the original content with some modifyed files. How do i proceed?

Running:

  1. disunity extract file.unity3d (works fine)
  2. disunity bundle-inject file.unity3d results in:

DisUnityProcessor: Cant process file.unity3d [...] caused by java.nio.file.AccessDeniedException: folder\CAB-folder

This appears even without changing anything at the folder\CAB-folder structure and running the console as admin.

Migano avatar Jul 02 '14 22:07 Migano

I forgot to add the command to the readme, that's correct. I'll add it soon, but your usage looks correct to me. Can you please provide a full stacktrace?

ata4 avatar Jul 03 '14 10:07 ata4