Skip to content

Commit 4e8264a

Browse files
committed
Lib: Fix field offsets on wasm. Closes #226
1 parent 812b3bb commit 4e8264a

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

LibCpp2IL/ClassReadingBinaryReader.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ public long Position
8787
return null;
8888
}
8989

90-
private Dictionary<FieldInfo, bool> _cachedNoSerialize = new();
91-
9290
public uint ReadUnityCompressedUIntAtRawAddr(long offset, out int bytesRead)
9391
{
9492
GetLockOrThrow();

LibCpp2IL/Il2CppBinary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public int GetFieldOffsetFromIndex(int typeIndex, int fieldIndexInType, int fiel
389389
{
390390
var offsetOffset = (ulong)MapVirtualAddressToRaw(ptr) + 4ul * (ulong)fieldIndexInType;
391391
Position = (long)offsetOffset;
392-
offset = ReadInt32();
392+
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.
393393
}
394394
}
395395
else

0 commit comments

Comments
 (0)