diff --git a/Il2CppInterop.Common/XrefScans/XrefScanMethodDb.cs b/Il2CppInterop.Common/XrefScans/XrefScanMethodDb.cs index 3958f4a7..6acd3bb6 100644 --- a/Il2CppInterop.Common/XrefScans/XrefScanMethodDb.cs +++ b/Il2CppInterop.Common/XrefScans/XrefScanMethodDb.cs @@ -21,7 +21,7 @@ static XrefScanMethodDb() XrefScanCache = new MethodXrefScanCache(GeneratedDatabasesUtil.GetDatabasePath(MethodXrefScanCache.FileName)); foreach (ProcessModule module in Process.GetCurrentProcess().Modules) - if (module.ModuleName == "GameAssembly.dll") + if (module.ModuleName is "GameAssembly.dll" or "GameAssembly_plus.dll") { GameAssemblyBase = (long)module.BaseAddress; break; diff --git a/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs b/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs index b1729e42..2966a4ff 100644 --- a/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs +++ b/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs @@ -8,30 +8,34 @@ using System.Runtime.InteropServices; using System.Threading; using Il2CppInterop.Common; -using Il2CppInterop.Common.Extensions; -using Il2CppInterop.Common.XrefScans; using Il2CppInterop.Runtime.Injection.Hooks; using Il2CppInterop.Runtime.Runtime; using Il2CppInterop.Runtime.Runtime.VersionSpecific.Assembly; -using Il2CppInterop.Runtime.Runtime.VersionSpecific.Class; -using Il2CppInterop.Runtime.Runtime.VersionSpecific.FieldInfo; using Il2CppInterop.Runtime.Runtime.VersionSpecific.Image; using Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo; -using Il2CppInterop.Runtime.Startup; using Microsoft.Extensions.Logging; namespace Il2CppInterop.Runtime.Injection { internal static unsafe class InjectorHelpers { + private static readonly string[] s_assemblies = {"GameAssembly.dll", "GameAssembly_plus.dll", "GameAssembly.so", "GameAssembly_plus.so", "UserAssembly.dll", "UserAssembly_plus.dll"}; + internal static Assembly Il2CppMscorlib = typeof(Il2CppSystem.Type).Assembly; internal static INativeAssemblyStruct InjectedAssembly; internal static INativeImageStruct InjectedImage; internal static ProcessModule Il2CppModule = Process.GetCurrentProcess() .Modules.OfType() - .Single((x) => x.ModuleName is "GameAssembly.dll" or "GameAssembly.so" or "UserAssembly.dll"); + .Single(x => s_assemblies.Contains(x.ModuleName, StringComparer.OrdinalIgnoreCase)); - internal static IntPtr Il2CppHandle = NativeLibrary.Load("GameAssembly", typeof(InjectorHelpers).Assembly, null); + internal static IntPtr Il2CppHandle + { + get + { + var assembly = Il2CppModule.ModuleName != null && Il2CppModule.ModuleName.Contains("_plus") ? "GameAssembly_plus" : "GameAssembly"; + return NativeLibrary.Load(assembly, typeof(InjectorHelpers).Assembly, null); + } + } internal static readonly Dictionary StIndOpcodes = new() {