Difference between revisions of "Sims 3:0x06B981ED"
HugeLunatic (Talk | contribs) |
|||
(29 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{TS3AdvancedModdingHeader}} | ||
+ | {{TS3Resource | ||
+ | |name=Object Scripts - OBJS | ||
+ | |typeid= 0x06B981ED | ||
+ | |expansion=The Sims 3 | ||
+ | }} | ||
+ | <br clear="all"> | ||
+ | |||
+ | ==Overview== | ||
OBJS - Serialized script objects | OBJS - Serialized script objects | ||
− | By Tiger | + | <br>By Tiger |
The data is divided into four sections | The data is divided into four sections | ||
− | == | + | == Format == |
=== Header (28 bytes) === | === Header (28 bytes) === | ||
− | DWORD version | + | DWORD version - currently 0x00000500 |
− | DWORD magic value ("OBJS") | + | DWORD magic value - ("OBJS") |
− | DWORD count1 - Count of defined object types | + | DWORD count1 - Count of defined object types |
− | DWORD count2 - Count of number of saved instances | + | DWORD count2 - Count of number of saved instances |
− | DWORD - Offset | + | (IF version >= 0x200) |
− | DWORD - Offset | + | DWORD - Offset of the type definitions |
− | DWORD - Offset | + | DWORD - Offset of the instance pointer table |
+ | (IF version >= 0x500) | ||
+ | DWORD - Offset of the header to a TGI index | ||
=== Instances === | === Instances === | ||
− | + | ''count2'' (above) entries:<!--Should that be count1?--><!--no count2 is correct, count1 is below for the type definitions--> | |
− | + | ||
BYTE - Data type | BYTE - Data type | ||
− | + | {Data} | |
− | + | See below for the types of data and the format of the data. Most common here are 0x10 and 0x11, but boxed value types can appear here as well, for example when a number or enum is added to a System.List<System.Object> collection. | |
− | + | ||
− | Most common here are 0x10 and 0x11, but boxed value types can appear here as well, for example when a number or enum is | + | |
=== Instance index === | === Instance index === | ||
Line 30: | Line 38: | ||
=== Type definitions === | === Type definitions === | ||
− | Very loosely structured data, with lots of flags and optional values | + | Very loosely structured data, with lots of flags and optional values including count1 entries |
− | + | Each entry consists of | |
− | + | TYPE_SIGNATURE {TYPE_METHODS | NULL_METHODS} | |
− | + | ||
− | + | TYPE_SIGNATURE = | |
− | + | [TYPE_MODIFIERS] [GENERIC_DEFINITION] NAMESTRING | |
− | + | ||
− | + | TYPE_MODIFIERS = | |
− | + | [POINTER_FLAG] [BYREF_FLAG] [ARRAY_TYPE_FLAG] [GENERIC_PARAMETERS] [NULLBYTE | ANONYMOUS] | |
− | + | ||
− | + | POINTER_FLAG = 0x01 | |
+ | |||
+ | BYREF_FLAG = 0x02 | ||
+ | |||
+ | ANONYMOUS_FLAG = 0x04 (An anonymous class created just to service the lowly "yield" operator - the class name & generic types will be the defining class) | ||
+ | |||
+ | ARRAY_TYPE_FLAG = ONE_DIMENSIONAL_ARRAY | MULTIDIMENSIONAL_ARRAY | ||
+ | |||
+ | ONE_DIMENSIONAL_ARRAY = 0x03 | ||
+ | |||
+ | MULTIDIMENSIONAL_ARRAY = 0x10 + rank - 1 | ||
+ | |||
+ | GENERIC_PARAMETERS = 0x20 + generic parameter count - 1 | ||
+ | |||
+ | GENERIC_DEFINITION = generic parameter count (GENERIC_PARAMETERS - 20 + 1) repeats of | ||
+ | TYPE_SIGNATURE | ||
+ | |||
+ | NAME = | ||
+ | CHAR_COUNT BYTE(With CHARCOUNT repeats) | ||
+ | |||
+ | CHAR_COUNT = | ||
+ | BYTE [BYTE] (7 bit LSB order bytes, with the high bit indicating continuation) | ||
+ | |||
+ | TYPE_METHODS = | ||
+ | METHOD_COUNT [(1..N)METHOD_DEFINITION] | ||
+ | |||
+ | METHODCOUNT = | ||
+ | BYTE [BYTE] (7 bit MSB order bytes, with the high bit indicating continuation and bit 7 in the first byte sign extended) | ||
+ | |||
+ | METHOD_DEFINITION = | ||
+ | NAME PRIMITIVE_TYPE | ||
+ | |||
+ | PRIMITIVE_TYPE = | ||
+ | BYTE (See section below) | ||
+ | |||
+ | NULL_METHODS = | ||
+ | 0x7F (Decodes as a 7 bit sign extended value to -1) | ||
+ | |||
+ | Generic parameter definitions can be nested in the data structure, as would be required by System.Dictionary<System.UInt32,System.List<Sims3.CAS.SimDescription>><br> | ||
+ | Some types do not list any fields even though they have them. In general, types listed with fields are any generic type serialized using reflection. Some types have special serialization handlers, in which case the format is hard coded rather than described. An example of hard coded types is delegates, or the root type ScriptCore. | ||
=== TGI === | === TGI === | ||
+ | (IF version >= 0x500) | ||
DWORD count5 - count of TGI entries | DWORD count5 - count of TGI entries | ||
TGI entries, in standard order | TGI entries, in standard order | ||
== Primitive Types == | == Primitive Types == | ||
+ | |||
+ | Defined in ScriptCore.PersistedTypeCode | ||
{| class="wikitable" border="1" | {| class="wikitable" border="1" | ||
Line 55: | Line 105: | ||
! Data format | ! Data format | ||
! Notes | ! Notes | ||
+ | |- | ||
+ | | 0x00 | ||
+ | | Null | ||
+ | | | ||
+ | | | ||
|- | |- | ||
| 0x01 | | 0x01 | ||
Line 69: | Line 124: | ||
| Byte | | Byte | ||
| BYTE | | BYTE | ||
− | | | + | | |
+ | |- | ||
+ | | 0x04 | ||
+ | | Char | ||
+ | | Unknown | ||
+ | | | ||
|- | |- | ||
| 0x05 | | 0x05 | ||
| DateTime | | DateTime | ||
| QWORD | | QWORD | ||
− | | [http://msdn.microsoft.com/en-us/library/system.datetime.frombinary.aspx System.DateTime] | + | | [http://msdn.microsoft.com/en-us/library/system.datetime.frombinary.aspx System.DateTime] Ticks value |
+ | |- | ||
+ | | 0x06 | ||
+ | | Decimal | ||
+ | | BYTE[16] | ||
+ | | See [http://msdn.microsoft.com/en-us/library/system.decimal.aspx MSDN] for the binary representation of a Decimal type. | ||
+ | |- | ||
+ | | 0x07 | ||
+ | | Double | ||
+ | | QWORD | ||
+ | | | ||
|- | |- | ||
| 0x08 | | 0x08 | ||
Line 92: | Line 162: | ||
|- | |- | ||
| 0x0B | | 0x0B | ||
− | | | + | | SByte |
| BYTE | | BYTE | ||
− | | | + | | Signed byte |
|- | |- | ||
| 0x0C | | 0x0C | ||
− | | | + | | Single |
− | | | + | | DWORD |
| Single precision floating point number | | Single precision floating point number | ||
|- | |- | ||
Line 117: | Line 187: | ||
|- | |- | ||
| 0x10 | | 0x10 | ||
− | | | + | | Object |
− | | DWORD type | + | | DWORD type<br> |
Various data | Various data | ||
| Type references a defined structure, with the fields for that object immediately following | | Type references a defined structure, with the fields for that object immediately following | ||
Line 124: | Line 194: | ||
|- | |- | ||
| 0x10 | | 0x10 | ||
− | | Object | + | | Object |
− | | DWORD type | + | | DWORD type<br> |
Count * DWORD instance reference | Count * DWORD instance reference | ||
| When in the context of an array (Type 0x11) | | When in the context of an array (Type 0x11) | ||
Line 131: | Line 201: | ||
| 0x11 | | 0x11 | ||
| Array | | Array | ||
− | | DWORD Length | + | | DWORD Length<br> |
− | BYTE Primitive type | + | BYTE Primitive type<br> |
− | Length * format appropriate for data type | + | Length * format appropriate for data type<br> |
Data type 0x10 is treated as an object reference rather than the direct formatted data | Data type 0x10 is treated as an object reference rather than the direct formatted data | ||
| Referenced by most single member collection classes as well (List, ArrayList, Queue, Stack, etc) | | Referenced by most single member collection classes as well (List, ArrayList, Queue, Stack, etc) | ||
+ | |- | ||
+ | | 0x12 | ||
+ | | Type Zero based | ||
+ | | | ||
+ | | Like Type One Based, but indexed starting at 0. Not written by current TS3 build. | ||
+ | |- | ||
+ | | 0x13 | ||
+ | | Broken Protected Object | ||
+ | | | ||
+ | | Like protected object, but with a broken encoding for the length. All but the final length byte are written as DWORDs. Not written by current TS3 builds. | ||
+ | |- | ||
+ | | 0x14 | ||
+ | | External Object | ||
+ | | BYTE+ Type (Zero based)<br> | ||
+ | [BYTE] Additional type bytes | ||
+ | Type specific data | ||
+ | | Currently used for shared objects, with a System.Type reference (Redundant) followed by a GUID. | ||
+ | |- | ||
+ | | 0x15 | ||
+ | | Broken Enum | ||
+ | | | ||
+ | | Like Enum but with a broken encoding for the type number. All but the final length byte are written as DWORDs. Not written by current TS3 builds. | ||
|- | |- | ||
| 0x16 | | 0x16 | ||
− | | | + | | Protected Object |
− | | BYTE length | + | | BYTE length<br> |
− | BYTE | + | [BYTE] Additional length bytes<br> |
− | | | + | BYTE x length Object Instance format data |
− | + | | Stores an object instance "protected" by a length encoding (Used for state machine client handles) | |
|- | |- | ||
| 0x17 | | 0x17 | ||
| Enum | | Enum | ||
− | | BYTE+ Type of enum | + | | BYTE+ Type of enum<br> |
− | (BYTES) optional additional as needed for the size of the type ID | + | (BYTES) optional additional as needed for the size of the type ID<br> |
− | BYTE Numerical primitive type (3, 8, 9, 10, etc) | + | BYTE Numerical primitive type (3, 8, 9, 10, etc)<br> |
BYTE/WORD/DWORD/QWORD Enum value | BYTE/WORD/DWORD/QWORD Enum value | ||
| The length is encoded as 7 bits, with the high bit indicating the value continues to further bytes. The value is in MSB order (Opposite normal byte order) | | The length is encoded as 7 bits, with the high bit indicating the value continues to further bytes. The value is in MSB order (Opposite normal byte order) | ||
+ | |- | ||
+ | | 0x18 | ||
+ | | Method | ||
+ | | DWORD Type ID of the declaring type<br> | ||
+ | DWORD Reference to a System.String of the method name<br> | ||
+ | DWPRD Reference to an array of parameter types<br> | ||
+ | DWORD Reference to an array of generic argument types<br> | ||
+ | | Serialization of System.Reflection.MethodInfo | ||
|- | |- | ||
| 0x19 | | 0x19 | ||
− | | | + | | ResKey |
| DWORD | | DWORD | ||
− | | Index into the TGI table | + | | Index into the TGI table. |
+ | | Corresponds to Sims3.SimIFace.ResourceKey | ||
|- | |- | ||
| 0x1A | | 0x1A | ||
− | | | + | | Type One Based |
− | | BYTE+ | + | | BYTE+<br> |
− | (BYTE)s as needed for the | + | (BYTE)s as needed for the type ID |
− | | Same format used for Enum definition | + | | Corresponds to System.Type, and references the type by ID<br> |
− | For example, 0x82 0x0A would encode the value 266. | + | Same format used for Enum definition where it encodes the type of the enum<br> |
− | + | For example, 0x82 0x0A would encode the value 266. This indexes the types starting at 1 rather than 0, so the actual type value is one less than the number (So the type number in the exampe would be 265). A value of 0 indicates null. | |
|} | |} | ||
+ | |||
+ | {{TS3AdvancedModdingHeader}} |
Latest revision as of 01:44, 5 May 2010
Modding Reference by Category | |
---|---|
Sims 3 :DBPF | File Types | RCOL(Scene) | Catalog Resource | String Table | Key Table | TS3 Programmer's Reference |
Object Scripts - OBJS | ||
---|---|---|
TypeID: | 0x06B981ED | |
Game Version: | The Sims 3 |
Contents |
[edit] Overview
OBJS - Serialized script objects
By Tiger
The data is divided into four sections
[edit] Format
[edit] Header (28 bytes)
DWORD version - currently 0x00000500 DWORD magic value - ("OBJS") DWORD count1 - Count of defined object types DWORD count2 - Count of number of saved instances (IF version >= 0x200) DWORD - Offset of the type definitions DWORD - Offset of the instance pointer table (IF version >= 0x500) DWORD - Offset of the header to a TGI index
[edit] Instances
count2 (above) entries:
BYTE - Data type {Data}
See below for the types of data and the format of the data. Most common here are 0x10 and 0x11, but boxed value types can appear here as well, for example when a number or enum is added to a System.List<System.Object> collection.
[edit] Instance index
count2 repeats of DWORD - Pointer to the start of the serialized instance data This index is 1 based, with the first entry referenced as entry 1. 0 is reserved to indicate null references
[edit] Type definitions
Very loosely structured data, with lots of flags and optional values including count1 entries Each entry consists of TYPE_SIGNATURE {TYPE_METHODS | NULL_METHODS} TYPE_SIGNATURE = [TYPE_MODIFIERS] [GENERIC_DEFINITION] NAMESTRING TYPE_MODIFIERS = [POINTER_FLAG] [BYREF_FLAG] [ARRAY_TYPE_FLAG] [GENERIC_PARAMETERS] [NULLBYTE | ANONYMOUS] POINTER_FLAG = 0x01 BYREF_FLAG = 0x02 ANONYMOUS_FLAG = 0x04 (An anonymous class created just to service the lowly "yield" operator - the class name & generic types will be the defining class) ARRAY_TYPE_FLAG = ONE_DIMENSIONAL_ARRAY | MULTIDIMENSIONAL_ARRAY ONE_DIMENSIONAL_ARRAY = 0x03 MULTIDIMENSIONAL_ARRAY = 0x10 + rank - 1 GENERIC_PARAMETERS = 0x20 + generic parameter count - 1 GENERIC_DEFINITION = generic parameter count (GENERIC_PARAMETERS - 20 + 1) repeats of TYPE_SIGNATURE NAME = CHAR_COUNT BYTE(With CHARCOUNT repeats) CHAR_COUNT = BYTE [BYTE] (7 bit LSB order bytes, with the high bit indicating continuation) TYPE_METHODS = METHOD_COUNT [(1..N)METHOD_DEFINITION] METHODCOUNT = BYTE [BYTE] (7 bit MSB order bytes, with the high bit indicating continuation and bit 7 in the first byte sign extended) METHOD_DEFINITION = NAME PRIMITIVE_TYPE PRIMITIVE_TYPE = BYTE (See section below) NULL_METHODS = 0x7F (Decodes as a 7 bit sign extended value to -1)
Generic parameter definitions can be nested in the data structure, as would be required by System.Dictionary<System.UInt32,System.List<Sims3.CAS.SimDescription>>
Some types do not list any fields even though they have them. In general, types listed with fields are any generic type serialized using reflection. Some types have special serialization handlers, in which case the format is hard coded rather than described. An example of hard coded types is delegates, or the root type ScriptCore.
[edit] TGI
(IF version >= 0x500) DWORD count5 - count of TGI entries TGI entries, in standard order
[edit] Primitive Types
Defined in ScriptCore.PersistedTypeCode
Byte | Type of data | Data format | Notes | |
---|---|---|---|---|
0x00 | Null | |||
0x01 | Reference | DWORD of instance ID | ||
0x02 | Boolean | BYTE | 0 for false, 1 for true | |
0x03 | Byte | BYTE | ||
0x04 | Char | Unknown | ||
0x05 | DateTime | QWORD | System.DateTime Ticks value | |
0x06 | Decimal | BYTE[16] | See MSDN for the binary representation of a Decimal type. | |
0x07 | Double | QWORD | ||
0x08 | Short | WORD | ||
0x09 | Int | DWORD | ||
0x0A | Long | QWORD | ||
0x0B | SByte | BYTE | Signed byte | |
0x0C | Single | DWORD | Single precision floating point number | |
0x0D | Ushort | WORD | Unsigned | |
0x0E | Uint | DWORD | Unsigned | |
0x0F | Ulong | QWORD | Unsigned | |
0x10 | Object | DWORD type Various data |
Type references a defined structure, with the fields for that object immediately following
Usually appears as the type of an instance, but it can appear in the middle of formatted data to represent a non-system defined value type (IE a struct) | |
0x10 | Object | DWORD type Count * DWORD instance reference |
When in the context of an array (Type 0x11) | |
0x11 | Array | DWORD Length BYTE Primitive type |
Referenced by most single member collection classes as well (List, ArrayList, Queue, Stack, etc) | |
0x12 | Type Zero based | Like Type One Based, but indexed starting at 0. Not written by current TS3 build. | ||
0x13 | Broken Protected Object | Like protected object, but with a broken encoding for the length. All but the final length byte are written as DWORDs. Not written by current TS3 builds. | ||
0x14 | External Object | BYTE+ Type (Zero based) [BYTE] Additional type bytes Type specific data |
Currently used for shared objects, with a System.Type reference (Redundant) followed by a GUID. | |
0x15 | Broken Enum | Like Enum but with a broken encoding for the type number. All but the final length byte are written as DWORDs. Not written by current TS3 builds. | ||
0x16 | Protected Object | BYTE length [BYTE] Additional length bytes |
Stores an object instance "protected" by a length encoding (Used for state machine client handles) | |
0x17 | Enum | BYTE+ Type of enum (BYTES) optional additional as needed for the size of the type ID |
The length is encoded as 7 bits, with the high bit indicating the value continues to further bytes. The value is in MSB order (Opposite normal byte order) | |
0x18 | Method | DWORD Type ID of the declaring type DWORD Reference to a System.String of the method name |
Serialization of System.Reflection.MethodInfo | |
0x19 | ResKey | DWORD | Index into the TGI table. | Corresponds to Sims3.SimIFace.ResourceKey |
0x1A | Type One Based | BYTE+ (BYTE)s as needed for the type ID |
Corresponds to System.Type, and references the type by ID Same format used for Enum definition where it encodes the type of the enum |
Modding Reference by Category | |
---|---|
Sims 3 :DBPF | File Types | RCOL(Scene) | Catalog Resource | String Table | Key Table | TS3 Programmer's Reference |