Skip to content

Commit

Permalink
Extended Mono and Il2Cpp Loading to its own Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
HerpDerpinstine committed Dec 5, 2023
1 parent 4b1a698 commit 6f3af42
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 36 deletions.
14 changes: 14 additions & 0 deletions MelonLoader/MelonLoader.Mono/MelonLoader.Mono.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>MelonLoader.Mono</RootNamespace>
<TargetFramework>net6</TargetFramework>
<LangVersion>Latest</LangVersion>
<OutputPath>$(SolutionDir)Output\$(Configuration)\MelonLoader\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MelonLoader.Bootstrap\MelonLoader.Bootstrap.csproj" Private="false" ExcludeAssets="runtime" />
<ProjectReference Include="..\MelonLoader.Shared\MelonLoader.Shared.csproj" Private="false" ExcludeAssets="runtime" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using MelonLoader.Bootstrap;
using MelonLoader.Shared.NativeUtils;
using MelonLoader.Shared.Utils;
#pragma warning disable 0649

namespace MelonLoader.Unity.Mono
namespace MelonLoader.Mono
{
internal unsafe static class BootstrapMono
public unsafe static class MonoLoader
{
#region Private Members

Expand All @@ -24,7 +20,7 @@ internal unsafe static class BootstrapMono

#region Bootstrap

internal unsafe static void Startup(MonoRuntimeInfo runtimeInfo)
public unsafe static void Startup(MonoRuntimeInfo runtimeInfo)
{
// Apply the information
monoRuntimeInfo = runtimeInfo;
Expand All @@ -33,14 +29,10 @@ internal unsafe static void Startup(MonoRuntimeInfo runtimeInfo)
if (monoRuntimeInfo == null
|| string.IsNullOrEmpty(monoRuntimeInfo.FilePath))
{
Assertion.ThrowInternalFailure($"Failed to find Mono or MonoBleedingEdge Library!");
Assertion.ThrowInternalFailure($"Failed to find {runtimeInfo.Variant} Library!");
return;
}


// Log Engine Variant
MelonLogger.Msg($"Engine Variant: {monoRuntimeInfo.Variant}");

// Check if there is a Posix Helper included with the Mono variant library
if (!string.IsNullOrEmpty(monoRuntimeInfo.PosixPath))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace MelonLoader.Unity.Mono
namespace MelonLoader.Mono
{
public class MonoRuntimeInfo
{
Expand Down
13 changes: 13 additions & 0 deletions MelonLoader/MelonLoader.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Godot.Bootstrap", "Modules\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Unity.Bootstrap", "Modules\Unity\Unity.Bootstrap\Unity.Bootstrap.csproj", "{75F7B154-10E0-484F-A463-16376FFA5553}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MelonLoader.Mono", "MelonLoader.Mono\MelonLoader.Mono.csproj", "{712BC5B3-766A-4B44-9BF4-1012BE63D6F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Unity.Il2Cpp", "Modules\Unity\Unity.Il2Cpp\Unity.Il2Cpp.csproj", "{9EBD236C-42FC-4E98-8388-E763BA46FD10}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +49,14 @@ Global
{75F7B154-10E0-484F-A463-16376FFA5553}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75F7B154-10E0-484F-A463-16376FFA5553}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75F7B154-10E0-484F-A463-16376FFA5553}.Release|Any CPU.Build.0 = Release|Any CPU
{712BC5B3-766A-4B44-9BF4-1012BE63D6F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{712BC5B3-766A-4B44-9BF4-1012BE63D6F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{712BC5B3-766A-4B44-9BF4-1012BE63D6F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{712BC5B3-766A-4B44-9BF4-1012BE63D6F6}.Release|Any CPU.Build.0 = Release|Any CPU
{9EBD236C-42FC-4E98-8388-E763BA46FD10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EBD236C-42FC-4E98-8388-E763BA46FD10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EBD236C-42FC-4E98-8388-E763BA46FD10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EBD236C-42FC-4E98-8388-E763BA46FD10}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -54,6 +66,7 @@ Global
{3E7F5C09-221B-4492-9BA0-2D1ED9BEC58C} = {716CE800-E309-4104-ACA3-867BB8BF4FB0}
{483E5B56-7308-4DAD-BF90-B27DC97116D0} = {A5293DFE-1E8A-4933-B3D6-F8B06D995A23}
{75F7B154-10E0-484F-A463-16376FFA5553} = {3E7F5C09-221B-4492-9BA0-2D1ED9BEC58C}
{9EBD236C-42FC-4E98-8388-E763BA46FD10} = {3E7F5C09-221B-4492-9BA0-2D1ED9BEC58C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4490CB48-16CD-4D0A-858D-1484CB9DED02}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
<RootNamespace>MelonLoader.Godot</RootNamespace>
<TargetFramework>net6</TargetFramework>
<LangVersion>Latest</LangVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)Output\$(Configuration)\MelonLoader\Modules\Godot\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>embedded</DebugType>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\MelonLoader.Shared\MelonLoader.Shared.csproj" Private="false" ExcludeAssets="runtime"/>
Expand Down
17 changes: 14 additions & 3 deletions MelonLoader/Modules/Unity/Unity.Bootstrap/Bootstrap.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.IO;
using MelonLoader.Mono;
using MelonLoader.Shared.Interfaces;
using MelonLoader.Shared.Utils;
using MelonLoader.Unity.Il2Cpp;

namespace MelonLoader.Unity
{
Expand Down Expand Up @@ -40,12 +42,21 @@ public void Startup()
// Check if GameAssembly exists
string gameAssemblyPath = Path.Combine(MelonEnvironment.GameRootDirectory, gameAssemblyName);
if (File.Exists(gameAssemblyPath))
Il2Cpp.BootstrapIl2Cpp.Startup(gameAssemblyPath); // Start Il2Cpp Support
{
// Start Il2Cpp Support
MelonLogger.Msg("Engine Variant: Il2Cpp");
Il2CppLoader.Startup(gameAssemblyPath);
}
else
Mono.BootstrapMono.Startup(GetMonoRuntimeInfo()); // Start Mono Support
{
// Start Mono Support
MonoRuntimeInfo runtimeInfo = GetMonoRuntimeInfo();
MelonLogger.Msg($"Engine Variant: {runtimeInfo.Variant}");
MonoLoader.Startup(runtimeInfo);
}
}

internal static Mono.MonoRuntimeInfo GetMonoRuntimeInfo()
internal static MonoRuntimeInfo GetMonoRuntimeInfo()
{
// Folders the Mono folders might be located in
string[] directoriesToSearch = new string[]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
<RootNamespace>MelonLoader.Unity</RootNamespace>
<TargetFramework>net6</TargetFramework>
<LangVersion>Latest</LangVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)Output\$(Configuration)\MelonLoader\Modules\Unity\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>embedded</DebugType>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\MelonLoader.Bootstrap\MelonLoader.Bootstrap.csproj" Private="false" ExcludeAssets="runtime" />
<ProjectReference Include="..\..\..\MelonLoader.Bootstrap\MelonLoader.Bootstrap.csproj" Private="false" ExcludeAssets="runtime" />
<ProjectReference Include="..\..\..\MelonLoader.Mono\MelonLoader.Mono.csproj" />
<ProjectReference Include="..\..\..\MelonLoader.Shared\MelonLoader.Shared.csproj" Private="false" ExcludeAssets="runtime" />
<ProjectReference Include="..\Unity.Il2Cpp\Unity.Il2Cpp.csproj" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions MelonLoader/Modules/Unity/Unity.Il2Cpp/Il2CppLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MelonLoader.Unity.Il2Cpp
{
public static class Il2CppLoader
{
public static void Startup(string gameAssemblyPath)
{

}
}
}
15 changes: 15 additions & 0 deletions MelonLoader/Modules/Unity/Unity.Il2Cpp/Unity.Il2Cpp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>MelonLoader.Unity.Il2Cpp</RootNamespace>
<TargetFramework>net6</TargetFramework>
<LangVersion>Latest</LangVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)Output\$(Configuration)\MelonLoader\Modules\Unity\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\MelonLoader.Bootstrap\MelonLoader.Bootstrap.csproj" Private="false" ExcludeAssets="runtime" />
<ProjectReference Include="..\..\..\MelonLoader.Shared\MelonLoader.Shared.csproj" Private="false" ExcludeAssets="runtime" />
</ItemGroup>
</Project>

0 comments on commit 6f3af42

Please sign in to comment.