From f93226218c6caa34a5a3b3c83ae934fa67002cad Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 15 Oct 2024 01:07:12 -0600 Subject: [PATCH 01/41] Added Tilde to Disabled Melon Folder Check --- MelonLoader/Melons/MelonFolderHandler.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/MelonLoader/Melons/MelonFolderHandler.cs b/MelonLoader/Melons/MelonFolderHandler.cs index 49db6198..bd0c91d6 100644 --- a/MelonLoader/Melons/MelonFolderHandler.cs +++ b/MelonLoader/Melons/MelonFolderHandler.cs @@ -89,19 +89,21 @@ private static void LoadFolder(string path, } } + private static bool StartsOrEndsWith(string dirNameLower, string target) + => dirNameLower.StartsWith(target) + || dirNameLower.EndsWith(target); + private static bool IsUserLibsFolder(string dirNameLower) - => dirNameLower.StartsWith("userlibs") - || dirNameLower.EndsWith("userlibs"); + => StartsOrEndsWith(dirNameLower, "userlibs"); private static bool IsDisabledFolder(string path, out string dirNameLower) { string dirName = new DirectoryInfo(path).Name; dirNameLower = dirName.ToLowerInvariant(); - return dirNameLower.StartsWith("disabled") - || dirNameLower.EndsWith("disabled") - || dirNameLower.StartsWith("old") - || dirNameLower.EndsWith("old"); + return StartsOrEndsWith(dirNameLower, "disabled") + || StartsOrEndsWith(dirNameLower, "old") + || StartsOrEndsWith(dirNameLower, "~"); } private static void ProcessFolder(string path, From 4d4a33b2fe56561f3dcca25f9c44c4c9b350d4d7 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 15 Oct 2024 13:02:39 -0600 Subject: [PATCH 02/41] Fixed an issue with Linux Proxy failing to find dobby --- MelonProxy/src/core.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MelonProxy/src/core.rs b/MelonProxy/src/core.rs index 8f978b0f..c80f1778 100644 --- a/MelonProxy/src/core.rs +++ b/MelonProxy/src/core.rs @@ -59,9 +59,11 @@ pub fn init() -> Result<(), Box> { return Ok(()); } - //fix dobby_rs link - let dobby_path = files::get_dobby_dir(base_dir.clone(), game_dir)?; - add_dll_directory(dobby_path); + if cfg!(target_os = "windows") { + //fix dobby_rs link + let dobby_path = files::get_dobby_dir(base_dir.clone(), game_dir)?; + add_dll_directory(dobby_path); + } let bootstrap_path = files::get_bootstrap_path(&base_dir)?; From b6d35c7eb2e89843ae296467e3467be2d0160017 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Fri, 18 Oct 2024 17:56:05 -0600 Subject: [PATCH 03/41] Update Il2CppICallInjector.cs --- MelonLoader/Fixes/Il2CppICallInjector.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index bc2a8e7d..b99a144c 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -219,11 +219,11 @@ private static (DynamicMethodDefinition, MethodInfo, IntPtr) GenerateTrampoline( paramTypes[0] = _intPtrType; for (int i = 0; i < methodParams.Length; i++) { - if ((methodParams[i].ParameterType != _stringType) - && methodParams[i].ParameterType.IsValueType) - paramTypes[i + offset] = methodParams[i].ParameterType; - else + if ((methodParams[i].ParameterType == _stringType) + || !methodParams[i].ParameterType.IsValueType) paramTypes[i + offset] = _intPtrType; + else + paramTypes[i + offset] = methodParams[i].ParameterType; } // Convert Return Type From 0cdc619c1e0e534c046e15f8bc340953b115b04d Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 13:04:57 +0200 Subject: [PATCH 04/41] Redesigned metadata structure and workflow versioning --- .github/workflows/build.yml | 5 +- .github/workflows/nuget.yml | 3 +- .../CompatibilityLayers/Demeo/Demeo.csproj | 6 +-- .../Demeo/Properties/AssemblyInfo.cs | 11 +---- .../CompatibilityLayers/IPA/IPA.csproj | 2 - .../IPA/Properties/AssemblyInfo.cs | 11 +---- .../Muse_Dash_Mono/Muse_Dash_Mono.csproj | 2 - .../Muse_Dash_Mono/Properties/AssemblyInfo.cs | 11 +---- .../Properties/AssemblyInfo.cs | 11 +---- .../Stress_Level_Zero_Il2Cpp.csproj | 10 ++-- .../Il2CppAssemblyGenerator.csproj | 2 - .../Properties/AssemblyInfo.cs | 13 +---- .../MelonStartScreen/MelonStartScreen.csproj | 47 +++++++++---------- .../Properties/AssemblyInfo.cs | 13 +---- .../SupportModules/Il2Cpp/Il2Cpp.csproj | 27 ++++++----- .../Il2Cpp/Properties/AssemblyInfo.cs | 11 +---- Dependencies/SupportModules/Mono/Mono.csproj | 17 ++----- .../Mono/Properties/AssemblyInfo.cs | 11 +---- .../SupportModules/Preload/Preload.csproj | 25 +++++----- .../Preload/Properties/AssemblyInfo.cs | 13 +---- Directory.Build.props | 11 +++++ .../MelonLoader.NativeHost.csproj | 26 +++++----- MelonLoader/MelonLoader.csproj | 15 +++--- MelonLoader/Properties/AssemblyInfo.cs | 21 +-------- 24 files changed, 110 insertions(+), 214 deletions(-) create mode 100644 Directory.Build.props diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2da10f6..49b79cb5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,5 @@ name: Build MelonLoader +run-name: ${{ vars.DEVVERSION }}.${{ github.run_number }} | ${{ github.event.head_commit.message }} on: push: @@ -16,7 +17,7 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Build Melonloader Core shell: cmd - run: msbuild /restore /p:Platform="Windows - x64" # Platform is actually irrelevant for core, it's compiled as AnyCPU either way + run: msbuild /restore /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}.${{ github.run_number }}" # Platform is actually irrelevant for core, it's compiled as AnyCPU either way - name: Upload core artifact uses: actions/upload-artifact@v4 with: @@ -30,7 +31,7 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Build Melonloader Core shell: cmd - run: msbuild /restore /p:Configuration=Release /p:Platform="Windows - x64" + run: msbuild /restore /p:Configuration=Release /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}.${{ github.run_number }}" - name: Upload core artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 78042b0a..989b23b7 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -1,4 +1,5 @@ name: Build NuGet Package +run-name: ${{ vars.DEVVERSION }}.${{ github.run_number }} | ${{ github.event.head_commit.message }} on: push: @@ -17,7 +18,7 @@ jobs: with: dotnet-version: 7.0.x - name: .NET Pack - run: dotnet pack -c Release + run: dotnet pack -c Release -p:Version="${{ vars.DEVVERSION }}.${{ github.run_number }}" working-directory: ./MelonLoader/ - name: Upload artifact uses: actions/upload-artifact@v4 diff --git a/Dependencies/CompatibilityLayers/Demeo/Demeo.csproj b/Dependencies/CompatibilityLayers/Demeo/Demeo.csproj index 8ba1116e..a3c7b7a9 100644 --- a/Dependencies/CompatibilityLayers/Demeo/Demeo.csproj +++ b/Dependencies/CompatibilityLayers/Demeo/Demeo.csproj @@ -2,9 +2,7 @@ MelonLoader.CompatibilityLayers net472 - Latest true - false false $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\CompatibilityLayers\ true @@ -12,8 +10,6 @@ - - Runtime - + \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs index 81808f72..7cf484f8 100644 --- a/Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs +++ b/Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs @@ -1,13 +1,4 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] [assembly: Guid("FEAA0159-5871-4419-9827-3CF5CAD69A53")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] [assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/IPA/IPA.csproj b/Dependencies/CompatibilityLayers/IPA/IPA.csproj index cc4d68ba..73734cb7 100644 --- a/Dependencies/CompatibilityLayers/IPA/IPA.csproj +++ b/Dependencies/CompatibilityLayers/IPA/IPA.csproj @@ -2,9 +2,7 @@ MelonLoader.CompatibilityLayers net35 - Latest true - false false $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\CompatibilityLayers\ true diff --git a/Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs index 0f2b1903..b37b58bc 100644 --- a/Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs +++ b/Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs @@ -1,13 +1,4 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] [assembly: Guid("5100810A-9842-4073-9658-E5841FDF9D73")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] [assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj index cc4d68ba..73734cb7 100644 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj +++ b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj @@ -2,9 +2,7 @@ MelonLoader.CompatibilityLayers net35 - Latest true - false false $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\CompatibilityLayers\ true diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs index 7982318b..61a0f8db 100644 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs +++ b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs @@ -1,13 +1,4 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] [assembly: Guid("C268E68B-3DF1-4EE3-A49F-750A8F55B799")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] [assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs index 81808f72..7cf484f8 100644 --- a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs +++ b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs @@ -1,13 +1,4 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] [assembly: Guid("FEAA0159-5871-4419-9827-3CF5CAD69A53")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] [assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj index 93843970..c2eab15e 100644 --- a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj +++ b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj @@ -2,9 +2,7 @@ MelonLoader.CompatibilityLayers net472 - Latest true - false false $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\CompatibilityLayers\ true @@ -17,9 +15,9 @@ - - false - false - + + false + false + \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj b/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj index 09f20a55..e1f9c4b5 100644 --- a/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj +++ b/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj @@ -2,9 +2,7 @@ MelonLoader.Il2CppAssemblyGenerator net6 - Latest true - false true false $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\Il2CppAssemblyGenerator\ diff --git a/Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs b/Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs index e98f6337..947f0651 100644 --- a/Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs +++ b/Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs @@ -1,12 +1,3 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] -[assembly: Guid("0E4C9125-D149-441D-B7B6-16D9D8CF1DA5")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] \ No newline at end of file +[assembly: Guid("0E4C9125-D149-441D-B7B6-16D9D8CF1DA5")] \ No newline at end of file diff --git a/Dependencies/MelonStartScreen/MelonStartScreen.csproj b/Dependencies/MelonStartScreen/MelonStartScreen.csproj index e6ca3c74..587ad73e 100644 --- a/Dependencies/MelonStartScreen/MelonStartScreen.csproj +++ b/Dependencies/MelonStartScreen/MelonStartScreen.csproj @@ -1,26 +1,25 @@ - - MelonLoader.MelonStartScreen - net35;net6 - Latest - true - false - true - $(SolutionDir)Output\$(Configuration)\MelonLoader\ - true - embedded - - - - - - - - - - - - Runtime - - + + MelonLoader.MelonStartScreen + net35;net6 + true + true + $(SolutionDir)Output\$(Configuration)\MelonLoader\ + true + embedded + + + + + + + + + + + + Runtime + + \ No newline at end of file diff --git a/Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs b/Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs index efe73645..9f092501 100644 --- a/Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs +++ b/Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs @@ -1,12 +1,3 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] -[assembly: Guid("762d7545-6f6b-441a-b040-49cc31a1713b")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] \ No newline at end of file +[assembly: Guid("762d7545-6f6b-441a-b040-49cc31a1713b")] \ No newline at end of file diff --git a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj index 53f3003c..75b2c1e1 100644 --- a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj +++ b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj @@ -2,9 +2,7 @@ MelonLoader.Support net6 - Latest true - false false $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\SupportModules\ true @@ -12,14 +10,12 @@ SM_Il2Cpp true - - https://nuget.bepinex.dev/v3/index.json - + https://nuget.bepinex.dev/v3/index.json - - - + + + @@ -44,13 +40,18 @@ - + - - - + + + - + diff --git a/Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs b/Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs index d6418912..2de42c16 100644 --- a/Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs +++ b/Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs @@ -1,13 +1,4 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] [assembly: Guid("CD98B694-D833-41B0-AF57-A6B9D024B045")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] [assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/SupportModules/Mono/Mono.csproj b/Dependencies/SupportModules/Mono/Mono.csproj index 99ac434c..fb79954b 100644 --- a/Dependencies/SupportModules/Mono/Mono.csproj +++ b/Dependencies/SupportModules/Mono/Mono.csproj @@ -2,24 +2,19 @@ MelonLoader.Support net35 - Latest true - false false $(SolutionDir)\Output\$(Configuration)\MelonLoader\Dependencies\SupportModules\ true embedded - - - + + + - - Libs\UnityEngine.dll - False - + @@ -29,8 +24,6 @@ - - Runtime - + \ No newline at end of file diff --git a/Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs b/Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs index 1d42e64c..2749456a 100644 --- a/Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs +++ b/Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs @@ -1,13 +1,4 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] [assembly: Guid("EE48CA52-CCD3-48A5-B507-91773672E216")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] [assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/SupportModules/Preload/Preload.csproj b/Dependencies/SupportModules/Preload/Preload.csproj index 0c79f1cc..5b319c41 100644 --- a/Dependencies/SupportModules/Preload/Preload.csproj +++ b/Dependencies/SupportModules/Preload/Preload.csproj @@ -2,9 +2,7 @@ MelonLoader.Support net20 - Latest true - false false $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\SupportModules\ true @@ -17,22 +15,23 @@ - + - + - - True - True - Resources.resx - + + True + True + Resources.resx + - - ResXFileCodeGenerator - Resources.Designer.cs - + + ResXFileCodeGenerator + Resources.Designer.cs + \ No newline at end of file diff --git a/Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs b/Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs index a078c0f7..04d18e2f 100644 --- a/Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs +++ b/Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs @@ -1,12 +1,3 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] -[assembly: Guid("08BE056B-C854-4F88-92E8-F3B39187B6AF")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] \ No newline at end of file +[assembly: Guid("08BE056B-C854-4F88-92E8-F3B39187B6AF")] \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000..3656b33b --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,11 @@ + + + 0.6.6 + Lava Gang + discord.gg/2Wn3N2P + Copyright (c) 2022 Lava Gang + The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono. + Latest + + + \ No newline at end of file diff --git a/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj b/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj index 438c05c0..ca78036f 100644 --- a/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj +++ b/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj @@ -1,17 +1,17 @@  - - net6 - enable - enable - $(SolutionDir)Output\$(Configuration)\MelonLoader\ - true - True - embedded - + + net6 + enable + enable + $(SolutionDir)Output\$(Configuration)\MelonLoader\ + true + True + embedded + - - - + + + - + \ No newline at end of file diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index 7b13fc50..fb820795 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -1,9 +1,7 @@ net35;net6 - Latest true - false true $(SolutionDir)Output\$(Configuration)\MelonLoader\ $(OutputPath)$(TargetFramework)\MelonLoader.xml @@ -11,17 +9,12 @@ true embedded - 0.6.6 LavaGang.MelonLoader modding unity https://github.com/LavaGang/MelonLoader Apache-2.0 git https://github.com/LavaGang/MelonLoader - Lava Gang - Lava Gang - Copyright (c) 2022 Lava Gang - The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono. OnBuildSuccess @@ -31,6 +24,14 @@ all + + + + + + + + diff --git a/MelonLoader/Properties/AssemblyInfo.cs b/MelonLoader/Properties/AssemblyInfo.cs index 3277cba2..933bc4be 100644 --- a/MelonLoader/Properties/AssemblyInfo.cs +++ b/MelonLoader/Properties/AssemblyInfo.cs @@ -1,21 +1,4 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -[assembly: AssemblyTitle(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyDescription(MelonLoader.BuildInfo.Description)] -[assembly: AssemblyCompany(MelonLoader.BuildInfo.Company)] -[assembly: AssemblyProduct(MelonLoader.BuildInfo.Name)] -[assembly: AssemblyCopyright("Created by " + MelonLoader.BuildInfo.Author)] -[assembly: AssemblyTrademark(MelonLoader.BuildInfo.Company)] [assembly: Guid("A662769A-B294-434F-83B5-176FC4795334")] -[assembly: AssemblyVersion(MelonLoader.BuildInfo.Version)] -[assembly: AssemblyFileVersion(MelonLoader.BuildInfo.Version)] -[assembly: MelonLoader.PatchShield] - -[assembly: InternalsVisibleTo("MelonLoader.NativeHost")] -[assembly: InternalsVisibleTo("Il2CppAssemblyGenerator")] -[assembly: InternalsVisibleTo("Il2CppUnityTls")] -[assembly: InternalsVisibleTo("Il2Cpp")] -[assembly: InternalsVisibleTo("MelonStartScreen")] -[assembly: InternalsVisibleTo("EOS")] \ No newline at end of file +[assembly: MelonLoader.PatchShield] \ No newline at end of file From 81707dc7b2722894cdf0cfb8528f266f950b5d71 Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 13:13:07 +0200 Subject: [PATCH 05/41] Updated nuget workflow output path --- .github/workflows/nuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 989b23b7..69c81836 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -24,4 +24,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: MelonLoaderNuGetPackage - path: MelonLoader/Output/Release/MelonLoader/LavaGang.MelonLoader.0.6.6.nupkg \ No newline at end of file + path: MelonLoader/Output/Release/MelonLoader/LavaGang.MelonLoader.${{ vars.DEVVERSION }}.${{ github.run_number }}.nupkg From 57ab8cee881bc65d956cc192cc628a5578eeda7e Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 14:12:20 +0200 Subject: [PATCH 06/41] Cleanup --- .../CompatibilityLayers/Demeo/Module.cs | 2 + .../Demeo/Properties/AssemblyInfo.cs | 4 - .../CompatibilityLayers/IPA/Module.cs | 2 + .../IPA/Properties/AssemblyInfo.cs | 4 - .../Muse_Dash_Mono/Module.cs | 2 + .../Muse_Dash_Mono/Properties/AssemblyInfo.cs | 4 - .../Stress_Level_Zero_Il2Cpp/Module.cs | 2 + .../Properties/AssemblyInfo.cs | 4 - .../Properties/AssemblyInfo.cs | 3 - .../Properties/AssemblyInfo.cs | 3 - Dependencies/SupportModules/Il2Cpp/Main.cs | 2 + .../Il2Cpp/Properties/AssemblyInfo.cs | 4 - Dependencies/SupportModules/Mono/Main.cs | 2 + .../Mono/Properties/AssemblyInfo.cs | 4 - .../SupportModules/Preload/Preload.cs | 1 - .../Preload/Properties/AssemblyInfo.cs | 3 - .../Preload/Properties/Resources.resx | 252 +++++++++--------- Directory.Build.props | 1 - MelonLoader/Core.cs | 3 + MelonLoader/MelonLoader.csproj | 8 +- MelonLoader/Properties/AssemblyInfo.cs | 4 - 21 files changed, 147 insertions(+), 167 deletions(-) delete mode 100644 Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs delete mode 100644 Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs delete mode 100644 MelonLoader/Properties/AssemblyInfo.cs diff --git a/Dependencies/CompatibilityLayers/Demeo/Module.cs b/Dependencies/CompatibilityLayers/Demeo/Module.cs index 9ec9d47e..8bd856fd 100644 --- a/Dependencies/CompatibilityLayers/Demeo/Module.cs +++ b/Dependencies/CompatibilityLayers/Demeo/Module.cs @@ -4,6 +4,8 @@ using System.Reflection; using MelonLoader.Modules; +[assembly: MelonLoader.PatchShield] + namespace MelonLoader.CompatibilityLayers { internal class Demeo_Module : MelonModule diff --git a/Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs deleted file mode 100644 index 7cf484f8..00000000 --- a/Dependencies/CompatibilityLayers/Demeo/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("FEAA0159-5871-4419-9827-3CF5CAD69A53")] -[assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/IPA/Module.cs b/Dependencies/CompatibilityLayers/IPA/Module.cs index 018263c9..87cb99a1 100644 --- a/Dependencies/CompatibilityLayers/IPA/Module.cs +++ b/Dependencies/CompatibilityLayers/IPA/Module.cs @@ -7,6 +7,8 @@ using MelonLoader.Modules; using MelonLoader.Resolver; +[assembly: MelonLoader.PatchShield] + namespace MelonLoader.CompatibilityLayers { internal class IPA_Module : MelonModule diff --git a/Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs deleted file mode 100644 index b37b58bc..00000000 --- a/Dependencies/CompatibilityLayers/IPA/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("5100810A-9842-4073-9658-E5841FDF9D73")] -[assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Module.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Module.cs index 0551542a..80c8d1ce 100644 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Module.cs +++ b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Module.cs @@ -6,6 +6,8 @@ using ModHelper; using MelonLoader.Resolver; +[assembly: MelonLoader.PatchShield] + namespace MelonLoader.CompatibilityLayers { internal class Muse_Dash_Mono_Module : MelonModule diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs deleted file mode 100644 index 61a0f8db..00000000 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("C268E68B-3DF1-4EE3-A49F-750A8F55B799")] -[assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Module.cs b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Module.cs index 791f9c82..a71f73b7 100644 --- a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Module.cs +++ b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Module.cs @@ -1,6 +1,8 @@ using MelonLoader.Modules; using System.Collections.Generic; +[assembly: MelonLoader.PatchShield] + namespace MelonLoader.CompatibilityLayers { internal class SLZ_Module : MelonModule diff --git a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs deleted file mode 100644 index 7cf484f8..00000000 --- a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("FEAA0159-5871-4419-9827-3CF5CAD69A53")] -[assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs b/Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs deleted file mode 100644 index 947f0651..00000000 --- a/Dependencies/Il2CppAssemblyGenerator/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("0E4C9125-D149-441D-B7B6-16D9D8CF1DA5")] \ No newline at end of file diff --git a/Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs b/Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs deleted file mode 100644 index 9f092501..00000000 --- a/Dependencies/MelonStartScreen/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("762d7545-6f6b-441a-b040-49cc31a1713b")] \ No newline at end of file diff --git a/Dependencies/SupportModules/Il2Cpp/Main.cs b/Dependencies/SupportModules/Il2Cpp/Main.cs index 49f65d0c..21c3d41c 100644 --- a/Dependencies/SupportModules/Il2Cpp/Main.cs +++ b/Dependencies/SupportModules/Il2Cpp/Main.cs @@ -12,6 +12,8 @@ using MelonLoader.Utils; using System.IO; +[assembly: MelonLoader.PatchShield] + #pragma warning disable CS0618 // Type or member is obsolete namespace MelonLoader.Support diff --git a/Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs b/Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs deleted file mode 100644 index 2de42c16..00000000 --- a/Dependencies/SupportModules/Il2Cpp/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("CD98B694-D833-41B0-AF57-A6B9D024B045")] -[assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/SupportModules/Mono/Main.cs b/Dependencies/SupportModules/Mono/Main.cs index ea95dea2..a12bce57 100644 --- a/Dependencies/SupportModules/Mono/Main.cs +++ b/Dependencies/SupportModules/Mono/Main.cs @@ -3,6 +3,8 @@ using MelonLoader.Support.Preferences; using UnityEngine; +[assembly: MelonLoader.PatchShield] + namespace MelonLoader.Support { internal static class Main diff --git a/Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs b/Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs deleted file mode 100644 index 2749456a..00000000 --- a/Dependencies/SupportModules/Mono/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("EE48CA52-CCD3-48A5-B507-91773672E216")] -[assembly: MelonLoader.PatchShield] \ No newline at end of file diff --git a/Dependencies/SupportModules/Preload/Preload.cs b/Dependencies/SupportModules/Preload/Preload.cs index 1e0c30c6..b071e1e3 100644 --- a/Dependencies/SupportModules/Preload/Preload.cs +++ b/Dependencies/SupportModules/Preload/Preload.cs @@ -1,5 +1,4 @@ using System.IO; -using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System; diff --git a/Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs b/Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs deleted file mode 100644 index 04d18e2f..00000000 --- a/Dependencies/SupportModules/Preload/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("08BE056B-C854-4F88-92E8-F3B39187B6AF")] \ No newline at end of file diff --git a/Dependencies/SupportModules/Preload/Properties/Resources.resx b/Dependencies/SupportModules/Preload/Properties/Resources.resx index a2b6ad7b..14eda986 100644 --- a/Dependencies/SupportModules/Preload/Properties/Resources.resx +++ b/Dependencies/SupportModules/Preload/Properties/Resources.resx @@ -1,130 +1,130 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Resources\System.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\System.Core.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\System.Drawing.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\System.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\System.Core.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\System.Drawing.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 3656b33b..d2327910 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,6 @@ Lava Gang discord.gg/2Wn3N2P Copyright (c) 2022 Lava Gang - The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono. Latest diff --git a/MelonLoader/Core.cs b/MelonLoader/Core.cs index 5f5819b1..7423c33e 100644 --- a/MelonLoader/Core.cs +++ b/MelonLoader/Core.cs @@ -7,6 +7,9 @@ using MelonLoader.Resolver; using MelonLoader.Utils; using MelonLoader.InternalUtils; + +[assembly: MelonLoader.PatchShield] + #pragma warning disable IDE0051 // Prevent the IDE from complaining about private unreferenced methods namespace MelonLoader diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index fb820795..2a17d117 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -8,13 +8,16 @@ true true embedded - + LavaGang.MelonLoader modding unity https://github.com/LavaGang/MelonLoader Apache-2.0 git https://github.com/LavaGang/MelonLoader + + The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono. + OnBuildSuccess @@ -47,7 +50,8 @@ - + diff --git a/MelonLoader/Properties/AssemblyInfo.cs b/MelonLoader/Properties/AssemblyInfo.cs deleted file mode 100644 index 933bc4be..00000000 --- a/MelonLoader/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.InteropServices; - -[assembly: Guid("A662769A-B294-434F-83B5-176FC4795334")] -[assembly: MelonLoader.PatchShield] \ No newline at end of file From 1906317cf173a7d63f6812ef44aacfd19423f96c Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 15:00:52 +0200 Subject: [PATCH 07/41] Fixed internal versioning --- .../VerifyLoaderVersionAttribute.cs | 91 +++++++++---------- MelonLoader/BuildInfo.cs | 22 +++++ MelonLoader/Melons/MelonBase.cs | 8 +- MelonLoader/Properties/BuildInfo.cs | 11 --- MelonLoader/Semver/SemVersion.cs | 3 +- 5 files changed, 75 insertions(+), 60 deletions(-) create mode 100644 MelonLoader/BuildInfo.cs delete mode 100644 MelonLoader/Properties/BuildInfo.cs diff --git a/MelonLoader/Attributes/VerifyLoaderVersionAttribute.cs b/MelonLoader/Attributes/VerifyLoaderVersionAttribute.cs index ae49bf02..941f841b 100644 --- a/MelonLoader/Attributes/VerifyLoaderVersionAttribute.cs +++ b/MelonLoader/Attributes/VerifyLoaderVersionAttribute.cs @@ -1,51 +1,50 @@ using System; using Semver; -namespace MelonLoader +namespace MelonLoader; + +[AttributeUsage(AttributeTargets.Assembly)] +public class VerifyLoaderVersionAttribute(SemVersion semver, bool is_minimum) : Attribute { - [AttributeUsage(AttributeTargets.Assembly)] - public class VerifyLoaderVersionAttribute : Attribute - { - /// - /// Specified SemVersion. - /// - public SemVersion SemVer { get; private set; } - - /// - /// Specified Version Major. - /// - public int Major { get; } - - /// - /// Specified Version Minor. - /// - public int Minor { get; } - - /// - /// Specified Version Patch. - /// - public int Patch { get; } - - /// - /// If Version Specified is a Minimum. - /// - public bool IsMinimum { get; private set; } - - - public VerifyLoaderVersionAttribute(int major, int minor, int patch) : this(new SemVersion(major, minor, patch), false) { } - public VerifyLoaderVersionAttribute(int major, int minor, int patch, bool is_minimum) : this(new SemVersion(major, minor, patch), is_minimum) { } - public VerifyLoaderVersionAttribute(string version) : this(version, false) { } - public VerifyLoaderVersionAttribute(string version, bool is_minimum) : this(SemVersion.Parse(version), is_minimum) { } - public VerifyLoaderVersionAttribute(SemVersion semver, bool is_minimum) - { - SemVer = semver; - IsMinimum = is_minimum; - } - - public bool IsCompatible(SemVersion version) - => SemVer == null || version == null || (IsMinimum ? SemVer <= version : SemVer == version); - - public bool IsCompatible(string version) - => !SemVersion.TryParse(version, out SemVersion ver) || IsCompatible(ver); - } + /// + /// Specified SemVersion. + /// + public SemVersion SemVer { get; private set; } = semver; + + /// + /// Specified Version Major. + /// + public int Major => SemVer.Major; + + /// + /// Specified Version Minor. + /// + public int Minor => SemVer.Minor; + + /// + /// Specified Version Patch. + /// + public int Patch => SemVer.Patch; + + /// + /// Specified Version Prerelease. + /// + public string Prerelease => SemVer.Prerelease; + + /// + /// If Version Specified is a Minimum. + /// + public bool IsMinimum { get; private set; } = is_minimum; + + public VerifyLoaderVersionAttribute(int major, int minor, int patch) : this(new SemVersion(major, minor, patch), false) { } + public VerifyLoaderVersionAttribute(int major, int minor, int patch, string prerelease, bool is_minimum = false) : this(new SemVersion(major, minor, patch, prerelease), is_minimum) { } + public VerifyLoaderVersionAttribute(int major, int minor, int patch, bool is_minimum) : this(new SemVersion(major, minor, patch), is_minimum) { } + public VerifyLoaderVersionAttribute(string version) : this(version, false) { } + public VerifyLoaderVersionAttribute(string version, bool is_minimum) : this(SemVersion.Parse(version), is_minimum) { } + + public bool IsCompatible(SemVersion version) + => SemVer == null || version == null || (IsMinimum ? SemVer <= version : SemVer == version); + + public bool IsCompatible(string version) + => !SemVersion.TryParse(version, out SemVersion ver) || IsCompatible(ver); } \ No newline at end of file diff --git a/MelonLoader/BuildInfo.cs b/MelonLoader/BuildInfo.cs new file mode 100644 index 00000000..23e627e1 --- /dev/null +++ b/MelonLoader/BuildInfo.cs @@ -0,0 +1,22 @@ +using Semver; + +namespace MelonLoader; + +public static class BuildInfo +{ + public const string Name = "MelonLoader"; + public const string Description = "MelonLoader"; + public const string Author = "Lava Gang"; + public const string Company = "discord.gg/2Wn3N2P"; + + public static SemVersion VersionNumber { get; private set; } + + // NOTICE: This used to be a constant. Making it a property won't break backwards compatibility. + public static string Version { get; private set; } = VersionNumber.ToString(); + + static BuildInfo() + { + var version = typeof(BuildInfo).Assembly.GetName().Version!; + VersionNumber = new(version.Major, version.Minor, version.Build, version.Revision == 0 ? "" : ("ci." + version.Revision.ToString())); + } +} \ No newline at end of file diff --git a/MelonLoader/Melons/MelonBase.cs b/MelonLoader/Melons/MelonBase.cs index 94d77a07..367031af 100644 --- a/MelonLoader/Melons/MelonBase.cs +++ b/MelonLoader/Melons/MelonBase.cs @@ -1,4 +1,5 @@ using MelonLoader.InternalUtils; +using Semver; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -274,6 +275,11 @@ public virtual void OnDeinitializeMelon() { } public Incompatibility[] FindIncompatiblities(MelonGameAttribute game, string processName, string gameVersion, string mlVersion, string mlBuildHashCode, MelonPlatformAttribute.CompatiblePlatforms platform, MelonPlatformDomainAttribute.CompatibleDomains domain) + => FindIncompatiblities(game, processName, gameVersion, SemVersion.Parse(mlVersion), mlBuildHashCode, platform, domain); + + public Incompatibility[] FindIncompatiblities(MelonGameAttribute game, string processName, string gameVersion, + SemVersion mlVersion, string mlBuildHashCode, MelonPlatformAttribute.CompatiblePlatforms platform, + MelonPlatformDomainAttribute.CompatibleDomains domain) { var result = new List(); if (!(Games.Length == 0 || Games.Any(x => x.IsCompatible(game)))) @@ -305,7 +311,7 @@ public Incompatibility[] FindIncompatiblities(MelonGameAttribute game, string pr public Incompatibility[] FindIncompatiblitiesFromContext() { - return FindIncompatiblities(MelonUtils.CurrentGameAttribute, Process.GetCurrentProcess().ProcessName, MelonUtils.GameVersion, BuildInfo.Version, MelonUtils.HashCode, MelonUtils.CurrentPlatform, MelonUtils.CurrentDomain); + return FindIncompatiblities(MelonUtils.CurrentGameAttribute, Process.GetCurrentProcess().ProcessName, MelonUtils.GameVersion, BuildInfo.VersionNumber, MelonUtils.HashCode, MelonUtils.CurrentPlatform, MelonUtils.CurrentDomain); } public static void PrintIncompatibilities(Incompatibility[] incompatibilities, MelonBase melon) diff --git a/MelonLoader/Properties/BuildInfo.cs b/MelonLoader/Properties/BuildInfo.cs deleted file mode 100644 index c6ff6b10..00000000 --- a/MelonLoader/Properties/BuildInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MelonLoader -{ - public static class BuildInfo - { - public const string Name = "MelonLoader"; - public const string Description = "MelonLoader"; - public const string Author = "Lava Gang"; - public const string Company = "discord.gg/2Wn3N2P"; - public const string Version = "0.6.6"; - } -} \ No newline at end of file diff --git a/MelonLoader/Semver/SemVersion.cs b/MelonLoader/Semver/SemVersion.cs index 1b7aec5a..72bdc9c9 100644 --- a/MelonLoader/Semver/SemVersion.cs +++ b/MelonLoader/Semver/SemVersion.cs @@ -337,8 +337,7 @@ public int CompareTo(SemVersion other) var r = CompareByPrecedence(other); if (r != 0) return r; - // If other is null, CompareByPrecedence() returns 1 - return CompareComponent(Build, other.Build); + return CompareComponent(Prerelease, other.Prerelease, true); } /// From acc6b364755c6b960e0fbf3477d04b55bcf73317 Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 16:15:25 +0200 Subject: [PATCH 08/41] Cleanup --- Dependencies/SupportModules/Preload/Preload.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Dependencies/SupportModules/Preload/Preload.csproj b/Dependencies/SupportModules/Preload/Preload.csproj index 5b319c41..5cf76474 100644 --- a/Dependencies/SupportModules/Preload/Preload.csproj +++ b/Dependencies/SupportModules/Preload/Preload.csproj @@ -17,10 +17,6 @@ - - - True From 4583979fe443983f7c3c8488279cf701a4d40e33 Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 16:24:56 +0200 Subject: [PATCH 09/41] Minor fixes --- MelonLoader/BuildInfo.cs | 3 ++- MelonLoader/MelonLoader.csproj | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/MelonLoader/BuildInfo.cs b/MelonLoader/BuildInfo.cs index 23e627e1..c83b90ff 100644 --- a/MelonLoader/BuildInfo.cs +++ b/MelonLoader/BuildInfo.cs @@ -12,11 +12,12 @@ public static class BuildInfo public static SemVersion VersionNumber { get; private set; } // NOTICE: This used to be a constant. Making it a property won't break backwards compatibility. - public static string Version { get; private set; } = VersionNumber.ToString(); + public static string Version { get; private set; } static BuildInfo() { var version = typeof(BuildInfo).Assembly.GetName().Version!; VersionNumber = new(version.Major, version.Minor, version.Build, version.Revision == 0 ? "" : ("ci." + version.Revision.ToString())); + Version = VersionNumber.ToString(); } } \ No newline at end of file diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index 2a17d117..30586f06 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -15,9 +15,7 @@ Apache-2.0 git https://github.com/LavaGang/MelonLoader - - The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono. - + The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono. OnBuildSuccess From fd0f2660ca3154430ac0ce9d8ef235b762ce82e3 Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 17:34:06 +0200 Subject: [PATCH 10/41] Fixed workflows --- .github/workflows/build.yml | 6 +++--- .github/workflows/nuget.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49b79cb5..e1e604f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Build MelonLoader -run-name: ${{ vars.DEVVERSION }}.${{ github.run_number }} | ${{ github.event.head_commit.message }} +run-name: ${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && github.event.head_commit.message || 'Manual Build' }} on: push: @@ -17,7 +17,7 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Build Melonloader Core shell: cmd - run: msbuild /restore /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}.${{ github.run_number }}" # Platform is actually irrelevant for core, it's compiled as AnyCPU either way + run: msbuild /restore /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('.{0}', github.run_number) || '' }}" # Platform is actually irrelevant for core, it's compiled as AnyCPU either way - name: Upload core artifact uses: actions/upload-artifact@v4 with: @@ -31,7 +31,7 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Build Melonloader Core shell: cmd - run: msbuild /restore /p:Configuration=Release /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}.${{ github.run_number }}" + run: msbuild /restore /p:Configuration=Release /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('.{0}', github.run_number) || '' }}" - name: Upload core artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 69c81836..78647c15 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -1,5 +1,5 @@ name: Build NuGet Package -run-name: ${{ vars.DEVVERSION }}.${{ github.run_number }} | ${{ github.event.head_commit.message }} +run-name: ${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && github.event.head_commit.message || 'Manual Build' }} on: push: @@ -18,10 +18,10 @@ jobs: with: dotnet-version: 7.0.x - name: .NET Pack - run: dotnet pack -c Release -p:Version="${{ vars.DEVVERSION }}.${{ github.run_number }}" + run: dotnet pack -c Release ${{ github.event_name != 'workflow_dispatch' && format('-p:Version="{0}-ci.{1}" -p:AssemblyVersion="{0}.{1}"', vars.DEVVERSION, github.run_number) || format('-p:Version="{0}"', vars.DEVVERSION) }} working-directory: ./MelonLoader/ - name: Upload artifact uses: actions/upload-artifact@v4 with: name: MelonLoaderNuGetPackage - path: MelonLoader/Output/Release/MelonLoader/LavaGang.MelonLoader.${{ vars.DEVVERSION }}.${{ github.run_number }}.nupkg + path: MelonLoader/Output/Release/MelonLoader/LavaGang.MelonLoader.${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }}.nupkg From 7b98436f0db33101ef250366c5c24065efebfd94 Mon Sep 17 00:00:00 2001 From: slxdy Date: Sun, 13 Oct 2024 21:11:37 +0200 Subject: [PATCH 11/41] Fixed run name for PRs --- .github/workflows/build.yml | 2 +- .github/workflows/nuget.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1e604f9..8da0c0c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Build MelonLoader -run-name: ${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && github.event.head_commit.message || 'Manual Build' }} +run-name: ${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && (github.event.head_commit.message || format('`[PR]` {0}', github.event.pull_request.title)) || 'Manual Build' }} on: push: diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 78647c15..b9cc470c 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -1,5 +1,5 @@ name: Build NuGet Package -run-name: ${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && github.event.head_commit.message || 'Manual Build' }} +run-name: ${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && (github.event.head_commit.message || format('`[PR]` {0}', github.event.pull_request.title)) || 'Manual Build' }} on: push: From f05c252f8e3a11af64897700a3f8eb9e51b734c8 Mon Sep 17 00:00:00 2001 From: slxdy Date: Mon, 14 Oct 2024 14:07:52 +0200 Subject: [PATCH 12/41] Optimized/simplified the Build workflow --- .github/workflows/build.yml | 363 +++++++++--------- .github/workflows/nuget.yml | 27 -- .../SupportModules/Il2Cpp/Il2Cpp.csproj | 5 - Dependencies/SupportModules/Mono/Mono.csproj | 7 +- .../System.Core.dll | Bin .../System.Drawing.dll | Bin .../System.dll | Bin .../SupportModules/Preload/Preload.cs | 34 +- .../SupportModules/Preload/Preload.csproj | 15 +- .../Preload/Properties/Resources.Designer.cs | 93 ----- .../Preload/Properties/Resources.resx | 130 ------- Directory.Build.props | 1 + MelonLoader.sln | 2 - MelonLoader/MelonLoader.csproj | 3 +- 14 files changed, 195 insertions(+), 485 deletions(-) delete mode 100644 .github/workflows/nuget.yml rename Dependencies/SupportModules/Preload/{Resources => NetStandardPatches}/System.Core.dll (100%) rename Dependencies/SupportModules/Preload/{Resources => NetStandardPatches}/System.Drawing.dll (100%) rename Dependencies/SupportModules/Preload/{Resources => NetStandardPatches}/System.dll (100%) delete mode 100644 Dependencies/SupportModules/Preload/Properties/Resources.Designer.cs delete mode 100644 Dependencies/SupportModules/Preload/Properties/Resources.resx diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8da0c0c9..e42c8359 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,35 +9,47 @@ on: workflow_dispatch: jobs: - build_core_debug: + build_core: + name: Build Managed Binaries runs-on: windows-latest steps: - uses: actions/checkout@v4 - - name: setup-msbuild - uses: microsoft/setup-msbuild@v2 - - name: Build Melonloader Core - shell: cmd - run: msbuild /restore /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('.{0}', github.run_number) || '' }}" # Platform is actually irrelevant for core, it's compiled as AnyCPU either way - - name: Upload core artifact + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Restore Dependencies + run: dotnet restore + + - name: Build Melonloader Core Debug + run: dotnet build --no-restore -c Debug -p:Platform="Windows - x64" -p:Version="${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('.{0}', github.run_number) || '' }}" # Platform is actually irrelevant for core, it's compiled as AnyCPU either way + + - name: Upload Debug Core Artifact uses: actions/upload-artifact@v4 with: name: MLCoreDebug path: Output/Debug/MelonLoader/ - build_core_release: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - name: setup-msbuild - uses: microsoft/setup-msbuild@v2 - - name: Build Melonloader Core - shell: cmd - run: msbuild /restore /p:Configuration=Release /p:Platform="Windows - x64" /p:Version="${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('.{0}', github.run_number) || '' }}" - - name: Upload core artifact + + - name: Build MelonLoader Core Release + run: dotnet build --no-restore -c Release -p:Platform="Windows - x64" -p:Version="${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('.{0}', github.run_number) || '' }}" + + - name: Upload Release Core Artifact uses: actions/upload-artifact@v4 with: name: MLCoreRelease path: Output/Release/MelonLoader/ + + - name: Pack NuGet Package + run: dotnet pack --no-build -c Release -p:Version="${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }}" + + - name: Upload NuGet Artifact + uses: actions/upload-artifact@v4 + with: + name: MelonLoader.NuGet + path: Output/Release/MelonLoader/LavaGang.MelonLoader.${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }}.nupkg build_rust_windows: + name: Build Native Binaries (Windows) runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -110,6 +122,7 @@ jobs: name: MLBootstrapX64-Windows-Debug path: target/x86_64-pc-windows-msvc/debug/Bootstrap.dll build_rust_linux: + name: Build Native Binaries (Linux) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -151,279 +164,244 @@ jobs: with: name: MLBootstrapX64-Linux-Debug path: target/x86_64-unknown-linux-gnu/debug/libBootstrap.so - finalize_x64_debug_zip_windows: - runs-on: windows-latest - needs: [build_core_debug, build_rust_windows] + + finalize_windows: + name: Finalize Windows Artifacts + runs-on: ubuntu-22.04 + needs: [build_core, build_rust_windows] steps: - uses: actions/checkout@v4 - - name: Download core artifact + - name: Download Debug Managed Artifact uses: actions/download-artifact@v4 with: name: MLCoreDebug - path: Output/Debug/x64/MelonLoader/ - - name: Download proxy x64 + path: Output/Debug/Managed/ + - name: Download Debug Proxy x64 Artifact uses: actions/download-artifact@v4 with: name: MLProxyX64-Windows-Debug path: Output/Debug/x64/ - - name: Download bootstrap x64 + - name: Download Debug Bootstrap x64 Artifact uses: actions/download-artifact@v4 with: name: MLBootstrapX64-Windows-Debug path: Output/Debug/x64/MelonLoader/Dependencies/ - - name: Package x64 zip - shell: cmd + - name: Package Debug x64 Artifact run: | echo Copying Managed Libs... - mkdir Output\Debug\x64\MelonLoader\Dependencies\Mono - xcopy BaseLibs\Mono Output\Debug\x64\MelonLoader\Dependencies\Mono\ /E /H /Y - xcopy BaseLibs\net35 Output\Debug\x64\MelonLoader\net35\ /E /H /Y - xcopy BaseLibs\net6 Output\Debug\x64\MelonLoader\net6\ /E /H /Y - echo. + mkdir -p Output/Debug/x64/MelonLoader/Dependencies/Mono + cp -r Output/Debug/Managed/* Output/Debug/x64/MelonLoader/ + cp -r BaseLibs/Mono Output/Debug/x64/MelonLoader/Dependencies/ + cp -r BaseLibs/net35 Output/Debug/x64/MelonLoader/ + cp -r BaseLibs/net6 Output/Debug/x64/MelonLoader/ + echo echo Copying Dobby x64... - xcopy BaseLibs\dobby_x64.dll Output\Debug\x64\MelonLoader\Dependencies\dobby.dll* - echo. + cp BaseLibs/dobby_x64.dll Output/Debug/x64/MelonLoader/Dependencies/dobby.dll + echo echo Copying documentation files... - copy NOTICE.txt Output\Debug\x64 - mkdir Output\Debug\x64\MelonLoader\Documentation - copy CHANGELOG.md Output\Debug\x64\MelonLoader\Documentation\ - copy LICENSE.md Output\Debug\x64\MelonLoader\Documentation\ - copy NOTICE.txt Output\Debug\x64\MelonLoader\Documentation\ - copy README.md Output\Debug\x64\MelonLoader\Documentation\ - del Output\Debug\x64\MelonLoader\net6\MelonStartScreen.dll - del Output\Debug\x64\MelonLoader\net6\MelonStartScreen.deps.json + cp NOTICE.txt Output/Debug/x64/ + mkdir -p Output/Debug/x64/MelonLoader/Documentation + cp CHANGELOG.md Output/Debug/x64/MelonLoader/Documentation/ + cp LICENSE.md Output/Debug/x64/MelonLoader/Documentation/ + cp NOTICE.txt Output/Debug/x64/MelonLoader/Documentation/ + cp README.md Output/Debug/x64/MelonLoader/Documentation/ - uses: actions/upload-artifact@v4 - name: Upload Zip | Windows - x64 + name: Upload Zip | Windows - Debug - x64 with: name: MelonLoader.Windows.x64.CI.Debug path: ./Output/Debug/x64/* - finalize_x86_debug_zip_windows: - runs-on: windows-latest - needs: [build_core_debug, build_rust_windows] - steps: - - uses: actions/checkout@v4 - - name: Download core artifact - uses: actions/download-artifact@v4 - with: - name: MLCoreDebug - path: Output/Debug/x86/MelonLoader/ - - name: Download proxy x86 - uses: actions/download-artifact@v4 - with: - name: MLProxyX86-Windows-Debug - path: Output/Debug/x86/ - - name: Download bootstrap x86 - uses: actions/download-artifact@v4 - with: - name: MLBootstrapX86-Windows-Debug - path: Output/Debug/x86/MelonLoader/Dependencies/ - - name: Package x86 zip - shell: cmd - run: | - echo Copying Managed Libs... - mkdir Output\Debug\x86\MelonLoader\Dependencies\Mono - xcopy BaseLibs\Mono Output\Debug\x86\MelonLoader\Dependencies\Mono\ /E /H /Y - xcopy BaseLibs\net35 Output\Debug\x86\MelonLoader\net35\ /E /H /Y - xcopy BaseLibs\net6 Output\Debug\x86\MelonLoader\net6\ /E /H /Y - echo. - echo Copying Dobby x86... - xcopy BaseLibs\dobby_x86.dll Output\Debug\x86\MelonLoader\Dependencies\dobby.dll* - echo. - echo Copying documentation files... - copy NOTICE.txt Output\Debug\x86 - mkdir Output\Debug\x86\MelonLoader\Documentation - copy CHANGELOG.md Output\Debug\x86\MelonLoader\Documentation\ - copy LICENSE.md Output\Debug\x86\MelonLoader\Documentation\ - copy NOTICE.txt Output\Debug\x86\MelonLoader\Documentation\ - copy README.md Output\Debug\x86\MelonLoader\Documentation\ - del Output\Debug\x86\MelonLoader\net6\MelonStartScreen.dll - del Output\Debug\x86\MelonLoader\net6\MelonStartScreen.deps.json - - uses: actions/upload-artifact@v4 - name: Upload Zip | Windows - x86 - with: - name: MelonLoader.Windows.x86.CI.Debug - path: ./Output/Debug/x86/* - finalize_x64_release_zip_windows: - runs-on: windows-latest - needs: [build_core_release, build_rust_windows] - steps: - - uses: actions/checkout@v4 - - name: Download core artifact + + - name: Download Release Managed Artifact uses: actions/download-artifact@v4 with: name: MLCoreRelease - path: Output/Release/x64/MelonLoader/ - - name: Download proxy x64 + path: Output/Release/Managed/ + - name: Download Release Proxy x64 Artifact uses: actions/download-artifact@v4 with: name: MLProxyX64-Windows-Release path: Output/Release/x64/ - - name: Download bootstrap x64 + - name: Download Debug Bootstrap x64 Artifact uses: actions/download-artifact@v4 with: name: MLBootstrapX64-Windows-Release path: Output/Release/x64/MelonLoader/Dependencies/ - - name: Package x64 zip - shell: cmd + - name: Package Release x64 Artifact run: | echo Copying Managed Libs... - mkdir Output\Release\x64\MelonLoader\Dependencies\Mono - xcopy BaseLibs\Mono Output\Release\x64\MelonLoader\Dependencies\Mono\ /E /H /Y - xcopy BaseLibs\net35 Output\Release\x64\MelonLoader\net35\ /E /H /Y - xcopy BaseLibs\net6 Output\Release\x64\MelonLoader\net6\ /E /H /Y - echo. + mkdir -p Output/Release/x64/MelonLoader/Dependencies/Mono + cp -r Output/Release/Managed/* Output/Release/x64/MelonLoader/ + cp -r BaseLibs/Mono Output/Release/x64/MelonLoader/Dependencies/ + cp -r BaseLibs/net35 Output/Release/x64/MelonLoader/ + cp -r BaseLibs/net6 Output/Release/x64/MelonLoader/ + echo echo Copying Dobby x64... - xcopy BaseLibs\dobby_x64.dll Output\Release\x64\MelonLoader\Dependencies\dobby.dll* - echo. + cp BaseLibs/dobby_x64.dll Output/Release/x64/MelonLoader/Dependencies/dobby.dll + echo echo Copying documentation files... - copy NOTICE.txt Output\Release\x64 - mkdir Output\Release\x64\MelonLoader\Documentation - copy CHANGELOG.md Output\Release\x64\MelonLoader\Documentation\ - copy LICENSE.md Output\Release\x64\MelonLoader\Documentation\ - copy NOTICE.txt Output\Release\x64\MelonLoader\Documentation\ - copy README.md Output\Release\x64\MelonLoader\Documentation\ - del Output\Release\x64\MelonLoader\net6\MelonStartScreen.dll - del Output\Release\x64\MelonLoader\net6\MelonStartScreen.deps.json + cp NOTICE.txt Output/Release/x64/ + mkdir -p Output/Release/x64/MelonLoader/Documentation + cp CHANGELOG.md Output/Release/x64/MelonLoader/Documentation/ + cp LICENSE.md Output/Release/x64/MelonLoader/Documentation/ + cp NOTICE.txt Output/Release/x64/MelonLoader/Documentation/ + cp README.md Output/Release/x64/MelonLoader/Documentation/ - uses: actions/upload-artifact@v4 - name: Upload Zip | Windows - x64 + name: Upload Zip | Windows - Release - x64 with: name: MelonLoader.Windows.x64.CI.Release path: ./Output/Release/x64/* - finalize_x86_release_zip_windows: - runs-on: windows-latest - needs: [build_core_release, build_rust_windows] - steps: - - uses: actions/checkout@v4 - - name: Download core artifact + + - name: Download Debug Proxy x86 Artifact uses: actions/download-artifact@v4 with: - name: MLCoreRelease - path: Output/Release/x86/MelonLoader/ - - name: Download proxy x86 + name: MLProxyX86-Windows-Debug + path: Output/Debug/x86/ + - name: Download Debug Bootstrap x86 Artifact + uses: actions/download-artifact@v4 + with: + name: MLBootstrapX86-Windows-Debug + path: Output/Debug/x86/MelonLoader/Dependencies/ + - name: Package Debug x86 Artifact + run: | + echo Copying Managed Libs... + mkdir -p Output/Debug/x86/MelonLoader/Dependencies/Mono + cp -r Output/Debug/Managed/* Output/Debug/x86/MelonLoader/ + cp -r BaseLibs/Mono Output/Debug/x86/MelonLoader/Dependencies/ + cp -r BaseLibs/net35 Output/Debug/x86/MelonLoader/ + cp -r BaseLibs/net6 Output/Debug/x86/MelonLoader/ + echo + echo Copying Dobby x86... + cp BaseLibs/dobby_x86.dll Output/Debug/x86/MelonLoader/Dependencies/dobby.dll + echo + echo Copying documentation files... + cp NOTICE.txt Output/Debug/x86/ + mkdir -p Output/Debug/x86/MelonLoader/Documentation + cp CHANGELOG.md Output/Debug/x86/MelonLoader/Documentation/ + cp LICENSE.md Output/Debug/x86/MelonLoader/Documentation/ + cp NOTICE.txt Output/Debug/x86/MelonLoader/Documentation/ + cp README.md Output/Debug/x86/MelonLoader/Documentation/ + - uses: actions/upload-artifact@v4 + name: Upload Zip | Windows - Debug - x86 + with: + name: MelonLoader.Windows.x86.CI.Debug + path: ./Output/Debug/x86/* + + - name: Download Release Proxy x86 Artifact uses: actions/download-artifact@v4 with: name: MLProxyX86-Windows-Release path: Output/Release/x86/ - - name: Download bootstrap x86 + - name: Download Release Bootstrap x86 Artifact uses: actions/download-artifact@v4 with: name: MLBootstrapX86-Windows-Release path: Output/Release/x86/MelonLoader/Dependencies/ - - name: Package x86 zip - shell: cmd + - name: Package Release x86 Artifact run: | echo Copying Managed Libs... - mkdir Output\Release\x86\MelonLoader\Dependencies\Mono - xcopy BaseLibs\Mono Output\Release\x86\MelonLoader\Dependencies\Mono\ /E /H /Y - xcopy BaseLibs\net35 Output\Release\x86\MelonLoader\net35\ /E /H /Y - xcopy BaseLibs\net6 Output\Release\x86\MelonLoader\net6\ /E /H /Y - echo. + mkdir -p Output/Release/x86/MelonLoader/Dependencies/Mono + cp -r Output/Release/Managed/* Output/Release/x86/MelonLoader/ + cp -r BaseLibs/Mono Output/Release/x86/MelonLoader/Dependencies/ + cp -r BaseLibs/net35 Output/Release/x86/MelonLoader/ + cp -r BaseLibs/net6 Output/Release/x86/MelonLoader/ + echo echo Copying Dobby x86... - xcopy BaseLibs\dobby_x86.dll Output\Release\x86\MelonLoader\Dependencies\dobby.dll* - echo. + cp BaseLibs/dobby_x86.dll Output/Release/x86/MelonLoader/Dependencies/dobby.dll + echo echo Copying documentation files... - copy NOTICE.txt Output\Release\x86 - mkdir Output\Release\x86\MelonLoader\Documentation - copy CHANGELOG.md Output\Release\x86\MelonLoader\Documentation\ - copy LICENSE.md Output\Release\x86\MelonLoader\Documentation\ - copy NOTICE.txt Output\Release\x86\MelonLoader\Documentation\ - copy README.md Output\Release\x86\MelonLoader\Documentation\ - del Output\Release\x86\MelonLoader\net6\MelonStartScreen.dll - del Output\Release\x86\MelonLoader\net6\MelonStartScreen.deps.json + cp NOTICE.txt Output/Release/x86/ + mkdir -p Output/Release/x86/MelonLoader/Documentation + cp CHANGELOG.md Output/Release/x86/MelonLoader/Documentation/ + cp LICENSE.md Output/Release/x86/MelonLoader/Documentation/ + cp NOTICE.txt Output/Release/x86/MelonLoader/Documentation/ + cp README.md Output/Release/x86/MelonLoader/Documentation/ - uses: actions/upload-artifact@v4 - name: Upload Zip | Windows - x86 + name: Upload Zip | Windows - Release - x86 with: name: MelonLoader.Windows.x86.CI.Release path: ./Output/Release/x86/* - finalize_x64_debug_zip_linux: - runs-on: windows-latest - needs: [build_core_debug, build_rust_linux] + + finalize_linux: + name: Finalize Linux Artifacts + runs-on: ubuntu-22.04 + needs: [build_core, build_rust_linux] steps: - uses: actions/checkout@v4 - - name: Download core artifact + - name: Download Debug Managed Artifact uses: actions/download-artifact@v4 with: name: MLCoreDebug path: Output/Debug/x64/MelonLoader/ - - name: Download proxy x64 + - name: Download Debug Proxy Artifact uses: actions/download-artifact@v4 with: name: MLProxyX64-Linux-Debug path: Output/Debug/x64/ - - name: Download bootstrap x64 + - name: Download Debug Bootstrap Artifact uses: actions/download-artifact@v4 with: name: MLBootstrapX64-Linux-Debug path: Output/Debug/x64/MelonLoader/Dependencies/ - - name: Package x64 zip - shell: cmd + - name: Package Debug Zip run: | echo Copying Managed Libs... - mkdir Output\Debug\x64\MelonLoader\Dependencies\Mono - xcopy BaseLibs\Mono Output\Debug\x64\MelonLoader\Dependencies\Mono\ /E /H /Y - xcopy BaseLibs\net35 Output\Debug\x64\MelonLoader\net35\ /E /H /Y - xcopy BaseLibs\net6 Output\Debug\x64\MelonLoader\net6\ /E /H /Y - echo. + mkdir -p Output/Debug/x64/MelonLoader/Dependencies/Mono + cp -r BaseLibs/Mono Output/Debug/x64/MelonLoader/Dependencies/ + cp -r BaseLibs/net35 Output/Debug/x64/MelonLoader/ + cp -r BaseLibs/net6 Output/Debug/x64/MelonLoader/ + echo echo Copying documentation files... - copy NOTICE.txt Output\Debug\x64 - mkdir Output\Debug\x64\MelonLoader\Documentation - copy CHANGELOG.md Output\Debug\x64\MelonLoader\Documentation\ - copy LICENSE.md Output\Debug\x64\MelonLoader\Documentation\ - copy NOTICE.txt Output\Debug\x64\MelonLoader\Documentation\ - copy README.md Output\Debug\x64\MelonLoader\Documentation\ - del Output\Debug\x64\MelonLoader\net6\MelonStartScreen.dll - del Output\Debug\x64\MelonLoader\net6\MelonStartScreen.deps.json + cp NOTICE.txt Output/Debug/x64 + mkdir -p Output/Debug/x64/MelonLoader/Documentation + cp CHANGELOG.md Output/Debug/x64/MelonLoader/Documentation/ + cp LICENSE.md Output/Debug/x64/MelonLoader/Documentation/ + cp NOTICE.txt Output/Debug/x64/MelonLoader/Documentation/ + cp README.md Output/Debug/x64/MelonLoader/Documentation/ - uses: actions/upload-artifact@v4 - name: Upload Zip | Linux - x64 + name: Upload Zip | Linux - Debug - x64 with: name: MelonLoader.Linux.x64.CI.Debug path: ./Output/Debug/x64/* - finalize_x64_release_zip_linux: - runs-on: windows-latest - needs: [build_core_release, build_rust_linux] - steps: - - uses: actions/checkout@v4 - - name: Download core artifact + - name: Download Release Managed Artifact uses: actions/download-artifact@v4 with: name: MLCoreRelease path: Output/Release/x64/MelonLoader/ - - name: Download proxy x64 + - name: Download Release Proxy Artifact uses: actions/download-artifact@v4 with: name: MLProxyX64-Linux-Release path: Output/Release/x64/ - - name: Download bootstrap x64 + - name: Download Release Bootstrap Artifact uses: actions/download-artifact@v4 with: name: MLBootstrapX64-Linux-Release path: Output/Release/x64/MelonLoader/Dependencies/ - - name: Package x64 zip - shell: cmd + - name: Package Release Zip run: | echo Copying Managed Libs... - mkdir Output\Release\x64\MelonLoader\Dependencies\Mono - xcopy BaseLibs\Mono Output\Release\x64\MelonLoader\Dependencies\Mono\ /E /H /Y - xcopy BaseLibs\net35 Output\Release\x64\MelonLoader\net35\ /E /H /Y - xcopy BaseLibs\net6 Output\Release\x64\MelonLoader\net6\ /E /H /Y - echo. + mkdir -p Output/Release/x64/MelonLoader/Dependencies/Mono + cp -r BaseLibs/Mono Output/Release/x64/MelonLoader/Dependencies/ + cp -r BaseLibs/net35 Output/Release/x64/MelonLoader/ + cp -r BaseLibs/net6 Output/Release/x64/MelonLoader/ + echo echo Copying documentation files... - copy NOTICE.txt Output\Release\x64 - mkdir Output\Release\x64\MelonLoader\Documentation - copy CHANGELOG.md Output\Release\x64\MelonLoader\Documentation\ - copy LICENSE.md Output\Release\x64\MelonLoader\Documentation\ - copy NOTICE.txt Output\Release\x64\MelonLoader\Documentation\ - copy README.md Output\Release\x64\MelonLoader\Documentation\ - del Output\Release\x64\MelonLoader\net6\MelonStartScreen.dll - del Output\Release\x64\MelonLoader\net6\MelonStartScreen.deps.json + cp NOTICE.txt Output/Release/x64/ + mkdir -p Output/Release/x64/MelonLoader/Documentation + cp CHANGELOG.md Output/Release/x64/MelonLoader/Documentation/ + cp LICENSE.md Output/Release/x64/MelonLoader/Documentation/ + cp NOTICE.txt Output/Release/x64/MelonLoader/Documentation/ + cp README.md Output/Release/x64/MelonLoader/Documentation/ - uses: actions/upload-artifact@v4 - name: Upload Zip | Linux - x64 + name: Upload Zip | Linux - Release - x64 with: name: MelonLoader.Linux.x64.CI.Release path: ./Output/Release/x64/* + cleanup_artifacts: - runs-on: windows-latest - needs: [finalize_x86_debug_zip_windows, finalize_x64_debug_zip_windows, finalize_x86_release_zip_windows, finalize_x64_release_zip_windows, finalize_x64_debug_zip_linux, finalize_x64_release_zip_linux] + name: Cleanup Artifacts + runs-on: ubuntu-22.04 + needs: [finalize_windows, finalize_linux] steps: - uses: GeekyEggo/delete-artifact@v5.0.0 with: @@ -441,4 +419,5 @@ jobs: MLProxyX64-Windows-Release MLBootstrapX64-Windows-Release MLProxyX64-Linux-Release - MLBootstrapX64-Linux-Release \ No newline at end of file + MLBootstrapX64-Linux-Release + \ No newline at end of file diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml deleted file mode 100644 index b9cc470c..00000000 --- a/.github/workflows/nuget.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Build NuGet Package -run-name: ${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && (github.event.head_commit.message || format('`[PR]` {0}', github.event.pull_request.title)) || 'Manual Build' }} - -on: - push: - branches: [ master, alpha-development, v0.6.0-rewrite ] - pull_request: - branches: [ master, alpha-development, v0.6.0-rewrite ] - workflow_dispatch: - -jobs: - build_nuget_package: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - name: Setup .NET - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: 7.0.x - - name: .NET Pack - run: dotnet pack -c Release ${{ github.event_name != 'workflow_dispatch' && format('-p:Version="{0}-ci.{1}" -p:AssemblyVersion="{0}.{1}"', vars.DEVVERSION, github.run_number) || format('-p:Version="{0}"', vars.DEVVERSION) }} - working-directory: ./MelonLoader/ - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: MelonLoaderNuGetPackage - path: MelonLoader/Output/Release/MelonLoader/LavaGang.MelonLoader.${{ vars.DEVVERSION }}${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }}.nupkg diff --git a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj index 75b2c1e1..f708b4b5 100644 --- a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj +++ b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj @@ -12,11 +12,6 @@ https://nuget.bepinex.dev/v3/index.json - - - - - Libs\Il2Cppmscorlib.dll diff --git a/Dependencies/SupportModules/Mono/Mono.csproj b/Dependencies/SupportModules/Mono/Mono.csproj index fb79954b..53d0fbf8 100644 --- a/Dependencies/SupportModules/Mono/Mono.csproj +++ b/Dependencies/SupportModules/Mono/Mono.csproj @@ -4,15 +4,10 @@ net35 true false - $(SolutionDir)\Output\$(Configuration)\MelonLoader\Dependencies\SupportModules\ + $(SolutionDir)Output\$(Configuration)\MelonLoader\Dependencies\SupportModules\ true embedded - - - - - diff --git a/Dependencies/SupportModules/Preload/Resources/System.Core.dll b/Dependencies/SupportModules/Preload/NetStandardPatches/System.Core.dll similarity index 100% rename from Dependencies/SupportModules/Preload/Resources/System.Core.dll rename to Dependencies/SupportModules/Preload/NetStandardPatches/System.Core.dll diff --git a/Dependencies/SupportModules/Preload/Resources/System.Drawing.dll b/Dependencies/SupportModules/Preload/NetStandardPatches/System.Drawing.dll similarity index 100% rename from Dependencies/SupportModules/Preload/Resources/System.Drawing.dll rename to Dependencies/SupportModules/Preload/NetStandardPatches/System.Drawing.dll diff --git a/Dependencies/SupportModules/Preload/Resources/System.dll b/Dependencies/SupportModules/Preload/NetStandardPatches/System.dll similarity index 100% rename from Dependencies/SupportModules/Preload/Resources/System.dll rename to Dependencies/SupportModules/Preload/NetStandardPatches/System.dll diff --git a/Dependencies/SupportModules/Preload/Preload.cs b/Dependencies/SupportModules/Preload/Preload.cs index b071e1e3..a74b603e 100644 --- a/Dependencies/SupportModules/Preload/Preload.cs +++ b/Dependencies/SupportModules/Preload/Preload.cs @@ -12,26 +12,30 @@ private static void Initialize() if (Environment.Version >= new Version("3.0.0.0")) return; - string managedFolder = string.Copy(GetManagedDirectory()); + var ownDir = typeof(Preload).Assembly.Location; + if (string.IsNullOrEmpty(ownDir)) + return; - WriteResource(Properties.Resources.System, Path.Combine(managedFolder, "System.dll")); - WriteResource(Properties.Resources.System_Core, Path.Combine(managedFolder, "System.Core.dll")); - WriteResource(Properties.Resources.System_Drawing, Path.Combine(managedFolder, "System.Drawing.dll")); - } + ownDir = Path.GetDirectoryName(ownDir); - [MethodImpl(MethodImplOptions.InternalCall)] - [return: MarshalAs(UnmanagedType.LPStr)] - private static extern string GetManagedDirectory(); + var managedFolder = GetManagedDirectory(); - private static void WriteResource(byte[] data, string destination) - { - try + var patchesDir = Path.Combine(ownDir, "NetStandardPatches"); + if (!Directory.Exists(patchesDir)) + return; + + foreach (var patch in Directory.GetFiles(patchesDir)) { - if (File.Exists(destination)) - File.Delete(destination); - File.WriteAllBytes(destination, data); + try + { + File.Copy(patch, Path.Combine(managedFolder, Path.GetFileName(patch)), true); + } + catch { } } - catch { } } + + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.LPStr)] + private static extern string GetManagedDirectory(); } } \ No newline at end of file diff --git a/Dependencies/SupportModules/Preload/Preload.csproj b/Dependencies/SupportModules/Preload/Preload.csproj index 5cf76474..6dbe152a 100644 --- a/Dependencies/SupportModules/Preload/Preload.csproj +++ b/Dependencies/SupportModules/Preload/Preload.csproj @@ -15,19 +15,6 @@ - - - - - True - True - Resources.resx - - - - - ResXFileCodeGenerator - Resources.Designer.cs - + \ No newline at end of file diff --git a/Dependencies/SupportModules/Preload/Properties/Resources.Designer.cs b/Dependencies/SupportModules/Preload/Properties/Resources.Designer.cs deleted file mode 100644 index d7760797..00000000 --- a/Dependencies/SupportModules/Preload/Properties/Resources.Designer.cs +++ /dev/null @@ -1,93 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace MelonLoader.Support.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MelonLoader.Support.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] System { - get { - object obj = ResourceManager.GetObject("System", resourceCulture); - return ((byte[])(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] System_Core { - get { - object obj = ResourceManager.GetObject("System.Core", resourceCulture); - return ((byte[])(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] System_Drawing { - get { - object obj = ResourceManager.GetObject("System.Drawing", resourceCulture); - return ((byte[])(obj)); - } - } - } -} diff --git a/Dependencies/SupportModules/Preload/Properties/Resources.resx b/Dependencies/SupportModules/Preload/Properties/Resources.resx deleted file mode 100644 index 14eda986..00000000 --- a/Dependencies/SupportModules/Preload/Properties/Resources.resx +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Resources\System.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\System.Core.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\System.Drawing.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index d2327910..4b42315a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,7 @@ discord.gg/2Wn3N2P Copyright (c) 2022 Lava Gang Latest + false \ No newline at end of file diff --git a/MelonLoader.sln b/MelonLoader.sln index a432ca00..01a75c5d 100644 --- a/MelonLoader.sln +++ b/MelonLoader.sln @@ -96,13 +96,11 @@ Global {762D7545-6F6B-441A-B040-49CC31A1713B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Debug|Any CPU.Build.0 = Debug|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Debug|Windows - x64.ActiveCfg = Debug|Any CPU - {762D7545-6F6B-441A-B040-49CC31A1713B}.Debug|Windows - x64.Build.0 = Debug|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Debug|Windows - x86.ActiveCfg = Debug|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Debug|Windows - x86.Build.0 = Debug|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Release|Any CPU.ActiveCfg = Release|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Release|Any CPU.Build.0 = Release|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Release|Windows - x64.ActiveCfg = Release|Any CPU - {762D7545-6F6B-441A-B040-49CC31A1713B}.Release|Windows - x64.Build.0 = Release|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Release|Windows - x86.ActiveCfg = Release|Any CPU {762D7545-6F6B-441A-B040-49CC31A1713B}.Release|Windows - x86.Build.0 = Release|Any CPU {542EC51D-E480-4802-B5AA-96EEC05AF19C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index 30586f06..eca46a1d 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -1,4 +1,4 @@ - + net35;net6 true @@ -9,6 +9,7 @@ true embedded + true LavaGang.MelonLoader modding unity https://github.com/LavaGang/MelonLoader From e0f30d6d096a68ccaa6d6e286724f6982e6cab2c Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Mon, 21 Oct 2024 22:22:45 -0600 Subject: [PATCH 13/41] Reworked Il2CppICallInjector to use Il2CppInterop's Native to Manage trampoline generation --- MelonLoader/Fixes/Il2CppICallInjector.cs | 227 +++-------------------- 1 file changed, 27 insertions(+), 200 deletions(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index b99a144c..51cef3fd 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -1,14 +1,11 @@ #if NET6_0_OR_GREATER -using Il2CppInterop.Runtime; -using Il2CppInterop.Runtime.InteropTypes; using MelonLoader.NativeUtils; using MonoMod.RuntimeDetour; using MonoMod.Utils; using System; using System.Collections.Generic; using System.Reflection; -using System.Reflection.Emit; using System.Runtime.InteropServices; namespace MelonLoader.Fixes @@ -17,7 +14,7 @@ internal static class Il2CppICallInjector { private const string _customICallSuffix = "_INative"; - private static Dictionary _lookup = new(); + private static Dictionary _lookup = new(); private delegate IntPtr dil2cpp_resolve_icall(IntPtr signature); private static NativeHook il2cpp_resolve_icall_hook; @@ -25,17 +22,8 @@ internal static class Il2CppICallInjector private delegate void dil2cpp_add_internal_call(IntPtr signature, IntPtr funcPtr); private static dil2cpp_add_internal_call il2cpp_add_internal_call; - private static Type _stringType; - private static Type _intPtrType; - private static Type _exceptionType; - private static Type _il2CppObjectBaseType; - - private static MethodInfo _stringConcat; - private static MethodInfo _objectToString; - private static MethodInfo _melonLoggerError; - private static MethodInfo _stringToIl2CppPtr; - private static MethodInfo _il2CppPtrToString; - private static MethodInfo _il2CppObjectBaseGetPointer; + private static Type _il2CppDetourMethodPatcher; + private static MethodInfo _generateNativeToManagedTrampoline; private static MelonLogger.Instance _logger; @@ -45,41 +33,13 @@ internal static unsafe void Install() { _logger = new MelonLogger.Instance(nameof(Il2CppICallInjector)); - Type thisType = typeof(Il2CppICallInjector); - Type objectType = typeof(object); - Type il2cppType = typeof(IL2CPP); - - _il2CppObjectBaseType = typeof(Il2CppObjectBase); - _exceptionType = typeof(Exception); - _intPtrType = typeof(IntPtr); - _stringType = typeof(string); - - _stringConcat = _stringType.GetMethod(nameof(string.Concat), [_stringType, _stringType]); - if (_stringConcat == null) - throw new Exception("Failed to get string.Concat"); - - _objectToString = objectType.GetMethod(nameof(ToString)); - if (_objectToString == null) - throw new Exception("Failed to get object.ToString"); - - _stringToIl2CppPtr = il2cppType.GetMethod(nameof(IL2CPP.ManagedStringToIl2Cpp)); - if (_stringToIl2CppPtr == null) - throw new Exception("Failed to get IL2CPP.ManagedStringToIl2Cpp"); - - _melonLoggerError = thisType.GetMethod(nameof(LogError), - BindingFlags.Static | BindingFlags.NonPublic, - [_stringType]); - if (_melonLoggerError == null) - throw new Exception("Failed to get MelonLogger.Error"); + _il2CppDetourMethodPatcher = typeof(Il2CppInterop.HarmonySupport.HarmonySupport).Assembly.GetType("Il2CppInterop.HarmonySupport.Il2CppDetourMethodPatcher"); + if (_il2CppDetourMethodPatcher == null) + throw new Exception("Failed to get Il2CppDetourMethodPatcher"); - _il2CppPtrToString = il2cppType.GetMethod(nameof(IL2CPP.Il2CppStringToManaged)); - if (_il2CppPtrToString == null) - throw new Exception("Failed to get IL2CPP.Il2CppStringToManaged"); - - PropertyInfo pointerProp = _il2CppObjectBaseType.GetProperty(nameof(Il2CppObjectBase.Pointer)); - if (_il2CppPtrToString == null) - throw new Exception("Failed to get Il2CppObjectBase.Pointer"); - _il2CppObjectBaseGetPointer = pointerProp.GetMethod; + _generateNativeToManagedTrampoline = _il2CppDetourMethodPatcher.GetMethod("GenerateNativeToManagedTrampoline", BindingFlags.NonPublic | BindingFlags.Instance); + if (_generateNativeToManagedTrampoline == null) + throw new Exception("Failed to get Il2CppDetourMethodPatcher.GenerateNativeToManagedTrampoline"); string gameAssemblyName = "GameAssembly"; NativeLibrary gameAssemblyLib = NativeLibrary.Load(gameAssemblyName); @@ -134,14 +94,14 @@ private static IntPtr il2cpp_resolve_icall_Detour(IntPtr signature) // Check Cache if (_lookup.TryGetValue(signatureStr, out var result)) - return result.Item3; + return result.Item4; // Run Original IntPtr originalResult = il2cpp_resolve_icall_hook.Trampoline(signature); if (originalResult != IntPtr.Zero) { // Cache Original Result - _lookup[signatureStr] = (null, null, originalResult); + _lookup[signatureStr] = (null, null, null, originalResult); return originalResult; } @@ -150,15 +110,17 @@ private static IntPtr il2cpp_resolve_icall_Detour(IntPtr signature) return IntPtr.Zero; // Create Injected Function and Cache Return - var pair = - _lookup[signatureStr] = GenerateTrampoline(unityShimMethod); + var pair = GenerateTrampoline(unityShimMethod); + if (pair.Item4 == IntPtr.Zero) + return IntPtr.Zero; // Add New ICall to Il2Cpp Domain - il2cpp_add_internal_call(signature, pair.Item3); + _lookup[signatureStr] = pair; + il2cpp_add_internal_call(signature, pair.Item4); _logger.Msg($"Registered mono icall {signatureStr} in il2cpp domain"); // Return New Function Pointer - return pair.Item3; + return pair.Item4; } private static Type FindType(string typeFullName) @@ -209,156 +171,21 @@ private static bool ShouldInject(string signature, out MethodInfo unityShimMetho return true; } - private static (DynamicMethodDefinition, MethodInfo, IntPtr) GenerateTrampoline(MethodInfo unityShimMethod) + private static (object, DynamicMethodDefinition, MethodInfo, IntPtr) GenerateTrampoline(MethodInfo unityShimMethod) { - // Convert Method Parameters to Native Parameters - var methodParams = unityShimMethod.GetParameters(); - int offset = unityShimMethod.IsStatic ? 0 : 1; - Type[] paramTypes = new Type[methodParams.Length + offset]; - if (!unityShimMethod.IsStatic) - paramTypes[0] = _intPtrType; - for (int i = 0; i < methodParams.Length; i++) - { - if ((methodParams[i].ParameterType == _stringType) - || !methodParams[i].ParameterType.IsValueType) - paramTypes[i + offset] = _intPtrType; - else - paramTypes[i + offset] = methodParams[i].ParameterType; - } - - // Convert Return Type - Type returnType = unityShimMethod.ReturnType; - if ((returnType == _stringType) - || !returnType.IsValueType) - returnType = _intPtrType; + // Create Patcher + object patcher = Activator.CreateInstance(_il2CppDetourMethodPatcher, [ unityShimMethod ]); + if (patcher == null) + return (null, null, null, IntPtr.Zero); // Create New Injected ICall Method - string newMethodName = $"{unityShimMethod.Name}{_customICallSuffix}"; - var trampoline = new DynamicMethodDefinition( - newMethodName, - returnType, - paramTypes); - var ilGenerator = trampoline.GetILGenerator(); - - // Begin Try-Catch - ilGenerator.BeginExceptionBlock(); - - // Emit This Object - if (!unityShimMethod.IsStatic) - ilGenerator.EmitPtrArgToManagedObject(0, unityShimMethod.DeclaringType); - - // Convert Method Parameters to Managed Objects - for (var i = 0; i < methodParams.Length; i++) - { - var param = methodParams[i]; - var paramType = param.ParameterType; - if (paramType == _stringType) - ilGenerator.EmitPtrArgToString(i + offset); - else if (paramType.IsValueType) - ilGenerator.EmitArg(i + offset); - else - ilGenerator.EmitPtrArgToManagedObject(i + offset, paramType); - } - - // Call Existing Method - ilGenerator.Emit(OpCodes.Call, unityShimMethod); - - // Convert Managed Return - var oldreturnType = unityShimMethod.ReturnType; - if (oldreturnType == _stringType) - ilGenerator.EmitStringToPtr(); - else if ((oldreturnType == _il2CppObjectBaseType) - || oldreturnType.IsSubclassOf(_il2CppObjectBaseType)) - ilGenerator.EmitIl2CppObjectBaseToPtr(); - - // Cache Return Value in Lcal - LocalBuilder returnLocal = null; - if (returnType != typeof(void)) - { - returnLocal = ilGenerator.DeclareLocal(returnType); - ilGenerator.Emit(OpCodes.Stloc, returnLocal); - } - - // End Try-Catch - ilGenerator.EmitExceptionCatch(); - - // Restore Return Value from Local - if (returnLocal != null) - ilGenerator.Emit(OpCodes.Ldloc, returnLocal); - - // Return even if there is no Return Value - ilGenerator.Emit(OpCodes.Ret); - + DynamicMethodDefinition trampoline = (DynamicMethodDefinition)_generateNativeToManagedTrampoline.Invoke(patcher, [ unityShimMethod ]); + if (trampoline == null) + return (null, null, null, IntPtr.Zero); + // Return the New Method MethodInfo newMethod = trampoline.Generate().Pin(); - return (trampoline, newMethod, newMethod.GetNativeStart()); - } - - private static void EmitArg(this ILGenerator ilGenerator, - int index) - => ilGenerator.Emit(OpCodes.Ldarg, index); - - private static void EmitPtrArgToString(this ILGenerator ilGenerator, - int argIndex) - { - ilGenerator.EmitArg(argIndex); - ilGenerator.Emit(OpCodes.Call, _il2CppPtrToString); - } - - private static void EmitStringToPtr(this ILGenerator ilGenerator) - => ilGenerator.Emit(OpCodes.Call, _stringToIl2CppPtr); - - private static void EmitPtrArgToManagedObject(this ILGenerator ilGenerator, - int argIndex, - Type managedType) - { - ilGenerator.EmitArg(argIndex); - - var labelNull = ilGenerator.DefineLabel(); - var labelDone = ilGenerator.DefineLabel(); - ilGenerator.Emit(OpCodes.Brfalse, labelNull); - ilGenerator.EmitArg(argIndex); - - ilGenerator.Emit(OpCodes.Newobj, - managedType.GetConstructor([ _intPtrType ])); - - ilGenerator.Emit(OpCodes.Br, labelDone); - ilGenerator.MarkLabel(labelNull); - ilGenerator.Emit(OpCodes.Ldnull); - ilGenerator.MarkLabel(labelDone); - } - - private static void EmitIl2CppObjectBaseToPtr(this ILGenerator ilGenerator) - { - var labelNull = ilGenerator.DefineLabel(); - var labelDone = ilGenerator.DefineLabel(); - ilGenerator.Emit(OpCodes.Dup); - ilGenerator.Emit(OpCodes.Brfalse, labelNull); - - ilGenerator.Emit(OpCodes.Call, _il2CppObjectBaseGetPointer); - - ilGenerator.Emit(OpCodes.Br, labelDone); - ilGenerator.MarkLabel(labelNull); - ilGenerator.Emit(OpCodes.Pop); - ilGenerator.Emit(OpCodes.Ldc_I4_0); - ilGenerator.Emit(OpCodes.Conv_I); - ilGenerator.MarkLabel(labelDone); - } - - private static void EmitExceptionCatch(this ILGenerator ilGenerator) - { - var exceptionLocal = ilGenerator.DeclareLocal(_exceptionType); - ilGenerator.BeginCatchBlock(_exceptionType); - - ilGenerator.Emit(OpCodes.Stloc, exceptionLocal); - ilGenerator.Emit(OpCodes.Ldstr, "Exception in IL2CPP Injected ICall: "); - ilGenerator.Emit(OpCodes.Ldloc, exceptionLocal); - - ilGenerator.Emit(OpCodes.Callvirt, _objectToString); - ilGenerator.Emit(OpCodes.Call, _stringConcat); - ilGenerator.Emit(OpCodes.Call, _melonLoggerError); - - ilGenerator.EndExceptionBlock(); + return (patcher, trampoline, newMethod, newMethod.GetNativeStart()); } } } From 680bc8c2842f7f17ad9804f95dec632f6d01d7dc Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Mon, 21 Oct 2024 22:24:25 -0600 Subject: [PATCH 14/41] Reworked Il2CppICallInjector to use Il2CppInterop's Native to Manage trampoline generation --- MelonLoader/Fixes/Il2CppICallInjector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index 51cef3fd..feadddac 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; +using Il2CppInterop.HarmonySupport; namespace MelonLoader.Fixes { @@ -33,7 +34,7 @@ internal static unsafe void Install() { _logger = new MelonLogger.Instance(nameof(Il2CppICallInjector)); - _il2CppDetourMethodPatcher = typeof(Il2CppInterop.HarmonySupport.HarmonySupport).Assembly.GetType("Il2CppInterop.HarmonySupport.Il2CppDetourMethodPatcher"); + _il2CppDetourMethodPatcher = typeof(HarmonySupport).Assembly.GetType("Il2CppInterop.HarmonySupport.Il2CppDetourMethodPatcher"); if (_il2CppDetourMethodPatcher == null) throw new Exception("Failed to get Il2CppDetourMethodPatcher"); From 6f4a8adc0ab4c7ed954d397206372e0a8caf75b8 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Mon, 21 Oct 2024 22:54:28 -0600 Subject: [PATCH 15/41] Update Il2CppICallInjector.cs --- MelonLoader/Fixes/Il2CppICallInjector.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index feadddac..134f8dab 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -13,8 +13,6 @@ namespace MelonLoader.Fixes { internal static class Il2CppICallInjector { - private const string _customICallSuffix = "_INative"; - private static Dictionary _lookup = new(); private delegate IntPtr dil2cpp_resolve_icall(IntPtr signature); From 6ed02850ba4b63f39884562dc593cc760b336037 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 00:59:17 -0600 Subject: [PATCH 16/41] Implemented ICall Injection Extern Validation --- MelonLoader/Fixes/Il2CppICallInjector.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index 134f8dab..fe4ed0e9 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -165,6 +165,15 @@ private static bool ShouldInject(string signature, out MethodInfo unityShimMetho if (method == null) return false; + // Check for Extern to prevent Recursion + if (method.Attributes.HasFlag(MethodAttributes.PinvokeImpl)) + return false; + var methodImpl = method.GetMethodImplementationFlags(); + if (methodImpl.HasFlag(MethodImplAttributes.InternalCall) + || methodImpl.HasFlag(MethodImplAttributes.Native) + || methodImpl.HasFlag(MethodImplAttributes.Unmanaged)) + return false; + // Inject ICall unityShimMethod = method; return true; From 6cdfa7539755f7d3f8e4a0d55863f2402f4871a0 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 01:01:21 -0600 Subject: [PATCH 17/41] Cleaned up Il2CppInteropFixes Logging --- MelonLoader/Fixes/Il2CppInteropFixes.cs | 63 +++++++++++++++---------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/MelonLoader/Fixes/Il2CppInteropFixes.cs b/MelonLoader/Fixes/Il2CppInteropFixes.cs index ea58d70a..f6ccc8db 100644 --- a/MelonLoader/Fixes/Il2CppInteropFixes.cs +++ b/MelonLoader/Fixes/Il2CppInteropFixes.cs @@ -67,6 +67,19 @@ internal unsafe static class Il2CppInteropFixes private static MethodInfo _reportException; private static MethodInfo _reportException_Prefix; + private static void LogMsg(string msg) + => _logger.Msg(msg); + private static void LogError(Exception ex) + => _logger.Error(ex); + private static void LogError(string msg, Exception ex) + => _logger.Error(msg, ex); + private static void LogDebugMsg(string msg) + { + if (!MelonDebug.IsEnabled()) + return; + _logger.Msg(msg); + } + internal static void Install() { try @@ -173,61 +186,61 @@ internal static void Install() _rewriteGlobalContext_TryGetNewTypeForOriginal_Prefix = thisType.GetMethod(nameof(RewriteGlobalContext_TryGetNewTypeForOriginal_Prefix), BindingFlags.NonPublic | BindingFlags.Static); _reportException_Prefix = thisType.GetMethod(nameof(ReportException_Prefix), BindingFlags.NonPublic | BindingFlags.Static); - MelonDebug.Msg("Patching Il2CppInterop ClassInjector.SystemTypeFromIl2CppType..."); + LogDebugMsg("Patching Il2CppInterop ClassInjector.SystemTypeFromIl2CppType..."); Core.HarmonyInstance.Patch(_systemTypeFromIl2CppType, new HarmonyMethod(_systemTypeFromIl2CppType_Prefix), null, new HarmonyMethod(_systemTypeFromIl2CppType_Transpiler)); - MelonDebug.Msg("Patching Il2CppInterop ClassInjector.RegisterTypeInIl2Cpp..."); + LogDebugMsg("Patching Il2CppInterop ClassInjector.RegisterTypeInIl2Cpp..."); Core.HarmonyInstance.Patch(_registerTypeInIl2Cpp, null, null, new HarmonyMethod(_registerTypeInIl2Cpp_Transpiler)); - MelonDebug.Msg("Patching Il2CppInterop ClassInjector.IsTypeSupported..."); + LogDebugMsg("Patching Il2CppInterop ClassInjector.IsTypeSupported..."); Core.HarmonyInstance.Patch(_isTypeSupported, null, null, new HarmonyMethod(_isTypeSupported_Transpiler)); - MelonDebug.Msg("Patching Il2CppInterop ClassInjector.RewriteType..."); + LogDebugMsg("Patching Il2CppInterop ClassInjector.RewriteType..."); Core.HarmonyInstance.Patch(_rewriteType, new HarmonyMethod(_rewriteType_Prefix)); - MelonDebug.Msg("Patching Il2CppInterop ClassInjector.ConvertMethodInfo..."); + LogDebugMsg("Patching Il2CppInterop ClassInjector.ConvertMethodInfo..."); Core.HarmonyInstance.Patch(_convertMethodInfo, null, null, new HarmonyMethod(_convertMethodInfo_Transpiler)); - MelonDebug.Msg("Patching Il2CppInterop ILGeneratorEx.EmitObjectToPointer..."); + LogDebugMsg("Patching Il2CppInterop ILGeneratorEx.EmitObjectToPointer..."); Core.HarmonyInstance.Patch(_emitObjectToPointer, new HarmonyMethod(_emitObjectToPointer_Prefix)); - MelonDebug.Msg("Patching Il2CppInterop RewriteGlobalContext.AddAssemblyContext..."); + LogDebugMsg("Patching Il2CppInterop RewriteGlobalContext.AddAssemblyContext..."); Core.HarmonyInstance.Patch(_rewriteGlobalContext_AddAssemblyContext, null, new HarmonyMethod(_rewriteGlobalContext_AddAssemblyContext_Postfix)); - MelonDebug.Msg("Patching Il2CppInterop RewriteGlobalContext.Dispose..."); + LogDebugMsg("Patching Il2CppInterop RewriteGlobalContext.Dispose..."); Core.HarmonyInstance.Patch(_rewriteGlobalContext_Dispose, new HarmonyMethod(_rewriteGlobalContext_Dispose_Prefix)); - MelonDebug.Msg("Patching Il2CppInterop RewriteGlobalContext.GetNewAssemblyForOriginal..."); + LogDebugMsg("Patching Il2CppInterop RewriteGlobalContext.GetNewAssemblyForOriginal..."); Core.HarmonyInstance.Patch(_rewriteGlobalContext_GetNewAssemblyForOriginal, new HarmonyMethod(_rewriteGlobalContext_GetNewAssemblyForOriginal_Prefix)); - MelonDebug.Msg("Patching Il2CppInterop RewriteGlobalContext.TryGetNewTypeForOriginal..."); + LogDebugMsg("Patching Il2CppInterop RewriteGlobalContext.TryGetNewTypeForOriginal..."); Core.HarmonyInstance.Patch(_rewriteGlobalContext_TryGetNewTypeForOriginal, new HarmonyMethod(_rewriteGlobalContext_TryGetNewTypeForOriginal_Prefix)); - MelonDebug.Msg("Patching Il2CppInterop Il2CppDetourMethodPatcher.ReportException..."); + LogDebugMsg("Patching Il2CppInterop Il2CppDetourMethodPatcher.ReportException..."); Core.HarmonyInstance.Patch(_reportException, new HarmonyMethod(_reportException_Prefix)); } catch (Exception e) { - MelonLogger.Error(e); + LogError(e); } } @@ -250,6 +263,8 @@ internal static void Shutdown() _typeLookup.Clear(); _typeLookup = null; } + + _shouldLog = false; } private static bool FixedIsByRef(Type type) @@ -299,15 +314,13 @@ private static void FixedAddTypeToLookup(Type type, IntPtr typePointer) private static bool ReportException_Prefix(Exception __0) { - _logger.Error("During invoking native->managed trampoline", __0); - + MelonLogger.Error("During invoking native->managed trampoline", __0); return false; } private static bool EmitObjectToPointer_Prefix(bool __7, ref bool __8) { __8 = __7; - return true; } @@ -342,7 +355,7 @@ private static void RewriteGlobalContext_AddAssemblyContext_Postfix(RewriteGloba return; contexts[assemblyName] = __1; - //MelonDebug.Msg($"[RewriteGlobalContext] Added: {assemblyName}"); + //LogDebugMsg($"[RewriteGlobalContext] Added: {assemblyName}"); } private static bool RewriteGlobalContext_Dispose_Prefix(RewriteGlobalContext __instance) @@ -370,7 +383,7 @@ private static bool RewriteGlobalContext_GetNewAssemblyForOriginal_Prefix(Rewrit string assemblyName = __0.Name; if (contexts.TryGetValue(assemblyName, out __result)) { - //MelonDebug.Msg($"[RewriteGlobalContext] Found: {assemblyName}"); + //LogDebugMsg($"[RewriteGlobalContext] Found: {assemblyName}"); return false; } @@ -381,7 +394,7 @@ private static bool RewriteGlobalContext_GetNewAssemblyForOriginal_Prefix(Rewrit if (contexts.TryGetValue(assemblyName, out __result)) { - //MelonDebug.Msg($"[RewriteGlobalContext] Found: {assemblyName}"); + //LogDebugMsg($"[RewriteGlobalContext] Found: {assemblyName}"); return false; } @@ -407,7 +420,7 @@ private static bool RewriteGlobalContext_TryGetNewTypeForOriginal_Prefix(Rewrite AssemblyRewriteContext rewriteContext = null; if (contexts.TryGetValue(assemblyName, out rewriteContext)) { - //MelonDebug.Msg($"[RewriteGlobalContext] Found: {assemblyName}"); + //LogDebugMsg($"[RewriteGlobalContext] Found: {assemblyName}"); __result = rewriteContext.TryGetContextForOriginalType(__0); return false; } @@ -418,7 +431,7 @@ private static bool RewriteGlobalContext_TryGetNewTypeForOriginal_Prefix(Rewrite assemblyName = $"Il2Cpp{assemblyName}"; if (contexts.TryGetValue(assemblyName, out rewriteContext)) { - //MelonDebug.Msg($"[RewriteGlobalContext] Found: {assemblyName}"); + //LogDebugMsg($"[RewriteGlobalContext] Found: {assemblyName}"); __result = rewriteContext.TryGetContextForOriginalType(__0); return false; } @@ -510,7 +523,7 @@ private static IEnumerable SystemTypeFromIl2CppType_Transpiler( instruction.opcode = OpCodes.Call; instruction.operand = _fixedFindType; - MelonDebug.Msg("Patched Il2CppInterop ClassInjector.SystemTypeFromIl2CppType -> Type.GetType"); + LogDebugMsg("Patched Il2CppInterop ClassInjector.SystemTypeFromIl2CppType -> Type.GetType"); } yield return instruction; @@ -529,7 +542,7 @@ private static IEnumerable RegisterTypeInIl2Cpp_Transpiler(IEnu found = true; instruction.opcode = OpCodes.Call; instruction.operand = _fixedAddTypeToLookup; - MelonDebug.Msg("Patched Il2CppInterop ClassInjector.RegisterTypeInIl2Cpp -> InjectorHelpers.AddTypeToLookup"); + LogDebugMsg("Patched Il2CppInterop ClassInjector.RegisterTypeInIl2Cpp -> InjectorHelpers.AddTypeToLookup"); } if (!found2 @@ -539,7 +552,7 @@ private static IEnumerable RegisterTypeInIl2Cpp_Transpiler(IEnu found2 = true; instruction.opcode = OpCodes.Call; instruction.operand = _fixedFindAbstractMethods; - MelonDebug.Msg("Patched Il2CppInterop ClassInjector.RegisterTypeInIl2Cpp -> FindAbstractMethods"); + LogDebugMsg("Patched Il2CppInterop ClassInjector.RegisterTypeInIl2Cpp -> FindAbstractMethods"); } yield return instruction; @@ -558,7 +571,7 @@ private static IEnumerable ConvertMethodInfo_Transpiler(IEnumer found = true; instruction.opcode = OpCodes.Call; instruction.operand = _fixedIsByRef; - MelonDebug.Msg("Patched Il2CppInterop ClassInjector.ConvertMethodInfo -> Type.IsByRef"); + LogDebugMsg("Patched Il2CppInterop ClassInjector.ConvertMethodInfo -> Type.IsByRef"); } yield return instruction; @@ -576,7 +589,7 @@ private static IEnumerable IsTypeSupported_Transpiler(IEnumerab found = true; instruction.opcode = OpCodes.Call; instruction.operand = _fixedIsByRef; - MelonDebug.Msg("Patched Il2CppInterop ClassInjector.IsTypeSupported -> Type.IsByRef"); + LogDebugMsg("Patched Il2CppInterop ClassInjector.IsTypeSupported -> Type.IsByRef"); } yield return instruction; From 220e6c2f3ff019e5c8ceaf3e080dd02f11dfbc61 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 01:02:03 -0600 Subject: [PATCH 18/41] Reworked MelonFolderHandler to allow scanning for UserLibs --- MelonLoader/Core.cs | 4 +- MelonLoader/Melons/MelonFolderHandler.cs | 178 +++++++++++++---------- MelonLoader/Melons/MelonHandler.cs | 87 +---------- 3 files changed, 110 insertions(+), 159 deletions(-) diff --git a/MelonLoader/Core.cs b/MelonLoader/Core.cs index 7423c33e..bb220687 100644 --- a/MelonLoader/Core.cs +++ b/MelonLoader/Core.cs @@ -110,7 +110,7 @@ internal static int Initialize() bHapticsManager.Connect(BuildInfo.Name, UnityInformationHandler.GameName); MelonHandler.LoadUserlibs(MelonEnvironment.UserLibsDirectory); - MelonHandler.LoadMelonFolders(MelonEnvironment.PluginsDirectory); + MelonHandler.LoadMelonsFromDirectory(MelonEnvironment.PluginsDirectory); MelonEvents.MelonHarmonyEarlyInit.Invoke(); MelonEvents.OnPreInitialization.Invoke(); @@ -140,7 +140,7 @@ internal static int Start() return 1; MelonEvents.OnPreModsLoaded.Invoke(); - MelonHandler.LoadMelonFolders(MelonEnvironment.ModsDirectory); + MelonHandler.LoadMelonsFromDirectory(MelonEnvironment.ModsDirectory); MelonEvents.OnPreSupportModule.Invoke(); if (!SupportModule.Setup()) diff --git a/MelonLoader/Melons/MelonFolderHandler.cs b/MelonLoader/Melons/MelonFolderHandler.cs index bd0c91d6..3a813a51 100644 --- a/MelonLoader/Melons/MelonFolderHandler.cs +++ b/MelonLoader/Melons/MelonFolderHandler.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Drawing; using System.IO; @@ -6,7 +7,25 @@ namespace MelonLoader.Melons { internal class MelonFolderHandler { - internal static void Scan(string path) where T : MelonTypeBase + private static bool firstSpacer = false; + + internal static void ScanUserLibs(string path) + { + // Get Full Directory Path + path = Path.GetFullPath(path); + + // Log Loading Message + var loadingMsg = $"Loading UserLibs from '{path}'..."; + MelonLogger.WriteSpacer(); + MelonLogger.Msg(loadingMsg); + + // Parse Folders + bool hasWroteLine = false; + List melonAssemblies = new(); + ProcessFolder(false, path, true, ref hasWroteLine, ref melonAssemblies); + } + + internal static void ScanMelons(string path) where T : MelonTypeBase { // Get Full Directory Path path = Path.GetFullPath(path); @@ -17,9 +36,11 @@ internal static void Scan(string path) where T : MelonTypeBase MelonLogger.Msg(loadingMsg); // Parse Folders + Type melonType = typeof(T); + bool isMod = melonType == typeof(MelonMod); bool hasWroteLine = false; List melonAssemblies = new(); - ProcessFolder(path, ref hasWroteLine, ref melonAssemblies); + ProcessFolder(isMod, path, false, ref hasWroteLine, ref melonAssemblies); // Parse Queue var melons = new List(); @@ -57,16 +78,20 @@ internal static void Scan(string path) where T : MelonTypeBase // Log Melon Count var count = MelonTypeBase._registeredMelons.Count; MelonLogger.Msg($"{count} {MelonTypeBase.TypeName.MakePlural(count)} loaded."); - if (MelonHandler.firstSpacer || (typeof(T) == typeof(MelonMod))) + if (firstSpacer || (typeof(T) == typeof(MelonMod))) MelonLogger.WriteSpacer(); - MelonHandler.firstSpacer = true; + firstSpacer = true; } - private static void LoadFolder(string path, + private static void LoadFolder(string path, bool addToList, ref bool hasWroteLine, - ref List melonAssemblies) where T : MelonTypeBase + ref List melonAssemblies) { + // Validate Path + if (!Directory.Exists(path)) + return; + // Get DLLs in Directory var files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); foreach (var f in files) @@ -89,90 +114,95 @@ private static void LoadFolder(string path, } } - private static bool StartsOrEndsWith(string dirNameLower, string target) - => dirNameLower.StartsWith(target) - || dirNameLower.EndsWith(target); - - private static bool IsUserLibsFolder(string dirNameLower) - => StartsOrEndsWith(dirNameLower, "userlibs"); - - private static bool IsDisabledFolder(string path, - out string dirNameLower) - { - string dirName = new DirectoryInfo(path).Name; - dirNameLower = dirName.ToLowerInvariant(); - return StartsOrEndsWith(dirNameLower, "disabled") - || StartsOrEndsWith(dirNameLower, "old") - || StartsOrEndsWith(dirNameLower, "~"); - } - - private static void ProcessFolder(string path, + private static void ProcessFolder(bool isMod, + string path, + bool userLibsOnly, ref bool hasWroteLine, - ref List melonAssemblies) where T : MelonTypeBase + ref List melonAssemblies) { // Validate Path if (!Directory.Exists(path)) return; - // Add Base Path to Resolver - Resolver.MelonAssemblyResolver.AddSearchDirectory(path); + // Scan Directories + List melonDirectories = new(); + List userLibDirectories = new(); + ScanFolder(isMod, path, userLibsOnly, ref melonDirectories, ref userLibDirectories); - // Get Directories - var directories = Directory.GetDirectories(path, "*", SearchOption.AllDirectories); + // Add Base Path to End of Directories List + if (userLibsOnly) + userLibDirectories.Add(path); + else + melonDirectories.Add(path); // Add Directories to Resolver - if ((directories != null) && (directories.Length > 0)) + foreach (string directory in userLibDirectories) { - foreach (var dir in directories) - { - // Validate Path - if (!Directory.Exists(dir)) - continue; - - // Skip Disabled Folders - if (IsDisabledFolder(dir, out string dirNameLower)) - continue; - - // Load Assemblies - if (IsUserLibsFolder(dirNameLower)) - MelonUtils.AddNativeDLLDirectory(dir); - Resolver.MelonAssemblyResolver.AddSearchDirectory(dir); - } + MelonUtils.AddNativeDLLDirectory(directory); + Resolver.MelonAssemblyResolver.AddSearchDirectory(directory); + } + if (!userLibsOnly) + foreach (string directory in melonDirectories) + Resolver.MelonAssemblyResolver.AddSearchDirectory(directory); + + // Load UserLibs + foreach (var dir in userLibDirectories) + LoadFolder(dir, false, ref hasWroteLine, ref melonAssemblies); + + // Load Melons from Folders + if (!userLibsOnly) + foreach (var dir in melonDirectories) + LoadFolder(dir, true, ref hasWroteLine, ref melonAssemblies); + } - // Load UserLibs - foreach (var dir in directories) - { - // Validate Path - if (!Directory.Exists(dir)) - continue; + private static void ScanFolder(bool isMod, + string path, + bool userLibsOnly, + ref List melonDirectories, + ref List userLibDirectories) + { + // Get Directories + string[] directories = Directory.GetDirectories(path, "*", SearchOption.AllDirectories); + if ((directories == null) + || (directories.Length <= 0)) + return; - // Skip Disabled Folders and any folders that doesn't end with or isn't equal to UserLibs - if (IsDisabledFolder(dir, out string dirNameLower) - || !IsUserLibsFolder(dirNameLower)) - continue; + // Parse Directories + foreach (var dir in directories) + { + // Validate Path + if (!Directory.Exists(dir) + || userLibDirectories.Contains(dir) + || melonDirectories.Contains(dir)) + continue; - // Load Assemblies - LoadFolder(dir, false, ref hasWroteLine, ref melonAssemblies); - } + // Validate Folder + if (IsDisabledFolder(dir, out string dirNameLower)) + continue; - // Load Melons from Extended Folders - foreach (var dir in directories) - { - // Validate Path - if (!Directory.Exists(dir)) - continue; + // Check for UserLibs + if (userLibsOnly || IsUserLibsFolder(dirNameLower)) + userLibDirectories.Add(dir); + else + melonDirectories.Add(dir); + } + } - // Skip Disabled Folders - if (IsDisabledFolder(dir, out _)) - continue; + private static bool StartsOrEndsWith(string dirNameLower, string target) + => dirNameLower.StartsWith(target) + || dirNameLower.EndsWith(target); - // Load Melons from Extended Folder - LoadFolder(dir, true, ref hasWroteLine, ref melonAssemblies); - } - } + private static bool IsUserLibsFolder(string dirNameLower) + => StartsOrEndsWith(dirNameLower, "userlibs"); - // Load Melons from Base Path - LoadFolder(path, true, ref hasWroteLine, ref melonAssemblies); + private static bool IsDisabledFolder(string path, + out string dirNameLower) + { + string dirName = new DirectoryInfo(path).Name; + dirNameLower = dirName.ToLowerInvariant(); + return StartsOrEndsWith(dirNameLower, "disabled") + || StartsOrEndsWith(dirNameLower, "old") + || StartsOrEndsWith(dirNameLower, "~"); } } } \ No newline at end of file diff --git a/MelonLoader/Melons/MelonHandler.cs b/MelonLoader/Melons/MelonHandler.cs index 80725eaf..8abe773f 100644 --- a/MelonLoader/Melons/MelonHandler.cs +++ b/MelonLoader/Melons/MelonHandler.cs @@ -32,91 +32,12 @@ internal static void Setup() Directory.CreateDirectory(MelonEnvironment.ModsDirectory); } - internal static bool firstSpacer = false; - public static void LoadMelonsFromDirectory(string path) where T : MelonTypeBase - { - path = Path.GetFullPath(path); - - var loadingMsg = $"Loading {MelonTypeBase.TypeName}s from '{path}'..."; - MelonLogger.WriteSpacer(); - MelonLogger.Msg(loadingMsg); - - bool hasWroteLine = false; - - var files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); - var melonAssemblies = new List(); - foreach (var f in files) - { - if (!hasWroteLine) - { - hasWroteLine = true; - MelonLogger.WriteLine(Color.Magenta); - } - - var asm = MelonAssembly.LoadMelonAssembly(f, false); - if (asm == null) - continue; - - melonAssemblies.Add(asm); - } - - var melons = new List(); - foreach (var asm in melonAssemblies) - { - asm.LoadMelons(); - foreach (var m in asm.LoadedMelons) - { - if (m is T t) - { - melons.Add(t); - } - else - { - MelonLogger.Warning($"Failed to load Melon '{m.Info.Name}' from '{path}': The given Melon is a {m.MelonTypeName} and cannot be loaded as a {MelonTypeBase.TypeName}. Make sure it's in the right folder."); - continue; - } - } - } - - if (hasWroteLine) - MelonLogger.WriteSpacer(); - - MelonBase.RegisterSorted(melons); - - if (hasWroteLine) - MelonLogger.WriteLine(Color.Magenta); - - var count = MelonTypeBase._registeredMelons.Count; - MelonLogger.Msg($"{count} {MelonTypeBase.TypeName.MakePlural(count)} loaded."); - if (firstSpacer || (typeof(T) == typeof(MelonMod))) - MelonLogger.WriteSpacer(); - firstSpacer = true; - } - public static void LoadUserlibs(string path) - { - path = Path.GetFullPath(path); - - var loadingMsg = $"Loading UserLibs from '{path}'..."; - MelonLogger.WriteSpacer(); - MelonLogger.Msg(loadingMsg); - - bool hasWroteLine = false; - var files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); - foreach (var f in files) - { - if (!hasWroteLine) - { - hasWroteLine = true; - MelonLogger.WriteLine(Color.Magenta); - } - - MelonAssembly.LoadMelonAssembly(f, false); - } - } + => MelonFolderHandler.ScanUserLibs(path); - public static void LoadMelonFolders(string path) where T : MelonTypeBase - => MelonFolderHandler.Scan(path); + public static void LoadMelonsFromDirectory(string path) + where T : MelonTypeBase + => MelonFolderHandler.ScanMelons(path); #region Obsolete Members /// From 588b998e3d08fbb5f2ef2a6c03423c07aec18d7b Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 02:30:39 -0600 Subject: [PATCH 19/41] Improved ICall Injection Method Validation --- MelonLoader/Fixes/Il2CppICallInjector.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index fe4ed0e9..5a256b36 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Runtime.InteropServices; using Il2CppInterop.HarmonySupport; +using HarmonyLib; namespace MelonLoader.Fixes { @@ -165,15 +166,22 @@ private static bool ShouldInject(string signature, out MethodInfo unityShimMetho if (method == null) return false; - // Check for Extern to prevent Recursion + // Check for PInvoke to prevent Recursion if (method.Attributes.HasFlag(MethodAttributes.PinvokeImpl)) return false; + + // Check for Extern to prevent Recursion var methodImpl = method.GetMethodImplementationFlags(); if (methodImpl.HasFlag(MethodImplAttributes.InternalCall) || methodImpl.HasFlag(MethodImplAttributes.Native) || methodImpl.HasFlag(MethodImplAttributes.Unmanaged)) return false; + // Check if Method has no Body or just throws NotImplementedException + if (!method.HasMethodBody() + || method.IsNotImplemented()) + return false; + // Inject ICall unityShimMethod = method; return true; From 013f4a6bca3c4d698005b99e242ced501aef3c6f Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 02:33:27 -0600 Subject: [PATCH 20/41] Update Il2CppInteropFixes.cs --- MelonLoader/Fixes/Il2CppInteropFixes.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/MelonLoader/Fixes/Il2CppInteropFixes.cs b/MelonLoader/Fixes/Il2CppInteropFixes.cs index f6ccc8db..b5a0ef70 100644 --- a/MelonLoader/Fixes/Il2CppInteropFixes.cs +++ b/MelonLoader/Fixes/Il2CppInteropFixes.cs @@ -263,8 +263,6 @@ internal static void Shutdown() _typeLookup.Clear(); _typeLookup = null; } - - _shouldLog = false; } private static bool FixedIsByRef(Type type) From eb175bbc963f08a7ac1b011b287f5727d3f9eca6 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 02:38:59 -0600 Subject: [PATCH 21/41] Fix Il2CppInterop ReportException Logging not having the proper prefix --- MelonLoader/Fixes/Il2CppInteropFixes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MelonLoader/Fixes/Il2CppInteropFixes.cs b/MelonLoader/Fixes/Il2CppInteropFixes.cs index b5a0ef70..c94fc035 100644 --- a/MelonLoader/Fixes/Il2CppInteropFixes.cs +++ b/MelonLoader/Fixes/Il2CppInteropFixes.cs @@ -312,7 +312,7 @@ private static void FixedAddTypeToLookup(Type type, IntPtr typePointer) private static bool ReportException_Prefix(Exception __0) { - MelonLogger.Error("During invoking native->managed trampoline", __0); + LogError("During invoking native->managed trampoline", __0); return false; } From f5e2b16b6a38cc36e7c716701775d17002e1d9bc Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 03:22:27 -0600 Subject: [PATCH 22/41] Attempt to prevent trying to load Managed Assemblies from Native Libraries inside UserLibs #774 --- MelonLoader/MelonUtils.cs | 21 ++++++++++++++++++++- MelonLoader/Melons/MelonFolderHandler.cs | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/MelonLoader/MelonUtils.cs b/MelonLoader/MelonUtils.cs index fa0e6497..c09313d2 100644 --- a/MelonLoader/MelonUtils.cs +++ b/MelonLoader/MelonUtils.cs @@ -345,6 +345,26 @@ public static bool IsNotImplemented(this MethodBase methodBase) return returnval; } + public static bool IsManagedDLL(string path) + { + if (Path.GetExtension(path).ToLower() != ".dll") + return false; + + try + { + AssemblyName.GetAssemblyName(path); + return true; + } + catch (FileLoadException) + { + return true; + } + catch + { + return false; + } + } + public static HarmonyMethod ToNewHarmonyMethod(this MethodInfo methodInfo) { if (methodInfo == null) @@ -352,7 +372,6 @@ public static HarmonyMethod ToNewHarmonyMethod(this MethodInfo methodInfo) return new HarmonyMethod(methodInfo); } - public static DynamicMethodDefinition ToNewDynamicMethodDefinition(this MethodBase methodBase) { if (methodBase == null) diff --git a/MelonLoader/Melons/MelonFolderHandler.cs b/MelonLoader/Melons/MelonFolderHandler.cs index 3a813a51..7215faf9 100644 --- a/MelonLoader/Melons/MelonFolderHandler.cs +++ b/MelonLoader/Melons/MelonFolderHandler.cs @@ -96,6 +96,10 @@ private static void LoadFolder(string path, var files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); foreach (var f in files) { + // Ignore Native DLLs + if (!MelonUtils.IsManagedDLL(f)) + continue; + // Log if (!hasWroteLine) { From 4f1e3f4cc184e2e61e4471a3e528540fdd6cce53 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 13:52:40 -0600 Subject: [PATCH 23/41] Update Il2CppICallInjector.cs --- MelonLoader/Fixes/Il2CppICallInjector.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index 5a256b36..a577a3be 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -178,9 +178,9 @@ private static bool ShouldInject(string signature, out MethodInfo unityShimMetho return false; // Check if Method has no Body or just throws NotImplementedException - if (!method.HasMethodBody() - || method.IsNotImplemented()) - return false; + //if (!method.HasMethodBody() + // || method.IsNotImplemented()) + // return false; // Inject ICall unityShimMethod = method; From 425855253cb0b1ddec26c7476cecdf8c6e393efd Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 18:03:43 -0600 Subject: [PATCH 24/41] Reworked Il2CppICallInjector to improve method scanning and ignore generic methods --- MelonLoader/Fixes/Il2CppICallInjector.cs | 91 ++++++++++++++++++------ MelonLoader/MelonUtils.cs | 2 +- 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index a577a3be..abec4db4 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -25,6 +25,7 @@ internal static class Il2CppICallInjector private static Type _il2CppDetourMethodPatcher; private static MethodInfo _generateNativeToManagedTrampoline; + private static bool _extendedDebug; private static MelonLogger.Instance _logger; internal static unsafe void Install() @@ -82,8 +83,24 @@ internal static void Shutdown() } } + private static void LogMsg(string msg) + => _logger.Msg(msg); private static void LogError(string msg) => _logger.Error(msg); + private static void LogDebugMsg(string msg) + { + if (!_extendedDebug + || !MelonDebug.IsEnabled()) + return; + _logger.Msg(msg); + } + private static void LogDebugWarning(string msg) + { + if (!_extendedDebug + || !MelonDebug.IsEnabled()) + return; + _logger.Warning(msg); + } private static IntPtr il2cpp_resolve_icall_Detour(IntPtr signature) { @@ -94,30 +111,41 @@ private static IntPtr il2cpp_resolve_icall_Detour(IntPtr signature) // Check Cache if (_lookup.TryGetValue(signatureStr, out var result)) + { + LogDebugMsg($"Resolved {signatureStr} to ICall in Cache"); return result.Item4; + } // Run Original IntPtr originalResult = il2cpp_resolve_icall_hook.Trampoline(signature); if (originalResult != IntPtr.Zero) { // Cache Original Result + LogDebugMsg($"Resolved {signatureStr} to Unity ICall"); _lookup[signatureStr] = (null, null, null, originalResult); return originalResult; } // Check if Injection is Needed if (!ShouldInject(signatureStr, out MethodInfo unityShimMethod)) + { + LogDebugWarning($"Unable to find suitable method to inject for {signatureStr}"); return IntPtr.Zero; + } // Create Injected Function and Cache Return + LogDebugMsg($"Generating Trampoline for {signatureStr}"); var pair = GenerateTrampoline(unityShimMethod); if (pair.Item4 == IntPtr.Zero) + { + LogDebugWarning($"Failed to generate trampoline for {signatureStr}"); return IntPtr.Zero; + } // Add New ICall to Il2Cpp Domain _lookup[signatureStr] = pair; il2cpp_add_internal_call(signature, pair.Item4); - _logger.Msg($"Registered mono icall {signatureStr} in il2cpp domain"); + LogMsg($"Registered mono icall {signatureStr} in il2cpp domain"); // Return New Function Pointer return pair.Item4; @@ -154,6 +182,7 @@ private static bool ShouldInject(string signature, out MethodInfo unityShimMetho // Split the Signature string[] split = signature.Split("::"); string typeName = split[0]; + string methodName = split[1]; // Find Managed Type Type newType = FindType(typeName); @@ -161,29 +190,49 @@ private static bool ShouldInject(string signature, out MethodInfo unityShimMetho return false; // Find Managed Method - string methodName = split[1]; - MethodInfo method = newType.FindMethod(methodName); - if (method == null) - return false; - - // Check for PInvoke to prevent Recursion - if (method.Attributes.HasFlag(MethodAttributes.PinvokeImpl)) - return false; - - // Check for Extern to prevent Recursion - var methodImpl = method.GetMethodImplementationFlags(); - if (methodImpl.HasFlag(MethodImplAttributes.InternalCall) - || methodImpl.HasFlag(MethodImplAttributes.Native) - || methodImpl.HasFlag(MethodImplAttributes.Unmanaged)) + MethodInfo targetMethod = null; + try + { + // Get All Methods + MethodInfo[] allMethods = newType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); + foreach (var method in allMethods) + { + // Validate Method + if ((method == null) + || (method.Name != methodName)) + continue; + + // Check for Generic Method since ICalls can't be Generic + if (method.IsGenericMethod) + continue; + + // Check for PInvoke to prevent Recursion + if (method.Attributes.HasFlag(MethodAttributes.PinvokeImpl)) + continue; + + // Check for Extern to prevent Recursion + var methodImpl = method.GetMethodImplementationFlags(); + if (methodImpl.HasFlag(MethodImplAttributes.InternalCall) + || methodImpl.HasFlag(MethodImplAttributes.Native) + || methodImpl.HasFlag(MethodImplAttributes.Unmanaged)) + continue; + + // Check if Method has no Body or just throws NotImplementedException + if (!method.HasMethodBody() + || method.IsNotImplemented()) + continue; + + // Found Shim + targetMethod = method; + break; + } + } + catch { return false; } + if (targetMethod == null) return false; - // Check if Method has no Body or just throws NotImplementedException - //if (!method.HasMethodBody() - // || method.IsNotImplemented()) - // return false; - // Inject ICall - unityShimMethod = method; + unityShimMethod = targetMethod; return true; } diff --git a/MelonLoader/MelonUtils.cs b/MelonLoader/MelonUtils.cs index c09313d2..dc16cc52 100644 --- a/MelonLoader/MelonUtils.cs +++ b/MelonLoader/MelonUtils.cs @@ -51,7 +51,7 @@ internal static void Setup(AppDomain domain) UnityInformationHandler.Setup(); CurrentGameAttribute = new MelonGameAttribute(UnityInformationHandler.GameDeveloper, UnityInformationHandler.GameName); - CurrentPlatform = IsGame32Bit() ? MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X86 : MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64; // Temporarily + CurrentPlatform = IsGame32Bit() ? MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X86 : MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64; CurrentDomain = IsGameIl2Cpp() ? MelonPlatformDomainAttribute.CompatibleDomains.IL2CPP : MelonPlatformDomainAttribute.CompatibleDomains.MONO; } From 34566854d2327a2a119d47a17c1c11ad7f150a0b Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 22 Oct 2024 18:12:04 -0600 Subject: [PATCH 25/41] Fixed an issue with Compatibility Layer loading not validating Names Checked --- .../CompatibilityLayers/MelonCompatibilityLayer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs b/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs index 0f380aa4..f9b62223 100644 --- a/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs +++ b/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs @@ -18,10 +18,15 @@ public static class MelonCompatibilityLayer private static void CheckGameLayerWithPlatform(string name, Func shouldBeIgnored) { + if (string.IsNullOrEmpty(name)) + return; + string nameNoSpaces = name.Replace(' ', '_'); foreach (var file in Directory.GetFiles(baseDirectory)) { string fileName = Path.GetFileNameWithoutExtension(file); + if (string.IsNullOrEmpty(fileName)) + continue; if (fileName.StartsWith(nameNoSpaces)) layers.Add(new MelonModule.Info(file, shouldBeIgnored)); } @@ -29,6 +34,9 @@ private static void CheckGameLayerWithPlatform(string name, Func shouldBeI private static void CheckGameLayer(string name) { + if (string.IsNullOrEmpty(name)) + return; + CheckGameLayerWithPlatform(name, () => false); CheckGameLayerWithPlatform($"{name}_Mono", () => MelonUtils.IsGameIl2Cpp()); CheckGameLayerWithPlatform($"{name}_Il2Cpp", () => !MelonUtils.IsGameIl2Cpp()); @@ -37,6 +45,9 @@ private static void CheckGameLayer(string name) if (spaceIndex > 0) { name = name.Substring(0, spaceIndex - 1); + if (string.IsNullOrEmpty(name)) + return; + CheckGameLayerWithPlatform(name, () => false); CheckGameLayerWithPlatform($"{name}_Mono", () => MelonUtils.IsGameIl2Cpp()); CheckGameLayerWithPlatform($"{name}_Il2Cpp", () => !MelonUtils.IsGameIl2Cpp()); From 1bac6b04360bcc20648099feff38ad0770b9fd50 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Sat, 26 Oct 2024 23:53:09 -0600 Subject: [PATCH 26/41] Fixed a race condition with Multi-Launching a Game and the Logger trying to delete old files --- MelonLoader/Utils/MelonLogger.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MelonLoader/Utils/MelonLogger.cs b/MelonLoader/Utils/MelonLogger.cs index 117a6937..365dc5fe 100644 --- a/MelonLoader/Utils/MelonLogger.cs +++ b/MelonLoader/Utils/MelonLogger.cs @@ -55,7 +55,12 @@ internal static void Setup() break; else { - File.Delete(pair.Item1); + // This is cursed but better than crashing + try + { + File.Delete(pair.Item1); + } + catch { } fileCount--; } } From 9f135c13c4260344277e5951f3900add25349423 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Sun, 27 Oct 2024 00:29:59 -0600 Subject: [PATCH 27/41] Fixed an issue with Disabled Melon Folders not being ignored during Melon Scanning --- MelonLoader/Melons/MelonFolderHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MelonLoader/Melons/MelonFolderHandler.cs b/MelonLoader/Melons/MelonFolderHandler.cs index 7215faf9..de455f0f 100644 --- a/MelonLoader/Melons/MelonFolderHandler.cs +++ b/MelonLoader/Melons/MelonFolderHandler.cs @@ -166,7 +166,7 @@ private static void ScanFolder(bool isMod, ref List userLibDirectories) { // Get Directories - string[] directories = Directory.GetDirectories(path, "*", SearchOption.AllDirectories); + string[] directories = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly); if ((directories == null) || (directories.Length <= 0)) return; @@ -189,6 +189,8 @@ private static void ScanFolder(bool isMod, userLibDirectories.Add(dir); else melonDirectories.Add(dir); + + ScanFolder(isMod, dir, userLibsOnly, ref melonDirectories, ref userLibDirectories); } } From bbce3a649b50fed23842169f213dba6ba661210c Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Mon, 4 Nov 2024 00:11:12 -0600 Subject: [PATCH 28/41] Reworked Melon Folder Scanning to be manifest json aware --- MelonLoader/Melons/MelonFolderHandler.cs | 80 +++++++++++++----------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/MelonLoader/Melons/MelonFolderHandler.cs b/MelonLoader/Melons/MelonFolderHandler.cs index de455f0f..9eeb86af 100644 --- a/MelonLoader/Melons/MelonFolderHandler.cs +++ b/MelonLoader/Melons/MelonFolderHandler.cs @@ -9,6 +9,13 @@ internal class MelonFolderHandler { private static bool firstSpacer = false; + internal enum eScanType + { + UserLibs, + Plugins, + Mods, + } + internal static void ScanUserLibs(string path) { // Get Full Directory Path @@ -22,7 +29,7 @@ internal static void ScanUserLibs(string path) // Parse Folders bool hasWroteLine = false; List melonAssemblies = new(); - ProcessFolder(false, path, true, ref hasWroteLine, ref melonAssemblies); + ProcessFolder(eScanType.UserLibs, path, ref hasWroteLine, ref melonAssemblies); } internal static void ScanMelons(string path) where T : MelonTypeBase @@ -40,7 +47,7 @@ internal static void ScanMelons(string path) where T : MelonTypeBase bool isMod = melonType == typeof(MelonMod); bool hasWroteLine = false; List melonAssemblies = new(); - ProcessFolder(isMod, path, false, ref hasWroteLine, ref melonAssemblies); + ProcessFolder(isMod ? eScanType.Mods : eScanType.Plugins, path, ref hasWroteLine, ref melonAssemblies); // Parse Queue var melons = new List(); @@ -118,9 +125,8 @@ private static void LoadFolder(string path, } } - private static void ProcessFolder(bool isMod, + private static void ProcessFolder(eScanType scanType, string path, - bool userLibsOnly, ref bool hasWroteLine, ref List melonAssemblies) { @@ -131,10 +137,10 @@ private static void ProcessFolder(bool isMod, // Scan Directories List melonDirectories = new(); List userLibDirectories = new(); - ScanFolder(isMod, path, userLibsOnly, ref melonDirectories, ref userLibDirectories); + ScanFolder(scanType, path, ref melonDirectories, ref userLibDirectories); // Add Base Path to End of Directories List - if (userLibsOnly) + if (scanType == eScanType.UserLibs) userLibDirectories.Add(path); else melonDirectories.Add(path); @@ -145,7 +151,7 @@ private static void ProcessFolder(bool isMod, MelonUtils.AddNativeDLLDirectory(directory); Resolver.MelonAssemblyResolver.AddSearchDirectory(directory); } - if (!userLibsOnly) + if (scanType != eScanType.UserLibs) foreach (string directory in melonDirectories) Resolver.MelonAssemblyResolver.AddSearchDirectory(directory); @@ -154,15 +160,14 @@ private static void ProcessFolder(bool isMod, LoadFolder(dir, false, ref hasWroteLine, ref melonAssemblies); // Load Melons from Folders - if (!userLibsOnly) + if (scanType != eScanType.UserLibs) foreach (var dir in melonDirectories) LoadFolder(dir, true, ref hasWroteLine, ref melonAssemblies); } - private static void ScanFolder(bool isMod, + private static void ScanFolder(eScanType scanType, string path, - bool userLibsOnly, - ref List melonDirectories, + ref List melonDirectories, ref List userLibDirectories) { // Get Directories @@ -175,40 +180,39 @@ private static void ScanFolder(bool isMod, foreach (var dir in directories) { // Validate Path - if (!Directory.Exists(dir) - || userLibDirectories.Contains(dir) - || melonDirectories.Contains(dir)) + if (!Directory.Exists(dir)) continue; - // Validate Folder - if (IsDisabledFolder(dir, out string dirNameLower)) + // Validate Manifest + string manifestPath = Path.Combine(dir, "manifest.json"); + if (!File.Exists(manifestPath)) continue; - // Check for UserLibs - if (userLibsOnly || IsUserLibsFolder(dirNameLower)) - userLibDirectories.Add(dir); + // Check for Deeper UserLibs + string userLibsPath = Path.Combine(dir, "UserLibs"); + if (Directory.Exists(userLibsPath)) + { + userLibDirectories.Add(userLibsPath); + ScanFolder(eScanType.UserLibs, userLibsPath, ref melonDirectories, ref userLibDirectories); + } + + // Is UserLibs Scan? + if (scanType == eScanType.UserLibs) + userLibDirectories.Add(dir); // Add to Directories List else - melonDirectories.Add(dir); + { + // Check for Deeper Melon Folder + string melonPath = Path.Combine(dir, (scanType == eScanType.Plugins) ? "Plugins" : "Mods"); + if (Directory.Exists(melonPath)) + { + melonDirectories.Add(melonPath); + ScanFolder(scanType, melonPath, ref melonDirectories, ref userLibDirectories); + } - ScanFolder(isMod, dir, userLibsOnly, ref melonDirectories, ref userLibDirectories); + // Add to Directories List + melonDirectories.Add(dir); + } } } - - private static bool StartsOrEndsWith(string dirNameLower, string target) - => dirNameLower.StartsWith(target) - || dirNameLower.EndsWith(target); - - private static bool IsUserLibsFolder(string dirNameLower) - => StartsOrEndsWith(dirNameLower, "userlibs"); - - private static bool IsDisabledFolder(string path, - out string dirNameLower) - { - string dirName = new DirectoryInfo(path).Name; - dirNameLower = dirName.ToLowerInvariant(); - return StartsOrEndsWith(dirNameLower, "disabled") - || StartsOrEndsWith(dirNameLower, "old") - || StartsOrEndsWith(dirNameLower, "~"); - } } } \ No newline at end of file From 41ed9419a99df74a1452fcdecb9265ffdf9b57fe Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Mon, 4 Nov 2024 02:42:00 -0600 Subject: [PATCH 29/41] Implemented Melon Preprocessor to prevent Loading Duplicates --- MelonLoader/Melons/MelonFolderHandler.cs | 41 +--------- MelonLoader/Melons/MelonPreprocessor.cs | 95 ++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 39 deletions(-) create mode 100644 MelonLoader/Melons/MelonPreprocessor.cs diff --git a/MelonLoader/Melons/MelonFolderHandler.cs b/MelonLoader/Melons/MelonFolderHandler.cs index 9eeb86af..44213d08 100644 --- a/MelonLoader/Melons/MelonFolderHandler.cs +++ b/MelonLoader/Melons/MelonFolderHandler.cs @@ -90,41 +90,6 @@ internal static void ScanMelons(string path) where T : MelonTypeBase firstSpacer = true; } - private static void LoadFolder(string path, - bool addToList, - ref bool hasWroteLine, - ref List melonAssemblies) - { - // Validate Path - if (!Directory.Exists(path)) - return; - - // Get DLLs in Directory - var files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); - foreach (var f in files) - { - // Ignore Native DLLs - if (!MelonUtils.IsManagedDLL(f)) - continue; - - // Log - if (!hasWroteLine) - { - hasWroteLine = true; - MelonLogger.WriteLine(Color.Magenta); - } - - // Load Assembly - var asm = MelonAssembly.LoadMelonAssembly(f, false); - if (asm == null) - continue; - - // Queue Assembly for Melon Parsing - if (addToList) - melonAssemblies.Add(asm); - } - } - private static void ProcessFolder(eScanType scanType, string path, ref bool hasWroteLine, @@ -156,13 +121,11 @@ private static void ProcessFolder(eScanType scanType, Resolver.MelonAssemblyResolver.AddSearchDirectory(directory); // Load UserLibs - foreach (var dir in userLibDirectories) - LoadFolder(dir, false, ref hasWroteLine, ref melonAssemblies); + MelonPreprocessor.LoadFolders(userLibDirectories, false, ref hasWroteLine, ref melonAssemblies); // Load Melons from Folders if (scanType != eScanType.UserLibs) - foreach (var dir in melonDirectories) - LoadFolder(dir, true, ref hasWroteLine, ref melonAssemblies); + MelonPreprocessor.LoadFolders(melonDirectories, true, ref hasWroteLine, ref melonAssemblies); } private static void ScanFolder(eScanType scanType, diff --git a/MelonLoader/Melons/MelonPreprocessor.cs b/MelonLoader/Melons/MelonPreprocessor.cs new file mode 100644 index 00000000..95097170 --- /dev/null +++ b/MelonLoader/Melons/MelonPreprocessor.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using Mono.Cecil; + +namespace MelonLoader.Melons +{ + internal static class MelonPreprocessor + { + internal static void LoadFolders(List directoryPaths, + bool isMelon, + ref bool hasWroteLine, + ref List melonAssemblies) + { + // Find All Assemblies + Dictionary foundAssemblies = new(); + foreach (string path in directoryPaths) + PreprocessFolder(path, isMelon, ref foundAssemblies); + + // Load from File Paths + foreach (var foundFile in foundAssemblies) + { + // Log + if (!hasWroteLine) + { + hasWroteLine = true; + MelonLogger.WriteLine(Color.Magenta); + } + + // Load Assembly + var asm = MelonAssembly.LoadMelonAssembly(foundFile.Value.Item2, false); + if (asm == null) + continue; + + // Queue Assembly for Melon Parsing + if (isMelon) + melonAssemblies.Add(asm); + } + } + + private static void PreprocessFolder(string path, + bool isMelon, + ref Dictionary foundAssemblies) + { + // Validate Path + if (!Directory.Exists(path)) + return; + + // Get DLLs in Directory + var files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); + foreach (var f in files) + { + // Ignore Native DLLs + if (!MelonUtils.IsManagedDLL(f)) + continue; + + // Load Definition using Cecil + AssemblyDefinition asmDef = LoadDefinition(f); + if (asmDef == null) + continue; + + // Pull Name and Version from AssemblyDefinitionName + string name = $"{asmDef.Name.Name}"; + Version version = new(asmDef.Name.Version.ToString()); + + // Dispose of Definition + asmDef.Dispose(); + + // Check for Existing Version + if (foundAssemblies.TryGetValue(name, out (Version, string) existingVersion) + && (existingVersion.Item1 >= version)) + continue; + + // Add File to List + foundAssemblies[name] = (version, f); + } + } + + private static AssemblyDefinition LoadDefinition(string path) + { + path = Path.GetFullPath(path); + + try + { + return AssemblyDefinition.ReadAssembly(path); + } + catch (Exception ex) + { + MelonLogger.Error($"Failed to load AssemblyDefinition from '{path}':\n{ex}"); + return null; + } + } + } +} From 2a784d2634ca8ee400d365cb7fa65f3c01fb2c28 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Mon, 4 Nov 2024 06:35:50 -0600 Subject: [PATCH 30/41] Fixed an issue with Type Load spamming errors when failing to resolve a Dependency --- MelonLoader/MelonUtils.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MelonLoader/MelonUtils.cs b/MelonLoader/MelonUtils.cs index dc16cc52..69cad429 100644 --- a/MelonLoader/MelonUtils.cs +++ b/MelonLoader/MelonUtils.cs @@ -303,8 +303,7 @@ public static IEnumerable GetValidTypes(this Assembly asm, LemonFunc Date: Mon, 4 Nov 2024 06:38:04 -0600 Subject: [PATCH 31/41] Cleanup --- MelonLoader/InternalUtils/DependencyGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MelonLoader/InternalUtils/DependencyGraph.cs b/MelonLoader/InternalUtils/DependencyGraph.cs index 546fbdba..8c232ef9 100644 --- a/MelonLoader/InternalUtils/DependencyGraph.cs +++ b/MelonLoader/InternalUtils/DependencyGraph.cs @@ -179,7 +179,7 @@ private static string BuildMissingDependencyMessage(IDictionary Date: Tue, 5 Nov 2024 03:05:07 -0600 Subject: [PATCH 32/41] Reworked Launch Option Parsing to ignore First Element --- MelonLoader/MelonLaunchOptions.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MelonLoader/MelonLaunchOptions.cs b/MelonLoader/MelonLaunchOptions.cs index d10efc6d..1e1340ee 100644 --- a/MelonLoader/MelonLaunchOptions.cs +++ b/MelonLoader/MelonLaunchOptions.cs @@ -42,10 +42,11 @@ static MelonLaunchOptions() internal static void Load() { - LemonEnumerator argEnumerator = new LemonEnumerator(CommandLineArgs); - while (argEnumerator.MoveNext()) + string[] args = CommandLineArgs; + int maxLen = args.Length; + for (int i = 1; i < maxLen; i++) { - string fullcmd = argEnumerator.Current; + string fullcmd = args[i]; if (string.IsNullOrEmpty(fullcmd)) continue; @@ -79,7 +80,7 @@ internal static void Load() cmdArg = split[1]; } if ((string.IsNullOrEmpty(cmdArg) - && !argEnumerator.Peek(out cmdArg)) + && ((i + 1) > (maxLen - 1))) || string.IsNullOrEmpty(cmdArg) || !cmdArg.StartsWith("--") || !cmdArg.StartsWith("-")) From a1b3d8e5741f2f24fa91c7976b01df3b03558f5b Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 03:12:46 -0600 Subject: [PATCH 33/41] Fixed an issue with Launch Option Parsing ignoring Argument Values --- MelonLoader/MelonLaunchOptions.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MelonLoader/MelonLaunchOptions.cs b/MelonLoader/MelonLaunchOptions.cs index 1e1340ee..7b784471 100644 --- a/MelonLoader/MelonLaunchOptions.cs +++ b/MelonLoader/MelonLaunchOptions.cs @@ -79,11 +79,12 @@ internal static void Load() noPrefixCmd = split[0]; cmdArg = split[1]; } + if ((string.IsNullOrEmpty(cmdArg) - && ((i + 1) > (maxLen - 1))) + && ((i + 1) >= maxLen)) || string.IsNullOrEmpty(cmdArg) - || !cmdArg.StartsWith("--") - || !cmdArg.StartsWith("-")) + || cmdArg.StartsWith("--") + || cmdArg.StartsWith("-")) { // Unknown Command, Add it to Dictionary ExternalArguments.Add(noPrefixCmd, null); From 6ba897e5302172e7fd4ac988da2c2db9170bd9a9 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 03:42:11 -0600 Subject: [PATCH 34/41] Cleanup --- MelonLoader/Fixes/Il2CppICallInjector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index abec4db4..d05ed611 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -62,7 +62,7 @@ internal static unsafe void Install() } catch (Exception e) { - LogError(e.ToString()); + LogDebugWarning(e.ToString()); } } From 2d08f761e904fe67a9be145dcc524f31e116a2b6 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 10:29:41 -0600 Subject: [PATCH 35/41] Updated NuGet Packages --- .../Il2CppAssemblyGenerator.csproj | 2 +- .../SupportModules/Il2Cpp/Il2Cpp.csproj | 17 ++++++----------- MelonLoader/MelonLoader.csproj | 9 ++++----- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj b/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj index e1f9c4b5..b7c19523 100644 --- a/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj +++ b/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj @@ -16,7 +16,7 @@ - + \ No newline at end of file diff --git a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj index f708b4b5..b661db0f 100644 --- a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj +++ b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj @@ -35,18 +35,13 @@ - + - - - - - + + + + + diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index eca46a1d..356f13a6 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -47,12 +47,11 @@ - - - + + + - + From 7f858935d2848a8d07b90c597a8738fe27ac5b93 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 10:35:41 -0600 Subject: [PATCH 36/41] Fixed Package Dependency --- MelonLoader/MelonLoader.csproj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index 356f13a6..0dd42675 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -43,6 +43,10 @@ + + + + @@ -50,14 +54,13 @@ + - - - + From 9ec682e415f7a182f29cbea0aadd58f37e9564e3 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 11:13:45 -0600 Subject: [PATCH 37/41] Cleanup Assembly Resolver --- MelonLoader/Resolver/MelonAssemblyResolver.cs | 89 ++++++++++++------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/MelonLoader/Resolver/MelonAssemblyResolver.cs b/MelonLoader/Resolver/MelonAssemblyResolver.cs index d4062503..1840ae23 100644 --- a/MelonLoader/Resolver/MelonAssemblyResolver.cs +++ b/MelonLoader/Resolver/MelonAssemblyResolver.cs @@ -19,62 +19,83 @@ internal static void Setup() return; // Setup Search Directories - string[] searchdirlist = - { + AddSearchDirectories( MelonEnvironment.UserLibsDirectory, MelonEnvironment.PluginsDirectory, MelonEnvironment.ModsDirectory, - MelonEnvironment.MelonBaseDirectory, - MelonEnvironment.GameRootDirectory, + (MelonUtils.IsGameIl2Cpp() + ? MelonEnvironment.Il2CppAssembliesDirectory + : MelonEnvironment.UnityGameManagedDirectory), MelonEnvironment.OurRuntimeDirectory, - MelonEnvironment.Il2CppAssembliesDirectory, - MelonEnvironment.UnityGameManagedDirectory, - }; - foreach (string path in searchdirlist) - AddSearchDirectory(path); - - ForceResolveRuntime("Mono.Cecil.dll"); - ForceResolveRuntime("MonoMod.exe"); - ForceResolveRuntime("MonoMod.Utils.dll"); - ForceResolveRuntime("MonoMod.RuntimeDetour.dll"); + MelonEnvironment.GameRootDirectory); // Setup Redirections - string[] assembly_list = - { - "MelonLoader", - "MelonLoader.ModHandler", - }; - Assembly base_assembly = typeof(MelonAssemblyResolver).Assembly; - foreach (string assemblyName in assembly_list) - GetAssemblyResolveInfo(assemblyName).Override = base_assembly; + OverrideBaseAssembly(); + + // Resolve Default Runtime Assemblies + ForceResolveRuntime( + "Mono.Cecil.dll", + "MonoMod.exe", + "MonoMod.Utils.dll", + "MonoMod.RuntimeDetour.dll"); MelonDebug.Msg("[MelonAssemblyResolver] Setup Successful!"); } - private static void ForceResolveRuntime(string fileName) + private static void OverrideBaseAssembly() { - string filePath = Path.Combine(MelonEnvironment.OurRuntimeDirectory, fileName); - if (!File.Exists(filePath)) - return; + Assembly base_assembly = typeof(MelonAssemblyResolver).Assembly; + GetAssemblyResolveInfo(base_assembly.GetName().Name).Override = base_assembly; + GetAssemblyResolveInfo("MelonLoader").Override = base_assembly; + GetAssemblyResolveInfo("MelonLoader.ModHandler").Override = base_assembly; + } - Assembly assembly = null; - try + private static void ForceResolveRuntime(params string[] fileNames) + { + foreach (string fileName in fileNames) { + string filePath = Path.Combine(MelonEnvironment.OurRuntimeDirectory, fileName); + if (!File.Exists(filePath)) + return; + + Assembly assembly = null; + try + { #if NET6_0_OR_GREATER - assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(filePath); + assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(filePath); #else assembly = Assembly.LoadFrom(filePath); #endif - } - catch { assembly = null; } + } + catch { assembly = null; } - if (assembly == null) - return; + if (assembly == null) + return; - GetAssemblyResolveInfo(Path.GetFileNameWithoutExtension(fileName)).Override = assembly; + GetAssemblyResolveInfo(Path.GetFileNameWithoutExtension(fileName)).Override = assembly; + } } // Search Directories + + public static void AddSearchDirectories(params string[] directories) + { + foreach (string directory in directories) + AddSearchDirectory(directory); + } + + public static void AddSearchDirectories(int priority, params string[] directories) + { + foreach (string directory in directories) + AddSearchDirectory(directory, priority); + } + + public static void AddSearchDirectories(params (string, int)[] directories) + { + foreach (var pair in directories) + AddSearchDirectory(pair.Item1, pair.Item2); + } + public static void AddSearchDirectory(string path, int priority = 0) => SearchDirectoryManager.Add(path, priority); public static void RemoveSearchDirectory(string path) From c31fd05f84b1434a283c231d74fee71a2c02d682 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 11:31:04 -0600 Subject: [PATCH 38/41] Fixed an issue with Preload Support Module attempting to resolve its own NetStandardPatches folder during compilation --- .github/workflows/build.yml | 12 ++++++++++++ .../NetStandardPatches/System.Core.dll | Bin .../NetStandardPatches/System.Drawing.dll | Bin .../NetStandardPatches/System.dll | Bin MelonLoader/Fixes/Il2CppICallInjector.cs | 2 ++ MelonLoader/MelonUtils.cs | 8 ++++++-- 6 files changed, 20 insertions(+), 2 deletions(-) rename {Dependencies/SupportModules/Preload => BaseLibs}/NetStandardPatches/System.Core.dll (100%) rename {Dependencies/SupportModules/Preload => BaseLibs}/NetStandardPatches/System.Drawing.dll (100%) rename {Dependencies/SupportModules/Preload => BaseLibs}/NetStandardPatches/System.dll (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e42c8359..937ad2ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -194,6 +194,8 @@ jobs: cp -r BaseLibs/Mono Output/Debug/x64/MelonLoader/Dependencies/ cp -r BaseLibs/net35 Output/Debug/x64/MelonLoader/ cp -r BaseLibs/net6 Output/Debug/x64/MelonLoader/ + mkdir -p Output/Debug/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches + cp -r BaseLibs/NetStandardPatches Output/Debug/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying Dobby x64... cp BaseLibs/dobby_x64.dll Output/Debug/x64/MelonLoader/Dependencies/dobby.dll @@ -234,6 +236,8 @@ jobs: cp -r BaseLibs/Mono Output/Release/x64/MelonLoader/Dependencies/ cp -r BaseLibs/net35 Output/Release/x64/MelonLoader/ cp -r BaseLibs/net6 Output/Release/x64/MelonLoader/ + mkdir -p Output/Release/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches + cp -r BaseLibs/NetStandardPatches Output/Release/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying Dobby x64... cp BaseLibs/dobby_x64.dll Output/Release/x64/MelonLoader/Dependencies/dobby.dll @@ -269,6 +273,8 @@ jobs: cp -r BaseLibs/Mono Output/Debug/x86/MelonLoader/Dependencies/ cp -r BaseLibs/net35 Output/Debug/x86/MelonLoader/ cp -r BaseLibs/net6 Output/Debug/x86/MelonLoader/ + mkdir -p Output/Debug/x86/MelonLoader/Dependencies/SupportModules/NetStandardPatches + cp -r BaseLibs/NetStandardPatches Output/Debug/x86/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying Dobby x86... cp BaseLibs/dobby_x86.dll Output/Debug/x86/MelonLoader/Dependencies/dobby.dll @@ -304,6 +310,8 @@ jobs: cp -r BaseLibs/Mono Output/Release/x86/MelonLoader/Dependencies/ cp -r BaseLibs/net35 Output/Release/x86/MelonLoader/ cp -r BaseLibs/net6 Output/Release/x86/MelonLoader/ + mkdir -p Output/Release/x86/MelonLoader/Dependencies/SupportModules/NetStandardPatches + cp -r BaseLibs/NetStandardPatches Output/Release/x86/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying Dobby x86... cp BaseLibs/dobby_x86.dll Output/Release/x86/MelonLoader/Dependencies/dobby.dll @@ -349,6 +357,8 @@ jobs: cp -r BaseLibs/Mono Output/Debug/x64/MelonLoader/Dependencies/ cp -r BaseLibs/net35 Output/Debug/x64/MelonLoader/ cp -r BaseLibs/net6 Output/Debug/x64/MelonLoader/ + mkdir -p Output/Debug/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches + cp -r BaseLibs/NetStandardPatches Output/Debug/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying documentation files... cp NOTICE.txt Output/Debug/x64 @@ -384,6 +394,8 @@ jobs: cp -r BaseLibs/Mono Output/Release/x64/MelonLoader/Dependencies/ cp -r BaseLibs/net35 Output/Release/x64/MelonLoader/ cp -r BaseLibs/net6 Output/Release/x64/MelonLoader/ + mkdir -p Output/Release/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches + cp -r BaseLibs/NetStandardPatches Output/Release/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying documentation files... cp NOTICE.txt Output/Release/x64/ diff --git a/Dependencies/SupportModules/Preload/NetStandardPatches/System.Core.dll b/BaseLibs/NetStandardPatches/System.Core.dll similarity index 100% rename from Dependencies/SupportModules/Preload/NetStandardPatches/System.Core.dll rename to BaseLibs/NetStandardPatches/System.Core.dll diff --git a/Dependencies/SupportModules/Preload/NetStandardPatches/System.Drawing.dll b/BaseLibs/NetStandardPatches/System.Drawing.dll similarity index 100% rename from Dependencies/SupportModules/Preload/NetStandardPatches/System.Drawing.dll rename to BaseLibs/NetStandardPatches/System.Drawing.dll diff --git a/Dependencies/SupportModules/Preload/NetStandardPatches/System.dll b/BaseLibs/NetStandardPatches/System.dll similarity index 100% rename from Dependencies/SupportModules/Preload/NetStandardPatches/System.dll rename to BaseLibs/NetStandardPatches/System.dll diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index d05ed611..7c4e00a4 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -10,6 +10,8 @@ using Il2CppInterop.HarmonySupport; using HarmonyLib; +#pragma warning disable 0649 + namespace MelonLoader.Fixes { internal static class Il2CppICallInjector diff --git a/MelonLoader/MelonUtils.cs b/MelonLoader/MelonUtils.cs index 69cad429..281a33ce 100644 --- a/MelonLoader/MelonUtils.cs +++ b/MelonLoader/MelonUtils.cs @@ -306,7 +306,11 @@ public static IEnumerable GetValidTypes(this Assembly asm, LemonFunc (x != null) && (predicate == null || predicate(x))); } @@ -317,7 +321,7 @@ public static Type GetValidType(this Assembly asm, string typeName, LemonFunc Date: Tue, 5 Nov 2024 11:36:21 -0600 Subject: [PATCH 39/41] Reverted AssetTools.NET to 3.0.0-preview3 --- MelonLoader/MelonLoader.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index 0dd42675..8abca360 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -36,7 +36,7 @@ - + From 07faaa5e53cdf5373898c9acbaf83f97419a5e16 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 12:09:06 -0600 Subject: [PATCH 40/41] Update CHANGELOG.md --- CHANGELOG.md | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da8e3655..39a24557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,25 +41,36 @@ ### v0.6.6 1. Updated Il2CppInterop to 1.4.6-ci.579 -2. Implemented a RegisterTypeInIl2CppWithInterfaces attribute -3. Implemented Recursive Melon Folders with extended UserLib Resolving -4. Reimplemented NetFramework Variant of Cpp2IL as fallback -5. Standardized Assembly Searching and Resolving to work on both Mono and Il2Cpp Games -6. Temporarily removed Start Screen for being broken in most cases -7. Modified Command-Line Argument Logging to show Internal Arguments Only -8. Added UserLibs folders to Native Library Search Directories -9. Moved `dobby.dll` to `MelonLoader\Dependencies` -10. Moved Assembly Resolver Related Classes to `MelonLoader.Resolver` Namespace -11. Moved `MonoLibrary` class to `MelonLoader.Utils` Namespace -12. Removed Useless TODO Warning from Il2CppAssemblyGenerator -13. Removed EOS Compatibility Layer for being Unneeded -14. Fixed Regression with LemonMD5, LemonSHA256, and LemonSHA512 -15. Fixed an issue with older Cpp2IL versions causing a download failure -16. Fixed an issue with Il2CppInterop not properly logging Trampoline Exceptions -17. Fixed an issue with Il2Cpp Class Injection Attributes causing exceptions to be thrown on Mono games -18. Fixed an issue with the Bootstrap not reading `--melonloader.basedir` correctly -19. Fixed an issue with Loading `dobby.dll` in some rare cases -20. Fixed an issue with Compatibility Layers getting Garbage Collected while still in use +2. Reverted AssetTools.NET to 3.0.0-preview3 +3. Implemented a RegisterTypeInIl2CppWithInterfaces attribute +4. Implemented Recursive Melon Folders with extended UserLib Resolving +5. Implemented Melon Preprocessor to prevent Loading Duplicates +6. Reimplemented NetFramework Variant of Cpp2IL as fallback +7. Standardized Assembly Searching and Resolving to work on both Mono and Il2Cpp Games +8. Temporarily removed Start Screen for being broken in most cases +9. Modified Command-Line Argument Logging to show Internal Arguments Only +10. Reworked Il2CppICallInjector to use Il2CppInterop's Native to Manage trampoline generation +11. Reworked Launch Option Parsing to ignore First Element +12. Added UserLibs folders to Native Library Search Directories +13. Moved `dobby.dll` to `MelonLoader\Dependencies` +14. Moved Assembly Resolver Related Classes to `MelonLoader.Resolver` Namespace +15. Moved `MonoLibrary` class to `MelonLoader.Utils` Namespace +16. Moved dobby scan to check Game Directory after Base Directory +17. Removed Useless TODO Warning from Il2CppAssemblyGenerator +18. Removed EOS Compatibility Layer for being Unneeded +19. Fixed Regression with LemonMD5, LemonSHA256, and LemonSHA512 +20. Fixed an issue with older Cpp2IL versions causing a download failure +21. Fixed an issue with Il2CppInterop not properly logging Trampoline Exceptions +22. Fixed an issue with Il2Cpp Class Injection Attributes causing exceptions to be thrown on Mono games +23. Fixed an issue with the Bootstrap not reading `--melonloader.basedir` correctly +24. Fixed an issue with Loading `dobby.dll` in some rare cases +25. Fixed an issue with Compatibility Layers getting Garbage Collected while still in use +26. Fixed an issue with Linux Proxy failing to find dobby +27. Fixed an issue with trying to load Managed Assemblies from Native Libraries inside UserLibs +28. Fixed an issue with Compatibility Layer loading not validating Names Checked +29. Fixed an issue with Type Load spamming errors when failing to resolve a Dependency +30. Fixed an issue with Launch Option Parsing ignoring Argument Values +31. Fixed a race condition crash with Multi-Launching a Game and the Logger trying to delete old files --- From 8620acd8e9d9904d074661b689b4b56e3f3a8af8 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Tue, 5 Nov 2024 15:38:59 -0600 Subject: [PATCH 41/41] Removed extra NOTICE.txt from packages --- .github/workflows/build.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 937ad2ae..00aa44c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -201,7 +201,6 @@ jobs: cp BaseLibs/dobby_x64.dll Output/Debug/x64/MelonLoader/Dependencies/dobby.dll echo echo Copying documentation files... - cp NOTICE.txt Output/Debug/x64/ mkdir -p Output/Debug/x64/MelonLoader/Documentation cp CHANGELOG.md Output/Debug/x64/MelonLoader/Documentation/ cp LICENSE.md Output/Debug/x64/MelonLoader/Documentation/ @@ -243,7 +242,6 @@ jobs: cp BaseLibs/dobby_x64.dll Output/Release/x64/MelonLoader/Dependencies/dobby.dll echo echo Copying documentation files... - cp NOTICE.txt Output/Release/x64/ mkdir -p Output/Release/x64/MelonLoader/Documentation cp CHANGELOG.md Output/Release/x64/MelonLoader/Documentation/ cp LICENSE.md Output/Release/x64/MelonLoader/Documentation/ @@ -280,7 +278,6 @@ jobs: cp BaseLibs/dobby_x86.dll Output/Debug/x86/MelonLoader/Dependencies/dobby.dll echo echo Copying documentation files... - cp NOTICE.txt Output/Debug/x86/ mkdir -p Output/Debug/x86/MelonLoader/Documentation cp CHANGELOG.md Output/Debug/x86/MelonLoader/Documentation/ cp LICENSE.md Output/Debug/x86/MelonLoader/Documentation/ @@ -317,7 +314,6 @@ jobs: cp BaseLibs/dobby_x86.dll Output/Release/x86/MelonLoader/Dependencies/dobby.dll echo echo Copying documentation files... - cp NOTICE.txt Output/Release/x86/ mkdir -p Output/Release/x86/MelonLoader/Documentation cp CHANGELOG.md Output/Release/x86/MelonLoader/Documentation/ cp LICENSE.md Output/Release/x86/MelonLoader/Documentation/ @@ -361,7 +357,6 @@ jobs: cp -r BaseLibs/NetStandardPatches Output/Debug/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying documentation files... - cp NOTICE.txt Output/Debug/x64 mkdir -p Output/Debug/x64/MelonLoader/Documentation cp CHANGELOG.md Output/Debug/x64/MelonLoader/Documentation/ cp LICENSE.md Output/Debug/x64/MelonLoader/Documentation/ @@ -398,7 +393,6 @@ jobs: cp -r BaseLibs/NetStandardPatches Output/Release/x64/MelonLoader/Dependencies/SupportModules/NetStandardPatches echo echo Copying documentation files... - cp NOTICE.txt Output/Release/x64/ mkdir -p Output/Release/x64/MelonLoader/Documentation cp CHANGELOG.md Output/Release/x64/MelonLoader/Documentation/ cp LICENSE.md Output/Release/x64/MelonLoader/Documentation/