Пример #1
0
        public static bool Detour(MethodInfo original, MethodInfo modified)
        {
            if (IsDetoured(original))
            {
                return(false);
            }

            // JIT the methods
            RuntimeHelpers.PrepareMethod(original.MethodHandle);
            RuntimeHelpers.PrepareMethod(modified.MethodHandle);

            // Load pointers
            IntPtr ptrOriginal = original.MethodHandle.GetFunctionPointer();
            IntPtr ptrModified = original.MethodHandle.GetFunctionPointer();

            // Run
            DetouredMethods.Add(original, new DetourInfo(original, modified));
            return(RedirectionHelper.DetourFunction(ptrOriginal, ptrModified));
        }