title: android kernel syscall table hook
body: <p>I am using android 4.2.2(Jelly Been) with linux-kernel 3.0.31 source code. I am trying to hook open system call but i don't know that how to change a page from read-only to writable given an address because sys_call_table is read-only.
  I have do it successfully on linux Ubuntu12.04 3.2.32 with lookup_address() function below.</p>
  
  <pre><code>int make_rw(unsigned long address)
     {
        unsigned int level;     
        pte_t *pte = lookup_address(address, &amp;level);
        if(pte-&gt;pte &amp;~ _PAGE_RW)
           pte-&gt;pte |= _PAGE_RW;
        return 0;
     }
  </code></pre>
  
  <p>but unfortunately this function is for x86 not for arm. I don't know how to do it on arm-arch </p>
  
  <p>another way: based on write protect register</p>
  
  <pre><code>    #define CR0_WP 0x10000  //Write Protect Bit (CR0:16)
      unsigned long cr0;
      cr0 = read_cr0();
      write_cr0(cr0 &amp; ~CR0_WP);/* remove write protection*/
      hookfunc(){...};  
      write_cr0(cr0);/* set write protection*/
  </code></pre>
  
  <p>but i do not know the relative register on arm-arch</p>
  
  <p>Does there anyone have solved this problem?   waiting for answer online!</p>