Make all file format classes public for API/plugins

This commit is contained in:
Katy Coe
2020-12-29 19:15:03 +01:00
parent 69d155af82
commit 466531f3bd
14 changed files with 53 additions and 53 deletions

View File

@@ -13,7 +13,7 @@ using System.Linq;
namespace Il2CppInspector namespace Il2CppInspector
{ {
// This is a wrapper for multiple binary files of different architectures within a single AAB // This is a wrapper for multiple binary files of different architectures within a single AAB
internal class AABReader : FileFormatStream<AABReader> public class AABReader : FileFormatStream<AABReader>
{ {
private ZipArchive zip; private ZipArchive zip;
private ZipArchiveEntry[] binaryFiles; private ZipArchiveEntry[] binaryFiles;

View File

@@ -13,7 +13,7 @@ using System.Linq;
namespace Il2CppInspector namespace Il2CppInspector
{ {
// This is a wrapper for multiple binary files of different architectures within a single APK // This is a wrapper for multiple binary files of different architectures within a single APK
internal class APKReader : FileFormatStream<APKReader> public class APKReader : FileFormatStream<APKReader>
{ {
private ZipArchive zip; private ZipArchive zip;
private ZipArchiveEntry[] binaryFiles; private ZipArchiveEntry[] binaryFiles;

View File

@@ -15,7 +15,7 @@ using NoisyCowStudios.Bin2Object;
namespace Il2CppInspector namespace Il2CppInspector
{ {
internal class ElfReader32 : ElfReader<uint, elf_32_phdr, elf_32_sym, ElfReader32, Convert32> public class ElfReader32 : ElfReader<uint, elf_32_phdr, elf_32_sym, ElfReader32, Convert32>
{ {
public ElfReader32() : base() { public ElfReader32() : base() {
ElfReloc.GetRelocType = info => (Elf) (info & 0xff); ElfReloc.GetRelocType = info => (Elf) (info & 0xff);
@@ -28,7 +28,7 @@ namespace Il2CppInspector
protected override void WriteWord(uint value) => Write(value); protected override void WriteWord(uint value) => Write(value);
} }
internal class ElfReader64 : ElfReader<ulong, elf_64_phdr, elf_64_sym, ElfReader64, Convert64> public class ElfReader64 : ElfReader<ulong, elf_64_phdr, elf_64_sym, ElfReader64, Convert64>
{ {
public ElfReader64() : base() { public ElfReader64() : base() {
ElfReloc.GetRelocType = info => (Elf) (info & 0xffff_ffff); ElfReloc.GetRelocType = info => (Elf) (info & 0xffff_ffff);
@@ -46,7 +46,7 @@ namespace Il2CppInspector
uint GetPLTAddress(); uint GetPLTAddress();
} }
internal abstract class ElfReader<TWord, TPHdr, TSym, TReader, TConvert> : FileFormatStream<TReader>, IElfReader public abstract class ElfReader<TWord, TPHdr, TSym, TReader, TConvert> : FileFormatStream<TReader>, IElfReader
where TWord : struct where TWord : struct
where TPHdr : Ielf_phdr<TWord>, new() where TPHdr : Ielf_phdr<TWord>, new()
where TSym : Ielf_sym<TWord>, new() where TSym : Ielf_sym<TWord>, new()

View File

@@ -109,7 +109,7 @@ namespace Il2CppInspector
} }
#pragma warning disable CS0649 #pragma warning disable CS0649
internal class elf_header<TWord> where TWord : struct public class elf_header<TWord> where TWord : struct
{ {
// 0x7f followed by ELF in ascii // 0x7f followed by ELF in ascii
public uint m_dwFormat; public uint m_dwFormat;
@@ -158,7 +158,7 @@ namespace Il2CppInspector
public ushort e_shtrndx; public ushort e_shtrndx;
} }
internal interface Ielf_phdr<TWord> where TWord : struct public interface Ielf_phdr<TWord> where TWord : struct
{ {
uint p_type { get; } uint p_type { get; }
TWord p_offset { get; set; } TWord p_offset { get; set; }
@@ -168,7 +168,7 @@ namespace Il2CppInspector
uint p_flags { get; } uint p_flags { get; }
} }
internal class elf_32_phdr : Ielf_phdr<uint> { public class elf_32_phdr : Ielf_phdr<uint> {
public uint p_type => f_p_type; public uint p_type => f_p_type;
public uint p_offset { get => f_p_offset; set => f_p_offset = value; } public uint p_offset { get => f_p_offset; set => f_p_offset = value; }
public uint p_filesz { get => f_p_filesz; set => f_p_filesz = value; } public uint p_filesz { get => f_p_filesz; set => f_p_filesz = value; }
@@ -186,7 +186,7 @@ namespace Il2CppInspector
public uint p_align; public uint p_align;
} }
internal class elf_64_phdr : Ielf_phdr<ulong> public class elf_64_phdr : Ielf_phdr<ulong>
{ {
public uint p_type => f_p_type; public uint p_type => f_p_type;
public ulong p_offset { get => f_p_offset; set => f_p_offset = value; } public ulong p_offset { get => f_p_offset; set => f_p_offset = value; }
@@ -205,7 +205,7 @@ namespace Il2CppInspector
public ulong p_align; public ulong p_align;
} }
internal class elf_shdr<TWord> where TWord : struct public class elf_shdr<TWord> where TWord : struct
{ {
public uint sh_name; public uint sh_name;
public uint sh_type; public uint sh_type;
@@ -219,7 +219,7 @@ namespace Il2CppInspector
public TWord sh_entsize; public TWord sh_entsize;
} }
internal interface Ielf_sym<TWord> where TWord : struct public interface Ielf_sym<TWord> where TWord : struct
{ {
uint st_name { get; } uint st_name { get; }
TWord st_value { get; } TWord st_value { get; }
@@ -228,7 +228,7 @@ namespace Il2CppInspector
Elf type { get; } Elf type { get; }
} }
internal class elf_32_sym : Ielf_sym<uint> public class elf_32_sym : Ielf_sym<uint>
{ {
public uint st_name => f_st_name; public uint st_name => f_st_name;
public uint st_value => f_st_value; public uint st_value => f_st_value;
@@ -244,7 +244,7 @@ namespace Il2CppInspector
public ushort f_st_shndx; public ushort f_st_shndx;
} }
internal class elf_64_sym : Ielf_sym<ulong> public class elf_64_sym : Ielf_sym<ulong>
{ {
public uint st_name => f_st_name; public uint st_name => f_st_name;
public ulong st_value => f_st_value; public ulong st_value => f_st_value;
@@ -260,19 +260,19 @@ namespace Il2CppInspector
public ulong st_size; public ulong st_size;
} }
internal class elf_dynamic<TWord> where TWord : struct public class elf_dynamic<TWord> where TWord : struct
{ {
public TWord d_tag; public TWord d_tag;
public TWord d_un; public TWord d_un;
} }
internal class elf_rel<TWord> where TWord : struct public class elf_rel<TWord> where TWord : struct
{ {
public TWord r_offset; public TWord r_offset;
public TWord r_info; public TWord r_info;
} }
internal class elf_rela<TWord> where TWord : struct public class elf_rela<TWord> where TWord : struct
{ {
public TWord r_offset; public TWord r_offset;
public TWord r_info; public TWord r_info;

View File

@@ -65,7 +65,7 @@ namespace Il2CppInspector
N_OSO = 0x66, N_OSO = 0x66,
} }
internal class MachOHeader<TWord> where TWord : struct public class MachOHeader<TWord> where TWord : struct
{ {
public uint Magic; public uint Magic;
public uint CPUType; public uint CPUType;
@@ -76,13 +76,13 @@ namespace Il2CppInspector
public TWord Flags; public TWord Flags;
} }
internal class MachOLoadCommand public class MachOLoadCommand
{ {
public uint Command; public uint Command;
public uint Size; public uint Size;
} }
internal class MachOSegmentCommand<TWord> where TWord : struct public class MachOSegmentCommand<TWord> where TWord : struct
{ {
// MachOLoadCommand // MachOLoadCommand
[String(FixedSize = 16)] [String(FixedSize = 16)]
@@ -97,7 +97,7 @@ namespace Il2CppInspector
public uint Flags; public uint Flags;
} }
internal class MachOSection<TWord> where TWord : struct public class MachOSection<TWord> where TWord : struct
{ {
[String(FixedSize = 16)] [String(FixedSize = 16)]
public string Name; public string Name;
@@ -114,14 +114,14 @@ namespace Il2CppInspector
public TWord Reserved2; public TWord Reserved2;
} }
internal class MachOLinkEditDataCommand public class MachOLinkEditDataCommand
{ {
// MachOLoadCommand // MachOLoadCommand
public uint Offset; public uint Offset;
public uint Size; public uint Size;
} }
internal class MachODyldInfoCommand public class MachODyldInfoCommand
{ {
public uint RebaseOffset; public uint RebaseOffset;
public uint RebaseSize; public uint RebaseSize;
@@ -135,7 +135,7 @@ namespace Il2CppInspector
public uint ExportSize; public uint ExportSize;
} }
internal class MachOSymtabCommand public class MachOSymtabCommand
{ {
public uint SymOffset; public uint SymOffset;
public uint NumSyms; public uint NumSyms;
@@ -143,7 +143,7 @@ namespace Il2CppInspector
public uint StrSize; public uint StrSize;
} }
internal class MachOEncryptionInfo public class MachOEncryptionInfo
{ {
// MachOLoadCommand // MachOLoadCommand
public uint CryptOffset; public uint CryptOffset;
@@ -151,7 +151,7 @@ namespace Il2CppInspector
public uint CryptID; public uint CryptID;
} }
internal class MachO_nlist<TWord> where TWord : struct public class MachO_nlist<TWord> where TWord : struct
{ {
public MachO_NType n_type => (MachO_NType) f_n_type; public MachO_NType n_type => (MachO_NType) f_n_type;
public uint n_strx; public uint n_strx;
@@ -161,7 +161,7 @@ namespace Il2CppInspector
public TWord n_value; public TWord n_value;
} }
internal class MachO_relocation_info public class MachO_relocation_info
{ {
public int r_address; public int r_address;
public uint r_data; public uint r_data;

View File

@@ -25,7 +25,7 @@ namespace Il2CppInspector
#pragma warning disable CS0649 #pragma warning disable CS0649
// _IMAGE_FILE_HEADER // _IMAGE_FILE_HEADER
internal class COFFHeader public class COFFHeader
{ {
public ushort Machine; public ushort Machine;
public ushort NumberOfSections; public ushort NumberOfSections;
@@ -37,7 +37,7 @@ namespace Il2CppInspector
} }
// _IMAGE_OPTIONAL_HEADER // _IMAGE_OPTIONAL_HEADER
internal interface IPEOptHeader public interface IPEOptHeader
{ {
PE ExpectedMagic { get; } PE ExpectedMagic { get; }
ushort Magic { get; } ushort Magic { get; }
@@ -46,7 +46,7 @@ namespace Il2CppInspector
RvaEntry[] DataDirectory { get; } RvaEntry[] DataDirectory { get; }
} }
internal class PEOptHeader32 : IPEOptHeader public class PEOptHeader32 : IPEOptHeader
{ {
public PE ExpectedMagic => PE.IMAGE_NT_OPTIONAL_HDR32_MAGIC; public PE ExpectedMagic => PE.IMAGE_NT_OPTIONAL_HDR32_MAGIC;
public ushort Magic => f_Magic; public ushort Magic => f_Magic;
@@ -89,7 +89,7 @@ namespace Il2CppInspector
} }
// _IMAGE_OPTIONAL_HEADER64 // _IMAGE_OPTIONAL_HEADER64
internal class PEOptHeader64 : IPEOptHeader public class PEOptHeader64 : IPEOptHeader
{ {
public PE ExpectedMagic => PE.IMAGE_NT_OPTIONAL_HDR64_MAGIC; public PE ExpectedMagic => PE.IMAGE_NT_OPTIONAL_HDR64_MAGIC;
public ushort Magic => f_Magic; public ushort Magic => f_Magic;
@@ -130,14 +130,14 @@ namespace Il2CppInspector
public RvaEntry[] f_DataDirectory; public RvaEntry[] f_DataDirectory;
} }
internal class RvaEntry public class RvaEntry
{ {
public uint VirtualAddress; public uint VirtualAddress;
public uint Size; public uint Size;
} }
// _IMAGE_SECTION_HEADER // _IMAGE_SECTION_HEADER
internal class PESection public class PESection
{ {
public PE Characteristics => (PE) f_Characteristics; public PE Characteristics => (PE) f_Characteristics;
@@ -155,7 +155,7 @@ namespace Il2CppInspector
} }
// _IMAGE_EXPORT_DIRECTORY // _IMAGE_EXPORT_DIRECTORY
internal class PEExportDirectory public class PEExportDirectory
{ {
public uint Characteristics; public uint Characteristics;
public uint TimeDateStamp; public uint TimeDateStamp;

View File

@@ -9,13 +9,13 @@ using NoisyCowStudios.Bin2Object;
namespace Il2CppInspector namespace Il2CppInspector
{ {
internal enum SElfConsts : uint public enum SElfConsts : uint
{ {
Magic = 0x1D3D154F Magic = 0x1D3D154F
} }
[Flags] [Flags]
internal enum SElfEntryFlags : ulong public enum SElfEntryFlags : ulong
{ {
Ordered = 0x1, Ordered = 0x1,
Encrypted = 0x2, Encrypted = 0x2,
@@ -30,7 +30,7 @@ namespace Il2CppInspector
} }
// SCE-specific definitions for e_type // SCE-specific definitions for e_type
internal enum SElfETypes : ushort public enum SElfETypes : ushort
{ {
ET_SCE_EXEC = 0xFE00, ET_SCE_EXEC = 0xFE00,
ET_SCE_RELEXEC = 0xFE04, ET_SCE_RELEXEC = 0xFE04,
@@ -48,7 +48,7 @@ namespace Il2CppInspector
} }
// SCE-specific definitions for program header type // SCE-specific definitions for program header type
internal enum SElfPTypes : uint public enum SElfPTypes : uint
{ {
PT_SCE_RELA = 0x60000000, PT_SCE_RELA = 0x60000000,
PT_SCE_DYNLIBDATA = 0x61000000, PT_SCE_DYNLIBDATA = 0x61000000,
@@ -60,7 +60,7 @@ namespace Il2CppInspector
} }
// Extended info types // Extended info types
internal enum SElfExInfoTypes public enum SElfExInfoTypes
{ {
PTYPE_FAKE = 0x1, PTYPE_FAKE = 0x1,
PTYPE_NPDRM_EXEC = 0x4, PTYPE_NPDRM_EXEC = 0x4,
@@ -73,7 +73,7 @@ namespace Il2CppInspector
} }
#pragma warning disable CS0649 #pragma warning disable CS0649
internal class SElfHeader public class SElfHeader
{ {
public uint Magic; public uint Magic;
public byte Version; public byte Version;
@@ -89,7 +89,7 @@ namespace Il2CppInspector
public uint Padding; public uint Padding;
} }
internal class SElfEntry public class SElfEntry
{ {
public ulong Flags; public ulong Flags;
public ulong FileOffset; public ulong FileOffset;
@@ -102,7 +102,7 @@ namespace Il2CppInspector
public ushort SegmentIndex => (ushort) ((Flags & (ulong) SElfEntryFlags.SegmentIndexMask) >> 20); public ushort SegmentIndex => (ushort) ((Flags & (ulong) SElfEntryFlags.SegmentIndexMask) >> 20);
} }
internal class SElfSCEData public class SElfSCEData
{ {
public ulong ProductAuthID; public ulong ProductAuthID;
public ulong ProductType; public ulong ProductType;

View File

@@ -15,14 +15,14 @@ namespace Il2CppInspector
} }
// Big-endian // Big-endian
internal class FatHeader public class FatHeader
{ {
public uint Magic; public uint Magic;
public uint NumArch; public uint NumArch;
} }
// Big-endian // Big-endian
internal class FatArch public class FatArch
{ {
public uint CPUType; public uint CPUType;
public uint CPUSubType; public uint CPUSubType;

View File

@@ -13,7 +13,7 @@ using NoisyCowStudios.Bin2Object;
namespace Il2CppInspector namespace Il2CppInspector
{ {
internal class MachOReader32 : MachOReader<uint, MachOReader32, Convert32> public class MachOReader32 : MachOReader<uint, MachOReader32, Convert32>
{ {
public override int Bits => 32; public override int Bits => 32;
@@ -33,7 +33,7 @@ namespace Il2CppInspector
} }
} }
internal class MachOReader64 : MachOReader<ulong, MachOReader64, Convert64> public class MachOReader64 : MachOReader<ulong, MachOReader64, Convert64>
{ {
public override int Bits => 64; public override int Bits => 64;
@@ -55,7 +55,7 @@ namespace Il2CppInspector
// We need this convoluted generic TReader declaration so that "static T FileFormatReader.Load(Stream)" // We need this convoluted generic TReader declaration so that "static T FileFormatReader.Load(Stream)"
// is inherited to MachOReader32/64 with a correct definition of T // is inherited to MachOReader32/64 with a correct definition of T
internal abstract class MachOReader<TWord, TReader, TConvert> : FileFormatStream<TReader> public abstract class MachOReader<TWord, TReader, TConvert> : FileFormatStream<TReader>
where TWord : struct where TWord : struct
where TReader : FileFormatStream<TReader> where TReader : FileFormatStream<TReader>
where TConvert : IWordConverter<TWord>, new() where TConvert : IWordConverter<TWord>, new()

View File

@@ -17,7 +17,7 @@ namespace Il2CppInspector
// References: // References:
// PE Header file: https://github.com/dotnet/llilc/blob/master/include/clr/ntimage.h // PE Header file: https://github.com/dotnet/llilc/blob/master/include/clr/ntimage.h
// PE format specification: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format?redirectedfrom=MSDN // PE format specification: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format?redirectedfrom=MSDN
internal class PEReader : FileFormatStream<PEReader> public class PEReader : FileFormatStream<PEReader>
{ {
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private extern static IntPtr LoadLibrary(string lpLibFileName); private extern static IntPtr LoadLibrary(string lpLibFileName);

View File

@@ -15,7 +15,7 @@ namespace Il2CppInspector
// This is a wrapper for a Linux memory dump // This is a wrapper for a Linux memory dump
// The supplied file is a text file containing the output of "cat /proc/["self"|process-id]/maps" // The supplied file is a text file containing the output of "cat /proc/["self"|process-id]/maps"
// We re-construct libil2cpp.so from the *.bin files and return it as the first image // We re-construct libil2cpp.so from the *.bin files and return it as the first image
internal class ProcessMapReader : FileFormatStream<ProcessMapReader> public class ProcessMapReader : FileFormatStream<ProcessMapReader>
{ {
private BinaryObjectStream il2cpp; private BinaryObjectStream il2cpp;

View File

@@ -24,7 +24,7 @@ namespace Il2CppInspector
// https://www.psxhax.com/threads/ps4-self-spkg-file-format-documentation-detailed-for-scene-devs.6636/ // https://www.psxhax.com/threads/ps4-self-spkg-file-format-documentation-detailed-for-scene-devs.6636/
// https://wiki.henkaku.xyz/vita/images/a/a2/Vita_SDK_specifications.pdf // https://wiki.henkaku.xyz/vita/images/a/a2/Vita_SDK_specifications.pdf
// https://www.psxhax.com/threads/make-fself-gui-for-flat_zs-make_fself-py-script-by-cfwprophet.3494/ // https://www.psxhax.com/threads/make-fself-gui-for-flat_zs-make_fself-py-script-by-cfwprophet.3494/
internal class SElfReader : FileFormatStream<SElfReader> public class SElfReader : FileFormatStream<SElfReader>
{ {
public override string DefaultFilename => "libil2cpp.so"; public override string DefaultFilename => "libil2cpp.so";

View File

@@ -9,7 +9,7 @@ using NoisyCowStudios.Bin2Object;
namespace Il2CppInspector namespace Il2CppInspector
{ {
internal class UBReader : FileFormatStream<UBReader> public class UBReader : FileFormatStream<UBReader>
{ {
private FatHeader header; private FatHeader header;

View File

@@ -10,7 +10,7 @@ namespace Il2CppInspector
{ {
// NOTE: What we really should have done here is add a TWord type parameter to FileFormatReader<T> // NOTE: What we really should have done here is add a TWord type parameter to FileFormatReader<T>
// then we could probably avoid most of this // then we could probably avoid most of this
interface IWordConverter<TWord> where TWord : struct public interface IWordConverter<TWord> where TWord : struct
{ {
TWord Add(TWord a, TWord b); TWord Add(TWord a, TWord b);
TWord Sub(TWord a, TWord b); TWord Sub(TWord a, TWord b);
@@ -25,7 +25,7 @@ namespace Il2CppInspector
uint[] UIntArray(TWord[] a); uint[] UIntArray(TWord[] a);
} }
internal class Convert32 : IWordConverter<uint> public class Convert32 : IWordConverter<uint>
{ {
public uint Add(uint a, uint b) => a + b; public uint Add(uint a, uint b) => a + b;
public uint Sub(uint a, uint b) => a - b; public uint Sub(uint a, uint b) => a - b;
@@ -40,7 +40,7 @@ namespace Il2CppInspector
public uint[] UIntArray(uint[] a) => a; public uint[] UIntArray(uint[] a) => a;
} }
internal class Convert64 : IWordConverter<ulong> public class Convert64 : IWordConverter<ulong>
{ {
public ulong Add(ulong a, ulong b) => a + b; public ulong Add(ulong a, ulong b) => a + b;
public ulong Sub(ulong a, ulong b) => a - b; public ulong Sub(ulong a, ulong b) => a - b;