diff --git a/Il2CppInspector.Common/Model/AppModel.cs b/Il2CppInspector.Common/Model/AppModel.cs index 7267c6b..f791d64 100644 --- a/Il2CppInspector.Common/Model/AppModel.cs +++ b/Il2CppInspector.Common/Model/AppModel.cs @@ -42,16 +42,16 @@ namespace Il2CppInspector.Model public List DependencyOrderedCppTypes { get; private set; } // Composite mapping of all the .NET methods in the IL2CPP binary - public MultiKeyDictionary Methods = new MultiKeyDictionary(); + public MultiKeyDictionary Methods { get; } = new MultiKeyDictionary(); // Composite mapping of all the .NET types in the IL2CPP binary - public MultiKeyDictionary Types = new MultiKeyDictionary(); + public MultiKeyDictionary Types { get; } = new MultiKeyDictionary(); // All of the string literals in the IL2CPP binary // Note: Does not include string literals from global-metadata.dat // Note: The virtual addresses are of String* (VAs of the pointer to String*) objects, not the strings themselves // For il2cpp < 19, the key is the string literal ordinal instead of the address - public Dictionary Strings = new Dictionary(); + public Dictionary Strings { get; } = new Dictionary(); public bool StringIndexesAreOrdinals => Package.MetadataUsages == null; @@ -61,6 +61,9 @@ namespace Il2CppInspector.Model // All of the symbol exports (including function exports) for the binary public List Exports { get; } + // All of the API exports defined in the IL2CPP binary + public Dictionary APIExports { get; private set; } = new Dictionary(); + // Delegated C++ types iterator public IEnumerator GetEnumerator() => CppTypeCollection.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable) CppTypeCollection).GetEnumerator(); @@ -129,6 +132,15 @@ namespace Il2CppInspector.Model // Calling declarationGenerator.GenerateRemainingTypeDeclarations() below will automatically add to this collection CppTypeCollection = CppTypeCollection.FromUnityHeaders(UnityHeaders, declarationGenerator); + // Populate APIExports with actual API symbols from Binary.GetAPIExports() and their matching header signatures + // NOTE: This will only be filled with exports that actually exist in the binary and have a mappable address + APIExports = ILModel.Package.Binary.GetAPIExports() + .Select(e => new { + VirtualAddress = e.Value, + FnPtr = CppTypeCollection.TypedefAliases[e.Key] + }) + .ToDictionary(kv => kv.VirtualAddress, kv => (CppFnPtrType) kv.FnPtr); + // Initialize ordered type list for code output DependencyOrderedCppTypes = new List();