Class BufferFile
Implements
Inherited Members
Namespace: PeNet.FileParser
Assembly: PeNet.dll
Syntax
public class BufferFile : IRawFile
Constructors
| Edit this page View SourceBufferFile(byte[])
Declaration
public BufferFile(byte[] file)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | file |
Properties
| Edit this page View SourceLength
Get the length of the unerlying PE file in bytes.
Declaration
public long Length { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
| Edit this page View SourceAppendBytes(Span<byte>)
Appends the given bytes to the current raw file. The file growths by the size of the given span.
Declaration
public int AppendBytes(Span<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<byte> | bytes | Bytes to append. |
Returns
| Type | Description |
|---|---|
| int | Raw start address of the appended bytes. |
AsSpan(long, long)
Get a Span from the underlying file.
Declaration
public Span<byte> AsSpan(long offset, long length)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Start offset of the span. |
| long | length | Length of the span in byte. |
Returns
| Type | Description |
|---|---|
| Span<byte> |
ReadAsciiString(long)
Read a ASCII (zero-terminated, one byte per character) string at a given offset.
Declaration
public string ReadAsciiString(long offset)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Start offset of the string. |
Returns
| Type | Description |
|---|---|
| string | Parsed C string. |
ReadByte(long)
Read a byte at the given offset.
Declaration
public byte ReadByte(long offset)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to read from. |
Returns
| Type | Description |
|---|---|
| byte | Byte at given offset. |
ReadUInt(long)
Read an unsigned integer (four bytes) at the given offset.
Declaration
public uint ReadUInt(long offset)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to read from. |
Returns
| Type | Description |
|---|---|
| uint | UInt at given offset. |
ReadULong(long)
Read an unsigned long (eight bytes) at the given offset.
Declaration
public ulong ReadULong(long offset)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to read from. |
Returns
| Type | Description |
|---|---|
| ulong | ULong at given offset. |
ReadUShort(long)
Read an unsigned short (two bytes) at the given offset.
Declaration
public ushort ReadUShort(long offset)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to read from. |
Returns
| Type | Description |
|---|---|
| ushort | UShort at given offset. |
ReadUnicodeString(long)
Read an unicode (two byte per char) string at a given offset.
Declaration
public string ReadUnicodeString(long offset)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Start offset of the string. |
Returns
| Type | Description |
|---|---|
| string | Parsed unicode string. |
ReadUnicodeString(long, long)
Read an unicode (two byte per char) string at a given offset of a given length.
Declaration
public string ReadUnicodeString(long offset, long length)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Start offset of the string. |
| long | length | Number of unicode chars to read. |
Returns
| Type | Description |
|---|---|
| string | Parsed unicode string. |
RemoveRange(long, long)
Remove a byte range from the underlying file.
Declaration
public void RemoveRange(long offset, long length)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset of the range to remove. |
| long | length | Length of the range to remove. |
ToArray()
Get the underlying file as a byte array.
Declaration
public byte[] ToArray()
Returns
| Type | Description |
|---|---|
| byte[] | Byte array representation fo the file. |
WriteByte(long, byte)
Write a byte at a given offset.
Declaration
public void WriteByte(long offset, byte value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to write to. |
| byte | value | Byte value to write. |
WriteBytes(long, Span<byte>)
Write a byte sequence to a given offset.
Declaration
public void WriteBytes(long offset, Span<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Start offset to write to. |
| Span<byte> | bytes | Byte sequence to write. |
WriteUInt(long, uint)
Write a uint at a given offset.
Declaration
public void WriteUInt(long offset, uint value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to write to. |
| uint | value | UInt value to write. |
WriteULong(long, ulong)
Write a ulong at a given offset.
Declaration
public void WriteULong(long offset, ulong value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to write to. |
| ulong | value | ULong value to write. |
WriteUShort(long, ushort)
Write a ushort at a given offset.
Declaration
public void WriteUShort(long offset, ushort value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | offset | Offset to write to. |
| ushort | value | UShort value to write. |