The problem:
I am trying to create a small memory dumper.
Sample code:
I though the call to mprotect should succeed when the program is run with super user permissions, but it doesn't.Code:#include <stdio.h> #include <stdlib.h> #include <sys/mman.h> int main() { int *x; int err; x = (int *)0xFF; err = mprotect(x, 256, PROT_READ); if(err) { printf("mprotect failed. Memory can not be read.\n"); exit(1); } printf("%p[%x]\n", x, *x); }
Any ideas?