From 1240fe364763e670930cc5f94375bcfc311ce566 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 25 Jul 2020 14:50:09 +0200 Subject: [PATCH] Unity: Fix types/API header version mismatch when binary is missing exports --- Il2CppInspector.Common/Cpp/UnityHeaders/UnityHeaders.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Il2CppInspector.Common/Cpp/UnityHeaders/UnityHeaders.cs b/Il2CppInspector.Common/Cpp/UnityHeaders/UnityHeaders.cs index 9cc8216..1421eb4 100644 --- a/Il2CppInspector.Common/Cpp/UnityHeaders/UnityHeaders.cs +++ b/Il2CppInspector.Common/Cpp/UnityHeaders/UnityHeaders.cs @@ -140,7 +140,8 @@ namespace Il2CppInspector.Cpp.UnityHeaders if (!exports.Any()) { Console.WriteLine("No IL2CPP API exports found in binary - IL2CPP APIs will be unavailable in C++ project"); - return typeHeaders.Select(t => new UnityHeaders(t, apis[0])).ToList(); + return typeHeaders.Select(t => new UnityHeaders(t, + apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList(); } // Go through all of the possible API versions and see how closely they match the binary @@ -169,7 +170,8 @@ namespace Il2CppInspector.Cpp.UnityHeaders // Select the oldest API version from the group - C++ project compilation will fail Console.WriteLine("No exact match for IL2CPP APIs found in binary - IL2CPP API availability in C++ project will be partial"); - return typeHeaders.Select(t => new UnityHeaders(t, apis[0])).ToList(); + return typeHeaders.Select(t => new UnityHeaders(t, + apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList(); } // Convert il2cpp-api-functions.h from "DO_API(r, n, p)" to "typedef r (*n)(p)"