AppModel: Add WordSizeBytes; tidy up a bit

This commit is contained in:
Katy Coe
2020-08-17 02:49:01 +02:00
parent 4b86087c7a
commit 2024a3bfac
4 changed files with 8 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ namespace Il2CppInspector.Cpp
private CppTypeCollection types => appModel.CppTypeCollection; private CppTypeCollection types => appModel.CppTypeCollection;
// Word size (32/64-bit) for this generator // Word size (32/64-bit) for this generator
public int WordSize => appModel.WordSize; public int WordSize => appModel.WordSizeBits;
// Version number and header file to generate structures for // Version number and header file to generate structures for
public UnityVersion UnityVersion => appModel.UnityVersion; public UnityVersion UnityVersion => appModel.UnityVersion;

View File

@@ -274,6 +274,7 @@ namespace Il2CppInspector
} }
// Get sorted list of function pointers from all sources // Get sorted list of function pointers from all sources
// TODO: This does not include IL2CPP API functions
var sortedFunctionPointers = (Version <= 24.1)? var sortedFunctionPointers = (Version <= 24.1)?
Binary.GlobalMethodPointers.ToList() : Binary.GlobalMethodPointers.ToList() :
Binary.ModuleMethodPointers.SelectMany(module => module.Value).ToList(); Binary.ModuleMethodPointers.SelectMany(module => module.Value).ToList();

View File

@@ -76,7 +76,10 @@ namespace Il2CppInspector.Model
// Convenience properties // Convenience properties
// The word size of the binary in bits // The word size of the binary in bits
public int WordSize => Image.Bits; public int WordSizeBits => Image.Bits;
// The word size of the binary in bytes
public int WordSizeBytes => WordSizeBits / 8;
// The binary image // The binary image
public IFileFormatReader Image => Package.BinaryImage; public IFileFormatReader Image => Package.BinaryImage;
@@ -317,7 +320,7 @@ namespace Il2CppInspector.Model
// Il2CppMethodPointer methodPtr; // Il2CppMethodPointer methodPtr;
// const MethodInfo* method; // const MethodInfo* method;
var offsetIntoVTable = offset - GetVTableOffset(); var offsetIntoVTable = offset - GetVTableOffset();
var vidSize = WordSize == 32? 8 : 16; var vidSize = WordSizeBits == 32? 8 : 16;
return offsetIntoVTable / vidSize; return offsetIntoVTable / vidSize;
} }
} }

View File

@@ -53,7 +53,7 @@ typedef size_t uintptr_t;
"); ");
writeSectionHeader("IL2CPP internal types"); writeSectionHeader("IL2CPP internal types");
writeCode(model.UnityHeaders.GetTypeHeaderText(model.WordSize)); writeCode(model.UnityHeaders.GetTypeHeaderText(model.WordSizeBits));
// Stop MSVC complaining about out-of-bounds enum values // Stop MSVC complaining about out-of-bounds enum values
if (model.TargetCompiler == CppCompilerType.MSVC) if (model.TargetCompiler == CppCompilerType.MSVC)