Example #1
0
        public void Unmodify(Delegate callback)
        {
            if (callback == null)
            {
                return;
            }

            int index = ILList.LastIndexOf(callback);

            if (index == -1)
            {
                return;
            }
            ILList.RemoveAt(index);

            DMD.Reload(null, true);
            MethodDefinition def = DMD.Definition;

            foreach (Delegate cb in ILList)
            {
                if (cb is ILManipulator manip)
                {
                    new HookIL(def.Body).Invoke(manip);
                }
                else
                {
                    cb.DynamicInvoke(def.Body, def.Body.GetILProcessor());
                }
            }

            DMD.Definition.RecalculateILOffsets();
            DMD.Definition.ConvertShortLongOps();
            DetourILDetourTarget();
        }
Example #2
0
        public void Unmodify(Delegate callback)
        {
            if (callback == null)
            {
                return;
            }

            int index = ILList.LastIndexOf(callback);

            if (index == -1)
            {
                return;
            }
            ILList.RemoveAt(index);

            DMD.Reload(null, true);
            MethodDefinition def = DMD.Definition;

            foreach (Delegate cb in ILList)
            {
                InvokeManipulator(def, cb);
            }

            DMD.Definition.RecalculateILOffsets();
            DMD.Definition.ConvertShortLongOps();
            DetourILDetourTarget();
        }
Example #3
0
        private bool RedirectDMD(MethodBase methodBase, Delegate callback)
        {
            var endPoint = GetHookEndPoint(methodBase);

            var dmd = new DynamicMethodDefinition(methodBase);

            dmd.Reload(null, true);
            ReplaceDMD(endPoint, dmd);

            return(true);
        }