IDA: Tidy up output ordering and titling
This commit is contained in:
@@ -32,9 +32,12 @@ namespace Il2CppInspector.Outputs
|
|||||||
writeSectionHeader("Preamble");
|
writeSectionHeader("Preamble");
|
||||||
writePreamble();
|
writePreamble();
|
||||||
|
|
||||||
|
writeTypes();
|
||||||
writeMethods();
|
writeMethods();
|
||||||
|
|
||||||
writeSectionHeader("Metadata Usages");
|
writeSectionHeader("String literals");
|
||||||
|
writeStringLiterals();
|
||||||
|
|
||||||
writeUsages();
|
writeUsages();
|
||||||
|
|
||||||
writeSectionHeader("Function boundaries");
|
writeSectionHeader("Function boundaries");
|
||||||
@@ -77,17 +80,27 @@ typedef __int16 int16_t;
|
|||||||
typedef __int32 int32_t;
|
typedef __int32 int32_t;
|
||||||
typedef __int64 int64_t;
|
typedef __int64 int64_t;
|
||||||
");
|
");
|
||||||
// IL2CPP internal types
|
}
|
||||||
|
|
||||||
|
private void writeTypes() {
|
||||||
|
writeSectionHeader("IL2CPP internal types");
|
||||||
writeDecls(model.UnityHeaderText);
|
writeDecls(model.UnityHeaderText);
|
||||||
|
|
||||||
|
writeSectionHeader("Application types from method calls");
|
||||||
|
writeTypes(model.GetDependencyOrderedCppTypeGroup("types_from_methods"));
|
||||||
|
|
||||||
|
writeSectionHeader("Application types from generic methods");
|
||||||
|
writeTypes(model.GetDependencyOrderedCppTypeGroup("types_from_generic_methods"));
|
||||||
|
|
||||||
|
writeSectionHeader("Application types from usage metadata");
|
||||||
|
writeTypes(model.GetDependencyOrderedCppTypeGroup("types_from_usages"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeMethods() {
|
private void writeMethods() {
|
||||||
writeSectionHeader("Method definitions");
|
writeSectionHeader("Method definitions");
|
||||||
writeTypes(model.GetDependencyOrderedCppTypeGroup("types_from_methods"));
|
|
||||||
writeMethods(model.GetMethodGroup("types_from_methods"));
|
writeMethods(model.GetMethodGroup("types_from_methods"));
|
||||||
|
|
||||||
writeSectionHeader("Constructed generic methods");
|
writeSectionHeader("Constructed generic methods");
|
||||||
writeTypes(model.GetDependencyOrderedCppTypeGroup("types_from_generic_methods"));
|
|
||||||
writeMethods(model.GetMethodGroup("types_from_generic_methods"));
|
writeMethods(model.GetMethodGroup("types_from_generic_methods"));
|
||||||
|
|
||||||
writeSectionHeader("Custom attributes generators");
|
writeSectionHeader("Custom attributes generators");
|
||||||
@@ -118,15 +131,7 @@ typedef __int64 int64_t;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string stringToIdentifier(string str) {
|
private void writeStringLiterals() {
|
||||||
str = str.Substring(0, Math.Min(32, str.Length));
|
|
||||||
return str.ToCIdentifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeUsages() {
|
|
||||||
|
|
||||||
// String literals
|
|
||||||
|
|
||||||
// For version < 19
|
// For version < 19
|
||||||
if (model.StringIndexesAreOrdinals) {
|
if (model.StringIndexesAreOrdinals) {
|
||||||
var enumSrc = new StringBuilder();
|
var enumSrc = new StringBuilder();
|
||||||
@@ -136,27 +141,27 @@ typedef __int64 int64_t;
|
|||||||
enumSrc.Append("};\n");
|
enumSrc.Append("};\n");
|
||||||
|
|
||||||
writeDecls(enumSrc.ToString());
|
writeDecls(enumSrc.ToString());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For version >= 19
|
// For version >= 19
|
||||||
else {
|
var stringType = model.CppTypeCollection.GetType("String *");
|
||||||
var stringType = model.CppTypeCollection.GetType("String *");
|
|
||||||
|
|
||||||
foreach (var str in model.Strings) {
|
foreach (var str in model.Strings) {
|
||||||
writeTypedName(str.Key, stringType.ToString(), $"StringLiteral_{stringToIdentifier(str.Value)}");
|
writeTypedName(str.Key, stringType.ToString(), $"StringLiteral_{stringToIdentifier(str.Value)}");
|
||||||
writeComment(str.Key, str.Value);
|
writeComment(str.Key, str.Value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Metadata usage C++ type dependencies
|
private void writeUsages() {
|
||||||
var usageCppTypes = model.GetDependencyOrderedCppTypeGroup("types_from_usages");
|
|
||||||
writeTypes(usageCppTypes);
|
|
||||||
|
|
||||||
// Definition and reference addresses for all types from metadata usages
|
// Definition and reference addresses for all types from metadata usages
|
||||||
|
writeSectionHeader("Il2CppClass (TypeInfo) and Il2CppType (TypeRef) pointers");
|
||||||
|
|
||||||
foreach (var type in model.Types.Values) {
|
foreach (var type in model.Types.Values) {
|
||||||
// A type may have no addresses, for example an unreferenced array type
|
// A type may have no addresses, for example an unreferenced array type
|
||||||
|
|
||||||
// Value types must not used the boxed definition
|
// Value types must not used the boxed definition
|
||||||
|
// TODO: Replace this with a future property of 'type' which gives the name
|
||||||
var name = type.CppValueType?.Name ?? type.CppType?.Name ?? model.declarationGenerator.TypeNamer.GetName(type.ILType);
|
var name = type.CppValueType?.Name ?? type.CppType?.Name ?? model.declarationGenerator.TypeNamer.GetName(type.ILType);
|
||||||
|
|
||||||
if (type.TypeClassAddress != 0xffffffff_ffffffff) {
|
if (type.TypeClassAddress != 0xffffffff_ffffffff) {
|
||||||
@@ -172,6 +177,8 @@ typedef __int64 int64_t;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Metedata usage methods
|
// Metedata usage methods
|
||||||
|
writeSectionHeader("MethodInfo pointers");
|
||||||
|
|
||||||
foreach (var method in model.Methods.Values.Where(m => m.MethodInfoPtrAddress != 0xffffffff_ffffffff)) {
|
foreach (var method in model.Methods.Values.Where(m => m.MethodInfoPtrAddress != 0xffffffff_ffffffff)) {
|
||||||
writeTypedName(method.MethodInfoPtrAddress, "struct MethodInfo *", $"{method.CppFnPtrType.Name}__MethodInfo");
|
writeTypedName(method.MethodInfoPtrAddress, "struct MethodInfo *", $"{method.CppFnPtrType.Name}__MethodInfo");
|
||||||
writeComment(method.MethodInfoPtrAddress, method.Method);
|
writeComment(method.MethodInfoPtrAddress, method.Method);
|
||||||
@@ -233,5 +240,10 @@ typedef __int64 int64_t;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeLine(string line) => writer.WriteLine(line);
|
private void writeLine(string line) => writer.WriteLine(line);
|
||||||
|
|
||||||
|
private static string stringToIdentifier(string str) {
|
||||||
|
str = str.Substring(0, Math.Min(32, str.Length));
|
||||||
|
return str.ToCIdentifier();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user