Skip to content

Commit fae0f95

Browse files
committed
Lib: Fix support for 2021.3.40+
Closes #317
1 parent 22e885c commit fae0f95

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

LibCpp2IL/BinaryStructures/Il2CppCodeRegistration.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static int GetStructSize(bool isBinary32Bit, float metadataVersion)
3434
//unresolvedVirtualCallPointers
3535
size += 2 * ptrSize;
3636

37-
if (metadataVersion >= 29.1f)
37+
if (metadataVersion is (> 29.1f and < 31f) or >= 31.1f)
3838
//unresolvedInstanceCallPointers and unresolvedStaticCallPointers
3939
size += 2 * ptrSize;
4040

@@ -78,8 +78,8 @@ public static int GetStructSize(bool isBinary32Bit, float metadataVersion)
7878
public ulong unresolvedVirtualCallCount; //Renamed to unresolvedIndirectCallCount in v29.1
7979
public ulong unresolvedVirtualCallPointers;
8080

81-
[Version(Min = 29.1f)] public ulong unresolvedInstanceCallPointers;
82-
[Version(Min = 29.1f)] public ulong unresolvedStaticCallPointers;
81+
[Version(Min = 29.1f, Max=31f), Version(Min=31.1f)] public ulong unresolvedInstanceCallPointers;
82+
[Version(Min = 29.1f, Max=31f), Version(Min=31.1f)] public ulong unresolvedStaticCallPointers;
8383

8484
[Version(Min = 23)] public ulong interopDataCount;
8585
[Version(Min = 23)] public ulong interopData;
@@ -119,7 +119,7 @@ public override void Read(ClassReadingBinaryReader reader)
119119
unresolvedVirtualCallCount = reader.ReadNUint();
120120
unresolvedVirtualCallPointers = reader.ReadNUint();
121121

122-
if (IsAtLeast(29.1f))
122+
if (IsAtLeast(29.1f) && IsNot(31f))
123123
{
124124
unresolvedInstanceCallPointers = reader.ReadNUint();
125125
unresolvedStaticCallPointers = reader.ReadNUint();

LibCpp2IL/Metadata/Il2CppMetadata.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ public static Il2CppMetadata ReadFrom(byte[] bytes, UnityVersion unityVersion)
116116
{
117117
//2022.3.33 introduces v31. Unity why would you bump this on a minor version.
118118
//Adds one new field (return type token) to method def
119-
actualVersion = 31;
119+
//2023.1.40 backported the new field but NOT the changes from v29.1, so there's a 31.1 now.
120+
if (unityVersion.GreaterThanOrEquals(2022, 3, 33, UnityVersionType.Final, 1))
121+
//V31 with changes in codereg
122+
actualVersion = 31.1f;
123+
else
124+
//v31 WITHOUT changes in codereg
125+
actualVersion = 31;
120126
}
121127
else actualVersion = version;
122128

0 commit comments

Comments
 (0)