Rename AppModel.ILModel to AppModel.TypeModel
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Il2CppInspector.Cpp
|
|||||||
{
|
{
|
||||||
private readonly AppModel appModel;
|
private readonly AppModel appModel;
|
||||||
|
|
||||||
private TypeModel model => appModel.ILModel;
|
private TypeModel model => appModel.TypeModel;
|
||||||
private CppTypeCollection types => appModel.CppTypeCollection;
|
private CppTypeCollection types => appModel.CppTypeCollection;
|
||||||
|
|
||||||
// Word size (32/64-bit) for this generator
|
// Word size (32/64-bit) for this generator
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ namespace Il2CppInspector.Model
|
|||||||
|
|
||||||
// Add all custom attributes generators
|
// Add all custom attributes generators
|
||||||
// The compiler might perform ICF which will cause duplicates with the above
|
// The compiler might perform ICF which will cause duplicates with the above
|
||||||
foreach (var cag in Model.ILModel.CustomAttributeGeneratorsByAddress)
|
foreach (var cag in Model.TypeModel.CustomAttributeGeneratorsByAddress)
|
||||||
TryAdd(cag.Key, cag.Value);
|
TryAdd(cag.Key, cag.Value);
|
||||||
|
|
||||||
// Add all method invokers. Multiple invoker indices may reference the same function address
|
// Add all method invokers. Multiple invoker indices may reference the same function address
|
||||||
foreach (var mi in Model.ILModel.MethodInvokers.Where(m => m != null))
|
foreach (var mi in Model.TypeModel.MethodInvokers.Where(m => m != null))
|
||||||
TryAdd(mi.VirtualAddress.Start, mi);
|
TryAdd(mi.VirtualAddress.Start, mi);
|
||||||
|
|
||||||
// String literals (metadata >= 19)
|
// String literals (metadata >= 19)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Il2CppInspector.Model
|
|||||||
public bool StringIndexesAreOrdinals => Package.MetadataUsages == null;
|
public bool StringIndexesAreOrdinals => Package.MetadataUsages == null;
|
||||||
|
|
||||||
// The .NET type model for the application
|
// The .NET type model for the application
|
||||||
public TypeModel ILModel { get; }
|
public TypeModel TypeModel { get; }
|
||||||
|
|
||||||
// All of the exports (including function exports) for the binary
|
// All of the exports (including function exports) for the binary
|
||||||
public List<Export> Exports { get; }
|
public List<Export> Exports { get; }
|
||||||
@@ -75,10 +75,10 @@ namespace Il2CppInspector.Model
|
|||||||
// Convenience properties
|
// Convenience properties
|
||||||
|
|
||||||
// The word size of the binary in bits
|
// The word size of the binary in bits
|
||||||
public int WordSize => ILModel.Package.BinaryImage.Bits;
|
public int WordSize => TypeModel.Package.BinaryImage.Bits;
|
||||||
|
|
||||||
// The IL2CPP package for this application
|
// The IL2CPP package for this application
|
||||||
public Il2CppInspector Package => ILModel.Package;
|
public Il2CppInspector Package => TypeModel.Package;
|
||||||
|
|
||||||
// The compiler used to build the binary
|
// The compiler used to build the binary
|
||||||
public CppCompilerType SourceCompiler => declarationGenerator.InheritanceStyle;
|
public CppCompilerType SourceCompiler => declarationGenerator.InheritanceStyle;
|
||||||
@@ -96,7 +96,7 @@ namespace Il2CppInspector.Model
|
|||||||
// Initialize
|
// Initialize
|
||||||
public AppModel(TypeModel model) {
|
public AppModel(TypeModel model) {
|
||||||
// Save .NET type model
|
// Save .NET type model
|
||||||
ILModel = model;
|
TypeModel = model;
|
||||||
|
|
||||||
// Get addresses of all exports
|
// Get addresses of all exports
|
||||||
Exports = Package.BinaryImage.GetExports()?.ToList() ?? new List<Export>();
|
Exports = Package.BinaryImage.GetExports()?.ToList() ?? new List<Export>();
|
||||||
@@ -117,18 +117,18 @@ namespace Il2CppInspector.Model
|
|||||||
Strings.Clear();
|
Strings.Clear();
|
||||||
|
|
||||||
// Set target compiler
|
// Set target compiler
|
||||||
TargetCompiler = compiler == CppCompilerType.BinaryFormat ? CppCompiler.GuessFromImage(ILModel.Package.BinaryImage) : compiler;
|
TargetCompiler = compiler == CppCompilerType.BinaryFormat ? CppCompiler.GuessFromImage(TypeModel.Package.BinaryImage) : compiler;
|
||||||
|
|
||||||
// Determine Unity version and get headers
|
// Determine Unity version and get headers
|
||||||
UnityHeaders = unityVersion != null ? UnityHeaders.GetHeadersForVersion(unityVersion) : UnityHeaders.GuessHeadersForBinary(ILModel.Package.Binary).Last();
|
UnityHeaders = unityVersion != null ? UnityHeaders.GetHeadersForVersion(unityVersion) : UnityHeaders.GuessHeadersForBinary(TypeModel.Package.Binary).Last();
|
||||||
UnityVersion = unityVersion ?? UnityHeaders.VersionRange.Min;
|
UnityVersion = unityVersion ?? UnityHeaders.VersionRange.Min;
|
||||||
|
|
||||||
Console.WriteLine($"Selected Unity version(s) {UnityHeaders.VersionRange} (types: {UnityHeaders.TypeHeaderResource.VersionRange}, APIs: {UnityHeaders.APIHeaderResource.VersionRange})");
|
Console.WriteLine($"Selected Unity version(s) {UnityHeaders.VersionRange} (types: {UnityHeaders.TypeHeaderResource.VersionRange}, APIs: {UnityHeaders.APIHeaderResource.VersionRange})");
|
||||||
|
|
||||||
// Check for matching metadata and binary versions
|
// Check for matching metadata and binary versions
|
||||||
if (UnityHeaders.MetadataVersion != ILModel.Package.BinaryImage.Version) {
|
if (UnityHeaders.MetadataVersion != TypeModel.Package.BinaryImage.Version) {
|
||||||
Console.WriteLine($"Warning: selected version {UnityVersion} (metadata version {UnityHeaders.MetadataVersion})" +
|
Console.WriteLine($"Warning: selected version {UnityVersion} (metadata version {UnityHeaders.MetadataVersion})" +
|
||||||
$" does not match metadata version {ILModel.Package.BinaryImage.Version}.");
|
$" does not match metadata version {TypeModel.Package.BinaryImage.Version}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize declaration generator to process every type in the binary
|
// Initialize declaration generator to process every type in the binary
|
||||||
@@ -141,7 +141,7 @@ namespace Il2CppInspector.Model
|
|||||||
// Populate AvailableAPIs with actual API symbols from Binary.GetAPIExports() and their matching header signatures
|
// Populate AvailableAPIs with actual API symbols from Binary.GetAPIExports() and their matching header signatures
|
||||||
// NOTE: This will only be filled with exports that actually exist in both the binary and the API header,
|
// NOTE: This will only be filled with exports that actually exist in both the binary and the API header,
|
||||||
// and have a mappable address. This prevents exceptions when cross-querying the header and binary APIs.
|
// and have a mappable address. This prevents exceptions when cross-querying the header and binary APIs.
|
||||||
var exports = ILModel.Package.Binary.GetAPIExports()
|
var exports = TypeModel.Package.Binary.GetAPIExports()
|
||||||
.Where(e => CppTypeCollection.TypedefAliases.ContainsKey(e.Key))
|
.Where(e => CppTypeCollection.TypedefAliases.ContainsKey(e.Key))
|
||||||
.Select(e => new {
|
.Select(e => new {
|
||||||
VirtualAddress = e.Value,
|
VirtualAddress = e.Value,
|
||||||
@@ -158,7 +158,7 @@ namespace Il2CppInspector.Model
|
|||||||
// Add method definitions and types used by them to C++ type model
|
// Add method definitions and types used by them to C++ type model
|
||||||
Group = "types_from_methods";
|
Group = "types_from_methods";
|
||||||
|
|
||||||
foreach (var method in ILModel.MethodsByDefinitionIndex.Where(m => m.VirtualAddress.HasValue)) {
|
foreach (var method in TypeModel.MethodsByDefinitionIndex.Where(m => m.VirtualAddress.HasValue)) {
|
||||||
declarationGenerator.IncludeMethod(method);
|
declarationGenerator.IncludeMethod(method);
|
||||||
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ namespace Il2CppInspector.Model
|
|||||||
// Add generic methods definitions and types used by them to C++ type model
|
// Add generic methods definitions and types used by them to C++ type model
|
||||||
Group = "types_from_generic_methods";
|
Group = "types_from_generic_methods";
|
||||||
|
|
||||||
foreach (var method in ILModel.GenericMethods.Values.Where(m => m.VirtualAddress.HasValue)) {
|
foreach (var method in TypeModel.GenericMethods.Values.Where(m => m.VirtualAddress.HasValue)) {
|
||||||
declarationGenerator.IncludeMethod(method);
|
declarationGenerator.IncludeMethod(method);
|
||||||
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
||||||
|
|
||||||
@@ -187,13 +187,13 @@ namespace Il2CppInspector.Model
|
|||||||
|
|
||||||
switch (usage.Type) {
|
switch (usage.Type) {
|
||||||
case MetadataUsageType.StringLiteral:
|
case MetadataUsageType.StringLiteral:
|
||||||
var str = ILModel.GetMetadataUsageName(usage);
|
var str = TypeModel.GetMetadataUsageName(usage);
|
||||||
Strings.Add(address, str);
|
Strings.Add(address, str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataUsageType.Type:
|
case MetadataUsageType.Type:
|
||||||
case MetadataUsageType.TypeInfo:
|
case MetadataUsageType.TypeInfo:
|
||||||
var type = ILModel.GetMetadataUsageType(usage);
|
var type = TypeModel.GetMetadataUsageType(usage);
|
||||||
declarationGenerator.IncludeType(type);
|
declarationGenerator.IncludeType(type);
|
||||||
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ namespace Il2CppInspector.Model
|
|||||||
break;
|
break;
|
||||||
case MetadataUsageType.MethodDef:
|
case MetadataUsageType.MethodDef:
|
||||||
case MetadataUsageType.MethodRef:
|
case MetadataUsageType.MethodRef:
|
||||||
var method = ILModel.GetMetadataUsageMethod(usage);
|
var method = TypeModel.GetMetadataUsageMethod(usage);
|
||||||
declarationGenerator.IncludeMethod(method);
|
declarationGenerator.IncludeMethod(method);
|
||||||
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
|
||||||
|
|
||||||
|
|||||||
@@ -55,13 +55,13 @@ namespace Il2CppInspector.Outputs
|
|||||||
// We could use ILModel.CustomAttributeGenerators here to ensure uniqueness but then we lose function name information
|
// We could use ILModel.CustomAttributeGenerators here to ensure uniqueness but then we lose function name information
|
||||||
// TODO: Merge CAG names that deal with multiple attribute types to reflect all of the attribute type names (solving the above)
|
// TODO: Merge CAG names that deal with multiple attribute types to reflect all of the attribute type names (solving the above)
|
||||||
writeArray("customAttributesGenerators", () => {
|
writeArray("customAttributesGenerators", () => {
|
||||||
foreach (var method in model.ILModel.AttributesByIndices.Values) {
|
foreach (var method in model.TypeModel.AttributesByIndices.Values) {
|
||||||
writeObject(() => writeTypedFunctionName(method.VirtualAddress.Start, method.Signature, method.Name));
|
writeObject(() => writeTypedFunctionName(method.VirtualAddress.Start, method.Signature, method.Name));
|
||||||
}
|
}
|
||||||
}, "Custom attributes generators");
|
}, "Custom attributes generators");
|
||||||
|
|
||||||
writeArray("methodInvokers", () => {
|
writeArray("methodInvokers", () => {
|
||||||
foreach (var method in model.ILModel.MethodInvokers.Where(m => m != null)) {
|
foreach (var method in model.TypeModel.MethodInvokers.Where(m => m != null)) {
|
||||||
writeObject(() => writeTypedFunctionName(method.VirtualAddress.Start, method.GetSignature(model.UnityVersion), method.Name));
|
writeObject(() => writeTypedFunctionName(method.VirtualAddress.Start, method.GetSignature(model.UnityVersion), method.Name));
|
||||||
}
|
}
|
||||||
}, "Method.Invoke thunks");
|
}, "Method.Invoke thunks");
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ namespace Il2CppInspectorGUI
|
|||||||
var model = (AppModel)((ListBox)sender).SelectedItem;
|
var model = (AppModel)((ListBox)sender).SelectedItem;
|
||||||
|
|
||||||
// Get namespaces
|
// Get namespaces
|
||||||
var namespaces = model.ILModel.Assemblies.SelectMany(x => x.DefinedTypes).GroupBy(t => t.Namespace).Select(n => n.Key);
|
var namespaces = model.TypeModel.Assemblies.SelectMany(x => x.DefinedTypes).GroupBy(t => t.Namespace).Select(n => n.Key);
|
||||||
|
|
||||||
// Break namespaces down into a tree
|
// Break namespaces down into a tree
|
||||||
var namespaceTree = deconstructNamespaces(namespaces);
|
var namespaceTree = deconstructNamespaces(namespaces);
|
||||||
@@ -347,7 +347,7 @@ namespace Il2CppInspectorGUI
|
|||||||
// Get options
|
// Get options
|
||||||
var excludedNamespaces = constructExcludedNamespaces((IEnumerable<CheckboxNode>) trvNamespaces.ItemsSource);
|
var excludedNamespaces = constructExcludedNamespaces((IEnumerable<CheckboxNode>) trvNamespaces.ItemsSource);
|
||||||
|
|
||||||
var writer = new CSharpCodeStubs(model.ILModel) {
|
var writer = new CSharpCodeStubs(model.TypeModel) {
|
||||||
ExcludedNamespaces = excludedNamespaces.ToList(),
|
ExcludedNamespaces = excludedNamespaces.ToList(),
|
||||||
SuppressMetadata = cbSuppressMetadata.IsChecked == true,
|
SuppressMetadata = cbSuppressMetadata.IsChecked == true,
|
||||||
MustCompile = cbMustCompile.IsChecked == true
|
MustCompile = cbMustCompile.IsChecked == true
|
||||||
|
|||||||
Reference in New Issue
Block a user