CXML structure

From PS4 Developer wiki
Jump to navigation Jump to search

XML implicit structure Overview[edit | edit source]

 namespace cxml {
     class cxml : public Base {
         struct Header { /*header of a cxml document*/
             char magic[4];
             int version;
             int tree_offset;
             int tree_size;
             int idstrtable_offset;
             int idstrtable_size;
             int idinttable_offset;
             int idinttable_size;
             int stringtable_offset;
             int stringtable_size;
             int chartable_offset;
             int chartable_size;
             int styleidtable_offset;
             int styleidtable_size;
             int intarraytable_offset;
             int intarraytable_size;
             int floatarraytable_offset;
             int floatarraytable_size;
             int filetable_offset;
             int filetable_size;
         };
        
         struct ChildElementBin {
             int name;
             int attr_num;
             int parent_node;
             int prev_sibling;
             int next_sibling;
             int first_child;
             int last_child;
             AttributeBin attribute;
         };
        
         struct SiblingElementBin {
             int name;
             int attr_num;
             int parent_node;
             int prev_sibling;
             int next_sibling;
             AttributeBin attribute;
         };
        
         struct AttributeBin {
             typedef enum {
                 NONE,
                 INTEGER,
                 FLOAT,
                 STRING,
                 CHAR,
                 STYLE_ID,
                 INTEGER_ARRAY,
                 FLOAT_ARRAY,
                 DATA,
                 ID_STR_LPB,
                 ID_STR,
                 ID_INT_LPB,
                 ID_INT,
             } TYPE;
 
             int name;
             TYPE type;
 
             struct SingleValue {
                 int intValue;
                 float floatValue;       
             };
 
             struct StringData {
                 int offset;
                 int len;
             };
 
             struct CharData {
                 int offset;
                 int len;
             };
                
             struct IntArrayData {
                 int offset;
                 int num;
             };
                
             struct FloatArrayData {
                 int offset;
                 int num;
             };
               
             struct FileData {
                 int offset;
                 int size;
             };
 
             struct IdStringTableData {
                 int offset;
                 bool loopback;
             };
 
             struct IdIntegerTableData {
                 int offset;
                 bool loopback;
             };
                
             union {
                 int i;
                 float f;
                 StringData s;
                 CharData c;
                 IntArrayData ia;
                 FloatArrayData fa;
                 FileData file;
                 int id;
                 int idref;
             };
         };
        
         struct IDBin {
             int entity_offset;
             char id[0];
         };
        
         enum AllocationType {
             AllocationType_Alloc_Tree,
             AllocationType_Alloc_IDSTRTable,
             AllocationType_Alloc_IDINTTable,
             AllocationType_Alloc_StringTable,
             AllocationType_Alloc_CharTable,
             AllocationType_Alloc_IntArrayTable,
             AllocationType_Alloc_FloatArrayTable,
             AllocationType_Alloc_FileTable,
             AllocationType_Alloc_StyleIDTable,
  
             AllocationType_Free_Tree,
             AllocationType_Free_IDSTRTable,
             AllocationType_Free_IDINTTable,
             AllocationType_Free_StringTable,
             AllocationType_Free_CharTable,
             AllocationType_Free_IntArrayTable,
             AllocationType_Free_FloatArrayTable,
             AllocationType_Free_FileTable,
             AllocationType_AFree_StyleIDTable,
         };
       
         enum AccessMode {
             AccessMode_ReadWrite,
             AccessMode_ReadOnly_File,
             AccessMode_ReadOnly_Memory,
         };
        
         class Document {
         public:
             typedef void (*Allocator)( AllocationType type, void * userdata, void * old_addr, unsigned int required_size, void ** addr, unsigned int * size );
        
         private:
             AccessMode access_mode;
             Header header;
             char *tree;
             unsigned int tree_capacity;
             char *idstrtable;
             unsigned int idstrtable_capacity;
             char *idinttable;
             unsigned int idinttable_capacity;
             char *stringtable;
             unsigned int stringtable_capacity;
             char *chartable;
             unsigned int chartable_capacity;
             int *intarraytable;
             unsigned int intarraytable_capacity;
             float *floatarraytable;
             unsigned int floatarraytable_capacity;
             char *filetable;
             unsigned int filetable_capacity;
             char *styleidtable;
             unsigned int styleidtable_capacity;
             Allocator allocator;
             void *allocator_userdata;
         };
        
         class Element {
         private:
             Document *doc;
             int offset;
         };
       
         class Attribute {
         private:
             Document *doc;
             int element_offset;
             int offset;
         };
 
         /// <summary>
         /// Initializes this class. Some times also called Constructore.
         /// </summary>
         void Initialize() {
             // All stuff that need to be set before running any function call...
             // goes into here.
         };
     };
 };

Element[edit | edit source]

CXML Child Element definition
Offset Length usage
0x00 0x04 Element name relative offset in TAGS Table
0x04 0x04 Number of attributes in TOC
0x08 0x04 Parent relative offset in TOC
0x0C 0x04 Previous Sibling relative offset in TOC
0x10 0x04 Next Sibling relative offset in TOC
0x14 0x04 First child relative offset in TOC
0x18 0x04 Last child relative offset in TOC

Length is 7 x 4 bytes == 28 bytes (0x1C).


CXML Sibling Element definition
Offset Length usage
0x00 0x04 Element name relative offset in TAGS Table
0x04 0x04 Number of attributes in TOC
0x08 0x04 Parent relative offset in TOC
0x0C 0x04 Previous Sibling relative offset in TOC
0x10 0x04 Next Sibling relative offset in TOC

Length is 5 x 4 bytes == 20 bytes (0x14).

NOTE:

  • The Child Element defination describe the Child Element without his Attributes where the Sibling Element describe the Sibling Element also without his Attributes.
  • So the full order to read will be Child Element >>> Attributes, Sibling Element >>> Attributes. The Root (so offset 0x00) of any SonyPlaystation Resource file always start's with a Child element to read.


Attribute[edit | edit source]

CXML Attribute definitions
Attribute name
(offset 0x0, length 0x4)
Attribute name relative offset in TAGS Table
Attribute type
(offset 0x4, length 0x4)
1
(Single Integer Val)
2
(Single Float Val)
3
(String)
4
(Char)
5
(ID STYLE)
6
(Integer Array)
7
(Float Array)
8
(File)
9
(ID STR wh lpb Ref)
A
(ID STR wo lpb Ref)
B
(ID INT wh lpb Ref)
C
(ID INT wo lpb Ref)
variable 1
(offset 0x8, length 0x4)
Integer value Float value Strings Table offset Char Table offset ID STYLE Table offset Integer Arrays Table offset Float Arrays Table offset Files Table offset ID STR Table offset ID STR Table offset ID INT Table offset ID INT Table offset
variable 2
(offset 0xC, length 0x4)
No use always 0 No use always 0 String length Chars length int to read always 4 Nr. of int's to read Nr. of float's to read File size No use always 0 No use always 0 No use always 0 No use always 0
* w = with || wo = without || lpb = loopback


XML Output[edit | edit source]

This is the Output, saved as xml, from the notification_settings_plugin.rco

download notification_settings_plugin.xml from FW??

*Note: That xml below isn't perfect right now. Especially the values from <styletable> need to be corrected. I'll change the xml here as soon i finished the CXML Tool and got a nice correct xml written out.
 <?xml version="1.0" encoding="UTF-16"?>
 <resource version="0.1" type="normal">
  <stringtable>
     <local origsize="1040" src="xmls/ja.xml"    compress="on" id="ja"/>
     <local origsize="1248" src="xmls/en-gb.xml" compress="on" id="en-gb"/>
     <local origsize="1248" src="xmls/en.cml"    compress="on" id="en"/>
     <local origsize="1328" src="xmls/fr.xml"    compress="on" id="fr"/>
     <local origsize="1392" src="xmls/es.xml"    compress="on" id="es"/>
     <local origsize="1312" src="xmls/de.xml"    compress="on" id="de"/>
     <local origsize="1280" src="xmls/it.xml"    compress="on" id="it"/>
     <local origsize="1296" src="xmls/nl.xml"    compress="on" id="nl"/>
     <local origsize="1312" src="xmls/pt-br.xml" compress="on" id="pt-br"/>
     <local origsize="1296" src="xmls/pt.xml"    compress="on" id="pt"/>
     <local origsize="1312" src="xmls/ru.xml"    compress="on" id="ru"/>
     <local origsize="1040" src="xmls/ko.xml"    compress="on" id="ko"/>
     <local origsize="992"  src="xmls/zh-t.xml"  compress="on" id="zh-t"/>
     <local origsize="992"  src="xmls/zh-s.xml"  compress="on" id="zh-s"/>
     <local origsize="1264" src="xmls/fi.xml"    compress="on" id="fi"/>
     <local origsize="1232" src="xmls/sv.xml"    compress="on" id="sv"/>
     <local origsize="1232" src="xmls/da.xml"    compress="on" id="da"/>
     <local origsize="1232" src="xmls/no.xml"    compress="on" id="no"/>
     <local origsize="1296" src="xmls/pl.xml"    compress="on" id="pl"/>
     <local origsize="1296" src="xmls/tr.xml"    compress="on" id="tr"/>
  </stringtable>
  <texturetable>
     <texture origsize="5328" src="texture/1DDD0E08.gim"  compress="on" id="1DDD0E08"  type="texture/gim"/>
     <texture origsize="7632" src="texture/2133CEEB.gim"  compress="on" id="2133CEEB"  type="texture/gim"/>
     <texture origsize="7632" src="texture/F7988312.gim" compress="on" id="F7988312" type="texture/gim"/>
     <texture origsize="5328" src="texture/6F57E251.gim" compress="on" id="6F57E251" type="texture/gim"/>
     <texture origsize="7632" src="texture/86645D41.gim" compress="on" id="86645D41" type="texture/gim"/>
     <texture src="texture/29B91F26.gim"  origsize="57648" div_ratio_h="0.49" compress="on" margin_v="1" id="29B91F26"  margin_h="1" type="texture/gim" div_mode="3x1"/>
     <texture src="texture/D0A272A1.gim" origsize="57648" div_ratio_h="0.49" compress="on" margin_v="1" id="D0A272A1" margin_h="1" type="texture/gim" div_mode="3x1"/>
  </texturetable>
  <styletable>
     <style_button id="86009135" bg_obj="1, 0, 0, 0" glow_obj="0, 0, 0, 0">
        <planeobj texture0="261FB929" id="01000000"/>
        <planeobj texture0="A172A2D0" blend="2" id="00000000" />
        <style_text textobj="00000000" id="E98E283C"/>
            <textobj font_size="28" bold="1" color="0.49, 1, 1, 1" max_line_count="1" line_pitch="28" word_wrap="1" ellipsis="1" id="00000000"/>
        </style_text>
     </style_button>
     <style_plane id="D7F12CC7" planeobj="0, 0, 0, 0">
        <planeobj texture0="0DD14518" id="01000000"/>
     </style_plane>
     <pagetable>
        <templatetable>
            <template id="9174183F">
                <file_list style="4B363870" id="04000000"/>
                <layout_hint align="0, 0" size="960, 448" id="00000000" pos="0, 0"/>
            </template>
            <template fast_open="1" id="60FB37AF">
                <list_item style="998F48F3" id="02000000">
                    <layout_hint align="0, 0" size="840, 80" id="00000000" pos="448, 0"/>
                    <text style="E98E283C" id="01000000">
                        <layout_hint size="462, 0" align="1, 0" adjust="0, 0" id="05000000" pos="-272, 0"/>
                        <plane style="2B337B5F" id="02000000">
                            <layout_hint pos="-30, 0" id="05000000" adjust="0, 0" alpha="0" anchor="1, 0" size="60, 60"/>
                        </plane>
                        <check_box style="98F8209F" id="00000000">
                            <layout_hint align="2, 0" size="46, 46" pos="602, 0" anchor="1, 0" id="05000000"/>
                            <focus_hint focus_shape="0" focus_size="47, 47"/>
                        </check_box>
                    </text>
                </list_item>
            </template>
            <template fast_open="1" id="23860CE8">
                <list_item style="998F48F3" id="02000000">
                    <layout_hint align="0, 0" size="840, 80" id="00000000" pos="0, 0"/>
                    <button sound="74324120" style="0520652F" id="00000000">
                        <layout_hint size="840, 80" adjust="1, 0" id="01000000" pos="0, 0"/>
                        <focus_hint focus_shape="3" focus_hint="960, 80"/>
                        <text style="E98E283C" id="02000000">
                            <layout_hint size="-206, 0" align="0, 0" adjust="4, 0" id="01000000" pos="0, 330"/>
                            <file_list style="2B337B5F" id="05000000">
                                <layout_hint pos="0, -40" id="01000000" adjust="1, 0" alpha="0" anchor="2, 0" size="60, 60"/>
                            </file_list>
                        </text>
                        <plane style="D7F12CC7" id="D9904322">
                            <layout_hint size="46, 46" align="5, 2" adjust="1, 0" id="EEA339DA" pos="330, 0"/>
                        </plane>
                    </button>
                </list_item>
            </template>
        </templatetable>
     </pagetable>
  </styletable>
 </resource>
 </xml>