title: How to call linux syscall PROCESS_VM_READV within python?
body: <p>I'm trying to learn how to call PROCESS_VM_READV within python. Reading from <a href="http://man7.org/linux/man-pages/man2/process_vm_writev.2.html" rel="nofollow noreferrer">the manual</a>, I've decided to create something similar to their example.</p>
  
  <p>I've opened python3 in terminal with root access. Then proceeded by importing&amp;initializing needed modules and variables</p>
  
  <pre><code>import ctypes
  libc = ctypes.CDLL('libc.so.6')
  vm=libc.process_vm_readv
  </code></pre>
  
  <p>In the example, there's a struct called <a href="https://riot-os.org/api/structiovec.html#a07aeddeccf80f14520fdd7ef0759442b" rel="nofollow noreferrer">iovec</a>. So, I need to re-create it in python</p>
  
  <pre><code>class iovec(ctypes.Structure):
      _fields_=[("iov_base",ctypes.c_void_p),("iov_len",ctypes.c_int)]
  </code></pre>
  
  <p>Then create the variables local and remote</p>
  
  <pre><code>p1=ctypes.c_char_p(b"")
  p1=ctypes.cast(p1,ctypes.c_void_p)
  local=iovec(p1,10)
  remote=iovec(0x00400000,20)  # Address of ELF header
  </code></pre>
  
  <p>Finally, calling PROCESS_VM_READV with pid of KMines</p>
  
  <pre><code>vm(2242,local,2,remote,1,0)
  </code></pre>
  
  <p>But it returns -1 and there are no changes in iov_base of local or remote. I feel like I'm doing a very simple mistake here but can't quite put my finger on it.</p>
  
  <p>Any help is appreciated, have a nice day.</p>