Reputation: 73
I want to protect a specific memory area by using mprotect.
So I wrote code to give a virtual address to protect but mprotect is not working.
Is there any problem in my code?
here is my code.
int main(int argc, char *argv[]) {
size_t vaddr = strtoull(argv[1], NULL, 0); //./a.out 0xffff880446ced000
printf("addr : %p\n", vaddr);
if(mprotect(vaddr, 0x1000, PROT_READ | PROT_WRITE)==-1) {
printf("mprotect error\n");
return 0;
}
return 0;
}
Upvotes: 1
Views: 289