Issue with headers in extracted files

Doubts, help and support about QuickBMS and other game research tools
flipperbw
Posts: 5
Joined: Tue Nov 04, 2014 5:58 pm

Issue with headers in extracted files

Post by flipperbw »

Hi there! I messaged you on twitter a while ago about the headers on some of these files being just slightly off. For every file I extract, I have to go in and manually change anywhere from 10-40 header bits to get the file to work correctly. Here is an example of what I'm talking about:

Starting with file SAMPLE.unity3d, I run

Code: Select all

./quickbms unity_old.bms SAMPLE.unity3d


Where unity_old.bms is http://aluigi.altervista.org/papers/bms ... player.bms. This produces one file, since it seems to just be a wrapper: SAMPLE.unity3d_unpacked/CAB-SAMPLE.

I inspected that file, which is the *actual* unity bundle, and it is perfectly fine header-wise. There is no issue there. The problem comes in the next step, where I try to get the actual file:

Code: Select all

quickbms -Y -o -f "{}EXAMPLE_OGG_FILE{}" unity_norm.bms SAMPLE.unity3d_unpacked/CAB-SAMPLE


Where unity_norm.bs is the file located here: http://aluigi.altervista.org/papers/bms/unity.bms. This gives me the proper file like this: TYPE_83/EXAMPLE_OGG_FILE

This is all fine and dandy, but that file is just *slightly* off from what I know it should be. Extracting that exact file with a different program (Disunity), the headers are almost, but not quite, the same:

QuickBMS File:

Code: Select all

00000000  02 00 00 00 0E 00 00 00 01 00 00 00 01 00 00 00  ................
00000010  A5 3B 01 00 4F 67 67 53 00 02 00 00 00 00 00 00  ¥;..OggS........
00000020  00 00 17 0F 00 00 00 00 00 00 BF BA 80 C2 01 1E  ..........¿º€Â..
00000030  01 76 6F 72 62 69 73 00 00 00 00 01 80 BB 00 00  .vorbis.....€»..
00000040  FF FF FF FF 00 F4 01 00 FF FF FF FF B8 01 4F 67  ÿÿÿÿ.ô..ÿÿÿÿ¸.Og
00000050  67 53 00 00 00 00 00 00 00 00 00 00 17 0F 00 00  gS..............
00000060  01 00 00 00 EB FB 80 09 0F 4E FF FF FF FF FF FF  ....ëû€..Nÿÿÿÿÿÿ
00000070  FF FF FF FF FF FF FF E8 03 76 6F 72 62 69 73 2D  ÿÿÿÿÿÿÿè.vorbis-
00000080  00 00 00 58 69 70 68 2E 4F 72 67 20 6C 69 62 56  ...Xiph.Org libV
...


Correct File:

Code: Select all

00000000  4F 67 67 53 00 02 00 00 00 00 00 00 00 00 30 7E  OggS..........0~
00000010  00 00 00 00 00 00 18 AD EF 14 01 1E 01 76 6F 72  ........ï....vor
00000020  62 69 73 00 00 00 00 01 80 BB 00 00 FF FF FF FF  bis.....€»..ÿÿÿÿ
00000030  00 F4 01 00 FF FF FF FF B8 01 4F 67 67 53 00 00  .ô..ÿÿÿÿ¸.OggS..
00000040  00 00 00 00 00 00 00 00 30 7E 00 00 01 00 00 00  ........0~......
00000050  D3 DC 03 10 0F 4E FF FF FF FF FF FF FF FF FF FF  ÓÜ...Nÿÿÿÿÿÿÿÿÿÿ
00000060  FF FF FF E8 03 76 6F 72 62 69 73 2D 00 00 00 58  ÿÿÿè.vorbis-...X
00000070  69 70 68 2E 4F 72 67 20 6C 69 62 56 6F 72 62 69  iph.Org libV
...



Everything after that point is exactly the same. The difference is literally just those initial bytes: 02 00 00 00 0E 00 00 00 01 00 00 00 01 00 00 00 A5 3B 01 00. If I delete them, the OGG file works perfectly fine.

Other types of files have similar issues. Here is an example of a DDS file I attempted to extract:

QuickBMS:

Code: Select all

00000000  00 04 00 00 00 04 00 00 00 00 10 00 0C 00 00 00  ................
00000010  00 00 01 00 01 00 00 00 02 00 00 00 01 00 00 00  ................
00000020  01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000030  01 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00  ................
00000040  46 21 25 21 FF FF FF FF 00 00 00 00 00 00 00 00  F!%!ÿÿÿÿ........
00000050  46 21 25 21 FF FF FF FF 00 00 00 00 00 00 00 00  F!%!ÿÿÿÿ........
...


Correct:

Code: Select all


Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000  44 44 53 20 7C 00 00 00 07 10 08 00 00 04 00 00  DDS |...........
00000010  00 04 00 00 00 00 10 00 00 00 00 00 00 00 00 00  ................
00000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000040  00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00  ............ ...
00000050  04 00 00 00 44 58 54 35 00 00 00 00 00 00 00 00  ....DXT5........
00000060  00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00  ................
00000070  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000080  00 00 00 00 00 00 00 00 46 21 25 21 FF FF FF FF  ........F!%!ÿÿÿÿ
00000090  00 00 00 00 00 00 00 00 46 21 25 21 FF FF FF FF  ........F!%!ÿÿÿÿ
000000A0  00 00 00 00 00 00 00 00 46 21 25 21 FF FF FF FF  .......
...


This time, it's actually missing the correct header (rather than including more bits as in example 1). When I add the DDS/DXT5 portion, it works fine.

Any ideas here? Thanks so much. It's really annoying to have to edit every single file manually before I can use them, and then convert them back before I can reimport.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Issue with headers in extracted files

Post by aluigi »

The behaviour of the script is correct because what you have in an Unity asset is not a file (or the original file) but you have a resource, so a value that specifies what type of resource and a container or directly the raw data.
In the example of the Ogg file you have a container that probably has information about the channels and similar stuff, while the DDS is headerless.

Probably you want to check Unity Assets Explorer:
viewtopic.php?f=9&t=36

It should give you better access to the resources.
flipperbw
Posts: 5
Joined: Tue Nov 04, 2014 5:58 pm

Re: Issue with headers in extracted files

Post by flipperbw »

Mmm, how is DisUnity able to do it then? Those files come out perfectly, with the exception of not being able to inject them back in.

UAE actually doesn't work for me. It hangs forever on the files and misinterprets the length of the data everytime.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Issue with headers in extracted files

Post by aluigi »

Disunity parses the resources, my script simply dumps them.

Regarding UAE post the issue in the thread, Haoose will fix it for sure.
flipperbw
Posts: 5
Joined: Tue Nov 04, 2014 5:58 pm

Re: Issue with headers in extracted files

Post by flipperbw »

aluigi wrote:Disunity parses the resources, my script simply dumps them.

Regarding UAE post the issue in the thread, Haoose will fix it for sure.


Thanks for the help, but I can't seem to get an answer in that thread (been a few months now). Any ideas on who to contact?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Issue with headers in extracted files

Post by aluigi »

The authors are AlphaTwentyThree, Haoose and OLEGator84.
Maybe they are busy at the moment.
Anyway upload that CAB file in that thread so that we can take a look at it.
Maybe it's not a sharedasset file and so the program can't read it.

A sample is ever the best way to receive answers, otherwise it's easy to get ignored.