MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / peek

Method peek

pydevd_attach_to_process/winappdbg/process.py:1957–1992  ·  view source on GitHub ↗

Reads the memory of the process. @see: L{read} @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 proc

(self, lpBaseAddress, nSize)

Source from the content-addressed store, hash-verified

1955 return self.poke(address, packed)
1956
1957 def peek(self, lpBaseAddress, nSize):
1958 """
1959 Reads the memory of the process.
1960
1961 @see: L{read}
1962
1963 @type lpBaseAddress: int
1964 @param lpBaseAddress: Memory address to begin reading.
1965
1966 @type nSize: int
1967 @param nSize: Number of bytes to read.
1968
1969 @rtype: str
1970 @return: Bytes read from the process memory.
1971 Returns an empty string on error.
1972 """
1973 # XXX TODO
1974 # + Maybe change page permissions before trying to read?
1975 # + Maybe use mquery instead of get_memory_map?
1976 # (less syscalls if we break out of the loop earlier)
1977 data = ""
1978 if nSize > 0:
1979 try:
1980 hProcess = self.get_handle(win32.PROCESS_VM_READ | win32.PROCESS_QUERY_INFORMATION)
1981 for mbi in self.get_memory_map(lpBaseAddress, lpBaseAddress + nSize):
1982 if not mbi.is_readable():
1983 nSize = mbi.BaseAddress - lpBaseAddress
1984 break
1985 if nSize > 0:
1986 data = win32.ReadProcessMemory(hProcess, lpBaseAddress, nSize)
1987 except WindowsError:
1988 e = sys.exc_info()[1]
1989 msg = "Error reading process %d address %s: %s"
1990 msg %= (self.get_pid(), HexDump.address(lpBaseAddress), e.strerror)
1991 warnings.warn(msg)
1992 return data
1993
1994 def poke(self, lpBaseAddress, lpBuffer):
1995 """

Callers 14

__peek_c_typeMethod · 0.95
peek_charMethod · 0.95
peek_stringMethod · 0.95
peek_pointers_in_dataMethod · 0.95
read_memoryMethod · 0.80
get_stack_frameMethod · 0.80
peek_stack_dataMethod · 0.80
peek_code_bytesMethod · 0.80

Calls 5

get_handleMethod · 0.95
get_memory_mapMethod · 0.95
get_pidMethod · 0.95
is_readableMethod · 0.80
addressMethod · 0.45

Tested by

no test coverage detected