Add BepInEx Il2CppInterop build

This commit is contained in:
Sinai 2022-06-23 06:03:58 +10:00
parent 706a18d1f6
commit 1af20ead9f
23 changed files with 142 additions and 26 deletions

View File

@ -12,7 +12,7 @@ Remove-Item $Path/UnhollowerBaseLib.dll
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
Move-Item -Path $Path/UnityExplorer.ML.IL2CPP.net6preview.dll -Destination $Path/Mods -Force
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.dll -Destination $Path/UserLibs -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.Unhollower.dll -Destination $Path/UserLibs -Force
# (create zip archive)
Remove-Item $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.zip -ErrorAction SilentlyContinue
7z a $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.zip .\$Path\*
@ -30,7 +30,7 @@ Remove-Item $Path/UnhollowerBaseLib.dll
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
Move-Item -Path $Path/UnityExplorer.ML.IL2CPP.dll -Destination $Path/Mods -Force
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.dll -Destination $Path/UserLibs -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.Unhollower.dll -Destination $Path/UserLibs -Force
# (create zip archive)
Remove-Item $Path/../UnityExplorer.MelonLoader.IL2CPP.zip -ErrorAction SilentlyContinue
7z a $Path/../UnityExplorer.MelonLoader.IL2CPP.zip .\$Path\*
@ -64,11 +64,32 @@ Remove-Item $Path/UnhollowerBaseLib.dll
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
New-Item -Path "$Path" -Name "plugins/sinai-dev-UnityExplorer" -ItemType "directory" -Force
Move-Item -Path $Path/UnityExplorer.BIE.IL2CPP.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.Unhollower.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
# (create zip archive)
Remove-Item $Path/../UnityExplorer.BepInEx.IL2CPP.zip -ErrorAction SilentlyContinue
7z a $Path/../UnityExplorer.BepInEx.IL2CPP.zip .\$Path\*
# ----------- BepInEx IL2CPP CoreCLR -----------
dotnet build src/UnityExplorer.sln -c Release_BIE_CoreCLR
$Path = "Release/UnityExplorer.BepInEx.IL2CPP.CoreCLR"
# ILRepack
lib/ILRepack.exe /target:library /lib:lib/net472 /lib:lib/net6/ /lib:lib/interop/ /lib:$Path /internalize /out:$Path/UnityExplorer.BIE.IL2CPP.CoreCLR.dll $Path/UnityExplorer.BIE.IL2CPP.CoreCLR.dll $Path/mcs.dll $Path/Tomlet.dll
# (cleanup and move files)
Remove-Item $Path/Tomlet.dll
Remove-Item $Path/mcs.dll
Remove-Item $Path/Iced.dll
Remove-Item $Path/Il2CppInterop.Common.dll
Remove-Item $Path/Il2CppInterop.Runtime.dll
Remove-Item $Path/Microsoft.Extensions.Logging.Abstractions.dll
Remove-Item $Path/UnityExplorer.BIE.IL2CPP.CoreCLR.deps.json
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
New-Item -Path "$Path" -Name "plugins/sinai-dev-UnityExplorer" -ItemType "directory" -Force
Move-Item -Path $Path/UnityExplorer.BIE.IL2CPP.CoreCLR.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
Move-Item -Path $Path/UniverseLib.IL2CPP.Interop.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
# (create zip archive)
Remove-Item $Path/../UnityExplorer.BepInEx.IL2CPP.CoreCLR.zip -ErrorAction SilentlyContinue
7z a $Path/../UnityExplorer.BepInEx.IL2CPP.CoreCLR.zip .\$Path\*
# ----------- BepInEx 5 Mono -----------
dotnet build src/UnityExplorer.sln -c Release_BIE5_Mono
$Path = "Release/UnityExplorer.BepInEx5.Mono"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/interop/UnityEngine.dll Normal file

Binary file not shown.

View File

@ -1,6 +1,10 @@
using UnityExplorer.UI;
#if CPP
#if UNHOLLOWER
using UnhollowerRuntimeLib;
#else
using Il2CppInterop.Runtime.Injection;
#endif
#endif
namespace UnityExplorer

View File

@ -19,7 +19,7 @@ namespace UnityExplorer
public static class ExplorerCore
{
public const string NAME = "UnityExplorer";
public const string VERSION = "4.8.2";
public const string VERSION = "4.9.0";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";
@ -77,8 +77,10 @@ namespace UnityExplorer
{
// check master toggle
if (InputManager.GetKeyDown(ConfigManager.Master_Toggle.Value))
{
UIManager.ShowMenu = !UIManager.ShowMenu;
}
}
#region LOGGING

View File

@ -6,7 +6,6 @@ using UnityExplorer.Config;
using UnityExplorer.Loader.BIE;
#if CPP
using BepInEx.IL2CPP;
using UnhollowerRuntimeLib;
#endif
namespace UnityExplorer
@ -29,8 +28,14 @@ namespace UnityExplorer
#else
=> Log;
#endif
public string UnhollowedModulesFolder => Path.Combine(Paths.BepInExRootPath, "unhollowed");
const string IL2CPP_LIBS_FOLDER =
#if UNHOLLOWER
"unhollowed"
#else
"interop"
#endif
;
public string UnhollowedModulesFolder => Path.Combine(Paths.BepInExRootPath, IL2CPP_LIBS_FOLDER);
public ConfigHandler ConfigHandler => _configHandler;
private BepInExConfigHandler _configHandler;

View File

@ -1,8 +1,13 @@
using System.Collections;
#if CPP
#if INTEROP
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime;
#else
using UnhollowerRuntimeLib;
using UnhollowerBaseLib;
#endif
#endif
namespace UnityExplorer.Tests
{
@ -253,7 +258,7 @@ namespace UnityExplorer.Tests
}
ExplorerCore.Log($"IL2CPP 9: Il2Cpp struct array of ints");
IL2CPP_structArray = new UnhollowerBaseLib.Il2CppStructArray<int>(5);
IL2CPP_structArray = new Il2CppStructArray<int>(5);
IL2CPP_structArray[0] = 0;
IL2CPP_structArray[1] = 1;
IL2CPP_structArray[2] = 2;
@ -261,7 +266,7 @@ namespace UnityExplorer.Tests
IL2CPP_structArray[4] = 4;
ExplorerCore.Log($"IL2CPP 10: Il2Cpp reference array of boxed objects");
IL2CPP_ReferenceArray = new UnhollowerBaseLib.Il2CppReferenceArray<Il2CppSystem.Object>(3);
IL2CPP_ReferenceArray = new Il2CppReferenceArray<Il2CppSystem.Object>(3);
IL2CPP_ReferenceArray[0] = new Il2CppSystem.Int32 { m_value = 5 }.BoxIl2CppObject();
IL2CPP_ReferenceArray[1] = null;
IL2CPP_ReferenceArray[2] = (Il2CppSystem.String)"whats up";

View File

@ -1,6 +1,12 @@
using UniverseLib.Input;
using UniverseLib.UI;
using UniverseLib.UI.Models;
#if UNHOLLOWER
using UnhollowerRuntimeLib;
#endif
#if INTEROP
using Il2CppInterop.Runtime.Injection;
#endif
namespace UnityExplorer.UI.Panels
{
@ -324,7 +330,7 @@ namespace UnityExplorer.UI.Panels
#if CPP
static FreeCamBehaviour()
{
UnhollowerRuntimeLib.ClassInjector.RegisterTypeInIl2Cpp<FreeCamBehaviour>();
ClassInjector.RegisterTypeInIl2Cpp<FreeCamBehaviour>();
}
public FreeCamBehaviour(IntPtr ptr) : base(ptr) { }

View File

@ -1,6 +1,12 @@
using HarmonyLib;
using UniverseLib.UI;
using UniverseLib.UI.Models;
#if UNHOLLOWER
using IL2CPPUtils = UnhollowerBaseLib.UnhollowerUtils;
#endif
#if INTEROP
using IL2CPPUtils = Il2CppInterop.Common.Il2CppInteropUtils;
#endif
namespace UnityExplorer.UI.Widgets
{
@ -90,7 +96,7 @@ namespace UnityExplorer.UI.Widgets
{
MethodInfo target = typeof(Time).GetProperty("timeScale").GetSetMethod();
#if CPP
if (UnhollowerBaseLib.UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(target) == null)
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(target) == null)
return;
#endif
ExplorerCore.Harmony.Patch(target,

View File

@ -5,6 +5,15 @@ using UnityExplorer.Inspectors;
using UniverseLib.UI;
using UniverseLib.UI.Models;
using UniverseLib.UI.ObjectPool;
#if CPP
#if INTEROP
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
#else
using UnhollowerRuntimeLib;
using UnhollowerBaseLib;
#endif
#endif
namespace UnityExplorer.UI.Widgets
{
@ -146,7 +155,7 @@ namespace UnityExplorer.UI.Widgets
AudioPlayerObject.hideFlags = HideFlags.HideAndDontSave;
AudioPlayerObject.transform.position = new(int.MinValue, int.MinValue); // move it as far away as possible
#if CPP
Source = AudioPlayerObject.AddComponent(UnhollowerRuntimeLib.Il2CppType.Of<AudioSource>()).TryCast<AudioSource>();
Source = AudioPlayerObject.AddComponent(Il2CppType.Of<AudioSource>()).TryCast<AudioSource>();
#else
Source = AudioPlayerObject.AddComponent<AudioSource>();
#endif
@ -320,7 +329,7 @@ namespace UnityExplorer.UI.Widgets
static void ConvertAndWrite(FileStream fileStream, AudioClip clip)
{
#if CPP
UnhollowerBaseLib.Il2CppStructArray<float> samples = new float[clip.samples * clip.channels];
Il2CppStructArray<float> samples = new float[clip.samples * clip.channels];
AudioClip.GetData(clip, samples, clip.samples, 0);
#else
float[] samples = new float[clip.samples * clip.channels];

View File

@ -11,21 +11,21 @@
<DebugType>none</DebugType>
<RootNamespace>UnityExplorer</RootNamespace>
<LangVersion>10.0</LangVersion>
<Configurations>BIE_Cpp;BIE5_Mono;BIE6_Mono;ML_Cpp_net6;ML_Mono;STANDALONE_Mono;STANDALONE_Cpp;ML_Cpp_net472</Configurations>
<Configurations>BIE_Cpp;BIE_Cpp_CoreCLR;BIE5_Mono;BIE6_Mono;ML_Cpp_net6;ML_Cpp_net472;ML_Mono;STANDALONE_Mono;STANDALONE_Cpp</Configurations>
</PropertyGroup>
<!-- ~~~~~ CONFIGURATIONS ~~~~~ -->
<!-- ML IL2CPP net6 -->
<PropertyGroup Condition="'$(Configuration)'=='ML_Cpp_net6'">
<TargetFramework>net6</TargetFramework>
<OutputPath>..\Release\UnityExplorer.MelonLoader.IL2CPP.net6preview\</OutputPath>
<DefineConstants>CPP,ML</DefineConstants>
<DefineConstants>CPP,ML,UNHOLLOWER</DefineConstants>
<AssemblyName>UnityExplorer.ML.IL2CPP.net6preview</AssemblyName>
</PropertyGroup>
<!-- ML IL2CPP net472 (TEMP) -->
<PropertyGroup Condition="'$(Configuration)'=='ML_Cpp_net472'">
<TargetFramework>net472</TargetFramework>
<OutputPath>..\Release\UnityExplorer.MelonLoader.IL2CPP\</OutputPath>
<DefineConstants>CPP,ML</DefineConstants>
<DefineConstants>CPP,ML,UNHOLLOWER</DefineConstants>
<AssemblyName>UnityExplorer.ML.IL2CPP</AssemblyName>
</PropertyGroup>
<!-- ML MONO -->
@ -39,9 +39,16 @@
<PropertyGroup Condition="'$(Configuration)'=='BIE_Cpp'">
<TargetFramework>net472</TargetFramework>
<OutputPath>..\Release\UnityExplorer.BepInEx.IL2CPP\</OutputPath>
<DefineConstants>CPP,BIE,BIE6</DefineConstants>
<DefineConstants>CPP,BIE,BIE6,UNHOLLOWER</DefineConstants>
<AssemblyName>UnityExplorer.BIE.IL2CPP</AssemblyName>
</PropertyGroup>
<!-- BEPINEX IL2CPP CoreCLR -->
<PropertyGroup Condition="'$(Configuration)'=='BIE_Cpp_CoreCLR'">
<TargetFramework>net6</TargetFramework>
<OutputPath>..\Release\UnityExplorer.BepInEx.IL2CPP.CoreCLR\</OutputPath>
<DefineConstants>CPP,BIE,BIE6,INTEROP</DefineConstants>
<AssemblyName>UnityExplorer.BIE.IL2CPP.CoreCLR</AssemblyName>
</PropertyGroup>
<!-- BEPINEX 6 MONO -->
<PropertyGroup Condition="'$(Configuration)'=='BIE6_Mono'">
<TargetFramework>net35</TargetFramework>
@ -56,18 +63,18 @@
<DefineConstants>MONO,BIE,BIE5</DefineConstants>
<AssemblyName>UnityExplorer.BIE5.Mono</AssemblyName>
</PropertyGroup>
<!-- STANDALONE IL2CPP -->
<!-- STANDALONE Mono -->
<PropertyGroup Condition="'$(Configuration)'=='STANDALONE_Mono'">
<TargetFramework>net35</TargetFramework>
<OutputPath>..\Release\UnityExplorer.Standalone.Mono\</OutputPath>
<DefineConstants>MONO,STANDALONE</DefineConstants>
<AssemblyName>UnityExplorer.STANDALONE.Mono</AssemblyName>
</PropertyGroup>
<!-- STANDALONE MONO -->
<!-- STANDALONE Il2Cpp -->
<PropertyGroup Condition="'$(Configuration)'=='STANDALONE_Cpp'">
<TargetFramework>net472</TargetFramework>
<OutputPath>..\Release\UnityExplorer.Standalone.IL2CPP\</OutputPath>
<DefineConstants>CPP,STANDALONE</DefineConstants>
<DefineConstants>CPP,STANDALONE,UNHOLLOWER</DefineConstants>
<AssemblyName>UnityExplorer.STANDALONE.IL2CPP</AssemblyName>
</PropertyGroup>
@ -79,11 +86,16 @@
<!-- il2cpp nuget -->
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net472' or '$(Configuration)'=='STANDALONE_Cpp' or '$(Configuration)'=='BIE_Cpp'">
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.22" />
<PackageReference Include="UniverseLib.IL2CPP" Version="1.4.3" />
<PackageReference Include="UniverseLib.IL2CPP.Unhollower" Version="1.5.1" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='BIE_Cpp_CoreCLR'">
<PackageReference Include="Il2CppInterop.Common" Version="1.0.0" />
<PackageReference Include="Il2CppInterop.Runtime" Version="1.0.0" />
<PackageReference Include="UniverseLib.IL2CPP.Interop" Version="1.5.1" />
</ItemGroup>
<!-- mono nuget -->
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='BIE5_Mono' or '$(Configuration)'=='ML_Mono' or '$(Configuration)'=='STANDALONE_Mono'">
<PackageReference Include="UniverseLib.Mono" Version="1.4.3" />
<PackageReference Include="UniverseLib.Mono" Version="1.5.1" />
</ItemGroup>
<!-- ~~~~~ ASSEMBLY REFERENCES ~~~~~ -->
@ -134,7 +146,7 @@
</Reference>
</ItemGroup>
<!-- BepInEx Il2Cpp -->
<ItemGroup Condition="'$(Configuration)'=='BIE_Cpp'">
<ItemGroup Condition="'$(Configuration)'=='BIE_Cpp' or '$(Configuration)'=='BIE_Cpp_CoreCLR'">
<Reference Include="BepInEx">
<HintPath>..\lib\net472\BepInEx.Core.dll</HintPath>
<Private>False</Private>
@ -155,7 +167,7 @@
<Private>False</Private>
</Reference>
</ItemGroup>
<!-- Il2Cpp -->
<!-- Il2Cpp Unhollower -->
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net472' or '$(Configuration)'=='STANDALONE_Cpp' or '$(Configuration)'=='BIE_Cpp'">
<Reference Include="Il2Cppmscorlib">
<HintPath>..\lib\unhollowed\Il2Cppmscorlib.dll</HintPath>
@ -198,4 +210,47 @@
<Private>False</Private>
</Reference>
</ItemGroup>
<!-- Il2Cpp Interop -->
<ItemGroup Condition="'$(Configuration)'=='BIE_Cpp_CoreCLR'">
<Reference Include="Il2Cppmscorlib">
<HintPath>..\lib\interop\Il2Cppmscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Il2CppSystem.Core">
<HintPath>..\lib\interop\Il2CppSystem.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\lib\interop\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>..\lib\interop\UnityEngine.AudioModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\lib\interop\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\lib\interop\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>..\lib\interop\UnityEngine.TextRenderingModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\lib\interop\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>..\lib\interop\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>..\lib\interop\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
</Project>

View File

@ -8,6 +8,7 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release_BIE_Cpp|Any CPU = Release_BIE_Cpp|Any CPU
Release_BIE_CoreCLR|Any CPU = Release_BIE_CoreCLR|Any CPU
Release_BIE5_Mono|Any CPU = Release_BIE5_Mono|Any CPU
Release_BIE6_Mono|Any CPU = Release_BIE6_Mono|Any CPU
Release_ML_Cpp_net472|Any CPU = Release_ML_Cpp_net472|Any CPU
@ -19,6 +20,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_BIE_Cpp|Any CPU.ActiveCfg = BIE_Cpp|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_BIE_Cpp|Any CPU.Build.0 = BIE_Cpp|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_BIE_CoreCLR|Any CPU.ActiveCfg = BIE_Cpp_CoreCLR|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_BIE_CoreCLR|Any CPU.Build.0 = BIE_Cpp_CoreCLR|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_BIE5_Mono|Any CPU.ActiveCfg = BIE5_Mono|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_BIE5_Mono|Any CPU.Build.0 = BIE5_Mono|Any CPU
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_BIE6_Mono|Any CPU.ActiveCfg = BIE6_Mono|Any CPU