/// <summary> /// Applies injection /// </summary> /// <returns>True if injection was succcessfull</returns> public override bool Apply() { if (OnyxMemory.WriteBytes(_hProcess, _injectionAddress, _injectionBytes)) { IsApplied = true; } return(IsApplied); }
/// <summary> /// Frees allocated memory block and makes calling injected code impossible /// </summary> /// <returns>True if injection was unapplied</returns> public override bool Remove() { if (OnyxMemory.FreeMemory(_hProcess, _injectionAddress)) { IsApplied = false; } return(IsApplied); }
/// <summary> /// Restores bytes to their original values /// </summary> /// <returns>True if patch was unapplied</returns> public override bool Remove() { if (OnyxMemory.WriteBytes(m_hProcess, m_patchAddress, m_originalBytes)) { IsApplied = false; } return(!IsApplied); }
/// <summary> /// Initializes a new instance of the OnyxPatch class. /// </summary> /// <param name="injectionAddress">Address of injection</param> /// <param name="injectionBytes">Bytes, that contains injection</param> /// <param name="injectionName">Patch name, that will be used in PatchManager</param> public OnyxInjection(IntPtr hProcess, byte[] injectionBytes, string injectionName = null) { if (injectionName != null) { m_name = injectionName; } if (hProcess == IntPtr.Zero) { throw new ArgumentNullException("hProcess"); } _injectionBytes = injectionBytes; _hProcess = hProcess; _injectionAddress = OnyxMemory.AllocateMemory(_hProcess, (uint)injectionBytes.Length); }
/// <summary> /// Initializes a new instance of the OnyxPatch class. /// </summary> /// <param name="_hProcess"></param> /// <param name="_patchAddress">Address of patch</param> /// <param name="_patchBytes">Bytes, that contains patch</param> /// <param name="_patchName">Patch name, that will be used in PatchManager</param> public OnyxPatch(IntPtr _hProcess, IntPtr _patchAddress, byte[] _patchBytes, string _patchName = null) { if (_patchName != null) { m_name = _patchName; } if (_hProcess == IntPtr.Zero) { throw new ArgumentNullException("_hProcess"); } if (_patchAddress == IntPtr.Zero) { throw new ArgumentNullException("_patchAddress"); } m_patchAddress = _patchAddress; m_patchBytes = _patchBytes; m_hProcess = _hProcess; m_originalBytes = OnyxMemory.ReadBytes(m_hProcess, m_patchAddress, m_patchBytes.Length); }
/// <summary> /// Applies patch /// </summary> /// <returns>True if patch was succcessfull</returns> public override bool Apply() { IsApplied = OnyxMemory.WriteBytes(m_hProcess, m_patchAddress, m_patchBytes); return(IsApplied); }