Alhexx' Playboy: The Mansion CAM Format Analysis V1.00 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Okay, this is not an archive format as most of the others, it's structured a bit different. I've decided to list up all needed structures here, and tell you later how to use them. Chapter I: Structures Listing ----------------------------- //-= Header =- //------------ struct PB_CAM_HEADER { char szMagic[8]; // "CYLBPC " unsigned long ulFormat; unsigned long ulNumTypes; // Number of File Formats unsigned long ulEntrySize; }; // 20 Bytes #define szMagic "CYLBPC " #define ulFormatNormal 65538 #define ulFormatOther 65537 // ??? struct PB_CAM_TYPE_ENTRY { char szName[4]; unsigned long ulNumFilesOffset; }; // 8 Bytes //-= Normal Type =- //----------------- struct PB_CAM_FILE_ENTRY { char szName[4]; unsigned long ulOffset; unsigned long ulFileSize; unsigned long ulUnknown; // 0 }; // 16 Bytes //-= Other Type =- //---------------- struct PB_CAM_FILE_ENTRY_OTHER { char szName[4]; unsigned long ulUnknown[4]; // All 0 unsigned long ulOffset; unsigned long ulFileSize; }; // 28 Bytes Chapter II: Normal Type and Other Type? WTF?!? ---------------------------------------------- So, you surely wonder what the heck the "normal" and the "other" type is. Yeah, I did too when I first took a look at the CAM files in a hex editor. After taking a closer look at the CAM files, I saw that only the "textdat*.cam" files are the "other" format files, all other files use the "normal" format. So we'll take a look at a "normal" file first... I suppose that the ulFormat entry in the header might be some kind of File Version. So, this would be an explanation for those two file formats... As you see, the only difference between the two types is in the FILE_ENTRY structures, all other parts of the two file formats are identical, so we do not need to take a look at two different formats here... Chapter III: File Structure --------------------------- I'll write down the general structure of a CAM file here first: (The offsets and lengths are decimal) Structure Length --------- ------ 1. PB_CAM_HEADER 20 2. PB_CAM_TYPE_ENTRY[] PB_CAM_HEADER.ulNumTypes * 8 3.1. unsigned long ulNumFiles 4 3.2. PB_CAM_FILE_ENTRY[] ulNumFiles * 16 4. Raw File Data * So as you see, the first thing in a CAM file is the PB_CAM_HEADER structure (what a surprise!). After that comes an array of PB_CAM_TYPE_ENTRY structures with PB_CAM_HEADER.ulNumTypes entries in it. After that starts another type of array. The PB_CAM_TYPE_ENTRY.ulNumFilesOffset if the offset to a 32-bit unsigned integer telling you, how many files there with this file type. After that comes an array of PB_CAM_FILE_ENTRY (or PB_CAM_FILE_ENTRY_OTHER) with ulNumFiles Entries. If PB_CAM_HEADER.ulNumTypes is 1, then you're finished with the entries now, and you can extract the files. (Chapter IV) If not, your need to check the PB_CAM_TYPE_ENTRY.ulNumFilesOffset of the second PB_CAM_TYPE_ENTRY type and start reading out file entries once again, and so on... Chapter IV: Extracting Files ---------------------------- Well, the title of this chapter is not 100% correct, I'm not gonna tell you how to extract files here, I'm just going to tell you how to name them. Once you have read out all PB_CAM_TYPE_ENTRY's and PB_CAM_FILE_ENTRY's, you can simply generate a filename like this: sprintf(szFileName, "%s.%s", PB_CAM_TYPE_ENTRY[iTypeIndex].szName, PB_CAM_FILE_ENTRY[iFileIndex].szName); That's it. Chapter V: Blabla ----------------- I know that this is not one of my best file format description, however, I'm tired and I have to do some homework now, so please forgive me ;) Good luck when writing an CAM extractor, I will do this, too, as soon as I have finished my homework. Maybe you'll be lucky and I'll release the Source Code, too ^_^ ~~ Greetings Fly Out To: ~~ Cici ficedula Jackrabbitz Kaddy #17 Levitikus MatsuJin mirex Pitty Qhimm s_kaspar The SaiNt ... and everyone who misses his/her name here! Visit or contact me: -------------------- Home : http://www.alhexx.com Forum : http://forums.alhexx.com Mail : alhexx@alhexx.com - Alhexx 01:24 2006-02-22