Crashpad
Public Member Functions | List of all members
crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType > Class Template Reference

Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in. More...

#include "util/numeric/checked_address_range.h"

Public Member Functions

 CheckedAddressRangeGeneric ()
 Initializes a default range. More...
 
 CheckedAddressRangeGeneric (bool is_64_bit, ValueType base, SizeType size)
 Initializes a range. More...
 
void SetRange (bool is_64_bit, ValueType base, SizeType size)
 Sets a range’s fields. More...
 
ValueType Base () const
 The range’s base address.
 
SizeType Size () const
 The range’s size.
 
ValueType End () const
 The range’s end address (its base address plus its size).
 
bool IsValid () const
 Returns the validity of the address range. More...
 
bool Is64Bit () const
 Returns whether this range refers to a 64-bit process.
 
bool ContainsValue (const ValueType value) const
 Returns whether the address range contains another address. More...
 
bool ContainsRange (const CheckedAddressRangeGeneric &that) const
 Returns whether the address range contains another address range. More...
 
std::string AsString () const
 Returns a string describing the address range. More...
 

Detailed Description

template<class ValueType, class SizeType>
class crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >

Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in.

This class checks bases of type ValueType and sizes of type SizeType against a process whose pointer type is either 32 or 64 bits wide.

Aside from varying the overall range on the basis of a process’ pointer type width, this class functions very similarly to CheckedRange.

See also
CheckedMachAddressRange

Constructor & Destructor Documentation

◆ CheckedAddressRangeGeneric() [1/2]

template<class ValueType , class SizeType >
crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::CheckedAddressRangeGeneric

Initializes a default range.

The default range has base 0, size 0, and appears to be from a 32-bit process.

◆ CheckedAddressRangeGeneric() [2/2]

template<class ValueType , class SizeType >
crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::CheckedAddressRangeGeneric ( bool  is_64_bit,
ValueType  base,
SizeType  size 
)

Initializes a range.

See SetRange().

Member Function Documentation

◆ AsString()

template<class ValueType , class SizeType >
std::string crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::AsString

Returns a string describing the address range.

The string will be formatted as "0x123 + 0x45 (64)", where the individual components are the address, size, and bitness.

◆ ContainsRange()

template<class ValueType , class SizeType >
bool crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::ContainsRange ( const CheckedAddressRangeGeneric< ValueType, SizeType > &  that) const

Returns whether the address range contains another address range.

Parameters
[in]thatThe (possibly) contained address range.
Returns
true if this address range, the containing address range, contains that, the contained address range. false otherwise.

An address range contains another address range when the contained address range’s base is greater than or equal to the containing address range’s base, and the contained address range’s end is less than or equal to the containing address range’s end.

This method should only be called on two CheckedAddressRangeGeneric objects representing address ranges in the same process.

This method must only be called if IsValid() would return true for both CheckedAddressRangeGeneric objects involved.

◆ ContainsValue()

template<class ValueType , class SizeType >
bool crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::ContainsValue ( const ValueType  value) const

Returns whether the address range contains another address.

Parameters
[in]valueThe (possibly) contained address.
Returns
true if the address range contains value, false otherwise.

An address range contains a value if the value is greater than or equal to its base address, and less than its end address (base address plus size).

This method must only be called if IsValid() would return true.

◆ IsValid()

template<class ValueType , class SizeType >
bool crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::IsValid

Returns the validity of the address range.

Returns
true if the address range is valid, false otherwise.

An address range is valid if its size can be converted to the address range’s data type without data loss, and if its end (base plus size) can be computed without overflowing its data type.

◆ SetRange()

template<class ValueType , class SizeType >
void crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::SetRange ( bool  is_64_bit,
ValueType  base,
SizeType  size 
)

Sets a range’s fields.

Parameters
[in]is_64_bittrue if base and size refer to addresses in a 64-bit process; false if they refer to addresses in a 32-bit process.
[in]baseThe range’s base address.
[in]sizeThe range’s size.

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