public T[] Read <T>(MemoryAddress address, int count) { if (!IsValidAddress(address)) { throw new ArgumentOutOfRangeException("address"); } if (count < 0) { throw new ArgumentOutOfRangeException("count"); } if (!IsValidAddress(address + TypeHelper <T> .SizeOf * count)) { throw new ArgumentException(); } T[] array = new T[count]; if (TypeHelper <T> .HasKnownStructLayout) { int bufferSize = TypeHelper <T> .SizeOf * count; byte[] buffer = GetBuffer(bufferSize); UnsafeReadBytes(address, buffer, 0, bufferSize); StructHelper <T> .CopyFromBuffer(buffer, 0, array, 0, count); } else if (TypeHelper <T> .IsMemoryObjectType) { for (int i = 0; i < count; i++) { array[i] = (T)(object)MemoryObjectFactory.UnsafeCreate(typeof(T), Memory, address + i * TypeHelper <T> .SizeOf); } } else if (TypeHelper <T> .IsMemoryPointerType) { var buffer = new byte[count * PointerSize]; UnsafeReadBytes(address, buffer, 0, buffer.Length); var bufferReader = new BufferMemoryReader(buffer, 0, buffer.Length, PointerSize); for (int i = 0; i < count; i++) { array[i] = (T)(object)MemoryPointerFactory.UnsafeCreate <T>(Memory, bufferReader.ReadMemoryAddress(i * PointerSize)); } } else if (TypeHelper <T> .IsMemoryAddressType) { for (int i = 0; i < count; i++) { array[i] = (T)(object)ReadMemoryAddress(address + i * PointerSize); } } else { throw new NotSupportedException(); } return(array); }
public MemorySnapshot(IMemory baseMemory, MemoryAddress baseAddress, byte[] buffer, int offset, int count) { BaseMemory = baseMemory; BaseAddress = baseAddress; SnapshotReader = new BufferMemoryReader(buffer, offset, count, baseMemory.Reader.PointerSize); }
public void FreeSnapshot() { Snapshot = null; }
public void SetSnapshot(byte[] buffer, int offset, int count) { Snapshot = new BufferMemoryReader(buffer, offset, count, Memory.Reader.PointerSize); }