// Token: 0x0600019C RID: 412 RVA: 0x00010A54 File Offset: 0x0000EC54 public static object CallOriginal(object instance = null, params object[] args) { StackTrace stackTrace = new StackTrace(false); if (stackTrace.FrameCount < 1) { throw new Exception("Invalid trace back to the original method! Please provide the methodinfo instead!"); } MethodBase method = stackTrace.GetFrame(1).GetMethod(); MethodInfo original = null; if (!Attribute.IsDefined(method, typeof(OverrideAttribute))) { method = stackTrace.GetFrame(2).GetMethod(); } OverrideAttribute overrideAttribute = (OverrideAttribute)Attribute.GetCustomAttribute(method, typeof(OverrideAttribute)); if (overrideAttribute == null) { throw new Exception("This method can only be called from an overwritten method!"); } if (!overrideAttribute.MethodFound) { throw new Exception("The original method was never found!"); } original = overrideAttribute.Method; if (OverrideManager.Overrides.All((KeyValuePair <OverrideAttribute, OverrideWrapper> o) => o.Value.Original != original)) { throw new Exception("The Override specified was not found!"); } return(OverrideManager.Overrides.First((KeyValuePair <OverrideAttribute, OverrideWrapper> a) => a.Value.Original == original).Value.CallOriginal(args, instance)); }
// Token: 0x06000195 RID: 405 RVA: 0x000108AC File Offset: 0x0000EAAC public static void LoadOverride(MethodInfo method) { OverrideAttribute attribute = (OverrideAttribute)Attribute.GetCustomAttribute(method, typeof(OverrideAttribute)); if (OverrideManager.Overrides.Count((KeyValuePair <OverrideAttribute, OverrideWrapper> a) => a.Key.Method == attribute.Method) > 0) { return; } OverrideWrapper overrideWrapper = new OverrideWrapper(attribute.Method, method, attribute, null); overrideWrapper.Override(); OverrideManager.Overrides.Add(attribute, overrideWrapper); }
// Token: 0x060001AC RID: 428 RVA: 0x00010D88 File Offset: 0x0000EF88 public OverrideWrapper(MethodInfo original, MethodInfo modified, OverrideAttribute attribute, object instance = null) { this.Original = original; this.Modified = modified; this.Instance = instance; this.Attribute = attribute; this.Local = (this.Modified.DeclaringType.Assembly == Assembly.GetExecutingAssembly()); RuntimeHelpers.PrepareMethod(original.MethodHandle); RuntimeHelpers.PrepareMethod(modified.MethodHandle); this.PtrOriginal = this.Original.MethodHandle.GetFunctionPointer(); this.PtrModified = this.Modified.MethodHandle.GetFunctionPointer(); this.OffsetBackup = new OverrideUtilities.OffsetBackup(this.PtrOriginal); this.Detoured = false; }