From 2ab43c41c9fbb49f4c54c39ac2d6a4a99c42d6d7 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 1 Aug 2020 18:58:54 +0200 Subject: [PATCH] IDA: Separate comment types and function/field types --- .../Outputs/IDAPythonScript.cs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs index 1b2e042..8557164 100755 --- a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs +++ b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs @@ -32,7 +32,7 @@ namespace Il2CppInspector.Outputs typeHeaderFile = existingTypeHeaderFIle; var typeHeaderRelativePath = Path.GetRelativePath(Path.GetDirectoryName(Path.GetFullPath(outputFile)), - Path.GetDirectoryName(Path.GetFullPath(typeHeaderFile))) + Path.GetDirectoryName(Path.GetFullPath(typeHeaderFile))) + Path.DirectorySeparatorChar + Path.GetFileName(typeHeaderFile); @@ -82,13 +82,19 @@ def SetName(addr, name): def MakeFunction(start): ida_funcs.add_func(start) +def SetFunctionType(addr, sig): + SetType(addr, sig) + def SetType(addr, type): ret = idc.SetType(addr, type) if ret is None: print('SetType(0x%x, %r) failed!' % (addr, type)) def SetComment(addr, text): - idc.set_cmt(addr, text, 1)"); + idc.set_cmt(addr, text, 1) + +def SetHeaderComment(addr, text): + SetComment(addr, text)"); } private void writeTypes(string typeHeaderFile) { @@ -105,19 +111,19 @@ def SetComment(addr, text): writeSectionHeader("Custom attributes generators"); foreach (var method in model.ILModel.AttributesByIndices.Values) { - writeTypedName(method.VirtualAddress.Value.Start, method.Signature, method.Name); + writeTypedFunctionName(method.VirtualAddress.Value.Start, method.Signature, method.Name); } writeSectionHeader("Method.Invoke thunks"); foreach (var method in model.ILModel.MethodInvokers.Where(m => m != null)) { - writeTypedName(method.VirtualAddress.Start, method.GetSignature(model.UnityVersion), method.Name); + writeTypedFunctionName(method.VirtualAddress.Start, method.GetSignature(model.UnityVersion), method.Name); } } private void writeMethods(IEnumerable methods) { foreach (var method in methods) { - writeTypedName(method.MethodCodeAddress, method.CppFnPtrType.ToSignatureString(), method.CppFnPtrType.Name); - writeComment(method.MethodCodeAddress, method.Method); + writeTypedFunctionName(method.MethodCodeAddress, method.CppFnPtrType.ToSignatureString(), method.CppFnPtrType.Name); + writeHeaderComment(method.MethodCodeAddress, method.Method); } } @@ -221,10 +227,19 @@ def SetComment(addr, text): writeLine($"SetType({address.ToAddressString()}, r'{type.ToEscapedString()}')"); } + private void writeTypedFunctionName(ulong address, string type, string name) { + writeName(address, name); + writeLine($"SetFunctionType({address.ToAddressString()}, r'{type.ToEscapedString()}')"); + } + private void writeComment(ulong address, object comment) { writeLine($"SetComment({address.ToAddressString()}, r'{comment.ToString().ToEscapedString()}')"); } + private void writeHeaderComment(ulong address, object comment) { + writeLine($"SetHeaderComment({address.ToAddressString()}, r'{comment.ToString().ToEscapedString()}')"); + } + private void writeLine(string line) => writer.WriteLine(line); private static string stringToIdentifier(string str) {