Example #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Detour" /> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="hook">The hook.</param>
        /// <param name="name">The name.</param>
        /// <param name="memory">The memory.</param>
        public Detour(Delegate target, Delegate hook, string name, MemoryPlus memory)
        {
            ProcessMemory = memory;
            Name = name;

            TargetDelegate = target;
            Target = UnmanagedHelper.GetDelegatePointer(target);

            _hookDelegate = hook;
            Hook = UnmanagedHelper.GetDelegatePointer(hook);

            //Store the orginal bytes
            Orginal = new List<byte>();
            Orginal.AddRange(memory.ReadBytes(Target, 6));

            //Setup the detour bytes
            New = new List<byte> {0x68};
            var tmp = BitConverter.GetBytes(Hook.ToInt32());
            New.AddRange(tmp);
            New.Add(0xC3);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="Detour" /> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="hook">The hook.</param>
        /// <param name="name">The name.</param>
        /// <param name="memory">The memory.</param>
        public Detour(Delegate target, Delegate hook, string name, MemoryPlus memory)
        {
            ProcessMemory = memory;
            Name          = name;

            TargetDelegate = target;
            Target         = UnmanagedHelper.GetDelegatePointer(target);

            _hookDelegate = hook;
            Hook          = UnmanagedHelper.GetDelegatePointer(hook);

            //Store the orginal bytes
            Orginal = new List <byte>();
            Orginal.AddRange(memory.ReadBytes(Target, 6));

            //Setup the detour bytes
            New = new List <byte> {
                0x68
            };
            var tmp = BitConverter.GetBytes(Hook.ToInt32());

            New.AddRange(tmp);
            New.Add(0xC3);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="DetourManager" /> class.
 /// </summary>
 public DetourManager(MemoryPlus memoryPlus)
 {
     MemoryPlus = memoryPlus;
 }