Model: Make assembly definitions available
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Il2CppInspector
|
|||||||
public void WriteFile(string outFile) {
|
public void WriteFile(string outFile) {
|
||||||
using (writer = new StreamWriter(new FileStream(outFile, FileMode.Create), Encoding.UTF8)) {
|
using (writer = new StreamWriter(new FileStream(outFile, FileMode.Create), Encoding.UTF8)) {
|
||||||
foreach (var asm in model.Assemblies) {
|
foreach (var asm in model.Assemblies) {
|
||||||
writer.Write($"// Image {asm.Index}: {asm.FullName} - {asm.Definition.typeStart}\n");
|
writer.Write($"// Image {asm.Index}: {asm.FullName} - {asm.ImageDefinition.typeStart}\n");
|
||||||
|
|
||||||
// Assembly-level attributes
|
// Assembly-level attributes
|
||||||
writer.Write(asm.CustomAttributes.ToString(attributePrefix: "assembly: "));
|
writer.Write(asm.CustomAttributes.ToString(attributePrefix: "assembly: "));
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
public Dictionary<int, string> Strings => Metadata.Strings;
|
public Dictionary<int, string> Strings => Metadata.Strings;
|
||||||
public Il2CppTypeDefinition[] TypeDefinitions => Metadata.Types;
|
public Il2CppTypeDefinition[] TypeDefinitions => Metadata.Types;
|
||||||
|
public Il2CppAssemblyDefinition[] Assemblies => Metadata.Assemblies;
|
||||||
public Il2CppImageDefinition[] Images => Metadata.Images;
|
public Il2CppImageDefinition[] Images => Metadata.Images;
|
||||||
public Il2CppMethodDefinition[] Methods => Metadata.Methods;
|
public Il2CppMethodDefinition[] Methods => Metadata.Methods;
|
||||||
public Il2CppParameterDefinition[] Params => Metadata.Params;
|
public Il2CppParameterDefinition[] Params => Metadata.Params;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace Il2CppInspector.Reflection
|
|||||||
if (Package.Version <= 24.0)
|
if (Package.Version <= 24.0)
|
||||||
return customAttributeIndex;
|
return customAttributeIndex;
|
||||||
|
|
||||||
var image = asm.Definition;
|
var image = asm.ImageDefinition;
|
||||||
var imageRange = image.customAttributeStart..(int)(image.customAttributeStart + image.customAttributeCount);
|
var imageRange = image.customAttributeStart..(int)(image.customAttributeStart + image.customAttributeCount);
|
||||||
|
|
||||||
// From v24.1 onwards, token was added to Il2CppCustomAttributeTypeRange and each Il2CppImageDefinition noted the CustomAttributeTypeRanges for the image
|
// From v24.1 onwards, token was added to Il2CppCustomAttributeTypeRange and each Il2CppImageDefinition noted the CustomAttributeTypeRanges for the image
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ namespace Il2CppInspector.Reflection {
|
|||||||
{
|
{
|
||||||
// IL2CPP-specific data
|
// IL2CPP-specific data
|
||||||
public Il2CppModel Model { get; }
|
public Il2CppModel Model { get; }
|
||||||
public Il2CppImageDefinition Definition { get; }
|
public Il2CppImageDefinition ImageDefinition { get; }
|
||||||
public Il2CppCodeGenModule Module { get; }
|
public Il2CppAssemblyDefinition AssemblyDefinition { get; }
|
||||||
|
public Il2CppCodeGenModule ModuleDefinition { get; }
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
|
||||||
// Custom attributes for this assembly
|
// Custom attributes for this assembly
|
||||||
@@ -35,19 +36,24 @@ namespace Il2CppInspector.Reflection {
|
|||||||
// Initialize from specified assembly index in package
|
// Initialize from specified assembly index in package
|
||||||
public Assembly(Il2CppModel model, int imageIndex) {
|
public Assembly(Il2CppModel model, int imageIndex) {
|
||||||
Model = model;
|
Model = model;
|
||||||
Definition = Model.Package.Images[imageIndex];
|
ImageDefinition = Model.Package.Images[imageIndex];
|
||||||
Index = Definition.assemblyIndex;
|
AssemblyDefinition = Model.Package.Assemblies[ImageDefinition.assemblyIndex];
|
||||||
FullName = Model.Package.Strings[Definition.nameIndex];
|
|
||||||
|
|
||||||
if (Definition.entryPointIndex != -1) {
|
if (AssemblyDefinition.imageIndex != imageIndex)
|
||||||
|
throw new InvalidOperationException("Assembly/image index mismatch");
|
||||||
|
|
||||||
|
Index = ImageDefinition.assemblyIndex;
|
||||||
|
FullName = Model.Package.Strings[ImageDefinition.nameIndex];
|
||||||
|
|
||||||
|
if (ImageDefinition.entryPointIndex != -1) {
|
||||||
// TODO: Generate EntryPoint method from entryPointIndex
|
// TODO: Generate EntryPoint method from entryPointIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find corresponding module (we'll need this for method pointers)
|
// Find corresponding module (we'll need this for method pointers)
|
||||||
Module = Model.Package.Modules?[FullName];
|
ModuleDefinition = Model.Package.Modules?[FullName];
|
||||||
|
|
||||||
// Generate types in DefinedTypes from typeStart to typeStart+typeCount-1
|
// Generate types in DefinedTypes from typeStart to typeStart+typeCount-1
|
||||||
for (var t = Definition.typeStart; t < Definition.typeStart + Definition.typeCount; t++) {
|
for (var t = ImageDefinition.typeStart; t < ImageDefinition.typeStart + ImageDefinition.typeCount; t++) {
|
||||||
var type = new TypeInfo(t, this);
|
var type = new TypeInfo(t, this);
|
||||||
|
|
||||||
// Don't add empty module definitions
|
// Don't add empty module definitions
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace Il2CppInspector.Reflection
|
|||||||
Name = pkg.Strings[Definition.nameIndex];
|
Name = pkg.Strings[Definition.nameIndex];
|
||||||
|
|
||||||
// Find method pointer
|
// Find method pointer
|
||||||
VirtualAddress = pkg.GetMethodPointer(Assembly.Module, Definition);
|
VirtualAddress = pkg.GetMethodPointer(Assembly.ModuleDefinition, Definition);
|
||||||
|
|
||||||
// Add to global method definition list
|
// Add to global method definition list
|
||||||
Assembly.Model.MethodsByDefinitionIndex[Index] = this;
|
Assembly.Model.MethodsByDefinitionIndex[Index] = this;
|
||||||
|
|||||||
Reference in New Issue
Block a user