fix cs filter metadata bug
This commit is contained in:
@@ -11,15 +11,7 @@ namespace Barotrauma {
|
|||||||
{
|
{
|
||||||
private static readonly string[] typesPermitted = new string[] {
|
private static readonly string[] typesPermitted = new string[] {
|
||||||
// Basics
|
// Basics
|
||||||
"System.Runtime.CompilerServices.CompilationRelaxationsAttribute",
|
|
||||||
"System.Runtime.CompilerServices.RuntimeCompatibilityAttribute",
|
|
||||||
"System.Diagnostics.DebuggableAttribute",
|
|
||||||
"System.Object",
|
|
||||||
"System.String",
|
|
||||||
"System.Collections",
|
|
||||||
"System",
|
"System",
|
||||||
// Some roslyn magic
|
|
||||||
".DebuggingModes",
|
|
||||||
// Barotrauma
|
// Barotrauma
|
||||||
"Barotrauma",
|
"Barotrauma",
|
||||||
// Lua
|
// Lua
|
||||||
@@ -76,7 +68,18 @@ namespace Barotrauma {
|
|||||||
reader.TypeReferences.ToList().ForEach(t =>
|
reader.TypeReferences.ToList().ForEach(t =>
|
||||||
{
|
{
|
||||||
var tRef = reader.GetTypeReference(t);
|
var tRef = reader.GetTypeReference(t);
|
||||||
var typeName = $"{reader.GetString(tRef.Namespace)}.{reader.GetString(tRef.Name)}";
|
|
||||||
|
var typeName = $"{reader.GetString(tRef.Name)}";
|
||||||
|
EntityHandle handle = tRef.ResolutionScope;
|
||||||
|
TypeReference tr = tRef;
|
||||||
|
while (!handle.IsNil && handle.Kind == HandleKind.TypeReference)
|
||||||
|
{
|
||||||
|
tr = reader.GetTypeReference((TypeReferenceHandle)handle);
|
||||||
|
handle = tr.ResolutionScope;
|
||||||
|
typeName = $"{reader.GetString(tr.Name)}.{typeName}";
|
||||||
|
}
|
||||||
|
typeName = $"{reader.GetString(tr.Namespace)}.{typeName}";
|
||||||
|
|
||||||
if (!IsTypeAllowed(typeName)) conflictingTypes.Add(typeName);
|
if (!IsTypeAllowed(typeName)) conflictingTypes.Add(typeName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using HarmonyLib;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using MoonSharp.Interpreter.Interop;
|
using MoonSharp.Interpreter.Interop;
|
||||||
|
using static Barotrauma.LuaCsSetup;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -221,8 +222,16 @@ namespace Barotrauma
|
|||||||
};
|
};
|
||||||
public void HookMethod(string identifier, MethodInfo method, LuaCsPatch patch, HookMethodType hookType = HookMethodType.Before, ACsMod owner = null)
|
public void HookMethod(string identifier, MethodInfo method, LuaCsPatch patch, HookMethodType hookType = HookMethodType.Before, ACsMod owner = null)
|
||||||
{
|
{
|
||||||
if (identifier == null || method == null || patch == null) throw new ArgumentNullException("Identifier, Method and Patch arguments must not be null.");
|
if (identifier == null || method == null || patch == null)
|
||||||
if (prohibitedHooks.Any(h => method.DeclaringType.FullName.StartsWith(h))) throw new ArgumentException("Hooks into Modding Environment are prohibited.");
|
{
|
||||||
|
GameMain.LuaCs.HandleException(new ArgumentNullException("Identifier, Method and Patch arguments must not be null."), exceptionType: ExceptionType.Both);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (prohibitedHooks.Any(h => method.DeclaringType.FullName.StartsWith(h)))
|
||||||
|
{
|
||||||
|
GameMain.LuaCs.HandleException(new ArgumentException("Hooks into Modding Environment are prohibited."), exceptionType: ExceptionType.Both);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var funcAddr = ((long)method.MethodHandle.GetFunctionPointer());
|
var funcAddr = ((long)method.MethodHandle.GetFunctionPointer());
|
||||||
var patches = Harmony.GetPatchInfo(method);
|
var patches = Harmony.GetPatchInfo(method);
|
||||||
|
|||||||
Reference in New Issue
Block a user