Reads from the memory of the process. @see: L{peek} @type lpBaseAddress: int @param lpBaseAddress: Memory address to begin reading. @type nSize: int @param nSize: Number of bytes to read. @rtype: str @return: Bytes read from the
(self, lpBaseAddress, nSize)
| 1541 | # XXX TODO |
| 1542 | # + Maybe change page permissions before trying to read? |
| 1543 | def read(self, lpBaseAddress, nSize): |
| 1544 | """ |
| 1545 | Reads from the memory of the process. |
| 1546 | |
| 1547 | @see: L{peek} |
| 1548 | |
| 1549 | @type lpBaseAddress: int |
| 1550 | @param lpBaseAddress: Memory address to begin reading. |
| 1551 | |
| 1552 | @type nSize: int |
| 1553 | @param nSize: Number of bytes to read. |
| 1554 | |
| 1555 | @rtype: str |
| 1556 | @return: Bytes read from the process memory. |
| 1557 | |
| 1558 | @raise WindowsError: On error an exception is raised. |
| 1559 | """ |
| 1560 | hProcess = self.get_handle(win32.PROCESS_VM_READ | win32.PROCESS_QUERY_INFORMATION) |
| 1561 | if not self.is_buffer(lpBaseAddress, nSize): |
| 1562 | raise ctypes.WinError(win32.ERROR_INVALID_ADDRESS) |
| 1563 | data = win32.ReadProcessMemory(hProcess, lpBaseAddress, nSize) |
| 1564 | if len(data) != nSize: |
| 1565 | raise ctypes.WinError() |
| 1566 | return data |
| 1567 | |
| 1568 | def write(self, lpBaseAddress, lpBuffer): |
| 1569 | """ |
no test coverage detected