/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; namespace dnSpy.Contracts.Hex { /// /// Edits a /// public abstract class HexEdit : IDisposable { /// /// Constructor /// protected HexEdit() { } /// /// true if this edit has been canceled /// public abstract bool Canceled { get; } /// /// Gets the buffer /// public abstract HexBuffer Buffer { get; } /// /// true if the edit has changes in non-read-only regions /// public abstract bool HasEffectiveChanges { get; } /// /// true if any changes failed to be added to this edit due to read-only regions /// public abstract bool HasFailedChanges { get; } /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, byte value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, sbyte value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, short value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, ushort value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, int value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, uint value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, long value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, ulong value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, float value); /// /// Replaces the at with /// /// Position /// New value /// public abstract bool Replace(HexPosition position, double value); /// /// Replaces the data at with /// /// Position /// New data /// public bool Replace(HexPosition position, byte[] data) { if (data is null) throw new ArgumentNullException(nameof(data)); return Replace(position, data, 0, data.LongLength); } /// /// Replaces the data at with /// /// Position /// New data /// Index /// Length /// public abstract bool Replace(HexPosition position, byte[] data, long index, long length); /// /// Commits all the modifications /// public abstract void Apply(); /// /// Cancels all modifications /// public abstract void Cancel(); /// /// Disposes this instance. If hasn't been called, the hex edit operation is canceled /// public abstract void Dispose(); } }