IL2CPP: Add Binary.GetAPIExports()
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 Perfare - https://github.com/Perfare/Il2CppDumper
|
Copyright 2017 Perfare - https://github.com/Perfare/Il2CppDumper
|
||||||
Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
Copyright 2017-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
@@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
{
|
{
|
||||||
@@ -266,5 +267,24 @@ namespace Il2CppInspector
|
|||||||
GenericMethodInvokerIndices.Add(MethodSpecs[tableEntry.genericMethodIndex], tableEntry.indices.invokerIndex);
|
GenericMethodInvokerIndices.Add(MethodSpecs[tableEntry.genericMethodIndex], tableEntry.indices.invokerIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IL2CPP API exports
|
||||||
|
// This strips leading underscores and selects only il2cpp_* symbols which can be mapped into the binary
|
||||||
|
// (therefore ignoring extern imports)
|
||||||
|
public Dictionary<string, ulong> GetAPIExports() {
|
||||||
|
var exports = Image.GetExports()?.Where(e => e.Name.StartsWith("il2cpp_") || e.Name.StartsWith("_il2cpp_") || e.Name.StartsWith("__il2cpp_"));
|
||||||
|
|
||||||
|
if (exports == null)
|
||||||
|
return new Dictionary<string, ulong>();
|
||||||
|
|
||||||
|
var exportRgx = new Regex(@"^_+");
|
||||||
|
var il2cppExports = new Dictionary<string, ulong>();
|
||||||
|
|
||||||
|
foreach (var export in exports)
|
||||||
|
if (Image.TryMapVATR(export.VirtualAddress, out _))
|
||||||
|
il2cppExports.Add(exportRgx.Replace(export.Name, ""), export.VirtualAddress);
|
||||||
|
|
||||||
|
return il2cppExports;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ namespace Il2CppInspector.Outputs
|
|||||||
writeHeader();
|
writeHeader();
|
||||||
writeSectionHeader("IL2CPP API function pointers");
|
writeSectionHeader("IL2CPP API function pointers");
|
||||||
|
|
||||||
var exports = model.Exports.Where(e => e.Name.StartsWith("il2cpp_") || e.Name.StartsWith("_il2cpp_") || e.Name.StartsWith("__il2cpp_"));
|
// TODO: Use model.APIExports instead once it is implemented
|
||||||
var exportRgx = new Regex(@"^_+");
|
var exports = model.Package.Binary.GetAPIExports();
|
||||||
|
|
||||||
foreach (var export in exports) {
|
foreach (var export in exports) {
|
||||||
writeCode($"#define {exportRgx.Replace(export.Name, "")}_ptr 0x{model.Package.BinaryImage.MapVATR(export.VirtualAddress):X8}");
|
writeCode($"#define {export.Key}_ptr 0x{model.Package.BinaryImage.MapVATR(export.Value):X8}");
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Close();
|
writer.Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user