Model and Output: Retrieve fully qualified assembly names

This commit is contained in:
Katy Coe
2019-11-28 04:44:27 +01:00
parent 946288a7b5
commit e48c1813f3
4 changed files with 27 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ namespace Il2CppInspector
public void WriteFilesByAssembly<TKey>(string outPath, Func<TypeInfo, TKey> orderBy) {
foreach (var asm in model.Assemblies) {
// 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();
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
text.Append(asm.CustomAttributes.Where(a => a.AttributeType.FullName != ExtAttribute)

View File

@@ -48,8 +48,8 @@ namespace Il2CppInspector.Reflection
Assemblies.Add(new Assembly(this, image));
}
// Get an assembly by its name
public Assembly GetAssembly(string name) => Assemblies.FirstOrDefault(a => a.FullName == name);
// Get an assembly by its image name
public Assembly GetAssembly(string name) => Assemblies.FirstOrDefault(a => a.ShortName == name);
private TypeInfo getNewTypeUsage(Il2CppType usage, MemberTypes memberType) {
switch (usage.type) {

View File

@@ -203,10 +203,10 @@ namespace Il2CppInspector
// They moved the position of publicKeyToken in v16 from the middle to the bottom of the struct
public byte[] publicKeyToken => publicKeyToken_post16;
public uint nameIndex;
public uint cultureIndex;
public uint hashValueIndex;
public uint publicKeyIndex;
public int nameIndex;
public int cultureIndex;
public int hashValueIndex;
public int publicKeyIndex;
[Version(Max = 15), ArrayLength(FixedSize = 8)]
public byte[] publicKeyToken_pre16;
public uint hash_alg;

View File

@@ -21,9 +21,12 @@ namespace Il2CppInspector.Reflection {
// Custom attributes for this assembly
public IEnumerable<CustomAttributeData> CustomAttributes => CustomAttributeData.GetCustomAttributes(this);
// Name of the assembly
// Fully qualified name of the assembly
public string FullName { get; }
// Display name of the assembly
public string ShortName { get; }
// Entry point method for the assembly
public MethodInfo EntryPoint => throw new NotImplementedException();
@@ -43,14 +46,27 @@ namespace Il2CppInspector.Reflection {
throw new InvalidOperationException("Assembly/image index mismatch");
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) {
// TODO: Generate EntryPoint method from entryPointIndex
}
// 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
for (var t = ImageDefinition.typeStart; t < ImageDefinition.typeStart + ImageDefinition.typeCount; t++) {