Important information: this site is currently scheduled to go offline indefinitely by end of the year.

how does the structure of a CPK work?

Read or post about compression. And decompression. Or ask questions how to decompress your files.
Post Reply
Shadowmael
ultra-n00b
Posts: 5
Joined: Fri Oct 28, 2022 4:00 pm
Has thanked: 1 time
Been thanked: 1 time

how does the structure of a CPK work?

Post by Shadowmael »

I was analyzing the files inside the psp Fate/extra game, then a question came to my mind

How do CPK files work? In this case, its structure, pointers, etc... With that in mind, I wanted to make an extractor for Fate/extra, an extractor capable of working on different devices, like for example on android phones, Linux, etc...

But I don't know anything about this file... The most I know is that at the beginning of the file header there is a String "CPK" not all CPK files contain this header

First I tried parsing the quickbms script used to extract the CPK files

bms script link: http://aluigi.altervista.org/papers/bms/cpk.bms

Even so, I still couldn't understand very well how CPK files work, after looking at the first lines of the script I was able to come to a conclusion.

Code: Select all

endian big
// this endian big is "wrong" because the first values ​​are actually little endian
comtype cpk

idstring "CPK "
// here it checks if the header starts with "CPK"

set query->offset long 0
// here it takes 4 bytes and uses it as a pointer

set query->index long 0
set query->name string "TocOffset"
// these two lines above are used to get 4 bytes each but I don't know for which server

callfunction query_utf 1
// Here it seems to call a function 
set toc_offset long UTF_VALUE
There are many questions in my head about CPK files and I would like to understand more about how they work

CPK: https://drive.google.com/file/d/1Y2P4dF ... p=drivesdk

Right above I left the CPK link that I mentioned at the beginning of the text

I know it's a lot to ask for a detailed explanation of these CPK files since there are several formats and different structures but I still want to ask for help for you more experienced ones

Yeah I tried parsing the codes from the CriPakTools But as I never used C# I couldn't understand much

CriPakTools: https://github.com/esperknight/CriPakTo ... kTools.exe
Last edited by Shadowmael on Fri Dec 02, 2022 9:56 pm, edited 3 times in total.
User avatar
ikskoks
Moderator
Posts: 1667
Joined: Thu Jul 26, 2012 5:06 pm
Location: Poland, Łódź
Has thanked: 647 times
Been thanked: 431 times
Contact:

Re: how does the structure of a CPK work?

Post by ikskoks »

You haven't posted any details. How do you expect people to help you if you didn't tell us anything useful like:
- What scripts are you talking about? Can you link them here?
- What game are those script for?
- Which CPK format do you try to analyze? (Yes, there are few formats with the same extension...)
- A CPK sample attached to the post or shared on some hosting server like mega.nz, google drive would be nice


Also using something like "!!!!!!??????" on the end of your post doesn't help with anything.


You should also check out this link viewtopic.php?f=29&t=22266
There are a lot tutorials there explaining how to read and write this "code" you were talking about ;)

By the way, every command is explained in the quickbms documentation http://aluigi.altervista.org/papers/quickbms.txt
Shadowmael
ultra-n00b
Posts: 5
Joined: Fri Oct 28, 2022 4:00 pm
Has thanked: 1 time
Been thanked: 1 time

Re: how does the structure of a CPK work?

Post by Shadowmael »

You're right, it was my mistake to ask for help without giving details about...

I'm already uploading the CPK file and I'll edit the post to correct my error, I'll also give more details
User avatar
ikskoks
Moderator
Posts: 1667
Joined: Thu Jul 26, 2012 5:06 pm
Location: Poland, Łódź
Has thanked: 647 times
Been thanked: 431 times
Contact:

Re: how does the structure of a CPK work?

Post by ikskoks »

For some reason we didn't have this format documented on our wiki.
Now it's there, I've just created this article http://wiki.xentax.com/index.php/CRI_Middleware_CPK

You should be really interested in this gist as well
https://gist.github.com/unknownbrackets ... ffb7f1bae4
because file format is described in details on this page.
Post Reply