From 359b99fded92486584bcb7fdb8b01b4d621a4b14 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Sat, 18 Apr 2020 01:59:09 -0700 Subject: [PATCH] Automatically infer function ends in IDA. The problem with using an end param in IDA is that IDA will quite stupidly treat the function end as gospel even if it makes no sense (e.g. a single "function" spanning many MB because there are no symbols in between). Leaving out end, on the other hand, tells IDA there's a function at a given starting address but lets IDA figure out the end by itself, which it usually does correctly. --- Il2CppInspector.Common/Outputs/IDAPythonScript.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs index 25ab9ca..be21341 100644 --- a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs +++ b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs @@ -72,15 +72,9 @@ def SetName(addr, name): new_name = name + '_' + str(addr) ret = idc.set_name(addr, new_name, SN_NOWARN | SN_NOCHECK) -def MakeFunction(start, end): - next_func = idc.get_next_func(start) - if next_func < end: - end = next_func - current_func = idaapi.get_func(start) - if current_func is not None and current_func.startEA == start: - ida_funcs.del_func(start) - ida_funcs.add_func(start, end)" - ); +def MakeFunction(start): + ida_funcs.add_func(start) +"); // Compatibility (in a separate decl block in case these are already defined) writeDecls(@" @@ -162,8 +156,7 @@ typedef __int64 int64_t; private void writeFunctions() { foreach (var func in model.Package.FunctionAddresses) - if (func.Key != func.Value) - writeLine($"MakeFunction({func.Key.ToAddressString()}, {func.Value.ToAddressString()})"); + writeLine($"MakeFunction({func.Key.ToAddressString()})"); } private void writeMetadata() {