Godzilla PS3 .pac files

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
tyrannojones
Posts: 30
Joined: Wed Aug 03, 2016 10:01 am

Godzilla PS3 .pac files

Post by tyrannojones »

Hey there! Would someone be able to perhaps take a look into these .pac files? Looking for a way to get at the assets inside... It appears to be using a different compression method to the NTSC version of the game, which I find interesting!

https://mega.nz/#F!nZ4V0TqC!sKjWNJu1VTrpkowRTa288Q
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Godzilla PS3 .pac files

Post by aluigi »

It's the known add_pac format:
http://aluigi.org/bms/add_pac.bms
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Godzilla PS3 .pac files

Post by Acewell »

viewtopic.php?f=9&t=457

even if you extract the files from the pac they are compressed with what looks like lzs
but this lzs bms script doesn't work on them even though it follows the structure perfectly. :?

http://aluigi.altervista.org/bms/lzs.bms

and daemon1 seems to have it figured out but has not told how to :|
http://forum.xentax.com/viewtopic.php?p=125101#p125101
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Godzilla PS3 .pac files

Post by aluigi »

Keep us updated when the doubt about the compression is solved.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Godzilla PS3 .pac files

Post by id-daemon »

Acewell wrote:and daemon1 seems to have it figured out but has not told how to


I didnt even had a chance to say anything! You expect me to answer in the middle of a night? :shock:
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Godzilla PS3 .pac files

Post by id-daemon »

Ok i had some food, and now I can answer!

This is what I did:

I took the quickbms LZS code, and rewritten it looking at the file data. It was all done correct, as luigi's code describes. So I don't know why script is not working, maybe some endianess issue.
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Godzilla PS3 .pac files

Post by Acewell »

id-daemon wrote:I didnt even had a chance to say anything!

sure you did, you made that post yesterday in a thread about compression
without saying anything about how you solved the decompression problem! :P
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Godzilla PS3 .pac files

Post by id-daemon »

Acewell wrote:sure you did, you made that post yesterday


You didn't ask me at that time! ;-)
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Godzilla PS3 .pac files

Post by Acewell »

aluigi wrote:Keep us updated when the doubt about the compression is solved.

nothing definitive, just endianess speculation, is that enough to work with? :)
i think its just not possible and i'm convinced daemon1 is practicing witchcraft, this is the only logical explanation :P
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Godzilla PS3 .pac files

Post by id-daemon »

Acewell wrote:daemon1 is practicing witchcraft


I'm practicing Zen, not witchcraft ;)
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Godzilla PS3 .pac files

Post by Acewell »

aluigi, i think there may be a problem with LZS decompression in QuickBMS,
i searched for other scripts and formats that use it and can't find anything
that extracted successfully to compare against though.

daemon1 basically says he is doing nothing out of the ordinary with the LZS decompression
and he is actually using your code translated to a programming language, see here
http://forum.xentax.com/viewtopic.php?p=125188#p125188


this is the error i'm seeing using "comtype LZS DICT DICT_SIZE" in the lzs.bms script

Code: Select all

Info:  algorithm   159
       offset      0000002e
       input size  0x000e3170 930160
       output size 0x0025129d 2429597
       result      0xffffffff -1

Error: the uncompressed data (-1) is bigger than the allocated buffer (2429597)

Last script line before the error or that produced the error:
  35  clog NAME OFFSET ZSIZE SIZE

with this file included in the attached samples
ch01a_00.dae
but the other samples are producing the same error
samples.zip


help me obi-aluigi, you're my only hope! :)
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Godzilla PS3 .pac files

Post by id-daemon »

Acewell wrote:and he is actually using your code translated to a programming language


I used c# instead of c++ Luigi used, because its better for me. Quickbms decompression routine was also surely written in programming language.

If I can help in something more, let me know.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Godzilla PS3 .pac files

Post by aluigi »

Well, there is HUGE difference which is clearly visible... there is a 16bit swapping of the data!
In fact if you add "encryption swap 16" before clog in my script it works perfectly.
Now the question is: what bit of the flag at offset 4 says that the data is swapped?

Maybe it works with the endianess of the file? In that case it's a joke to fix it but I want to know if it's sure at 100%
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Godzilla PS3 .pac files

Post by aluigi »

In the meantime I have updated the script to version 0.1.2 with that modification I said above (all the rest of the script is original).
Maybe in the next version of quickbms I can make the lzs_unzip() code compatible with the current endianess of the script, just to make it automatic without the "encryption" command.
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Godzilla PS3 .pac files

Post by Acewell »

aluigi wrote:In fact if you add "encryption swap 16" before clog in my script it works perfectly.

problem solved thank you, i think this is the first time i've seen that used, i learned something new. :D
this works with "lzs_unzip" but not "lzs", what is the difference between the two?

aluigi wrote:Well, there is HUGE difference which is clearly visible... there is a 16bit swapping of the data!

where do you see this 16bit swapping :oops:
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Godzilla PS3 .pac files

Post by aluigi »

lzs_unzip and lzs (mppc) are different algorithms.

The 16bit swapping is the part of code after "then reading the whole data block into memory"
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Godzilla PS3 .pac files

Post by id-daemon »

Acewell wrote:where do you see this 16bit swapping :oops:


Its the simple endianess, like I suspected. When reading every 2 bytes, you read them in different order. Its called endianess.
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Godzilla PS3 .pac files

Post by Acewell »

id-daemon wrote:Its the simple endianess, like I suspected. When reading every 2 bytes, you read them in different order. Its called endianess.

right, but i don't know C, C++ or C# programming languages, only the bits that look like python. :)

this is what i was hoping for when you posted your source, that someone else could spot
the difference between your code and the capabilities of QuickBMS and the bms script. :D

i'm a bit confused about why the endianess (big) didn't take from earlier in the script though,
unless "lzs_unzip" only decompresses little(?) endian by design or something :?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Godzilla PS3 .pac files

Post by aluigi »

Regarding the endianess I'm quite sure that the difference is in the code used by the developers and the one used in quickbms (not written by me).
In the former they have probably just used value=(16bit)data which means that the endianess of that value is dependent by the one of the system while in quickbms it's forced in little endian (data[0] | data[1] << 8).

Why this has not been spotted before?
Simple, the available samples :)
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: Godzilla PS3 .pac files

Post by id-daemon »