Fix x86 edge case bugs

This commit is contained in:
Katy Coe
2019-10-22 16:24:23 +02:00
parent 9ab6d16dd0
commit eeb46c5820

View File

@@ -12,6 +12,7 @@ namespace Il2CppInspector
{
public Il2CppBinaryX86(IFileFormatReader stream) : base(stream) { }
public Il2CppBinaryX86(IFileFormatReader stream, uint codeRegistration, uint metadataRegistration) : base(stream, codeRegistration, metadataRegistration) { }
protected override (ulong, ulong) ConsiderCode(uint loc, ulong globalOffset) {
ulong metadata, code;
long funcPtr;
@@ -20,7 +21,7 @@ namespace Il2CppInspector
// Variant 1
// Assembly bytes to search for at start of each function
var bytes = new byte[] { 0x6A, 0x00, 0x6A, 0x00, 0x68 };
var bytes = new byte[] {0x6A, 0x00, 0x6A, 0x00, 0x68};
Image.Position = loc;
var buff = Image.ReadBytes(5);
if (bytes.SequenceEqual(buff)) {
@@ -32,15 +33,16 @@ namespace Il2CppInspector
return (0, 0);
// Jump to Il2CppCodegenRegistration
Image.Position = Image.MapVATR((ulong) funcPtr) + 6;
Image.Position = Image.MapVATR((ulong) funcPtr + 6);
metadata = Image.ReadUInt32();
Image.Position = Image.MapVATR((ulong) funcPtr) + 11;
Image.Position = Image.MapVATR((ulong) funcPtr + 11);
code = Image.ReadUInt32();
return (code, metadata);
}
// Variant 2
bytes = new byte[] { 0x55, 0x89, 0xE5, 0x53, 0x83, 0xE4, 0xF0, 0x83, 0xEC, 0x20, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x5B };
bytes = new byte[]
{0x55, 0x89, 0xE5, 0x53, 0x83, 0xE4, 0xF0, 0x83, 0xEC, 0x20, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x5B};
Image.Position = loc;
buff = Image.ReadBytes(16);
if (!bytes.SequenceEqual(buff))
@@ -61,19 +63,20 @@ namespace Il2CppInspector
if (opcode == 0x838B) {
Image.Position = Image.MapVATR(metadata);
metadata = Image.ReadUInt32();
// Repeat the same logic for extracting the Code pointer
Image.Position = funcPtr + 0x2A;
opcode = Image.ReadUInt16();
code = Image.ReadUInt32() + globalOffset;
if (opcode == 0x838B) {
Image.Position = Image.MapVATR(code);
code = Image.ReadUInt32();
return (code, metadata);
}
}
// Repeat the same logic for extracting the Code pointer
Image.Position = funcPtr + 0x2A;
opcode = Image.ReadUInt16();
code = Image.ReadUInt32() + globalOffset;
if (opcode == 0x838B) {
Image.Position = Image.MapVATR(code);
code = Image.ReadUInt32();
}
return (code, metadata);
return (0, 0);
}
}
}