Terraria ModLoader  0.10.1.5
A framework for Terraria mods
Terraria.ModLoader.MonoModHooks Class Reference
+ Collaboration diagram for Terraria.ModLoader.MonoModHooks:

Static Public Member Functions

static void RequestNativeAccess ()
 

Static Private Member Functions

static ModuleDefinition GenerateCecilModule (AssemblyName name)
 
static string GetOwnerName (Delegate d)
 
static void NativeAccessCheck (Assembly asm)
 
static string StringRep (MethodBase m)
 

Static Private Attributes

static bool isInitialized
 
static DetourModManager manager = new DetourModManager()
 
static HashSet< Assembly > NativeDetouringGranted = new HashSet<Assembly>()
 

Detailed Description

Definition at line 15 of file MonoModHooks.cs.

Member Function Documentation

static ModuleDefinition Terraria.ModLoader.MonoModHooks.GenerateCecilModule ( AssemblyName  name)
staticprivate
static string Terraria.ModLoader.MonoModHooks.GetOwnerName ( Delegate  d)
staticprivate

Definition at line 77 of file MonoModHooks.cs.

77  {
78  return d.Method.DeclaringType.Assembly.GetName().Name;
79  }
static void Terraria.ModLoader.MonoModHooks.NativeAccessCheck ( Assembly  asm)
staticprivate

Definition at line 60 of file MonoModHooks.cs.

60  {
61  if (NativeDetouringGranted.Contains(asm))
62  return;
63 
64  throw new UnauthorizedAccessException(
65  $"Native detouring permissions not granted to {asm.GetName().Name}. \n" +
66  $"Mods should use HookEndpointManager for compatibility. \n" +
67  $"If Detour or NativeDetour are required, call MonoModHooks.RequestNativeAccess()");
68  }
static HashSet< Assembly > NativeDetouringGranted
Definition: MonoModHooks.cs:18
static void Terraria.ModLoader.MonoModHooks.RequestNativeAccess ( )
static

Definition at line 70 of file MonoModHooks.cs.

70  {
71  var stack = new StackTrace();
72  var asm = stack.GetFrame(1).GetMethod().DeclaringType.Assembly;
73  NativeDetouringGranted.Add(asm);
74  Logging.tML.Warn($"Granted native detouring access to {asm.GetName().Name}");
75  }
static HashSet< Assembly > NativeDetouringGranted
Definition: MonoModHooks.cs:18
static string Terraria.ModLoader.MonoModHooks.StringRep ( MethodBase  m)
staticprivate

Definition at line 81 of file MonoModHooks.cs.

References Terraria.ModLoader.Mod.Name.

81  {
82  var paramString = string.Join(", ", m.GetParameters().Select(p => {
83  var s = p.ParameterType.Name;
84  if (p.ParameterType.IsByRef)
85  s = p.IsOut ? "out " : "ref ";
86  return s;
87  }));
88  var owner = m.DeclaringType?.FullName ??
89  (m is DynamicMethod ? "dynamic" : "unknown");
90  return $"{owner}::{m.Name}({paramString})";
91  }

Member Data Documentation

bool Terraria.ModLoader.MonoModHooks.isInitialized
staticprivate

Definition at line 20 of file MonoModHooks.cs.

DetourModManager Terraria.ModLoader.MonoModHooks.manager = new DetourModManager()
staticprivate

Definition at line 17 of file MonoModHooks.cs.

HashSet<Assembly> Terraria.ModLoader.MonoModHooks.NativeDetouringGranted = new HashSet<Assembly>()
staticprivate

Definition at line 18 of file MonoModHooks.cs.