I'm trying to read a process's memory by reading /proc/<pid>/mem
.
My code works as expected when I'm using
char *data = malloc(123456);
read(fd_mem, buffer, 123456);
But that can take a lot of time because of the malloc/read
call, if the chuck of memory is really big. That's why I'm trying to switch to mmap
. I did some test code and it kept failing until I googled about mmaping /proc/<pid>/mem
and I realized that it's not possible (or is it?).
So my question is: How can I read the data inside /proc/<pid>/mem
like if it was a block of memory without the delay caused by malloc/read
EDIT: I need access to the entire block of memory. I do not want to read N bytes at a time.
EDIT: I already saw mmap on /proc/pid/mem. That question doesn't have an answer, it just says /proc/mem doesn't support mmap, which I already know. I'm asking for a solution.