Crashpad
Public Member Functions | List of all members
crashpad::ProcessMemoryRange Class Reference

Provides range protected access to the memory of another process. More...

#include "util/process/process_memory_range.h"

Public Member Functions

bool Initialize (const ProcessMemory *memory, bool is_64_bit, VMAddress base, VMSize size)
 Initializes this object. More...
 
bool Initialize (const ProcessMemory *memory, bool is_64_bit)
 Initializes this object with the maximum range for the address space. More...
 
bool Initialize (const ProcessMemoryRange &other)
 Initializes this object from an existing memory range. More...
 
bool Is64Bit () const
 Returns whether the range is part of a 64-bit address space.
 
VMAddress Base () const
 Returns the base address of the range.
 
VMSize Size () const
 Returns the size of the range.
 
bool RestrictRange (VMAddress base, VMSize size)
 Shrinks the range to the new base and size. More...
 
bool Read (VMAddress address, VMSize size, void *buffer) const
 Copies memory from the target process into a caller-provided buffer in the current process. More...
 
bool ReadCStringSizeLimited (VMAddress address, VMSize size, std::string *string) const
 Reads a NUL-terminated C string from the target process into a string in the current process. More...
 

Detailed Description

Provides range protected access to the memory of another process.

Member Function Documentation

◆ Initialize() [1/3]

bool crashpad::ProcessMemoryRange::Initialize ( const ProcessMemory memory,
bool  is_64_bit 
)

Initializes this object with the maximum range for the address space.

One of the Initialize methods must be successfully called on this object before calling any other.

Parameters
[in]memoryThe memory reader to delegate to.
[in]is_64_bitWhether the target process is 64-bit.

◆ Initialize() [2/3]

bool crashpad::ProcessMemoryRange::Initialize ( const ProcessMemory memory,
bool  is_64_bit,
VMAddress  base,
VMSize  size 
)

Initializes this object.

One of the Initialize methods must be successfully called on this object before calling any other.

Parameters
[in]memoryThe memory reader to delegate to.
[in]is_64_bitWhether the target process is 64-bit.
[in]baseThe base address of the initial range.
[in]sizeThe size of the initial range.
Returns
true on success. false on failure with a message logged.

◆ Initialize() [3/3]

bool crashpad::ProcessMemoryRange::Initialize ( const ProcessMemoryRange other)

Initializes this object from an existing memory range.

One of the Initialize methods must be successfully called on this object before calling any other.

Parameters
[in]otherThe memory range object to initialize from.
Returns
true on success. false on failure with a message logged.

◆ Read()

bool crashpad::ProcessMemoryRange::Read ( VMAddress  address,
VMSize  size,
void *  buffer 
) const

Copies memory from the target process into a caller-provided buffer in the current process.

Parameters
[in]addressThe address, in the target process' address space, of the memory region to copy.
[in]sizeThe size, in bytes, of the memory region to copy. buffer must be at least this size.
[out]bufferThe buffer into which the contents of the other process' memory will be copied.
Returns
true on success, with buffer filled appropriately. false on failure, with a message logged.

◆ ReadCStringSizeLimited()

bool crashpad::ProcessMemoryRange::ReadCStringSizeLimited ( VMAddress  address,
VMSize  size,
std::string *  string 
) const

Reads a NUL-terminated C string from the target process into a string in the current process.

Parameters
[in]addressThe address, in the target process’s address space, of the string to copy.
[in]sizeThe maximum number of bytes to read. The string is required to be NUL-terminated within this many bytes.
[out]stringThe string read from the other process.
Returns
true on success, with string set appropriately. false on failure, with a message logged. Failures can occur, for example, when a NUL terminator is not found within size bytes, or when encountering unmapped or unreadable pages.

◆ RestrictRange()

bool crashpad::ProcessMemoryRange::RestrictRange ( VMAddress  base,
VMSize  size 
)

Shrinks the range to the new base and size.

The new range must be contained within the existing range for this object.

Parameters
[in]baseThe new base of the range.
[in]sizeThe new size of the range.
Returns
true on success. false on failure with a message logged.

The documentation for this class was generated from the following files: