Formats: Add Section class and [Try]GetSection() interface

This commit is contained in:
Katy Coe
2020-12-04 15:39:54 +01:00
parent 72ddaef7b1
commit 5f03abcff7
3 changed files with 37 additions and 1 deletions

View File

@@ -31,6 +31,8 @@ namespace Il2CppInspector
Dictionary<string, Symbol> GetSymbolTable();
uint[] GetFunctionTable();
IEnumerable<Export> GetExports();
IEnumerable<Section> GetSections();
bool TryGetSections(out IEnumerable<Section> sections);
uint MapVATR(ulong uiAddr);
bool TryMapVATR(ulong uiAddr, out uint fileOffset);
@@ -183,6 +185,19 @@ namespace Il2CppInspector
// Find all symbol exports for the image
public virtual IEnumerable<Export> GetExports() => null;
// Get all sections for the image in a universal format
public virtual IEnumerable<Section> GetSections() => throw new NotImplementedException();
public bool TryGetSections(out IEnumerable<Section> sections) {
try {
sections = GetSections();
return true;
} catch (NotImplementedException) {
sections = null;
return false;
}
}
// Map an RVA to an offset into the file image
// No mapping by default
public virtual uint MapVATR(ulong uiAddr) => (uint) uiAddr;

View File

@@ -98,7 +98,7 @@ namespace Il2CppInspector
foreach (var entry in dataEntries) {
pht[entry.SegmentIndex].f_p_filesz = entry.EncryptedCompressedSize;
pht[entry.SegmentIndex].f_p_offset = entry.FileOffset;
pht[entry.SegmentIndex].p_memsz = entry.MemorySize;
pht[entry.SegmentIndex].f_p_memsz = entry.MemorySize;
}
// Filter out unused phdr entries

View File

@@ -0,0 +1,21 @@
/*
Copyright 2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
All rights reserved.
*/
namespace Il2CppInspector
{
// A code file function export
public class Section
{
public ulong VirtualStart;
public ulong VirtualEnd;
public uint ImageStart;
public uint ImageEnd;
public bool IsExec;
public bool IsData;
public bool IsBSS;
public string Name;
}
}