Page 1 of 1
Dragon Mania Legends (Gameloft) - PAK files
Posted: Tue May 31, 2022 12:42 pm
by fengyexiye
Almost all game resources have been compressed into DAT files. I tried many methods but could not unzip them.
Here are some sample files:
https://drive.google.com/file/d/1-WvCvk ... p=drivesdk
If you know something about these contents, please give me some ideas or tell me how to decompress them. Thank you
Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Tue Aug 09, 2022 4:43 pm
by barncastle
I've had a quick look at this and the format is using
Zstandard for compression.
There is an uncompressed header, followed by a compressed file table containing FileTableEntry structures, followed by each file's compressed data in order of the FileTable. Using the header you read FileTableCompressedSize bytes and Zstd decompress to get the FileTable, then iterating each FileTableEntry you read entry.CompressedSize bytes and Zstd decompress to get the raw file.
FYI it looks like some files are actually PKZip archives despite their file extension e.g. "ancient_divine_wind_eyes.tga" is a PKZip archive containing two ktx files.
Code: Select all
struct Archive
{
char Magic[4]; // "BUD\0"
uint FileTableCompressedSize;
uint FileTableDecompressedSize;
byte CompressedFileTable[FileTableCompressedSize];
byte CompressedFileDatas[x][y]; // x = num of FileTable entries, y = entry.CompressedSize
}
struct FileTableEntry
{
uint NameLen;
char Name[NameLen];
uint CompressedSize;
uint DecompressedSize;
}
Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Fri Aug 12, 2022 5:11 am
by fengye
Thank you very much for your reply.
I tried the method you provided, but there seems to be an error.
Code: Select all
Error: the requested amount of bytes to allocate is negative (0xfd2fb529)
Last script line before the error or that produced the error:
14 char Name[NameLen]
coverage file 0 0% 1437 6333033 . offset 0000059d
Is it that I lack any dependence? Or I made some mistakes.
Finally, thank you very much
Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Fri Aug 12, 2022 5:35 pm
by barncastle
Here is some sample code in C# which might help provide reference for your script. I've run this through all of your sample files again and everything is parsing correctly for me.
Based on the error I would assume your decompression isn't right as the first 4 bytes should be an integer below 256 e.g. "?? 00 00 00" so cannot be negative. You might also want to double check everything is in Little Endian.
If you can share your script someone might be able to pinpoint the issue (I'm not knowledgably of BMS unfortunately but will have a go).
Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Sat Aug 13, 2022 9:18 am
by fengye
barncastle wrote: ↑Fri Aug 12, 2022 5:35 pm
Here is some sample code in C# which might help provide reference for your script. I've run this through all of your sample files again and everything is parsing correctly for me.
Based on the error I would assume your decompression isn't right as the first 4 bytes should be an integer below 256 e.g. "?? 00 00 00" so cannot be negative. You might also want to double check everything is in Little Endian.
If you can share your script someone might be able to pinpoint the issue (I'm not knowledgably of BMS unfortunately but will have a go).
really thanks for your detailed explanation,this is very usefulI.And I found the mistake I made.Thankd again
Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Sat Aug 13, 2022 12:11 pm
by ikskoks
And here's the article for reference:
http://wiki.xentax.com/index.php/Dragon ... egends_PAK
Thanks for sharing, barncastle

Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Sat Aug 13, 2022 2:43 pm
by fengye
barncastle wrote: ↑Fri Aug 12, 2022 5:35 pm
Here is some sample code in C# which might help provide reference for your script. I've run this through all of your sample files again and everything is parsing correctly for me.
Based on the error I would assume your decompression isn't right as the first 4 bytes should be an integer below 256 e.g. "?? 00 00 00" so cannot be negative. You might also want to double check everything is in Little Endian.
If you can share your script someone might be able to pinpoint the issue (I'm not knowledgably of BMS unfortunately but will have a go).
Sorry to bother you again, I also want to try the C # code you provided, but I can't find the correct assembly containing the "zstdsharp. Decompressor()" function
It seems that there is no such function in the commonly used datasets on GitHub. If you can, please share the datasets you use. Thank you
Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Mon Aug 15, 2022 11:36 am
by barncastle
fengye wrote: ↑Sat Aug 13, 2022 2:43 pm
I can't find the correct assembly containing the "zstdsharp. Decompressor()" function
Sorry yeah I forgot to link the library I used - its
oleg-st's ZstdSharp.
Re: Dragon Mania Legends (Gameloft) - PAK files
Posted: Fri Aug 19, 2022 2:22 am
by fengye
barncastle wrote: ↑Mon Aug 15, 2022 11:36 am
fengye wrote: ↑Sat Aug 13, 2022 2:43 pm
I can't find the correct assembly containing the "zstdsharp. Decompressor()" function
Sorry yeah I forgot to link the library I used - its
oleg-st's ZstdSharp.
Thank you very much.