ByteBuffer bufSrc = ByteBuffer.allocateDirect(4);
bufSrc.put(new byte[]{5,10,15,20});
Pointer ptrSrc = Native.getDirectBufferPointer(bufSrc);
Pointer ptrDest = Native.getDirectBufferPointer(bufDest);
HANDLE selfHandle = kernel.GetCurrentProcess();
kernel.WriteProcessMemory(selfHandle, ptrDest, ptrSrc, 3, null);//Write only the first three
assertEquals(bufDest.get(0),5);
assertEquals(bufDest.get(1),10);
assertEquals(bufDest.get(2),15);