C# Class dnSpy.Contracts.Hex.HexBuffer

Hex buffer
Inheritance: Microsoft.VisualStudio.Utilities.IPropertyOwner, IDisposable
显示文件 Open project: 0xd4d/dnSpy Class Usage Examples

Public Methods

Method Description
CheckEditAccess ( ) : bool

Returns true if the current thread is allowed to modify the buffer

CreateEdit ( ) : dnSpy.Contracts.Hex.HexEdit

Creates a HexEdit object

CreateEdit ( int reiteratedVersionNumber, object editTag ) : dnSpy.Contracts.Hex.HexEdit

Creates a HexEdit object

Dispose ( ) : void

Disposes this instance

GetNextValidSpan ( HexPosition position, HexPosition upperBounds, bool fullSpan ) : HexSpan?

Gets the next valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.

GetNextValidSpan ( HexPosition position, bool fullSpan ) : HexSpan?

Gets the next valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.

GetPreviousValidSpan ( HexPosition position, HexPosition lowerBounds, bool fullSpan ) : HexSpan?

Gets the previous valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.

GetPreviousValidSpan ( HexPosition position, bool fullSpan ) : HexSpan?

Gets the previous valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.

GetSpanInfo ( HexPosition position ) : HexSpanInfo

Gets information about a position in the buffer. The returned info isn't normalized, there may be consecutive spans with the same flags. It's the responsibility of the caller to merge such spans.

GetValidSpans ( ) : IEnumerable

Gets all valid spans. This could be empty if it's a 0-byte buffer stream. This method merges all consecutive valid spans.

GetValidSpans ( HexSpan span, bool fullSpan ) : IEnumerable

Gets all valid spans overlapping span. This method merges all consecutive valid spans.

ReadByte ( HexPosition position ) : byte

Reads a byte

ReadBytes ( HexPosition position, long length ) : byte[]

Reads bytes

ReadBytes ( HexPosition position, ulong length ) : byte[]

Reads bytes

ReadBytes ( HexSpan span ) : byte[]

Reads bytes

ReadBytes ( HexPosition position, byte destination ) : void

Reads bytes

ReadBytes ( HexPosition position, byte destination, long destinationIndex, long length ) : void

Reads bytes

ReadDouble ( HexPosition position ) : double

Reads a double

ReadHexBytes ( HexPosition position, long length ) : dnSpy.Contracts.Hex.HexBytes

Reads bytes

ReadInt16 ( HexPosition position ) : short

Reads a short

ReadInt32 ( HexPosition position ) : int

Reads a int

ReadInt64 ( HexPosition position ) : long

Reads a long

ReadSByte ( HexPosition position ) : sbyte

Reads a sbyte

ReadSingle ( HexPosition position ) : float

Reads a float

ReadUInt16 ( HexPosition position ) : ushort

Reads a ushort

ReadUInt32 ( HexPosition position ) : uint

Reads a uint

ReadUInt64 ( HexPosition position ) : ulong

Reads a ulong

Refresh ( ) : void

Clears any read caches and raises BufferSpanInvalidated if needed

Replace ( HexPosition position, byte value ) : void

Replaces the byte at position with value

Replace ( HexPosition position, byte data, long index, long length ) : void

Replaces the data at position with data

Replace ( HexPosition position, double value ) : void

Replaces the double at position with value

Replace ( HexPosition position, float value ) : void

Replaces the float at position with value

Replace ( HexPosition position, int value ) : void

Replaces the int at position with value

Replace ( HexPosition position, long value ) : void

Replaces the long at position with value

Replace ( HexPosition position, sbyte value ) : void

Replaces the sbyte at position with value

Replace ( HexPosition position, short value ) : void

Replaces the short at position with value

Replace ( HexPosition position, uint value ) : void

Replaces the uint at position with value

Replace ( HexPosition position, ulong value ) : void

Replaces the ulong at position with value

Replace ( HexPosition position, ushort value ) : void

Replaces the ushort at position with value

TakeThreadOwnership ( ) : void

Claims ownership of this buffer for the current thread

TryReadByte ( HexPosition position ) : int

Tries to read a byte. If there's no data, a value less than 0 is returned.

Protected Methods

Method Description
DisposeCore ( ) : void

Disposes this instance

HexBuffer ( HexTags tags ) : System

Constructor

Private Methods

Method Description
GetStartOfData ( HexPosition start, bool validData ) : HexPosition
GetStartOfDataCore ( HexPosition start, bool validData ) : HexPosition

Method Details

CheckEditAccess() public abstract method

Returns true if the current thread is allowed to modify the buffer
public abstract CheckEditAccess ( ) : bool
return bool

CreateEdit() public abstract method

Creates a HexEdit object
public abstract CreateEdit ( ) : dnSpy.Contracts.Hex.HexEdit
return dnSpy.Contracts.Hex.HexEdit

CreateEdit() public abstract method

Creates a HexEdit object
public abstract CreateEdit ( int reiteratedVersionNumber, object editTag ) : dnSpy.Contracts.Hex.HexEdit
reiteratedVersionNumber int Use by undo/redo to restore a previous version
editTag object Edit tag, can be anything
return dnSpy.Contracts.Hex.HexEdit

Dispose() public method

Disposes this instance
public Dispose ( ) : void
return void

DisposeCore() protected method

Disposes this instance
protected DisposeCore ( ) : void
return void

GetNextValidSpan() public method

Gets the next valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.
public GetNextValidSpan ( HexPosition position, HexPosition upperBounds, bool fullSpan ) : HexSpan?
position HexPosition Start position to check
upperBounds HexPosition End position
fullSpan bool true if positions before should be included /// in the returned result. This could result in worse performance.
return HexSpan?

GetNextValidSpan() public method

Gets the next valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.
public GetNextValidSpan ( HexPosition position, bool fullSpan ) : HexSpan?
position HexPosition Start position to check
fullSpan bool true if positions before should be included /// in the returned result. This could result in worse performance.
return HexSpan?

GetPreviousValidSpan() public method

Gets the previous valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.
public GetPreviousValidSpan ( HexPosition position, HexPosition lowerBounds, bool fullSpan ) : HexSpan?
position HexPosition Start position to check
lowerBounds HexPosition End position
fullSpan bool true if positions after should be included /// in the returned result. This could result in worse performance.
return HexSpan?

GetPreviousValidSpan() public method

Gets the previous valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.
public GetPreviousValidSpan ( HexPosition position, bool fullSpan ) : HexSpan?
position HexPosition Start position to check
fullSpan bool true if positions after should be included /// in the returned result. This could result in worse performance.
return HexSpan?

GetSpanInfo() public abstract method

Gets information about a position in the buffer. The returned info isn't normalized, there may be consecutive spans with the same flags. It's the responsibility of the caller to merge such spans.
public abstract GetSpanInfo ( HexPosition position ) : HexSpanInfo
position HexPosition Position
return HexSpanInfo

GetValidSpans() public method

Gets all valid spans. This could be empty if it's a 0-byte buffer stream. This method merges all consecutive valid spans.
public GetValidSpans ( ) : IEnumerable
return IEnumerable

GetValidSpans() public method

Gets all valid spans overlapping span. This method merges all consecutive valid spans.
public GetValidSpans ( HexSpan span, bool fullSpan ) : IEnumerable
span HexSpan Span
fullSpan bool true if positions before should be included /// in the returned result. This could result in worse performance.
return IEnumerable

HexBuffer() protected method

Constructor
protected HexBuffer ( HexTags tags ) : System
tags HexTags
return System

ReadByte() public abstract method

Reads a byte
public abstract ReadByte ( HexPosition position ) : byte
position HexPosition Position
return byte

ReadBytes() public abstract method

Reads bytes
public abstract ReadBytes ( HexPosition position, long length ) : byte[]
position HexPosition Position
length long Number of bytes to read
return byte[]

ReadBytes() public abstract method

Reads bytes
public abstract ReadBytes ( HexPosition position, ulong length ) : byte[]
position HexPosition Position
length ulong Number of bytes to read
return byte[]

ReadBytes() public abstract method

Reads bytes
public abstract ReadBytes ( HexSpan span ) : byte[]
span HexSpan Span
return byte[]

ReadBytes() public method

Reads bytes
public ReadBytes ( HexPosition position, byte destination ) : void
position HexPosition Position
destination byte Destination array
return void

ReadBytes() public abstract method

Reads bytes
public abstract ReadBytes ( HexPosition position, byte destination, long destinationIndex, long length ) : void
position HexPosition Position
destination byte Destination array
destinationIndex long Index
length long Length
return void

ReadDouble() public abstract method

Reads a double
public abstract ReadDouble ( HexPosition position ) : double
position HexPosition Position
return double

ReadHexBytes() public abstract method

Reads bytes
public abstract ReadHexBytes ( HexPosition position, long length ) : dnSpy.Contracts.Hex.HexBytes
position HexPosition Position
length long Length
return dnSpy.Contracts.Hex.HexBytes

ReadInt16() public abstract method

Reads a short
public abstract ReadInt16 ( HexPosition position ) : short
position HexPosition Position
return short

ReadInt32() public abstract method

Reads a int
public abstract ReadInt32 ( HexPosition position ) : int
position HexPosition Position
return int

ReadInt64() public abstract method

Reads a long
public abstract ReadInt64 ( HexPosition position ) : long
position HexPosition Position
return long

ReadSByte() public abstract method

Reads a sbyte
public abstract ReadSByte ( HexPosition position ) : sbyte
position HexPosition Position
return sbyte

ReadSingle() public abstract method

Reads a float
public abstract ReadSingle ( HexPosition position ) : float
position HexPosition Position
return float

ReadUInt16() public abstract method

Reads a ushort
public abstract ReadUInt16 ( HexPosition position ) : ushort
position HexPosition Position
return ushort

ReadUInt32() public abstract method

Reads a uint
public abstract ReadUInt32 ( HexPosition position ) : uint
position HexPosition Position
return uint

ReadUInt64() public abstract method

Reads a ulong
public abstract ReadUInt64 ( HexPosition position ) : ulong
position HexPosition Position
return ulong

Refresh() public abstract method

Clears any read caches and raises BufferSpanInvalidated if needed
public abstract Refresh ( ) : void
return void

Replace() public method

Replaces the byte at position with value
public Replace ( HexPosition position, byte value ) : void
position HexPosition Position
value byte New value
return void

Replace() public method

Replaces the data at position with data
public Replace ( HexPosition position, byte data, long index, long length ) : void
position HexPosition Position
data byte New data
index long Index
length long Length
return void

Replace() public method

Replaces the double at position with value
public Replace ( HexPosition position, double value ) : void
position HexPosition Position
value double New value
return void

Replace() public method

Replaces the float at position with value
public Replace ( HexPosition position, float value ) : void
position HexPosition Position
value float New value
return void

Replace() public method

Replaces the int at position with value
public Replace ( HexPosition position, int value ) : void
position HexPosition Position
value int New value
return void

Replace() public method

Replaces the long at position with value
public Replace ( HexPosition position, long value ) : void
position HexPosition Position
value long New value
return void

Replace() public method

Replaces the sbyte at position with value
public Replace ( HexPosition position, sbyte value ) : void
position HexPosition Position
value sbyte New value
return void

Replace() public method

Replaces the short at position with value
public Replace ( HexPosition position, short value ) : void
position HexPosition Position
value short New value
return void

Replace() public method

Replaces the uint at position with value
public Replace ( HexPosition position, uint value ) : void
position HexPosition Position
value uint New value
return void

Replace() public method

Replaces the ulong at position with value
public Replace ( HexPosition position, ulong value ) : void
position HexPosition Position
value ulong New value
return void

Replace() public method

Replaces the ushort at position with value
public Replace ( HexPosition position, ushort value ) : void
position HexPosition Position
value ushort New value
return void

TakeThreadOwnership() public abstract method

Claims ownership of this buffer for the current thread
public abstract TakeThreadOwnership ( ) : void
return void

TryReadByte() public abstract method

Tries to read a byte. If there's no data, a value less than 0 is returned.
public abstract TryReadByte ( HexPosition position ) : int
position HexPosition Position
return int