Skip to content

Commit

Permalink
backport 29/31 version fixes from new versioning branch
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeFZ committed Aug 18, 2024
1 parent 665e703 commit 4ce4d0e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Il2CppInspector.Common/IL2CPP/Il2CppBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ private void PrepareMetadata(ulong codeRegistration, ulong metadataRegistration)
CodeRegistration = Image.ReadMappedObject<Il2CppCodeRegistration>(codeRegistration);
}

if (Image.Version == 29 && (long)CodeRegistration.genericMethodPointersCount - MetadataRegistration.genericMethodTableCount > 0x10000)
if (Image.Version is 29 or 31 && (long)CodeRegistration.genericMethodPointersCount - MetadataRegistration.genericMethodTableCount > 0x10000)
{
Image.Version = 29.1;
Image.Version += 0.1;
codeRegistration -= 2 * pointerSize;
CodeRegistration = Image.ReadMappedObject<Il2CppCodeRegistration>(codeRegistration);
}
Expand Down
19 changes: 19 additions & 0 deletions Il2CppInspector.Common/IL2CPP/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@ private void Initialize()
Header.attributeDataRangeSize / Sizeof(typeof(Il2CppCustomAttributeDataRange)));
}

if (Version is 29 or 31)
{
// 29.2/31.2 added a new isUnmanagedCallersOnly flag to Il2CppMethodDefinition.
// This offsets all subsequent entries by one - we can detect this by checking the
// top token byte (which should always be 0x06).

if (Methods.Length >= 2)
{
var secondToken = Methods[1].token;
if (secondToken >> 24 != 0x6)
{
Version += 0.2;

Methods = ReadArray<Il2CppMethodDefinition>(Header.methodsOffset,
Header.methodsCount / Sizeof(typeof(Il2CppMethodDefinition)));
}
}
}

// Get all metadata strings
var pluginGetStringsResult = PluginHooks.GetStrings(this);
if (pluginGetStringsResult.IsDataModified && !pluginGetStringsResult.IsInvalid)
Expand Down
2 changes: 1 addition & 1 deletion Il2CppInspector.Common/IL2CPP/MetadataClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public class Il2CppMethodDefinition
public ushort parameterCount;

[Version(Min = 29.2, Max = 31)]
public bool isUnmanagedCallersOnly;
public byte isUnmanagedCallersOnly;
}

public class Il2CppParameterDefinition
Expand Down

0 comments on commit 4ce4d0e

Please sign in to comment.