Exemplo n.º 1
0
 def read_pa(self, paddr, count):
     buffer = ffi.new("char[]", count)
     bytes_read = ffi.new("size_t *")
     status = lib.vmi_read_pa(self.vmi, paddr, count, buffer, bytes_read)
     check(status)
     # transform into Python bytes
     buffer = ffi.unpack(buffer, bytes_read[0])
     return (buffer, bytes_read[0])
Exemplo n.º 2
0
 def read_unicode_str_va(self, vaddr, pid):
     value = lib.vmi_read_unicode_str_va(self.vmi, vaddr, pid)
     if value == ffi.NULL:
         raise LibvmiError('VMI_FAILURE')
     encoding = ffi.string(value.encoding).decode()
     buffer = bytes(ffi.unpack(value.contents, value.length))
     self.free_unicode_str(value)
     return buffer.decode(encoding)
Exemplo n.º 3
0
 def read(self, ctx, count):
     buffer = ffi.new("char[]", count)
     bytes_read = ffi.new("size_t *")
     status = lib.vmi_read(self.vmi, ctx.to_ffi(), count, buffer,
                           bytes_read)
     check(status)
     # transform into Python bytes
     buffer = ffi.unpack(buffer, bytes_read[0])
     return buffer, bytes_read[0]
Exemplo n.º 4
0
 def read_pa_padded(self, paddr, count):
     buffer = ffi.new("char[]", count)
     bytes_read = ffi.new("size_t *")
     status = lib.vmi_read_pa(self.vmi, paddr, count, buffer, bytes_read)
     # transform into Python bytes
     buffer = ffi.unpack(buffer, bytes_read[0])
     if VMIStatus(status) == VMIStatus.FAILURE:
         # pad with zeroes
         pad_size = count - bytes_read[0]
         buffer += bytes(pad_size)
     return buffer