Disney's Tangled .bag archives

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Disney's Tangled .bag archives

Post by huckleberrypie »

Care if anyone can look into these files? They appear to be compressed or something, and they apparently don't have a clearly defined header or at least that's what I can remember when I last looked into them.

Here's a sample with a few level archives and shared assets:
https://mega.nz/#!ztp2mSKS!J5XrT7UAFhPz ... d2OHmc-gfE

I know this may not be worth bothering about but to be honest I am looking into modding the game at least to a degree as a fellow Discord member cheekily expressed his intent to replace Rapunzel with CJ from GTA San Andreas of all people. :P
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

Anyone?
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

huckleberrypie wrote:Anyone?


Lol you'll need to have a bit of patience, if you really just want to try pulling the data without the names and directory structure you can put this in a bms script.
The way the file is structured it seems like there linked string structure of the names, folders, etc. but it's not the most straight forward from what I saw looking at it quickly.

Code: Select all

get count long
for i = 0 < count
    get offset long
    get size long
    log "" offset size
next i
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

LokiReborn wrote:
huckleberrypie wrote:Anyone?


Lol you'll need to have a bit of patience, if you really just want to try pulling the data without the names and directory structure you can put this in a bms script.
The way the file is structured it seems like there linked string structure of the names, folders, etc. but it's not the most straight forward from what I saw looking at it quickly.

Code: Select all

get count long
for i = 0 < count
    get offset long
    get size long
    log "" offset size
next i

Yeah I can understand. Is it compressed in some way though?
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

huckleberrypie wrote:
LokiReborn wrote:
huckleberrypie wrote:Anyone?


Lol you'll need to have a bit of patience, if you really just want to try pulling the data without the names and directory structure you can put this in a bms script.
The way the file is structured it seems like there linked string structure of the names, folders, etc. but it's not the most straight forward from what I saw looking at it quickly.

Code: Select all

get count long
for i = 0 < count
    get offset long
    get size long
    log "" offset size
next i

Yeah I can understand. Is it compressed in some way though?


Not from what I saw reviewing some of the files, typically in the header if data is compressed you have compressed and uncompressed sizes so it can verify the uncompressed size but like i mentioned with the script it's just offsets and sizes.
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

LokiReborn wrote:Not from what I saw reviewing some of the files, typically in the header if data is compressed you have compressed and uncompressed sizes so it can verify the uncompressed size but like i mentioned with the script it's just offsets and sizes.

I see. What about the filenames though? And I presume this can be repacked in some way too, yes?

EDIT: So I ended up with these unpacked files:
https://mega.nz/#!e1wkRILC!m_qiblmrPglI ... oG0vlYBhn4

There's indeed some familiar stuff like FMOD FSBs, Bink Video files and what appears to be Havok 7.x animation files, but the model and texture assets appear to be a bit of a mystery. Not sure if the script chopped them up properly either. Ideally it would be best if we're able to decipher them formats but I guess that'll take some time to research them all.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

huckleberrypie wrote:
LokiReborn wrote:Not from what I saw reviewing some of the files, typically in the header if data is compressed you have compressed and uncompressed sizes so it can verify the uncompressed size but like i mentioned with the script it's just offsets and sizes.

I see. What about the filenames though? And I presume this can be repacked in some way too, yes?

EDIT: So I ended up with these unpacked files:
https://mega.nz/#!e1wkRILC!m_qiblmrPglI ... oG0vlYBhn4

There's indeed some familiar stuff like FMOD FSBs, Bink Video files and what appears to be Havok 7.x animation files, but the model and texture assets appear to be a bit of a mystery. Not sure if the script chopped them up properly either. Ideally it would be best if we're able to decipher them formats but I guess that'll take some time to research them all.


Looking through it a bit more it doesn't seem like using the data and offset table by itself isn't entirely a valid way to do it. After reviewing parts of some of the file entries it seems like the texture & mesh entries can be stored back to back and so basically that 'block' can contain 2-3 files from what I've seen so far but nothing is getting cut off for sure at most it's just multiple files + a bit of padding between them.

In regards to repacking the answer is probably? That said it would require figuring out the entire file it seems with the way everything links together and not sure this is the easiest thing to do with bms.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

This is closer to being correct, I still need to figure out the proper way it changes directories etc. but You should have at least 1 level of folders and all of proper file names and sizes now. I'll poke at it some more when I have a few, hopefully you can figure out what you need to work with in the mean time.
Last edited by LokiReborn on Fri Jan 24, 2020 12:30 pm, edited 1 time in total.
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

Now it's just the matter of reversing the model formats lol. Though since it uses Havok it might be a bit difficult.

EDIT: Just tested the extractor tool, and while I do get the filenames some of them files appear to be residing on the wrong directories.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

huckleberrypie wrote:Now it's just the matter of reversing the model formats lol. Though since it uses Havok it might be a bit difficult.

EDIT: Just tested the extractor tool, and while I do get the filenames some of them files appear to be residing on the wrong directories.


Ya it's a bug, well sort of anyways. All of the folder names are shifted, I thought the blank entry was at the end however it's actually at the start I noticed that in trying to create the directory structures. I have it fixed in the version I'm testing now trying to piece it together, still working on how they chain.

Edit: attached just an updated exe while i work on it, should fix the folders. Also needed to remove colon from the string as one of references is more like "Z:\build\xxx\filename" rather than a relative path so when it tried to create the directory z: it flipped out (in common file)
Last edited by LokiReborn on Fri Jan 24, 2020 12:30 pm, edited 1 time in total.
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

LokiReborn wrote:
huckleberrypie wrote:Now it's just the matter of reversing the model formats lol. Though since it uses Havok it might be a bit difficult.

EDIT: Just tested the extractor tool, and while I do get the filenames some of them files appear to be residing on the wrong directories.


Ya it's a bug, well sort of anyways. All of the folder names are shifted, I thought the blank entry was at the end however it's actually at the start I noticed that in trying to create the directory structures. I have it fixed in the version I'm testing now trying to piece it together, still working on how they chain.

Edit: attached just an updated exe while i work on it, should fix the folders. Also needed to remove colon from the string as one of references is more like "Z:\build\xxx\filename" rather than a relative path so when it tried to create the directory z: it flipped out (in common file)

Alright, that one seems to work better though as you said there appears to be some work needed to be done.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

huckleberrypie wrote:
LokiReborn wrote:
huckleberrypie wrote:Now it's just the matter of reversing the model formats lol. Though since it uses Havok it might be a bit difficult.

EDIT: Just tested the extractor tool, and while I do get the filenames some of them files appear to be residing on the wrong directories.


Ya it's a bug, well sort of anyways. All of the folder names are shifted, I thought the blank entry was at the end however it's actually at the start I noticed that in trying to create the directory structures. I have it fixed in the version I'm testing now trying to piece it together, still working on how they chain.

Edit: attached just an updated exe while i work on it, should fix the folders. Also needed to remove colon from the string as one of references is more like "Z:\build\xxx\filename" rather than a relative path so when it tried to create the directory z: it flipped out (in common file)

Alright, that one seems to work better though as you said there appears to be some work needed to be done.


Here ya go, this has the corrected paths so with that I'm calling it finished. There is another value that I could never find a use case for, not sure if anyone else can figure it out or if it even matters outside of potentially trying to create a file from scratch.
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

LokiReborn wrote:
huckleberrypie wrote:
LokiReborn wrote:
Ya it's a bug, well sort of anyways. All of the folder names are shifted, I thought the blank entry was at the end however it's actually at the start I noticed that in trying to create the directory structures. I have it fixed in the version I'm testing now trying to piece it together, still working on how they chain.

Edit: attached just an updated exe while i work on it, should fix the folders. Also needed to remove colon from the string as one of references is more like "Z:\build\xxx\filename" rather than a relative path so when it tried to create the directory z: it flipped out (in common file)

Alright, that one seems to work better though as you said there appears to be some work needed to be done.


Here ya go, this has the corrected paths so with that I'm calling it finished. There is another value that I could never find a use case for, not sure if anyone else can figure it out or if it even matters outside of potentially trying to create a file from scratch.

I see. Well at least the archive format doesn't seem to be that complicated; I just hope there's some way to repack them but I'm not in a rush anyway.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

huckleberrypie wrote:
LokiReborn wrote:
huckleberrypie wrote:Alright, that one seems to work better though as you said there appears to be some work needed to be done.


Here ya go, this has the corrected paths so with that I'm calling it finished. There is another value that I could never find a use case for, not sure if anyone else can figure it out or if it even matters outside of potentially trying to create a file from scratch.

I see. Well at least the archive format doesn't seem to be that complicated; I just hope there's some way to repack them but I'm not in a rush anyway.


The format isn't complicated but there are things that could impact performance / could break something. For example the Data blocks and entries are broken into do different areas, no idea why this is. Also the shared data blocks for some files when they appear to be related but not for others.

Because of stuff like that rather then extracting everything and repacking it (especially with the few unknown values etc. too) the better approach would be to read in the original archive and inject & adjust the values around a specific file(s) you want to change.

If you actually get to the point you can make the files you want to inject I can try adding something to add it back in.
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

LokiReborn wrote:
huckleberrypie wrote:
LokiReborn wrote:
Here ya go, this has the corrected paths so with that I'm calling it finished. There is another value that I could never find a use case for, not sure if anyone else can figure it out or if it even matters outside of potentially trying to create a file from scratch.

I see. Well at least the archive format doesn't seem to be that complicated; I just hope there's some way to repack them but I'm not in a rush anyway.


The format isn't complicated but there are things that could impact performance / could break something. For example the Data blocks and entries are broken into do different areas, no idea why this is. Also the shared data blocks for some files when they appear to be related but not for others.

Because of stuff like that rather then extracting everything and repacking it (especially with the few unknown values etc. too) the better approach would be to read in the original archive and inject & adjust the values around a specific file(s) you want to change.

If you actually get to the point you can make the files you want to inject I can try adding something to add it back in.

You mean like have a DLL of some sort read a bunch of modified files in a given directory, right?
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Disney's Tangled .bag archives

Post by LokiReborn »

huckleberrypie wrote:
LokiReborn wrote:
huckleberrypie wrote:I see. Well at least the archive format doesn't seem to be that complicated; I just hope there's some way to repack them but I'm not in a rush anyway.


The format isn't complicated but there are things that could impact performance / could break something. For example the Data blocks and entries are broken into do different areas, no idea why this is. Also the shared data blocks for some files when they appear to be related but not for others.

Because of stuff like that rather then extracting everything and repacking it (especially with the few unknown values etc. too) the better approach would be to read in the original archive and inject & adjust the values around a specific file(s) you want to change.

If you actually get to the point you can make the files you want to inject I can try adding something to add it back in.

You mean like have a DLL of some sort read a bunch of modified files in a given directory, right?


No, it will another button in the app that allows you to pick files and modifies the .bag file appropriately but requires the original bag file rather than creating one from scratch but you can think of it as more or less being the same. The method you're talking about is possible as well but requires a lot more work as you need to analyze the executable and find the correct memory addressing to inject into etc. I only usually do stuff for injecting into games when they use asymmetric encryption to replace the public key so you can use repacked files otherwise it's a lot of extra effort and depending on the game can break with updates. As long as there isn't hash checking (and even then you can do simple stuff to swap as the game loads) just modifying the files is usually more than sufficient.
huckleberrypie
Posts: 37
Joined: Sun Nov 11, 2018 2:27 am

Re: Disney's Tangled .bag archives

Post by huckleberrypie »

LokiReborn wrote:
huckleberrypie wrote:
LokiReborn wrote:
The format isn't complicated but there are things that could impact performance / could break something. For example the Data blocks and entries are broken into do different areas, no idea why this is. Also the shared data blocks for some files when they appear to be related but not for others.

Because of stuff like that rather then extracting everything and repacking it (especially with the few unknown values etc. too) the better approach would be to read in the original archive and inject & adjust the values around a specific file(s) you want to change.

If you actually get to the point you can make the files you want to inject I can try adding something to add it back in.

You mean like have a DLL of some sort read a bunch of modified files in a given directory, right?


No, it will another button in the app that allows you to pick files and modifies the .bag file appropriately but requires the original bag file rather than creating one from scratch but you can think of it as more or less being the same. The method you're talking about is possible as well but requires a lot more work as you need to analyze the executable and find the correct memory addressing to inject into etc. I only usually do stuff for injecting into games when they use asymmetric encryption to replace the public key so you can use repacked files otherwise it's a lot of extra effort and depending on the game can break with updates. As long as there isn't hash checking (and even then you can do simple stuff to swap as the game loads) just modifying the files is usually more than sufficient.

So there has to be two copies of a particular bag, right? As for updates, you need not to worry about it since Disney pretty much released just version 1.0 and that's it. Heck, the porting house Planet Moon subcontracted to do the Windows conversion grossly overestimated their target audience and only added support for just one controller in co-op mode, forcing the poor little girl who wanted to play as Rapunzel to make do with the keyboard.

EDIT: Yep, the extractor did seem to get the directories right, thanks! I'll see if we could get the model file formats to be deciphered in some way.