From 4e8264ab7031b65df7d4de2973c1685077c25b3e Mon Sep 17 00:00:00 2001 From: Sam Byass Date: Tue, 18 Jul 2023 13:37:24 +0100 Subject: [PATCH] Lib: Fix field offsets on wasm. Closes #226 --- LibCpp2IL/ClassReadingBinaryReader.cs | 2 -- LibCpp2IL/Il2CppBinary.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/LibCpp2IL/ClassReadingBinaryReader.cs b/LibCpp2IL/ClassReadingBinaryReader.cs index 77fddf26..db9c1c0c 100644 --- a/LibCpp2IL/ClassReadingBinaryReader.cs +++ b/LibCpp2IL/ClassReadingBinaryReader.cs @@ -87,8 +87,6 @@ public long Position return null; } - private Dictionary _cachedNoSerialize = new(); - public uint ReadUnityCompressedUIntAtRawAddr(long offset, out int bytesRead) { GetLockOrThrow(); diff --git a/LibCpp2IL/Il2CppBinary.cs b/LibCpp2IL/Il2CppBinary.cs index 624d7219..f85ace4d 100644 --- a/LibCpp2IL/Il2CppBinary.cs +++ b/LibCpp2IL/Il2CppBinary.cs @@ -389,7 +389,7 @@ public int GetFieldOffsetFromIndex(int typeIndex, int fieldIndexInType, int fiel { var offsetOffset = (ulong)MapVirtualAddressToRaw(ptr) + 4ul * (ulong)fieldIndexInType; Position = (long)offsetOffset; - offset = ReadInt32(); + offset = (int)ReadPrimitive(typeof(int))!; //Read 4 bytes. We can't just use ReadInt32 because that breaks e.g. Wasm. Hoping the JIT can optimize this as it knows the type. } } else