Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions BepInEx.Core/Bootstrap/BaseChainloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,11 @@ private static bool IsAssemblySafe(string assemblyPath)
return false;
}

if (module.Attributes.Has(ModuleAttributes.ILOnly) == false)
// TODO: better unsafe blocking
/*if (!module.Attributes.Has(ModuleAttributes.ILOnly))
{
return false;
}
}*/

if (!method.HasBody) continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<ItemGroup>
<PackageReference Include="Disarm" Version="2022.1.0-master.99" />
<PackageReference Include="HarmonyX" Version="2.16.0" />
<PackageReference Include="Il2CppInterop.Generator" Version="1.5.2-data-hook" />
<PackageReference Include="Il2CppInterop.HarmonySupport" Version="1.5.2-data-hook" />
<PackageReference Include="Il2CppInterop.Generator" Version="1.5.2-ci.star.5" />
<PackageReference Include="Il2CppInterop.HarmonySupport" Version="1.5.2-ci.star.5" />
<PackageReference Include="Il2CppInterop.ReferenceLibs" Version="1.0.0" IncludeAssets="compile" PrivateAssets="all"/>
<PackageReference Include="Il2CppInterop.Runtime" Version="1.5.2-data-hook" />
<PackageReference Include="Il2CppInterop.Runtime" Version="1.5.2-ci.star.5" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" IncludeAssets="compile" PrivateAssets="all"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" IncludeAssets="compile" PrivateAssets="all"/>
<PackageReference Include="MonoMod.Core" Version="1.3.4-star" />
Expand Down
8 changes: 5 additions & 3 deletions Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ public unsafe class NativeDetour : IDetour
public IntPtr Target { get; }
public IntPtr Detour { get; }
public bool UnityFunction { get; }
public bool SpecialReturnBuffer { get; }
public IntPtr OriginalTrampoline { get; private set; }

public NativeDetour(IntPtr target, Delegate detour)
: this(target, detour, false)
: this(target, detour, false, false)
{
}

public NativeDetour(IntPtr target, Delegate detour, bool unityFunction)
public NativeDetour(IntPtr target, Delegate detour, bool unityFunction, bool specialReturnBuffer)
{
Target = target;
Detour = Marshal.GetFunctionPointerForDelegate(detour);
UnityFunction = unityFunction;
SpecialReturnBuffer = specialReturnBuffer;
Apply();
}

Expand All @@ -30,7 +32,7 @@ public void Apply()
{
return;
}
OriginalTrampoline = StarlightInterop.hook(Target, Detour, UnityFunction);
OriginalTrampoline = StarlightInterop.hook(Target, Detour, UnityFunction, SpecialReturnBuffer);
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace BepInEx.Unity.IL2CPP.Hook;

public class NativeDetourProvider : IDetourProvider
{
public IDetour Create<TDelegate>(IntPtr original, TDelegate target, bool unityFunction) where TDelegate : Delegate
public IDetour Create<TDelegate>(IntPtr original, TDelegate target, bool unityFunction, bool specialReturnBuffer) where TDelegate : Delegate
{
var detour = new NativeDetour(original, target, unityFunction);
var detour = new NativeDetour(original, target, unityFunction, specialReturnBuffer);
return new CacheDetourWrapper(detour, target);
}
}
3 changes: 3 additions & 0 deletions Runtimes/Unity/BepInEx.Unity.IL2CPP/IL2CPPChainloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using BepInEx.Unity.IL2CPP.Hook;
using BepInEx.Unity.IL2CPP.Logging;
using BepInEx.Unity.IL2CPP.Utils;
using Il2CppInterop.HarmonySupport;
using Il2CppInterop.Runtime.InteropTypes;
using Logger = BepInEx.Logging.Logger;

Expand Down Expand Up @@ -76,6 +77,8 @@ public override void Execute()
{
try
{
BridgeInterop.Initialize();
StarlightInterop.init_bridge_helper(BridgeInterop.LibraryPath);
StarlightInterop.set_loading(true);

var paths = new Dictionary<string, bool>
Expand Down
7 changes: 6 additions & 1 deletion Runtimes/Unity/BepInEx.Unity.IL2CPP/StarlightInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ internal static partial class StarlightInterop
public static unsafe partial void write_log([MarshalAs(UnmanagedType.LPStr)] string message);

[LibraryImport(LIBRARY_NAME)]
public static unsafe partial IntPtr hook(IntPtr target, IntPtr detour, [MarshalAs(UnmanagedType.I1)] bool unityFunction);
public static unsafe partial void init_bridge_helper([MarshalAs(UnmanagedType.LPStr)] string bridgeLibPath);

[LibraryImport(LIBRARY_NAME)]
public static unsafe partial IntPtr hook(IntPtr target, IntPtr detour,
[MarshalAs(UnmanagedType.I1)] bool unityFunction,
[MarshalAs(UnmanagedType.I1)] bool specialReturnBuffer);

[LibraryImport(LIBRARY_NAME)]
public static unsafe partial void unhook(IntPtr target);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed packages/Il2CppInterop.Common.1.5.2-data-hook.nupkg
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 added packages/MonoMod.Core.1.3.4-star.nupkg
Binary file not shown.
Binary file added packages/MonoMod.RuntimeDetour.25.3.4-star.nupkg
Binary file not shown.
Binary file added packages/MonoMod.Utils.25.0.12-star.nupkg
Binary file not shown.
Loading