title: How can I protect the specific memory by using mprotect?
body: <p>I want to protect a specific memory area by using mprotect.</p>
  
  <p>So I wrote code to give a virtual address to protect but mprotect is not working.</p>
  
  <p>Is there any problem in my code?</p>
  
  <p>here is my code.</p>
  
  <pre><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;
  }
  </code></pre>