Exemple #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ADetour" /> class.
        /// </summary>
        /// <param name="target">The target delegate.</param>
        /// <param name="hook">The hook delegate.</param>
        /// <param name="identifier"></param>
        /// <param name="memory">The <see cref="MemoryPlus" /> instance.</param>
        /// <param name="ignoreRules"></param>
        public ADetour(Delegate target, Delegate hook, string identifier, IAMemory memory,
                       bool ignoreRules = false)
        {
            ProcessMemory = memory;
            Identifier    = identifier;
            IgnoreRules   = ignoreRules;

            TargetDelegate = target;
            Target         = target.ToFunctionPtr();

            _hookDelegate = hook;
            HookPointer   = hook.ToFunctionPtr(); //target

            //Store the original bytes
            Original = new List <byte>();
            Original.AddRange(memory.Read(Target, 6));

            //Setup the detour bytes
            New = new List <byte> {
                0x68
            };

            var bytes = IntPtr.Size == 4 ? BitConverter.GetBytes(HookPointer.ToInt32()) : BitConverter.GetBytes(HookPointer.ToInt64());


            New.AddRange(bytes);
            New.Add(0xC3);
        }
Exemple #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="APatch" /> class.
 /// </summary>
 /// <param name="address">The address where the patch is located in Memory.</param>
 /// <param name="patchWith">The bytes to be written.</param>
 /// <param name="identifier"></param>
 /// <param name="processPlus"></param>
 /// <param name="ignoreRules"></param>
 public APatch(IntPtr address, byte[] patchWith, string identifier, IAMemory processPlus,
               bool ignoreRules = false)
 {
     Identifier    = identifier;
     ProcessPlus   = processPlus;
     Address       = address;
     PatchBytes    = patchWith;
     OriginalBytes = processPlus.Read(address, patchWith.Length);
     IgnoreRules   = ignoreRules;
 }