IL2CPP: Vastly speed up Il2CppGenericInst detection + progress updates

This commit is contained in:
Katy Coe
2020-12-06 17:49:59 +01:00
parent 47ff61a996
commit a7522a64af

View File

@@ -66,6 +66,18 @@ namespace Il2CppInspector
var (codePtrsOrdered, codeCountLimits, codeCounts) = preparePointerList(typeof(Il2CppCodeRegistration), CodeRegistrationPointer, dataSections); var (codePtrsOrdered, codeCountLimits, codeCounts) = preparePointerList(typeof(Il2CppCodeRegistration), CodeRegistrationPointer, dataSections);
var (metaPtrsOrdered, metaCountLimits, metaCounts) = preparePointerList(typeof(Il2CppMetadataRegistration), MetadataRegistrationPointer, dataSections); var (metaPtrsOrdered, metaCountLimits, metaCounts) = preparePointerList(typeof(Il2CppMetadataRegistration), MetadataRegistrationPointer, dataSections);
// Progress updater
var maxProgress = codeCounts.Sum() + metaCounts.Sum();
var currentProgress = 0;
void UpdateProgress(int workDone) {
currentProgress += workDone;
StatusUpdate($"Reconstructing obfuscated core metadata ({currentProgress * 100 / maxProgress:F0}%)");
}
Console.WriteLine("Reconstructing obfuscated core metadata (this may take a while)...");
UpdateProgress(0);
// Some heuristic constants // Some heuristic constants
// Counts from minimal compiles // Counts from minimal compiles
@@ -152,6 +164,8 @@ namespace Il2CppInspector
foundCount--; foundCount--;
seqFnPtrs.Add(codePtrsOrdered[i], foundCount); seqFnPtrs.Add(codePtrsOrdered[i], foundCount);
UpdateProgress(foundCount);
} }
KeyValuePair<ulong, int> methodPointers, genericMethodPointers, customAttributeGenerators, invokerPointers; KeyValuePair<ulong, int> methodPointers, genericMethodPointers, customAttributeGenerators, invokerPointers;
@@ -372,7 +386,7 @@ namespace Il2CppInspector
// ie. typePtrs must be a subset of typesData.Keys // ie. typePtrs must be a subset of typesData.Keys
try { try {
var typePtrs = Image.ReadMappedArray<ulong>(item.type_argv, (int) item.type_argc); var typePtrs = Image.ReadMappedArray<ulong>(item.type_argv, (int) item.type_argc);
if (typePtrs.Except(typesPtrs).Any()) if (typePtrs.Any(p => !typePtrs.Contains(p)))
break; break;
// Pointers were invalid // Pointers were invalid
} }
@@ -474,6 +488,8 @@ namespace Il2CppInspector
// If we just found the Il2CppTypes data, prune the pointer list to the correct length // If we just found the Il2CppTypes data, prune the pointer list to the correct length
if (foundItem == types && typesPtrs.Count != foundData.count) if (foundItem == types && typesPtrs.Count != foundData.count)
typesPtrs = typesPtrs.Take(foundData.count).ToList(); typesPtrs = typesPtrs.Take(foundData.count).ToList();
UpdateProgress(foundData.count);
} }
#region Debugging validation checks #region Debugging validation checks