feature: first
All checks were successful
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m47s
Build / Build Nuget package (CringePlugins) (push) Successful in 5m31s
Build / Build Nuget package (NuGet) (push) Successful in 6m2s
Build / Build Nuget package (SharedCringe) (push) Successful in 7m25s
Build / Build Launcher (push) Successful in 9m11s
All checks were successful
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m47s
Build / Build Nuget package (CringePlugins) (push) Successful in 5m31s
Build / Build Nuget package (NuGet) (push) Successful in 6m2s
Build / Build Nuget package (SharedCringe) (push) Successful in 7m25s
Build / Build Launcher (push) Successful in 9m11s
This commit is contained in:
37
CringeLauncher/Patches/WhitelistRegistrationPatch.cs
Normal file
37
CringeLauncher/Patches/WhitelistRegistrationPatch.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using HarmonyLib;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using VRage.Scripting;
|
||||
|
||||
namespace CringeLauncher.Patches;
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class WhitelistRegistrationPatch
|
||||
{
|
||||
private static IEnumerable<MethodInfo> TargetMethods()
|
||||
{
|
||||
yield return AccessTools.Method(typeof(MyScriptWhitelist), "Register",
|
||||
new[] { typeof(MyWhitelistTarget), typeof(INamespaceSymbol), typeof(Type) });
|
||||
yield return AccessTools.Method(typeof(MyScriptWhitelist), "Register",
|
||||
new[] { typeof(MyWhitelistTarget), typeof(ITypeSymbol), typeof(Type) });
|
||||
}
|
||||
|
||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var ins = instructions.ToList();
|
||||
var throwIns = ins.FindAll(b => b.opcode == OpCodes.Throw).Select(b => ins.IndexOf(b));
|
||||
foreach (var index in throwIns)
|
||||
{
|
||||
var i = index;
|
||||
do
|
||||
{
|
||||
ins[i] = new(OpCodes.Nop);
|
||||
} while (ins[--i].opcode.FlowControl != FlowControl.Cond_Branch);
|
||||
|
||||
ins[index] = new(OpCodes.Ret);
|
||||
}
|
||||
|
||||
return ins;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user