public void Disable() { if (IsActive) { PatchAddress.Write(OriginalBytes); IsActive = false; } }
public void Enable() { if (!IsActive) { PatchAddress.Write(NewBytes); IsActive = true; } }
/// <summary> /// A patch can be used to change byte(s) starting at the defined address. /// </summary> /// <param name="addressToPatch">The address of the byte where we want our patch to start.</param> public MemoryPatch(MemoryPointer addressToPatch, byte[] newBytes) { PatchAddress = addressToPatch ?? throw new ArgumentNullException(nameof(addressToPatch)); NewBytes = newBytes ?? throw new ArgumentNullException(nameof(newBytes)); OriginalBytes = PatchAddress.Read(NewBytes.Length); MemoryPatches.Add(this); }