@Test public void readReadsManyBytes() { byte[] source = new byte[0xFF]; for (int i = 0; i < source.length; i++) { source[i] = (byte) i; } rawReader = new ByteArrayRawMemoryReader(source); byte[] readBytes = reader.read(process, 0, source.length); assertArrayEquals(source, readBytes); }
@Override public byte[] read(NativeProcess process, int offset, int bytesToRead) { if (bytesToRead < 1) { throw new IllegalArgumentException("Number of bytes to read must be greater than zero"); } ByteBuffer buffer = rawMemoryReader.read(process, offset, bytesToRead); byte[] ret = new byte[buffer.remaining()]; buffer.get(ret); return ret; }
MemoryReaderImpl implements MemoryReader { @Override public byte[] read(NativeProcess process, int offset, int bytesToRead) { if (bytesToRead < 1) { throw new IllegalArgumentException("Number of bytes to read must be greater than zero"); } ByteBuffer buffer = rawMemoryReader.read(process, offset, bytesToRead); byte[] ret = new byte[buffer.remaining()]; buffer.get(ret); return ret; } }
MemoryReaderImpl implements MemoryReader { @Override public byte[] read(NativeProcess process, int offset, int bytesToRead) { if (bytesToRead < 1) { throw new IllegalArgumentException("Number of bytes to read must be greater than zero"); } ByteBuffer buffer = rawMemoryReader.read(process, offset, bytesToRead); byte[] ret = new byte[buffer.remaining()]; buffer.get(ret); return ret; } MemoryReaderImpl(RawMemoryReader rawMemoryReader); }
MemoryReaderImpl implements MemoryReader { @Override public byte[] read(NativeProcess process, int offset, int bytesToRead) { if (bytesToRead < 1) { throw new IllegalArgumentException("Number of bytes to read must be greater than zero"); } ByteBuffer buffer = rawMemoryReader.read(process, offset, bytesToRead); byte[] ret = new byte[buffer.remaining()]; buffer.get(ret); return ret; } MemoryReaderImpl(RawMemoryReader rawMemoryReader); @Override boolean readBoolean(NativeProcess process, int offset); @Override byte readByte(NativeProcess process, int offset); @Override char readCharUTF8(NativeProcess process, int offset); @Override char readCharUTF16LE(NativeProcess process, int offset); @Override short readShort(NativeProcess process, int offset); @Override int readInt(NativeProcess process, int offset); @Override float readFloat(NativeProcess process, int offset); @Override long readLong(NativeProcess process, int offset); @Override double readDouble(NativeProcess process, int offset); @Override String readStringUTF8(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override String readStringUTF16LE(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override byte[] read(NativeProcess process, int offset, int bytesToRead); }
MemoryReaderImpl implements MemoryReader { @Override public byte[] read(NativeProcess process, int offset, int bytesToRead) { if (bytesToRead < 1) { throw new IllegalArgumentException("Number of bytes to read must be greater than zero"); } ByteBuffer buffer = rawMemoryReader.read(process, offset, bytesToRead); byte[] ret = new byte[buffer.remaining()]; buffer.get(ret); return ret; } MemoryReaderImpl(RawMemoryReader rawMemoryReader); @Override boolean readBoolean(NativeProcess process, int offset); @Override byte readByte(NativeProcess process, int offset); @Override char readCharUTF8(NativeProcess process, int offset); @Override char readCharUTF16LE(NativeProcess process, int offset); @Override short readShort(NativeProcess process, int offset); @Override int readInt(NativeProcess process, int offset); @Override float readFloat(NativeProcess process, int offset); @Override long readLong(NativeProcess process, int offset); @Override double readDouble(NativeProcess process, int offset); @Override String readStringUTF8(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override String readStringUTF16LE(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override byte[] read(NativeProcess process, int offset, int bytesToRead);  }