internal Patch(IntPtr address, byte[] patchWith, string name)
 {
     Name            = name;
     m_address       = address;
     m_patchBytes    = patchWith;
     m_originalBytes = HookMemory.Read(address, patchWith.Length);
 }
        public bool Remove()
        {
            try
            {
                HookMemory.Write(m_address, m_originalBytes);
            }
            catch
            {
                // ignored
            }

            return(false);
        }
Example #3
0
 public bool Remove()
 {
     try
     {
         HookMemory.Write(m_target, m_orginal.ToArray());
         IsApplied = false;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #4
0
 public bool Apply()
 {
     try
     {
         HookMemory.Write(m_target, m_new.ToArray());
         IsApplied = true;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public bool Apply()
        {
            try
            {
                HookMemory.Write(m_address, m_patchBytes);
                return(true);
            }
            catch
            {
                // ignored
            }

            return(false);
        }
Example #6
0
        internal Detour(Delegate target, Delegate hook, string name)
        {
            Name             = name;
            m_targetDelegate = target;
            m_target         = Marshal.GetFunctionPointerForDelegate(target);
            m_hookDelegate   = hook;
            m_hook           = Marshal.GetFunctionPointerForDelegate(hook);

            //Orginal bytes
            m_orginal = new List <byte>();
            m_orginal.AddRange(HookMemory.Read(m_target, 6));

            //Detour bytes
            m_new = new List <byte> {
                0x68
            };
            byte[] tmp = BitConverter.GetBytes(m_hook.ToInt32());
            m_new.AddRange(tmp);
            m_new.Add(0xC3);
        }