@@ -37,41 +37,32 @@ function __construct($file) {
37
37
$ this ->fileGen = $ stream ->long ;
38
38
$ dataOffset = $ stream ->long ;
39
39
40
- switch ($ this ->fileGen ) {
41
- case 6 :
42
- $ stream ->position = $ dataEnd - $ tableSize + 1 ;
43
- break ;
44
- case 7 :
45
- $ stream ->position = $ dataEnd - $ tableSize + 1 ;
46
- $ this ->m_Version = $ stream ->string ;
47
- break ;
48
- case 8 :
49
- $ stream ->position = $ dataEnd - $ tableSize + 1 ;
50
- $ this ->m_Version = $ stream ->string ;
51
- $ this ->platform = $ stream ->long ;
52
- break ;
53
- case 9 :
54
- $ stream ->position += 4 ;
55
- $ this ->m_Version = $ stream ->string ;
56
- $ this ->platform = $ stream ->long ;
57
- break ;
58
- case 14 :
59
- case 15 :
60
- case 16 :
61
- case 17 :
62
- $ stream ->position += 4 ;
63
- $ this ->m_Version = $ stream ->string ;
64
- $ this ->platform = $ stream ->long ;
65
- $ this ->baseDefinitions = $ stream ->readBoolean ();
66
- break ;
67
- default :
68
- return ;
40
+ if ($ this ->fileGen >= 9 ) {
41
+ $ endian = $ stream ->byte ;
42
+ $ stream ->readData (3 );
43
+ } else {
44
+ $ stream ->position = $ dataEnd - $ tableSize ;
45
+ $ endian = $ stream ->byte ;
69
46
}
70
-
71
- if ($ this ->platform > 255 || $ this ->platform < 0 ) {
72
- $ this ->platform = unpack ('V ' , pack ('N ' , $ this ->platform ))[1 ];
47
+ if ($ this ->fileGen >= 22 ) {
48
+ $ tableSize = $ stream ->ulong ;
49
+ $ dataEnd = $ stream ->longlong ;
50
+ $ dataOffset = $ stream ->longlong ;
51
+ }
52
+ if ($ endian === "\0" ) {
73
53
$ stream ->littleEndian = true ;
74
54
}
55
+
56
+ if ($ this ->fileGen >= 7 ) {
57
+ $ this ->m_Version = $ stream ->string ;
58
+ }
59
+ if ($ this ->fileGen >= 8 ) {
60
+ $ this ->platform = $ stream ->long ;
61
+ }
62
+ if ($ this ->fileGen >= 13 ) {
63
+ $ this ->baseDefinitions = $ stream ->byte === "\x01" ;
64
+ }
65
+
75
66
switch ($ this ->platform ) {
76
67
case -2 : $ this ->platformStr = 'Unity Package ' ; break ;
77
68
case 4 : $ this ->platformStr = 'OSX ' ; break ;
@@ -95,7 +86,7 @@ function __construct($file) {
95
86
if ($ this ->fileGen < 14 ) {
96
87
throw new Exception ('fileGen < 14 ' );
97
88
} else {
98
- $ this ->readBase5 ();
89
+ $ this ->readSerializedType ();
99
90
}
100
91
}
101
92
@@ -165,7 +156,7 @@ function __construct($file) {
165
156
} catch (Excepti4on $ e ) { }
166
157
}
167
158
168
- private function readBase5 () {
159
+ private function readSerializedType () {
169
160
$ stream = $ this ->stream ;
170
161
$ classID = $ stream ->long ;
171
162
if ($ this ->fileGen > 15 ) {
@@ -185,13 +176,17 @@ private function readBase5() {
185
176
}
186
177
$ stream ->position += 16 ;
187
178
if ($ this ->baseDefinitions ) {
179
+ $ nodeInfoSize = 24 ;
180
+ if ($ this ->fileGen >= 19 ) {
181
+ $ nodeInfoSize += 8 ;
182
+ }
188
183
$ varCount = $ stream ->long ;
189
184
$ stringSize = $ stream ->long ;
190
- $ stream ->position += $ varCount * 24 ;
185
+ $ stream ->position += $ varCount * $ nodeInfoSize ;
191
186
$ stringReader = new MemoryStream ($ stringSize ?$ stream ->readData ($ stringSize ):'' );
192
187
$ className = '' ;
193
188
$ classVar = [];
194
- $ stream ->position -= $ varCount * 24 + $ stringSize ;
189
+ $ stream ->position -= $ varCount * $ nodeInfoSize + $ stringSize ;
195
190
for ($ i =0 ; $ i <$ varCount ; $ i ++) {
196
191
$ stream ->readInt16 ();
197
192
$ level = ord ($ stream ->readData (1 ));
@@ -216,6 +211,9 @@ private function readBase5() {
216
211
$ size = $ stream ->long ;
217
212
$ flag2 = $ stream ->readInt32 () != 0 ;
218
213
$ flag = $ stream ->long ;
214
+ if ($ this ->fileGen >= 19 ) {
215
+ $ RefTypeHash = $ stream ->ulonglong ;
216
+ }
219
217
if (!$ flag2 ) {
220
218
$ className = $ varTypeStr . ' ' . $ varNameStr ;
221
219
} else {
@@ -237,6 +235,11 @@ private function readBase5() {
237
235
);
238
236
//aClass.SubItems.Add(classID.ToString());
239
237
$ this ->ClassStructures [$ classID ] = $ aClass ;
238
+
239
+ if ($ this ->fileGen >= 21 ) {
240
+ $ arrSize = $ stream ->long ;
241
+ $ stream ->position += $ arrSize * 4 ;
242
+ }
240
243
}
241
244
}
242
245
0 commit comments