From c72bd2174e5c3a8460822b98e18f9fd247c8d1d5 Mon Sep 17 00:00:00 2001 From: LukeFZ <17146677+LukeFZ@users.noreply.github.com> Date: Tue, 23 Dec 2025 00:51:00 +0100 Subject: [PATCH] add additional heuristics for metadata registration closes #35 --- Il2CppInspector.Common/IL2CPP/ImageScan.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/IL2CPP/ImageScan.cs b/Il2CppInspector.Common/IL2CPP/ImageScan.cs index b139fb3..ae7af7b 100644 --- a/Il2CppInspector.Common/IL2CPP/ImageScan.cs +++ b/Il2CppInspector.Common/IL2CPP/ImageScan.cs @@ -282,13 +282,18 @@ namespace Il2CppInspector // but I know of at least one binary where this will break detection. // Testing showed that we can just use the same heuristic used for v27+ // on older versions as well, so we'll just use it for all cases. + + // On some 32-bit (arm) binaries, just checking fields with the type count is not sufficient + // for uniquely identifying the metareg. We assume that all binaries have at least one generic class + inst + // and use this for an additional heuristic, though this is kinda jank and might not be enough for all binaries if (Image.Version >= MetadataVersions.V190) { foreach (var va in vas) { var mr = Image.ReadMappedVersionedObject(va); if (mr.TypeDefinitionsSizesCount == metadata.Types.Length - && mr.FieldOffsetsCount == metadata.Types.Length) + && mr.FieldOffsetsCount == metadata.Types.Length + && mr is { GenericInstsCount: > 0, GenericClassesCount: > 0 }) { metadataRegistration = va; break;