-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathramRead.cpp
More file actions
27 lines (23 loc) · 753 Bytes
/
ramRead.cpp
File metadata and controls
27 lines (23 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <jni.h>
#include "ramRead_MainClass.h"
#include <sys/uio.h>
#include <iostream>
JNIEXPORT void JNICALL Java_ramRead_MainClass_readRam
(JNIEnv *env, jclass, jobject byteBuffer, jlong addr, jint pid)
{
struct iovec local[1];
struct iovec remote[1];
void* buf = env->GetDirectBufferAddress(byteBuffer);
jlong len = env->GetDirectBufferCapacity(byteBuffer);
local[0].iov_base = buf;
local[0].iov_len = len;
remote[0].iov_base = (void *) addr;
remote[0].iov_len = len;
//1. process id
//2. localiov local
//3. local iov count
//4. remoteiov
//5. remote iov count
//6. flags
process_vm_readv(pid, local, 1, remote, 1, 0);
}