Model and Output: Retrieve fully qualified assembly names
This commit is contained in:
@@ -51,7 +51,7 @@ namespace Il2CppInspector
|
|||||||
public void WriteFilesByAssembly<TKey>(string outPath, Func<TypeInfo, TKey> orderBy) {
|
public void WriteFilesByAssembly<TKey>(string outPath, Func<TypeInfo, TKey> orderBy) {
|
||||||
foreach (var asm in model.Assemblies) {
|
foreach (var asm in model.Assemblies) {
|
||||||
// Sort namespaces into alphabetical order, then sort types within the namespaces by the specified sort function
|
// Sort namespaces into alphabetical order, then sort types within the namespaces by the specified sort function
|
||||||
writeFile($"{outPath}\\{asm.FullName}.cs", asm.DefinedTypes.OrderBy(t => t.Namespace).ThenBy(orderBy));
|
writeFile($"{outPath}\\{asm.ShortName}.cs", asm.DefinedTypes.OrderBy(t => t.Namespace).ThenBy(orderBy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ namespace Il2CppInspector
|
|||||||
var text = new StringBuilder();
|
var text = new StringBuilder();
|
||||||
|
|
||||||
foreach (var asm in assemblies) {
|
foreach (var asm in assemblies) {
|
||||||
text.Append($"// Image {asm.Index}: {asm.FullName} - {asm.ImageDefinition.typeStart}-{asm.ImageDefinition.typeStart + asm.ImageDefinition.typeCount - 1}\n");
|
text.Append($"// Image {asm.Index}: {asm.ShortName} - Assembly: {asm.FullName} - Types {asm.ImageDefinition.typeStart}-{asm.ImageDefinition.typeStart + asm.ImageDefinition.typeCount - 1}\n");
|
||||||
|
|
||||||
// Assembly-level attributes
|
// Assembly-level attributes
|
||||||
text.Append(asm.CustomAttributes.Where(a => a.AttributeType.FullName != ExtAttribute)
|
text.Append(asm.CustomAttributes.Where(a => a.AttributeType.FullName != ExtAttribute)
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ namespace Il2CppInspector.Reflection
|
|||||||
Assemblies.Add(new Assembly(this, image));
|
Assemblies.Add(new Assembly(this, image));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get an assembly by its name
|
// Get an assembly by its image name
|
||||||
public Assembly GetAssembly(string name) => Assemblies.FirstOrDefault(a => a.FullName == name);
|
public Assembly GetAssembly(string name) => Assemblies.FirstOrDefault(a => a.ShortName == name);
|
||||||
|
|
||||||
private TypeInfo getNewTypeUsage(Il2CppType usage, MemberTypes memberType) {
|
private TypeInfo getNewTypeUsage(Il2CppType usage, MemberTypes memberType) {
|
||||||
switch (usage.type) {
|
switch (usage.type) {
|
||||||
|
|||||||
@@ -203,10 +203,10 @@ namespace Il2CppInspector
|
|||||||
// They moved the position of publicKeyToken in v16 from the middle to the bottom of the struct
|
// They moved the position of publicKeyToken in v16 from the middle to the bottom of the struct
|
||||||
public byte[] publicKeyToken => publicKeyToken_post16;
|
public byte[] publicKeyToken => publicKeyToken_post16;
|
||||||
|
|
||||||
public uint nameIndex;
|
public int nameIndex;
|
||||||
public uint cultureIndex;
|
public int cultureIndex;
|
||||||
public uint hashValueIndex;
|
public int hashValueIndex;
|
||||||
public uint publicKeyIndex;
|
public int publicKeyIndex;
|
||||||
[Version(Max = 15), ArrayLength(FixedSize = 8)]
|
[Version(Max = 15), ArrayLength(FixedSize = 8)]
|
||||||
public byte[] publicKeyToken_pre16;
|
public byte[] publicKeyToken_pre16;
|
||||||
public uint hash_alg;
|
public uint hash_alg;
|
||||||
|
|||||||
@@ -21,9 +21,12 @@ namespace Il2CppInspector.Reflection {
|
|||||||
// Custom attributes for this assembly
|
// Custom attributes for this assembly
|
||||||
public IEnumerable<CustomAttributeData> CustomAttributes => CustomAttributeData.GetCustomAttributes(this);
|
public IEnumerable<CustomAttributeData> CustomAttributes => CustomAttributeData.GetCustomAttributes(this);
|
||||||
|
|
||||||
// Name of the assembly
|
// Fully qualified name of the assembly
|
||||||
public string FullName { get; }
|
public string FullName { get; }
|
||||||
|
|
||||||
|
// Display name of the assembly
|
||||||
|
public string ShortName { get; }
|
||||||
|
|
||||||
// Entry point method for the assembly
|
// Entry point method for the assembly
|
||||||
public MethodInfo EntryPoint => throw new NotImplementedException();
|
public MethodInfo EntryPoint => throw new NotImplementedException();
|
||||||
|
|
||||||
@@ -43,14 +46,27 @@ namespace Il2CppInspector.Reflection {
|
|||||||
throw new InvalidOperationException("Assembly/image index mismatch");
|
throw new InvalidOperationException("Assembly/image index mismatch");
|
||||||
|
|
||||||
Index = ImageDefinition.assemblyIndex;
|
Index = ImageDefinition.assemblyIndex;
|
||||||
FullName = Model.Package.Strings[ImageDefinition.nameIndex];
|
ShortName = Model.Package.Strings[ImageDefinition.nameIndex];
|
||||||
|
|
||||||
|
// Get full assembly name
|
||||||
|
var nameDef = AssemblyDefinition.aname;
|
||||||
|
var name = Model.Package.Strings[nameDef.nameIndex];
|
||||||
|
var culture = Model.Package.Strings[nameDef.cultureIndex];
|
||||||
|
if (string.IsNullOrEmpty(culture))
|
||||||
|
culture = "neutral";
|
||||||
|
var pkt = BitConverter.ToString(nameDef.publicKeyToken).Replace("-", "");
|
||||||
|
if (pkt == "0000000000000000")
|
||||||
|
pkt = "null";
|
||||||
|
var version = string.Format($"{nameDef.major}.{nameDef.minor}.{nameDef.build}.{nameDef.revision}");
|
||||||
|
|
||||||
|
FullName = string.Format($"{name}, Version={version}, Culture={culture}, PublicKeyToken={pkt.ToLower()}");
|
||||||
|
|
||||||
if (ImageDefinition.entryPointIndex != -1) {
|
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)
|
||||||
ModuleDefinition = Model.Package.Modules?[FullName];
|
ModuleDefinition = Model.Package.Modules?[ShortName];
|
||||||
|
|
||||||
// Generate types in DefinedTypes from typeStart to typeStart+typeCount-1
|
// Generate types in DefinedTypes from typeStart to typeStart+typeCount-1
|
||||||
for (var t = ImageDefinition.typeStart; t < ImageDefinition.typeStart + ImageDefinition.typeCount; t++) {
|
for (var t = ImageDefinition.typeStart; t < ImageDefinition.typeStart + ImageDefinition.typeCount; t++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user