Class PtrReader
Provides methods to read data from an unmanaged memory pointer.
public class PtrReader
- Inheritance
-
PtrReader
- Derived
- Inherited Members
- Extension Methods
Constructors
PtrReader(IntPtr)
Initializes a new instance of the PtrReader class with the specified pointer.
public PtrReader(IntPtr ptr)
Parameters
ptr
IntPtrThe unmanaged memory pointer to read from.
Exceptions
- ArgumentNullException
Thrown if
ptr
is Zero.
Properties
Ptr
Gets or sets the unmanaged memory pointer.
public IntPtr Ptr { get; set; }
Property Value
Exceptions
- ArgumentNullException
Thrown if the value is Zero.
Methods
GetByte()
Reads a byte from the current pointer and advances the pointer by the size of a byte.
public byte GetByte()
Returns
- byte
The byte read from the pointer.
GetInt()
Reads a 32-bit integer from the current pointer and advances the pointer by the size of an integer.
public int GetInt()
Returns
- int
The 32-bit integer read from the pointer.
GetIntPtr()
public IntPtr GetIntPtr()
Returns
GetLong()
Reads a 64-bit integer from the current pointer and advances the pointer by the size of a long.
public long GetLong()
Returns
- long
The 64-bit integer read from the pointer.
GetShort()
Reads a 16-bit integer from the current pointer and advances the pointer by the size of a short.
public short GetShort()
Returns
- short
The 16-bit integer read from the pointer.
GetString()
Reads a null-terminated ANSI string from the current pointer and advances the pointer by the size of an IntPtr.
public string GetString()
Returns
- string
The ANSI string read from the pointer. If the string is null, an empty string is returned.
GetString(int)
Reads an ANSI string of the specified length from the current pointer and advances the pointer by the specified length.
public string GetString(int length)
Parameters
length
intThe length of the string to read.
Returns
- string
The ANSI string read from the pointer. If the string is null, an empty string is returned.