예제 #1
0
        def read(self):
                ctarray = (ctypes.c_byte * self.buffer_size)()
                bytes_read = wintypes.DWORD(0)

                overlapped = wintypes.OVERLAPPED()
                overlapped.hEvent = m_k32.CreateEventW(None, True, False, None)
                if m_k32.ReadFile(self.handle, ctypes.byref(ctarray), self.buffer_size, ctypes.byref(bytes_read), ctypes.byref(overlapped)):
                        return utilities.ctarray_to_bytes(ctarray)[:bytes_read.value]
                error = m_k32.GetLastError()
                if error == ERROR_IO_PENDING and _wait_overlapped_io(overlapped):
                        return utilities.ctarray_to_bytes(ctarray)[:overlapped.InternalHigh]
                if error == ERROR_BROKEN_PIPE:
                        return None
                raise ctypes.WinError()
예제 #2
0
	def read(self):
		ctarray = (ctypes.c_byte * self.buffer_size)()
		bytes_read = wintypes.DWORD(0)

		overlapped = wintypes.OVERLAPPED()
		overlapped.hEvent = m_k32.CreateEventW(None, True, False, None)
		if m_k32.ReadFile(self.handle, ctypes.byref(ctarray), self.buffer_size, ctypes.byref(bytes_read), ctypes.byref(overlapped)):
			return utilities.ctarray_to_bytes(ctarray)[:bytes_read.value]
		error = m_k32.GetLastError()
		if error == ERROR_IO_PENDING and _wait_overlapped_io(overlapped):
			return utilities.ctarray_to_bytes(ctarray)[:overlapped.InternalHigh]
		if error == ERROR_BROKEN_PIPE:
			return None
		raise ctypes.WinError()
예제 #3
0
 def read(self):
     ctarray = (ctypes.c_byte * self.buffer_size)()
     bytes_read = wintypes.DWORD(0)
     if not kernel32.ReadFile(self.handle, ctarray, self.buffer_size,
                              ctypes.byref(bytes_read), 0):
         return None
     return utilities.ctarray_to_bytes(ctarray)[:bytes_read.value]
예제 #4
0
 def read_memory(self, address, size=0x400):
     _data = (ctypes.c_byte * size)
     data = _data()
     if (m_k32.ReadProcessMemory(self.handle, address, ctypes.byref(data),
                                 ctypes.sizeof(data), 0) == 0):
         raise WindowsProcessError('Error: ReadProcessMemory',
                                   get_last_error=m_k32.GetLastError())
     return ctarray_to_bytes(data)