Skip to content

Commit fc4d023

Browse files
committed
Add support for v38
1 parent bbfb922 commit fc4d023

9 files changed

Lines changed: 475 additions & 87 deletions

File tree

Il2CppDumper/IO/BinaryStream.cs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,110 @@ private object ReadPrimitive(Type type)
112112
return ReadClass<T>();
113113
}
114114

115+
public TypeIndex ReadTypeIndex()
116+
{
117+
if (Version < 35)
118+
{
119+
// Before Version 35, these were always Int32
120+
int value = ReadInt32();
121+
return new TypeIndex(value);
122+
}
123+
else
124+
{
125+
switch (Metadata.typeIndexSize)
126+
{
127+
case 1:
128+
{
129+
uint value = ReadByte();
130+
if (value == Byte.MaxValue) return new TypeIndex(-1);
131+
return new TypeIndex((int)value);
132+
}
133+
case 2:
134+
{
135+
uint value = ReadUInt16();
136+
if (value == UInt16.MaxValue) return new TypeIndex(-1);
137+
return new TypeIndex((int)value);
138+
}
139+
case 4:
140+
default:
141+
{
142+
uint value = ReadUInt32();
143+
if (value == UInt32.MaxValue) return new TypeIndex(-1);
144+
return new TypeIndex((int)value);
145+
}
146+
}
147+
}
148+
}
149+
150+
public TypeDefinitionIndex ReadTypeDefinitionIndex()
151+
{
152+
if (Version < 35)
153+
{
154+
// Before Version 35, these were always Int32
155+
int value = ReadInt32();
156+
return new TypeDefinitionIndex(value);
157+
}
158+
else
159+
{
160+
switch (Metadata.typeDefinitionIndexSize)
161+
{
162+
case 1:
163+
{
164+
uint value = ReadByte();
165+
if (value == Byte.MaxValue) return new TypeDefinitionIndex(-1);
166+
return new TypeDefinitionIndex((int)value);
167+
}
168+
case 2:
169+
{
170+
uint value = ReadUInt16();
171+
if (value == UInt16.MaxValue) return new TypeDefinitionIndex(-1);
172+
return new TypeDefinitionIndex((int)value);
173+
}
174+
case 4:
175+
default:
176+
{
177+
uint value = ReadUInt32();
178+
if (value == UInt32.MaxValue) return new TypeDefinitionIndex(-1);
179+
return new TypeDefinitionIndex((int)value);
180+
}
181+
}
182+
}
183+
}
184+
public GenericContainerIndex ReadGenericContainerIndex()
185+
{
186+
if (Version < 35)
187+
{
188+
// Before Version 35, these were always Int32
189+
int value = ReadInt32();
190+
return new GenericContainerIndex(value);
191+
}
192+
else
193+
{
194+
switch (Metadata.genericContainerIndexSize)
195+
{
196+
case 1:
197+
{
198+
uint value = ReadByte();
199+
if (value == Byte.MaxValue) return new GenericContainerIndex(-1);
200+
return new GenericContainerIndex((int)value);
201+
}
202+
case 2:
203+
{
204+
uint value = ReadUInt16();
205+
if (value == UInt16.MaxValue) return new GenericContainerIndex(-1);
206+
return new GenericContainerIndex((int)value);
207+
}
208+
case 4:
209+
default:
210+
{
211+
uint value = ReadUInt32();
212+
if (value == UInt32.MaxValue) return new GenericContainerIndex(-1);
213+
return new GenericContainerIndex((int)value);
214+
}
215+
}
216+
}
217+
}
218+
115219
public T ReadClass<T>() where T : new()
116220
{
117221
var type = typeof(T);
@@ -168,6 +272,22 @@ private object ReadPrimitive(Type type)
168272
}
169273
i.SetValue(t, methodInfo.Invoke(this, new object[] { arrayLengthAttribute.Length }));
170274
}
275+
else if (fieldType == typeof(TypeIndex))
276+
{
277+
i.SetValue(t, ReadTypeIndex());
278+
}
279+
else if (fieldType == typeof(TypeDefinitionIndex))
280+
{
281+
i.SetValue(t, ReadTypeDefinitionIndex());
282+
}
283+
else if (fieldType == typeof(GenericContainerIndex))
284+
{
285+
i.SetValue(t, ReadGenericContainerIndex());
286+
}
287+
else if (fieldType == typeof(Il2CppSectionMetadata))
288+
{
289+
i.SetValue(t, ReadClass<Il2CppSectionMetadata>());
290+
}
171291
else
172292
{
173293
if (!genericMethodCache.TryGetValue(fieldType, out var methodInfo))

Il2CppDumper/Il2Cpp/Il2Cpp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Il2CppDumper
77
{
88
public abstract class Il2Cpp : BinaryStream
99
{
10-
private Il2CppMetadataRegistration pMetadataRegistration;
10+
public Il2CppMetadataRegistration pMetadataRegistration;
1111
private Il2CppCodeRegistration pCodeRegistration;
1212
public ulong[] methodPointers;
1313
public ulong[] genericMethodPointers;

0 commit comments

Comments
 (0)