public override void Unload()
        {
            IL.InputHandler.OnGUI -= OnGUI;

            HookEndpointManager.Unmodify
            (
                MethodBase.GetMethodFromHandle(typeof(ModHooks).GetMethod("OnCursor", BindingFlags.Instance | BindingFlags.NonPublic).MethodHandle),
                (ILContext.Manipulator) OnCursor
            );
        }
        private static void HookMethods()
        {
            if (RageStatMethod != null)
            {
                HookEndpointManager.Modify(RageStatMethod, (ILContext.Manipulator)DisableStatHook);

                if (!rageStatHook)
                {
                    HookEndpointManager.Unmodify(RageStatMethod, (ILContext.Manipulator)DisableStatHook);
                    Logger.Warn("[PlasmaSpikeStripCompat] - DisableStatHook Failed! - Removing Hook");
                }
            }

            if (CloakOnHitMethod != null)
            {
                HookEndpointManager.Modify(CloakOnHitMethod, (ILContext.Manipulator)DisableCloakHook);
            }
        }
Beispiel #3
0
        private static void HookMethods()
        {
            if (AffixBlueDamageCoeffField != null)
            {
                if (OnHitAllMethod != null)
                {
                    HookEndpointManager.Modify(OnHitAllMethod, (ILContext.Manipulator)OverrideAffixBlueDamage);

                    if (affixBlueDamageHook != 2)
                    {
                        HookEndpointManager.Unmodify(OnHitAllMethod, (ILContext.Manipulator)OverrideAffixBlueDamage);

                        Debug.LogWarning("[EliteReworksCompat] - Failed to successfully hook OnHitAll.TriggerOnHitAllEffects, Unhooking!");
                    }
                    else
                    {
                        overrideAffixBlue = true;
                    }
                }
            }
        }
 private void Destroy()
 {
     HookEndpointManager.Unmodify(onNetworkUserLoadoutChanged, (ILContext.Manipulator)ReverseSkin.RevertSkinIL);
 }
 public void Remove_IL(ILContext.Manipulator hook) => HookEndpointManager.Unmodify(this.method, hook);
Beispiel #6
0
        private void Apply()
        {
            string typeName = Parent.Path;
            Type   type     = Parent.Type ?? ReflectionHelper.GetType(typeName);

            if (type == null)
            {
                throw new ArgumentException($"Couldn't find type {typeName}");
            }

            MethodBase method = null;

            // TODO: Handle overloads.
            if (Name == "ctor")
            {
                method = type.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).FirstOrDefault();
            }
            else
            {
                method = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static).FirstOrDefault(m => m.Name == Name);
            }
            if (method == null)
            {
                throw new ArgumentException($"Couldn't find method {typeName}::{Name}");
            }

            foreach (Tuple <ActionType, Delegate> action in Actions)
            {
                Delegate target = action.Item2;

                HookType hookType = NodeHookType;

                if (hookType == HookType.OnOrIL)
                {
                    MethodInfo      invoke = target.GetType().GetMethod("Invoke");
                    ParameterInfo[] args   = invoke.GetParameters();

                    if (invoke.ReturnType == typeof(void) &&
                        args.Length == 1 &&
                        args[0].ParameterType.IsCompatible(typeof(ILContext)) &&
                        !args[0].IsOut)
                    {
                        hookType = HookType.IL;
                    }
                    else
                    {
                        hookType = HookType.On;
                    }
                }

                switch (action.Item1)
                {
                case ActionType.Add:
                    if (hookType == HookType.IL)
                    {
                        HookEndpointManager.Modify(method, target);
                    }
                    else
                    {
                        HookEndpointManager.Add(method, target);
                    }
                    break;

                case ActionType.Remove:
                    if (hookType == HookType.IL)
                    {
                        HookEndpointManager.Unmodify(method, target);
                    }
                    else
                    {
                        HookEndpointManager.Remove(method, target);
                    }
                    break;
                }
            }

            Actions.Clear();
        }