IL2CPP: Encoded tokens in metadata v27 must be shifted right 1 bit
This commit is contained in:
@@ -127,9 +127,17 @@ namespace Il2CppInspector
|
||||
return ((ulong) pValue, value);
|
||||
}
|
||||
|
||||
// TODO: The resolution of metadata usages is broken for metadata v27 (MetadataUsageLists, MetadataUsagePairs no longer exist)
|
||||
private List<MetadataUsage> buildMetadataUsages()
|
||||
{
|
||||
// No metadata usages for versions < 19
|
||||
if (Version < 19)
|
||||
return null;
|
||||
|
||||
// Metadata usages are lazily initialized during runtime for versions >= 27
|
||||
if (Version >= 27)
|
||||
return buildLateBindingMetadataUsages();
|
||||
|
||||
// Version >= 19 && <= 24.3
|
||||
var usages = new Dictionary<uint, MetadataUsage>();
|
||||
foreach (var metadataUsageList in Metadata.MetadataUsageLists)
|
||||
{
|
||||
@@ -150,6 +158,11 @@ namespace Il2CppInspector
|
||||
return usages.Values.ToList();
|
||||
}
|
||||
|
||||
public List<MetadataUsage> buildLateBindingMetadataUsages() {
|
||||
// TODO: Resolve late binding for metadata v27
|
||||
return null;
|
||||
}
|
||||
|
||||
public Il2CppInspector(Il2CppBinary binary, Metadata metadata) {
|
||||
// Store stream representations
|
||||
Binary = binary;
|
||||
@@ -243,8 +256,7 @@ namespace Il2CppInspector
|
||||
}
|
||||
|
||||
// Merge all metadata usage references into a single distinct list
|
||||
if (Version >= 19)
|
||||
MetadataUsages = buildMetadataUsages();
|
||||
MetadataUsages = buildMetadataUsages();
|
||||
}
|
||||
|
||||
// Get a method pointer if available
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace Il2CppInspector
|
||||
var encodedType = encodedIndex & 0xE0000000;
|
||||
usageType = (MetadataUsageType)(encodedType >> 29);
|
||||
index = encodedIndex & 0x1FFFFFFF;
|
||||
|
||||
// From v27 the bottom bit is set to indicate the usage token hasn't been replaced with a pointer at runtime yet
|
||||
if (package.Version >= 27)
|
||||
index >>= 1;
|
||||
}
|
||||
return new MetadataUsage(usageType, (int)index);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Il2CppInspector.Model
|
||||
// For il2cpp < 19, the key is the string literal ordinal instead of the address
|
||||
public Dictionary<ulong, string> Strings { get; } = new Dictionary<ulong, string>();
|
||||
|
||||
public bool StringIndexesAreOrdinals => Package.MetadataUsages == null;
|
||||
public bool StringIndexesAreOrdinals => Package.Version < 19;
|
||||
|
||||
// The .NET type model for the application
|
||||
public TypeModel TypeModel { get; }
|
||||
@@ -239,7 +239,7 @@ namespace Il2CppInspector.Model
|
||||
}
|
||||
|
||||
// Add string literals for metadata <19 to the model
|
||||
else {
|
||||
if (Package.Version < 19) {
|
||||
/* Version < 19 calls `il2cpp_codegen_string_literal_from_index` to get string literals.
|
||||
* Unfortunately, metadata references are just loose globals in Il2CppMetadataUsage.cpp
|
||||
* so we can't automatically name those. Next best thing is to define an enum for the strings. */
|
||||
|
||||
Reference in New Issue
Block a user