safer HookMethod and more sandboxed cs mods
This commit is contained in:
@@ -34,8 +34,10 @@ namespace Barotrauma {
|
|||||||
};
|
};
|
||||||
private static readonly string[] typesProhibited = new string[] {
|
private static readonly string[] typesProhibited = new string[] {
|
||||||
//"System.Reflection",
|
//"System.Reflection",
|
||||||
|
//"System.Type",
|
||||||
"System.IO",
|
"System.IO",
|
||||||
"Moonsharp"
|
"Moonsharp",
|
||||||
|
"Barotrauma.IO",
|
||||||
};
|
};
|
||||||
public static bool IsTypeAllowed(string name)
|
public static bool IsTypeAllowed(string name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -215,9 +215,14 @@ namespace Barotrauma
|
|||||||
return methodInfo;
|
return methodInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly string[] prohibitedHooks = {
|
||||||
|
"Barotrauma.Lua",
|
||||||
|
"Barotrauma.Cs"
|
||||||
|
};
|
||||||
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) throw new ArgumentNullException("Identifier, Method and Patch arguments must not be null.");
|
||||||
|
if (prohibitedHooks.Any(h => method.DeclaringType.FullName.StartsWith(h))) throw new ArgumentException("Hooks into Modding Environment are prohibited.");
|
||||||
|
|
||||||
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