Page 7 of 20

Re: Star Stable Online - CSA & TGA files

Posted: Tue Jan 04, 2022 6:09 pm
by locknut
Hi!
I stumbled on this forum thread while researching the CSA file format ("Cold Storage Archive" btw). I saw that there are a lot of discussions regarding the texture resources and thought that I should contribute.

Long Story Short
they are not encrypted. They are just compressed with a newer, optimized version of Crunch. Specifically the version that is bundled with Unity 2017.3. It's open source, so if you have a developer environment then you can build the tool from sources at https://github.com/Unity-Technologies/crunch/tree/unity.

Slightly Longer Story
No QuickBMS script I have seen does a very good job at unpacking the CSA files so I wrote my own tool for that. In my opinion, the best approach is to use the csaheader files to unpack the packed resources into a proper folder structure. The QBMS scripts tries to unpack with an internal source path, which is why the output folder looks so weird and many files are corrupted or duplicated.

Doing it properly, you will end up with ~52.000 files in a handful of different formats. The textures are as you already know stored in .PTE files, and there are about 19.000 of them. PTE is also a container format, but it only contains a single texture. The texture is always in DDS-format, but most of them are compressed with Crunch as mentioned above. ~15K textures are compressed, and the rest are plain old DDS.

So to summarize how to do this with code or a script:
  1. Loop through each header file and extract the name, size and offset of each resource in the corresponding csa data file.
  2. Save each resource you are interesting in from the datafiles as separate files.
  3. For each PTE, extract the texture as a CRN or DDS file depending on it's type
  4. Use Crunch to convert them into a common format such as PNG. Handily enough, Crunch can read both CRN & DDS, so you can convert all files in one go. I only found one file that Crunch failed on (Item_PandorianCompass.PTE), so that had to be converted by hand.
The only data that is actually encrypted (well obfuscated at least) are text strings. It's a simple Caesar cipher which you reverse by adding each byte of the data with (lenOfData%16)+1.

3D Object Converter does a pretty good job with reading the mesh files, but unfortunately it doesn't work well with the textures, materials, bones and animations etc... If it was open source I would have fixed it, but it's not and I cant be bothered to write a new converter from scratch just for this.

I hope this helps anyone!

Re: Star Stable Online - CSA & TGA files

Posted: Tue Jan 04, 2022 9:27 pm
by Samyy360
so what are we doing wrong, was it the version of crunch we were using?

Re: Star Stable Online - CSA & TGA files

Posted: Tue Jan 04, 2022 9:52 pm
by kapibarcia
Samyy360 wrote: Tue Jan 04, 2022 9:27 pm so what are we doing wrong, was it the version of crunch we were using?
The version we used before was an older version and Star Stable Online uses a newer version of Crunch. At least that's what I understood from locknut's post.

Re: Star Stable Online - CSA & TGA files

Posted: Tue Jan 04, 2022 10:19 pm
by ikskoks
So mystery finally has been solved. I was following this topic in case if someone would crack this.
Thanks for the info, locknut.

Luckily I had one sample left from my research and I was able to test the solution - it works fine.
I have put in the attachment compiled crunch version for Unity with sample CRN file.
Use it like this:

Code: Select all

crunch_unity.exe -file CS_SignLogo_01.crn

Re: Star Stable Online - CSA & TGA files

Posted: Wed Jan 05, 2022 4:22 am
by Samyy360
so now that we have everything, can someone do a clean tutorial of how to use crunch, this crunch is not even opening for me

Re: Star Stable Online - CSA & TGA files

Posted: Wed Jan 05, 2022 8:30 am
by locknut
kapibarcia wrote: Tue Jan 04, 2022 9:52 pm
Samyy360 wrote: Tue Jan 04, 2022 9:27 pm so what are we doing wrong, was it the version of crunch we were using?
The version we used before was an older version and Star Stable Online uses a newer version of Crunch. At least that's what I understood from locknut's post.
Yup,pretty much :-)

Re: Star Stable Online - CSA & TGA files

Posted: Wed Jan 05, 2022 10:19 am
by ikskoks
can someone do a clean tutorial of how to use crunch, this crunch is not even opening for me
Crunch is regular command line program. And it works fine.
There are many tutorials on the web already https://www.google.com/search?client=fi ... ne+program

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 6:13 pm
by Samyy360
I understood the second step when using the crunch, but what do I do with the .pte file, is it just to change the extension to .dds or .crn?

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 6:17 pm
by Samyy360
wrong command?

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 7:02 pm
by Samyy360
help

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 8:12 pm
by locknut
Samyy360 wrote: Thu Jan 06, 2022 6:13 pm I understood the second step when using the crunch, but what do I do with the .pte file, is it just to change the extension to .dds or .crn?
It depends on if you have the full PTE file, or if the texture has already been extracted from it. You can check this if you open it with a hexeditor. If the file starts with the string "DDS" or "Hx", then it only contains the texture and you are OK to just rename the file to .DDS or .CRN depending on if it started with DDS or Hx.

If the file does not start with DDS or Hx, then you have the full PTE-file and must delete some bytes from it. Again, open it with a hexeditor and delete all bytes before the "DDS" or "Hx" string.

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 8:14 pm
by locknut
Samyy360 wrote: Thu Jan 06, 2022 7:02 pmhelp
You need to provide the full path to the image, unless it's in the current working folder of the command prompt. I dont think you put it in the system32 folder :-)

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 9:29 pm
by ikskoks
As far as I know PTE and TGA are (almost?) the same file formats. Both are containers for CRN files used by crunch.

By the way, if anyone have issues with converting PTE/TGA files to CRN,
then you can use this quickbms script to do it automatically:
https://github.com/bartlomiejduda/Tools ... script.bms

I have also updated wiki article with the new findings http://wiki.xentax.com/index.php/Star_S ... ne_TGA_PTE

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 10:23 pm
by Samyy360
i tried doing the .crn or .dds manually and i couldn't but the bms script that ikskoks provided worked, i'll try crunch now, thanks for being so patient, it's helping a lot

Re: Star Stable Online - CSA & TGA files

Posted: Thu Jan 06, 2022 10:33 pm
by Samyy360
okok, if it had worked, the .dds was supposed to be located where? what did I do wrong?