static public T[] ReadArray <T>( this IMemoryReader MemoryReader, Int64 Address, int NumberOfBytes) where T : struct { if (null == MemoryReader) { return(null); } var BytesRead = MemoryReader.ReadBytes(Address, NumberOfBytes); if (null == BytesRead) { return(null); } var ElementSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)); var NumberOfElements = (BytesRead.Length - 1) / ElementSize + 1; var Array = new T[NumberOfElements]; Buffer.BlockCopy(BytesRead, 0, Array, 0, BytesRead.Length); return(Array); }
internal static Guid ReadComGuid(this IMemoryReader reader, IntPtr p) { if (p == IntPtr.Zero) { return(IID_IUnknown); } return(new Guid(reader.ReadBytes(p, 16))); }
internal static Guid ReadGuid(IMemoryReader reader, IntPtr p) { if (p == IntPtr.Zero) { return(NdrInterfacePointerTypeReference.IID_IUnknown); } return(new Guid(reader.ReadBytes(p, 16))); }
public static byte[] ReadBytes(this IMemoryReader memoryReader, long address, int bytesCountMax) { byte[] array = new byte[bytesCountMax]; int num = memoryReader.ReadBytes(address, bytesCountMax, array); if (num < 1) { return(null); } if (num == array.Length) { return(array); } byte[] array2 = new byte[num]; Buffer.BlockCopy(array, 0, array2, 0, array2.Length); return(array2); }
public static T[] ReadArray <T>(this IMemoryReader memoryReader, long address, int numberOfBytes) where T : struct { if (memoryReader == null) { return(null); } byte[] array = memoryReader.ReadBytes(address, numberOfBytes); if (array == null) { return(null); } int num = Marshal.SizeOf(typeof(T)); int num2 = (array.Length - 1) / num + 1; T[] array2 = new T[num2]; Buffer.BlockCopy(array, 0, array2, 0, array.Length); return(array2); }
static public string ReadUnicodeString( this IMemoryReader MemoryReader, Int64 Address, int length) { if (null == MemoryReader) { return(null); } var Bytes = MemoryReader.ReadBytes(Address, 2 * length); if (null == Bytes) { return(null); } return(Encoding.Unicode.GetString(Bytes)); }
static public string ReadStringAsciiNullTerminated( this IMemoryReader MemoryReader, Int64 Address, int LengthMax = 0x1000) { if (null == MemoryReader) { return(null); } var Bytes = MemoryReader.ReadBytes(Address, LengthMax); if (null == Bytes) { return(null); } var BytesNullTerminated = Bytes.TakeWhile((Byte) => 0 != Byte).ToArray(); return(Encoding.ASCII.GetString(BytesNullTerminated)); }
static public UInt32?ReadUInt32( this IMemoryReader MemoryReader, Int64 Address) { if (null == MemoryReader) { return(null); } var Bytes = MemoryReader.ReadBytes(Address, 4); if (null == Bytes) { return(null); } if (Bytes.Length < 4) { return(null); } return(BitConverter.ToUInt32(Bytes, 0)); }
static public bool?ReadBool( this IMemoryReader MemoryReader, Int64 Address) { if (null == MemoryReader) { return(null); } var Bytes = MemoryReader.ReadBytes(Address, 1); if (null == Bytes) { return(null); } if (Bytes.Length < 1) { return(null); } return(BitConverter.ToBoolean(Bytes, 0)); }
static public double?ReadDouble( this IMemoryReader MemoryReader, Int64 Address) { if (null == MemoryReader) { return(null); } var Bytes = MemoryReader.ReadBytes(Address, 8); if (null == Bytes) { return(null); } if (Bytes.Length < 8) { return(null); } return(BitConverter.ToDouble(Bytes, 0)); }
byte[] IMemoryReader.ReadBytes(long Address, int BytesCount) { return(MemoryReader.ReadBytes(Address, BytesCount)); }
public static string ReadStringAsciiNullTerminated(this IMemoryReader memoryReader, long address, int lengthMax = 4096) { return(memoryReader?.ReadBytes(address, lengthMax)?.ReadStringAsciiNullTerminated(0, lengthMax)); }
public static long ListeOktetLeeseVonAdrese(this IMemoryReader reader, long adrese, long listeOktetZuLeeseAnzaal, byte[] ziilArray) { int num = reader?.ReadBytes(adrese, (int)listeOktetZuLeeseAnzaal, ziilArray) ?? 0; return(num); }