XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Mon Dec 17, 2018 2:31 am

All times are UTC + 1 hour


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Astonia - Compressed Archives (.pak/zlib/libpng)
PostPosted: Tue Aug 14, 2018 10:09 pm 
Offline
ultra-n00b

Joined: Mon Aug 13, 2018 2:03 pm
Posts: 2
Has thanked: 0 time
Have thanks: 0 time

I have been working on figuring out Astonia's .pak files but have not had much success. The game is now open source (see Github below). So far I have determined the following:


I am trying to learn more about C++ to figure out a way to reverse the process but it is currently beyond what I am capable of. Does anyone have suggested guides or tutorials I can learn from? If anyone else is up to the task of deconstructing the files that would be much appreciated as well :mrgreen:

Edit: There is another thread on the forum (http://forum.xentax.com/viewtopic.php?f=15&t=2134) but the MexScript did not yield any useful results.

You can make the ads go away by registering



Top
 Profile  
 
 Post subject: Re: Astonia - Compressed Archives (.pak/zlib/libpng)
PostPosted: Tue Aug 14, 2018 11:56 pm 
Offline
Moderator
User avatar

Joined: Sun May 18, 2008 3:01 pm
Posts: 2503
Has thanked: 57 times
Have thanks: 1248 times
use offzip
offzip.exe -a c:\file.pak c:\extractDir 0x0


Top
 Profile  
 
 Post subject: Re: Astonia - Compressed Archives (.pak/zlib/libpng)
PostPosted: Wed Aug 15, 2018 2:49 am 
Offline
ultra-n00b

Joined: Mon Aug 13, 2018 2:03 pm
Posts: 2
Has thanked: 0 time
Have thanks: 0 time
chrrox wrote:
use offzip
offzip.exe -a c:\file.pak c:\extractDir 0x0



Thanks for the suggestion. It seems to extract the correct number of files but does not get the correct data. Here is a screenshot with the extracted files (left) vs the expected output (right). Not sure what to make of this. Is it an offset issue or is there more to it?

Image


Top
 Profile  
 
 Post subject: Re: Astonia - Compressed Archives (.pak/zlib/libpng)
PostPosted: Tue Aug 21, 2018 9:16 am 
Offline
ultra-n00b

Joined: Thu Nov 16, 2017 6:03 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
[Google Translator]
The contents are very awkward using the translator.


Looking at line 288 of 'gfx.c', there are three types of pak files.
The structure of the pak file can be seen by looking at the 'pakdat' and 'gfxdata' directly below the type.

Let's go some more.
On line 804 we have the function 'gfx_save_pak'.
If you check this function, 'savetime', 'dat_cnt', 'offset', 'totsize', 'dat_id', 'dat_type' etc. exist with the size of the variable.

Code:
# savetime,4
# dat_cnt,4
# offset,4 => 4+4 + dat_cnt*(4+4+4+4)
# totsize,4 => 4+4 + gfxdata[i].compsize +8
# gfxdata[i].dat_id,4
# gfxdata[i].dat_type,4


Let's take an example of this file. (00000000.pak)
The first 4 bytes 'B0 62 9A 46' is 'savetime'. The next 4 bytes '63 00 00 00' are 'dat_cnt'.
This is a separate value up to this point.
From this point, it is repeated by 'dat_cnt' until offset 638h.
The format is 'offset', 'totsize', 'dat_id', and 'dat_type', each of 4 bytes.

Now move to the 'offset' section. (638h)
Looking at the data in this next section, 697h.

The total size is 5F. This is 'totsize'.
This block is also the contents of the for statement on line 841.
If you look carefully at the content, you can see that this data has the following form:

Code:
# gfxdata[i].compsize,4
# gfxdata[i].realsize,4
# gfxdata[i].data, gfxdata[i].compsize
# gfxdata[i].xres,2
# gfxdata[i].yres,2
# gfxdata[i].xoff,2
# gfxdata[i].yoff,2


Now, with 'compsize' and 'realsize', you can output the same result as using offzip.
So far, it's very easy, But what you see now is the most important issue.

This is followed by the image palette value. On line 860.
The last 4 bytes of sample file are '00 00 00 00 '.
In other words, this means that the first three types of data were palette-free.

To extract an image from a pak file, you need to figure out the palette value. (The last 36 bytes of the 00124000.pak file have the same value.)
That is, you have to distinguish the type of the file.
Probably related functions are estimated to be 'gfx_load_image_pak', 'load_gfx_num', 'make_gfx_num' and so on.
And the variables 'xres', 'yres', 'xoff', and 'yoff' also seem to be related.

That's all I've analyzed.
It was beyond my ability to reverse this part.
I hope these contents will help you.

# This script is for a sample file. (same offzip output)
Code:
get savetime long
get dat_cnt long

for i=0 < dat_cnt
    if i == dat_cnt
        break
    endif

    get offset long
    get totsize long
    get dat_id long
    get dat_type long
    savepos nextoff

    goto offset
    get compsize long
    get realsize long
    xmath offset "offset + 8"
    clog "" offset compsize realsize

    goto nextoff
next i




Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group