Skip to content

Commit

Permalink
Lib: Fix field offsets on wasm. Closes SamboyCoding#226
Browse files Browse the repository at this point in the history
  • Loading branch information
SamboyCoding committed Jul 18, 2023
1 parent 812b3bb commit 4e8264a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions LibCpp2IL/ClassReadingBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ public long Position
return null;
}

private Dictionary<FieldInfo, bool> _cachedNoSerialize = new();

public uint ReadUnityCompressedUIntAtRawAddr(long offset, out int bytesRead)
{
GetLockOrThrow();
Expand Down
2 changes: 1 addition & 1 deletion LibCpp2IL/Il2CppBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e8264a

Please sign in to comment.