Example #1
0
        public unsafe void ApplyTrampoline(MethodBase from, MethodBase to)
        {
            DynamicMethod trampoline = to.CreateTrampoline();

            _MMD.LogVerbose($"[ApplyTrampoline] {from} -> {to} ({trampoline})");
            _MMD.LogVerbose($"[ApplyTrampoline] 0x{((ulong) RuntimeDetour.GetMethodStart(from)).ToString("X16")} -> 0x{((ulong) RuntimeDetour.GetMethodStart(trampoline)).ToString("X16")}");

            RuntimeDetour.Detour(
                RuntimeDetour.GetMethodStart(from),
                RuntimeDetour.GetMethodStart(trampoline),
                false);
            _TrampolineDMs[(long)
                           ((ulong)from.MetadataToken) << 32 |
                           ((uint )to.MetadataToken)
            ] = trampoline;
        }