C++: Output Il2CppClass* (TypeInfo) pointers
This commit is contained in:
@@ -25,7 +25,8 @@ namespace Il2CppInspector
|
|||||||
string Format { get; }
|
string Format { get; }
|
||||||
string Arch { get; }
|
string Arch { get; }
|
||||||
int Bits { get; }
|
int Bits { get; }
|
||||||
ulong GlobalOffset { get; }
|
ulong GlobalOffset { get; } // The virtual address where the code section (.text) would be loaded in memory
|
||||||
|
ulong ImageBase { get; } // The virtual address of where the image would be loaded in memory (same as GlobalOffset except for PE)
|
||||||
Dictionary<string, ulong> GetSymbolTable();
|
Dictionary<string, ulong> GetSymbolTable();
|
||||||
uint[] GetFunctionTable();
|
uint[] GetFunctionTable();
|
||||||
IEnumerable<Export> GetExports();
|
IEnumerable<Export> GetExports();
|
||||||
@@ -87,6 +88,8 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
public ulong GlobalOffset { get; protected set; }
|
public ulong GlobalOffset { get; protected set; }
|
||||||
|
|
||||||
|
public virtual ulong ImageBase => GlobalOffset;
|
||||||
|
|
||||||
public virtual string Format => throw new NotImplementedException();
|
public virtual string Format => throw new NotImplementedException();
|
||||||
|
|
||||||
public virtual string Arch => throw new NotImplementedException();
|
public virtual string Arch => throw new NotImplementedException();
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ namespace Il2CppInspector
|
|||||||
// Could also use coff.Characteristics (IMAGE_FILE_32BIT_MACHINE) or coff.Machine
|
// Could also use coff.Characteristics (IMAGE_FILE_32BIT_MACHINE) or coff.Machine
|
||||||
public override int Bits => (PE) pe.Magic == PE.IMAGE_NT_OPTIONAL_HDR64_MAGIC ? 64 : 32;
|
public override int Bits => (PE) pe.Magic == PE.IMAGE_NT_OPTIONAL_HDR64_MAGIC ? 64 : 32;
|
||||||
|
|
||||||
|
public override ulong ImageBase => pe.ImageBase;
|
||||||
|
|
||||||
protected override bool Init() {
|
protected override bool Init() {
|
||||||
// Check for MZ signature "MZ"
|
// Check for MZ signature "MZ"
|
||||||
if (ReadUInt16() != 0x5A4D)
|
if (ReadUInt16() != 0x5A4D)
|
||||||
|
|||||||
@@ -61,7 +61,22 @@ namespace Il2CppInspector.Outputs
|
|||||||
var exportRgx = new Regex(@"^_+");
|
var exportRgx = new Regex(@"^_+");
|
||||||
|
|
||||||
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 {exportRgx.Replace(export.Name, "")}_ptr 0x{model.Package.BinaryImage.MapVATR(export.VirtualAddress):X8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.Close();
|
||||||
|
|
||||||
|
// Write application type definition addresses to il2cpp-type-ptr.h
|
||||||
|
var il2cppTypeInfoFile = Path.Combine(outputPath, "il2cpp-type-ptr.h");
|
||||||
|
|
||||||
|
using var fs3 = new FileStream(il2cppTypeInfoFile, FileMode.Create);
|
||||||
|
writer = new StreamWriter(fs3, Encoding.UTF8);
|
||||||
|
|
||||||
|
writeHeader();
|
||||||
|
writeSectionHeader("IL2CPP application-specific type definition addresses");
|
||||||
|
|
||||||
|
foreach (var type in model.Types.Values.Where(t => t.TypeClassAddress != 0xffffffff_ffffffff)) {
|
||||||
|
writeCode($"DO_TYPEDEF(0x{type.TypeClassAddress - model.Package.BinaryImage.ImageBase:X8}, {type.Name});");
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Close();
|
writer.Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user