Editing CXML structure

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
== XML implicit structure Overview ==
== XML implicit structure Overview ==
<source lang="cpp">
<source lang="cpp">
  namespace cxml {
  namespace cxml
    class cxml : public Base {
{
        struct Header { /*header of a cxml document*/
struct Header { /*header of a cxml document*/
            char magic[4];
                char magic[4];
            int version;
                int version;
            int tree_offset;
                int tree_offset;
            int tree_size;
                int tree_size;
            int idstrtable_offset;
                int idstrtable_offset;
            int idstrtable_size;
                int idstrtable_size;
            int idinttable_offset;
                int idinttable_offset;
            int idinttable_size;
                int idinttable_size;
            int stringtable_offset;
                int stringtable_offset;
            int stringtable_size;
                int stringtable_size;
            int chartable_offset;
                int styleidtable_offset;
            int chartable_size;
                int styleidtable_size;
            int styleidtable_offset;
                int intarraytable_offset;
            int styleidtable_size;
                int intarraytable_size;
            int intarraytable_offset;
                int floatarraytable_offset;
            int intarraytable_size;
                int floatarraytable_size;
            int floatarraytable_offset;
                int filetable_offset;
            int floatarraytable_size;
                int filetable_size;
            int filetable_offset;
        };
            int filetable_size;
        };
          
          
        struct ChildElementBin {
        struct ChildElementBin
            int name;
        {
            int attr_num;
                int name;
            int parent_node;
                int attr_num;
            int prev_sibling;
                int parent;
            int next_sibling;
                int prev;
            int first_child;
                int next;
            int last_child;
                int first_child;
            AttributeBin attribute;
                int last_child;
        };
        };
          
          
        struct SiblingElementBin {
        struct BrotherElementBin
            int name;
        {
            int attr_num;
                int name;
            int parent_node;
                int attr_num;
            int prev_sibling;
                int parent;
            int next_sibling;
                int prev;
            AttributeBin attribute;
                int next;
        };
        };
          
          
        struct AttributeBin {
        struct AttributeBin
            typedef enum {
        {
                NONE,
                int INTEGER = 1;
                INTEGER,
                int FLOAT = 2;
                FLOAT,
                int STRING = 3;
                STRING,
                int unk = 4;
                CHAR,
                int STYLE_ID = 5;
                STYLE_ID,
                int INTEGER_ARRAY = 6;
                INTEGER_ARRAY,
                int FLOAT_ARRAY = 7;
                FLOAT_ARRAY,
                int DATA = 8;
                DATA,
                int ID_STR_REF = 9;
                ID_STR_LPB,
                int ID_STR_NO_REF = 10;
                ID_STR,
                int ID_INT_REF = 11;
                ID_INT_LPB,
                int ID_INT_NO_REF = 12;
                ID_INT,
                int name;
            } TYPE;
                int type;
   
   
            int name;
                struct StringData
            TYPE type;
                {
                        int offset;
            struct SingleValue {
                        int len;
                int intValue;
                };
                float floatValue;     
            };
            struct StringData {
                int offset;
                int len;
            };
            struct CharData {
                int offset;
                int len;
            };
                  
                  
            struct IntArrayData {
                struct IntArrayData
                int offset;
                {
                int num;
                        int offset;
            };
                        int num;
                };
                  
                  
            struct FloatArrayData {
                struct FloatArrayData
                int offset;
                {
                int num;
                        int offset;
            };
                        int num;
                };
                
                
            struct FileData {
                struct FileData
                int offset;
                {
                int size;
                        int offset;
            };
                        int size;
                };
            struct IdStringTableData {
                int offset;
                bool loopback;
            };
            struct IdIntegerTableData {
                int offset;
                bool loopback;
            };
                  
                  
            union {
                union
                int i;
                {
                float f;
                        int i;
                StringData s;
                        float f;
                CharData c;
                        StringData s;
                IntArrayData ia;
                        IntArrayData ia;
                FloatArrayData fa;
                        FloatArrayData fa;
                FileData file;
                        FileData file;
                int id;
                        int id;
                int idref;
                        int idref;
            };
                };
        };
        };
          
          
        struct IDBin {
        struct IDBin
            int entity_offset;
        {
            char id[0];
                int entity_offset;
        };
                char id[0];
        };
          
          
        enum AllocationType {
        enum AllocationType
            AllocationType_Alloc_Tree,
        {
            AllocationType_Alloc_IDSTRTable,
                AllocationType_Alloc_Tree,
            AllocationType_Alloc_IDINTTable,
                AllocationType_Alloc_IDSTRTable,
            AllocationType_Alloc_StringTable,
                AllocationType_Alloc_IDINTTable,
            AllocationType_Alloc_CharTable,
                AllocationType_Alloc_StringTable,
            AllocationType_Alloc_IntArrayTable,
                AllocationType_Alloc_IntArrayTable,
            AllocationType_Alloc_FloatArrayTable,
                AllocationType_Alloc_FloatArrayTable,
            AllocationType_Alloc_FileTable,
                AllocationType_Alloc_FileTable,
            AllocationType_Alloc_StyleIDTable,
                AllocationType_Alloc_StyleIDTable,
    
    
            AllocationType_Free_Tree,
                AllocationType_Free_Tree,
            AllocationType_Free_IDSTRTable,
                AllocationType_Free_IDSTRTable,
            AllocationType_Free_IDINTTable,
                AllocationType_Free_IDINTTable,
            AllocationType_Free_StringTable,
                AllocationType_Free_StringTable,
            AllocationType_Free_CharTable,
                AllocationType_Free_IntArrayTable,
            AllocationType_Free_IntArrayTable,
                AllocationType_Free_FloatArrayTable,
            AllocationType_Free_FloatArrayTable,
                AllocationType_Free_FileTable,
            AllocationType_Free_FileTable,
                AllocationType_AFree_StyleIDTable,
            AllocationType_AFree_StyleIDTable,
        };
        };
        
        
        enum AccessMode {
        enum AccessMode
            AccessMode_ReadWrite,
        {
            AccessMode_ReadOnly_File,
                AccessMode_ReadWrite,
            AccessMode_ReadOnly_Memory,
                AccessMode_ReadOnly_File,
        };
                AccessMode_ReadOnly_Memory,
        };
          
          
        class Document {
        class Document {
        public:
        public:
            typedef void (*Allocator)( AllocationType type, void * userdata, void * old_addr, unsigned int required_size, void ** addr, unsigned int * size );
                typedef void (*Allocator)( AllocationType type, void * userdata, void * old_addr, unsigned int required_size, void ** addr, unsigned int * size );
          
          
        private:
        private:
            AccessMode access_mode;
                AccessMode access_mode;
            Header header;
                Header header;
            char *tree;
                char * tree;
            unsigned int tree_capacity;
                unsigned int tree_capacity;
            char *idstrtable;
                char * idstrtable;
            unsigned int idstrtable_capacity;
                unsigned int idstrtable_capacity;
            char *idinttable;
                char * idinttable;
            unsigned int idinttable_capacity;
                unsigned int idinttable_capacity;
            char *stringtable;
                char * stringtable;
            unsigned int stringtable_capacity;
                unsigned int stringtable_capacity;
            char *chartable;
                int * intarraytable;
            unsigned int chartable_capacity;
                unsigned int intarraytable_capacity;
            int *intarraytable;
                float * floatarraytable;
            unsigned int intarraytable_capacity;
                unsigned int floatarraytable_capacity;
            float *floatarraytable;
                char * filetable;
            unsigned int floatarraytable_capacity;
                unsigned int filetable_capacity;
            char *filetable;
                char * styleidtable;
            unsigned int filetable_capacity;
                unsigned int styleidtable_capacity;
            char *styleidtable;
                Allocator allocator;
            unsigned int styleidtable_capacity;
                void * allocator_userdata;
            Allocator allocator;
        };
            void *allocator_userdata;
        };
          
          
        class Element {
        class Element {
        private:
        private:
            Document *doc;
                Document * doc;
            int offset;
                int offset;
        };
        };
        
        
        class Attribute {
        class Attribute {
        private:
        private:
            Document *doc;
                Document * doc;
            int element_offset;
                int element_offset;
            int 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.
        };
    };
  };
  };
</source>
</source>
Line 216: Line 185:
| 0x08 || 0x04 || Parent relative offset in '''TOC'''
| 0x08 || 0x04 || Parent relative offset in '''TOC'''
|-
|-
| 0x0C || 0x04 || Previous Sibling relative offset in '''TOC'''
| 0x0C || 0x04 || Previous Brother relative offset in '''TOC'''
|-
|-
| 0x10 || 0x04 || Next Sibling relative offset in '''TOC'''
| 0x10 || 0x04 || Next Brother relative offset in '''TOC'''
|-
|-
| 0x14 || 0x04 || First child relative offset in '''TOC'''
| 0x14 || 0x04 || First child relative offset in '''TOC'''
Line 224: Line 193:
| 0x18 || 0x04 || Last child relative offset in '''TOC'''
| 0x18 || 0x04 || Last child relative offset in '''TOC'''
|}
|}
Length is 7 x 4 bytes == 28 bytes (0x1C).


{| class="wikitable" style="text-align:center;"
{| class="wikitable" style="text-align:center;"
|+ CXML Sibling Element definition
|+ CXML Brother Element definition
! Offset !! Length !! usage
! Offset !! Length !! usage
|-
|-
Line 237: Line 204:
| 0x08 || 0x04 || Parent relative offset in '''TOC'''
| 0x08 || 0x04 || Parent relative offset in '''TOC'''
|-
|-
| 0x0C || 0x04 || Previous Sibling relative offset in '''TOC'''
| 0x1C || 0x04 || Previous Brother relative offset in '''TOC'''
|-
|-
| 0x10 || 0x04 || Next Sibling relative offset in '''TOC'''
| 0x10 || 0x04 || Next Brother relative offset in '''TOC'''
|}
|}
Length is 5 x 4 bytes == 20 bytes (0x14).
*NOTE: The '''Child Element''' defination describe the Child Element and his Attributes where the '''Brother Element''' describe the Brother Element and his Attributes.
 
So the full order to read will be '''Child Element''' >>> '''Attributes''', '''Brother Element''' >>> '''Attributes'''. The Root (so offset 0x00) of any SonyPlaystation Resource file always start's with a Child element to read.
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===
===Attribute===
Line 255: Line 218:
|-
|-
! Attribute type<BR />(offset 0x4, length 0x4)
! Attribute type<BR />(offset 0x4, length 0x4)
! 1<BR />(Single Integer Val) !! 2<BR />(Single Float Val) !! 3<BR />(String) !! 4<BR />(Char) !! 5<BR />(ID STYLE) !! 6<BR />(Integer Array) !! 7<BR />(Float Array) !! 8<BR />(File) !! 9<BR />(ID STR wh lpb Ref) !! A<BR />(ID STR wo lpb Ref) !! B<BR />(ID INT wh lpb Ref) !! C<BR />(ID INT wo lpb Ref)
! 1<BR />(Single Integer) !! 2<BR />(Single Float) !! 3<BR />(String) !! 4<BR />(analysing...) !! 5<BR />(ID STYLE) !! 6<BR />(Integer Array) !! 7<BR />(Float Array) !! 8<BR />(File) !! 9<BR />(ID STR w lpb Ref) !! A<BR />(ID STR wo lpb Ref) !! B<BR />(ID INT w lpb Ref) !! C<BR />(ID INT wo lpb Ref)
|-
|-
! variable 1<BR />(offset 0x8, length 0x4)
! variable 1<BR />(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
| Integer value || Float value || '''Strings Table''' offset || analysing... || '''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<BR />(offset 0xC, length 0x4)
! variable 2<BR />(offset 0xC, length 0x4)
| {{cellcolors|#ffaaaa}} No use <abbr title="(always 0 in the samples found)">always 0</abbr> || {{cellcolors|#ffaaaa}} No use <abbr title="(always 0 in the samples found)">always 0</abbr> || String length || Chars length || int to read always 4 || Nr. of int's to read || Nr. of float's to read || File size || {{cellcolors|#ffaaaa}} No use <abbr title="(always 0 in the samples found)">always 0</abbr> || {{cellcolors|#ffaaaa}} No use <abbr title="(always 0 in the samples found)">always 0</abbr> || {{cellcolors|#ffaaaa}} No use <abbr title="(always 0 in the samples found)">always 0</abbr> || {{cellcolors|#ffaaaa}} No use <abbr title="(always 0 in the samples found)">always 0</abbr>
| {{cellcolors|#ffaaaa}} Not used <abbr title="(always 0 in the samples found)">(always 0)</abbr> || {{cellcolors|#ffaaaa}} Not used <abbr title="(always 0 in the samples found)">(always 0)</abbr> || String length || analysing... || Nr. of int's to read (always 4) || Nr. of int's to read || Nr. of float's to read || File size || {{cellcolors|#ffaaaa}} Not used <abbr title="(always 0 in the samples found)">(always 0)</abbr> || {{cellcolors|#ffaaaa}} Not used <abbr title="(always 0 in the samples found)">(always 0)</abbr> || {{cellcolors|#ffaaaa}} Not used <abbr title="(always 0 in the samples found)">(always 0)</abbr> || {{cellcolors|#ffaaaa}} Not used <abbr title="(always 0 in the samples found)">(always 0)</abbr>
|}
|}
  * w = with || wo = without || lpb = loopback
  * w = with || wo = without || lpb = loopback
Line 272: Line 235:
  *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.
  *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.
<source lang="xml">
<source lang="xml">
  <?xml version="1.0" encoding="UTF-16"?>
  <?xml version="1.0" encoding="UTF-8"?>
  <resource version="0.1" type="normal">
  <resource version="0.1" type="normal">
   <stringtable>
   <stringtable>
Please note that all contributions to PS4 Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see PS4 Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)

Template used on this page: