Xenoblade - .pkh/.pkb files

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Xenoblade - .pkh/.pkb files

Post by AnonBaiter »

Here's a sample. filecutter.bms applied when needed.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Xenoblade - .pkh/.pkb files

Post by aluigi »

AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Xenoblade - .pkh/.pkb files

Post by AnonBaiter »

Cool. This script worked for almost all files except for adx.pkb/.pkh and ahx.pkb/.pkh.

Code: Select all

  offset   filesize   filename
--------------------------------------
- enter in folder E:\Dolphin-x64\Games\xenoblade
  coverage file 0     0%   0          1430
- open input file E:\Dolphin-x64\Games\xenoblade\adx.pkh
- enter in folder E:\Dolphin-x64\Games\xenoblade
- open input file E:\Dolphin-x64\Games\xenoblade\adx.pkb

Error: incomplete input file 0: E:\Dolphin-x64\Games\xenoblade\adx.pkh
       Can't read 4 bytes from offset 00000596.
       Anyway don't worry, it's possible that the BMS script has been written
       to exit in this way if it's reached the end of the archive so check it
       or contact its author or verify that all the files have been extracted.
       Please check the following coverage information to know if it's ok.

  coverage file 0    93%   1334       1430

Last script line before the error or that produced the error:
  25  get OFFSET long

-----

  offset   filesize   filename
--------------------------------------
- enter in folder E:\Dolphin-x64\Games\xenoblade
  coverage file 0     0%   0          67510
- open input file E:\Dolphin-x64\Games\xenoblade\ahx.pkh
- enter in folder E:\Dolphin-x64\Games\xenoblade
- open input file E:\Dolphin-x64\Games\xenoblade\ahx.pkb

Error: incomplete input file 0: E:\Dolphin-x64\Games\xenoblade\ahx.pkh
       Can't read 4 bytes from offset 000107b6.
       Anyway don't worry, it's possible that the BMS script has been written
       to exit in this way if it's reached the end of the archive so check it
       or contact its author or verify that all the files have been extracted.
       Please check the following coverage information to know if it's ok.

  coverage file 0    99%   67414      67510

Last script line before the error or that produced the error:
  25  get OFFSET long

Since the adx.pkb and ahx.pkb files are AFS archives themselves...
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Xenoblade - .pkh/.pkb files

Post by aluigi »

Script 0.2

The problem was caused by the lack of OFFSETs in these 2 archives... yeah completely missing, so I use the size to get the offsets.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Xenoblade - .pkh/.pkb files

Post by AnonBaiter »

Huh. I tested these files on your updated script and they worked fine.
However, I also tested these files with the afs.bms script, so this is sort of an alternative solution.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Xenoblade - .pkh/.pkb files

Post by aluigi »

I think that AFS is one of the archived files, you should have multiple AFS files in the archives.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Xenoblade - .pkh/.pkb files

Post by AnonBaiter »

"multiple AFS files"... So you're saying that most of the .pkb files have .afs files in them?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Xenoblade - .pkh/.pkb files

Post by aluigi »

Well, it's an archive so it's meant to contain multiple files.
With only 2Mb I can't give you a complete answer because it's possible that for those 2 archives it opts for the AFS archive format instead of the pkh/pkb used for the other files. That would explain why the offsets are missing from pkh.
I'm no longer surprised of the weird choices of developers :)
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Xenoblade - .pkh/.pkb files

Post by AnonBaiter »

So that means the adx.pkb and ahx.pkb files are meant to be AFS files, isn't that so?
Ma'am, these developer choices are confusing me...
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Xenoblade - .pkh/.pkb files

Post by aluigi »

You can do a very simple test.
Open one of these two pkb files in a hex editor and search for the occurrences of the following bytes 0x41 0x46 0x53 0x00 ("AFS\0").
From a quick check that I have just made it appears that adx.pkb and adx.pkb are just AFS archives because the offset containing the filenames (retrieved with afs.bms) is very close to the end of the pkb archives, so there is no space for other files.

After this finding I have updated the xenoblade.bms script for telling the user to use afs.bms with these pkb archives.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Xenoblade - .pkh/.pkb files

Post by AnonBaiter »

That's good enough, thanks.