IL2CPP: Use mapped objects for Sizeof

This commit is contained in:
Katy Coe
2020-12-21 22:03:43 +01:00
parent c60eca4ec7
commit fbc8e0950c
3 changed files with 12 additions and 9 deletions

View File

@@ -198,7 +198,7 @@ namespace Il2CppInspector
// Now confirm that all the keys are present
// If they aren't, that means one or more of the null terminators wasn't null, indicating potential encryption
// Only do this if we need to because it's very slow
if (stringOffsets.Except(Strings.Keys).Any()) {
if (Header.stringCount > 0 && stringOffsets.Except(Strings.Keys).Any()) {
Console.WriteLine("Decrypting strings...");
StatusUpdate("Decrypting strings");
@@ -251,9 +251,12 @@ namespace Il2CppInspector
CopyTo(outFile);
}
internal int Sizeof(Type type) => Sizeof(type, Version);
public int Sizeof(Type type) => Sizeof(type, Version);
public int Sizeof(Type type, double metadataVersion, int longSizeBytes = 8) {
public static int Sizeof(Type type, double metadataVersion, int longSizeBytes = 8) {
if (Reader.ObjectMappings.TryGetValue(type, out var streamType))
type = streamType;
int size = 0;
foreach (var i in type.GetTypeInfo().GetFields())