The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Mysticus
Posts: 182
Joined: Sat Mar 02, 2019 3:24 pm

The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by Mysticus »

Does anybody of you know some program or script to extract this assets.pka file from Trails of Cold Steel 3?
I tried with the ToCS script of Luigi but I ended up with the big dat file.
Also the script doesn't work well with pkg files.
I need help please.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by aluigi »

The parts of the table containing offset and size of the files are encrypted.
The demo of the game doesn't use encryption.
I don't think I can do anything but I will keep you update if I have news.
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by Ekey »

I'm not sure about encrypted values because they are repeated in the next table, it looks more like 2 hashes like MD5/SHA1. The second table has values more similar to toc.

I think it looks like this:
First table - filenames + hashes
The second table - hashes + toc

Example for first entry > asset_D3D11.xml :

We have a two values (hashes) after the file name in first table

Code: Select all

17 3E BC 7E 83 09 36 69 F8 EA 57 0B 2C F6 DE 9E
97 02 C7 75 8F 97 2D 0A 5C F5 6C FE CF D5 7B FF


These hashes are also in the second table:

Code: Select all

17 3E BC 7E 83 09 36 69 F8 EA 57 0B 2C F6 DE 9E
97 02 C7 75 8F 97 2D 0A 5C F5 6C FE CF D5 7B FF


And toc after them with structure (Int64, Int, Int, Int) (Offset, ZSize, Size, CompType)

Code: Select all

30 3D A1 01 00 00 00 00 3D 04 00 00 EA 0F 00 00 04 00 00 00


The table is quite huge since the archive size is 20GB, therefore, the cutted piece on first post is not complete :)

I cut out 20mb - that's enough for research: https://www112.zippyshare.com/v/fWq9fBrL/file.html

Edited:

Code: Select all

  if ( CompType & 1 )
  {
    Type = "LZSS";
  }
  else if ( CompType & 4 )
  {
    Type = "LZ4";
  }
  else if ( CompType & 8 )
  {
    Type = "LZMA";
  }
  else
  {
    Type = "none";
    if ( CompType & 0x10 )
      Type = "ZSTD";
  }


Edited2: I can confirm i was right :)

Image

Offset
303DA10100000000 -> 27344176

ZSize
3D040000 -> 1085

Size
EA0F0000 -> 4074

Comtype -> 4 (LZ4)

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<fassets>
   <asset symbol="C_CHR000">
      <cluster path="data/D3D11/chr/chr/chr000/chr000.dae.phyre" type="p_collada" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_00_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_01_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_01hr_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_01n_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_02_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_02n_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_03_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_03n_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_04_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_eyes_a_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_eyes_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr000_eyes_r_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/chr_shadow_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/dlight_all_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/dlight_skin_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/eyes_sphere_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/assetconv_temp/dds_dae/D3D11/fc_damyc00_conv.dds.phyre" type="p_texture" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#08C8FC5FEAD6E06894BF4EB45DEC6A5F.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#0FBE93BD2C4F285287841E563DFA6A1C.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#12E95E97335BB5E9123101B561012457.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#182CB47D409B58614BCF175D3BB88D29.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#4F6AAA954B4B0521D4567BE48528012B.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#708FF2E56FE7F2B60EDDA9346F1D06B7.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#7D5B6AA14716CB4C48A6EB8A4185E522.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#84A792CED08197DDC0D51A942C41B60A.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#8C50DE4D78FE82E47887092B04A1235F.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#A5EC46E00AB1156F7729FD6E1CF65C6A.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#BEA3F7EBA1FAF9250BB13F738F9411EE.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#C8235F8118A156BCAD53F183D2B40702.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#C9A2B3287C97CF113E8ECD3BD89CA8D7.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#CA1189E297A3283D186AA47BA6BED748.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#D5B47D3D319B2FDEAB17275029899D59.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#E4190FFCCD5298D51DF017A02E738939.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#E91E8FC1BF15F44F4F5C69C27351F5ED.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#E9FC17FBFF3CE3CA039AC619D8EBEECE.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#F92D1853F259EE44A5A02F9E3C2B32F0.phyre" type="binary" />
      <cluster path="data/D3D11/shaders/ed8_chr.fx#FD475805C05CFAA3CD419F156CC20E72.phyre" type="binary" />
   </asset>
</fassets>


:mrgreen:
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by aluigi »

Where is this second TOC?
In the sample there is only filename + hashes.

*edit* ok it was in the part not available in the sample
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by Ekey »

Good job :P
Mysticus
Posts: 182
Joined: Sat Mar 02, 2019 3:24 pm

Re: The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by Mysticus »

Thank you very much for being so kind, Luigi!
I deeply owe you one.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by aluigi »

I have a couple of questions about this game and the script I made:

1) are we sure the compression of Type & 1 is "lzss"?
In my original script of 2017 I used "nislzs" (with ZSIZE and SIZE repeated in the first 8 bytes)

2) the new script doesn't work with the PKG file provided by Mysticus in the first topic and those of the demo too.
So is the script supposed for the PKA files only?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: The Legend of Heroes: Trails of Cold Steel III (Steam) PKA & PKG file help

Post by aluigi »

I just checked on my own and I was right.
PKA and PKG are different.
And yes, it's nislzs.
I removed the script above and put everything in the following:
http://aluigi.org/bms/legend_of_heroes.bms