Crashpad
|
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... | |
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.
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.
crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::CheckedAddressRangeGeneric | ( | bool | is_64_bit, |
ValueType | base, | ||
SizeType | size | ||
) |
Initializes a range.
See SetRange().
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.
bool crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::ContainsRange | ( | const CheckedAddressRangeGeneric< ValueType, SizeType > & | that | ) | const |
Returns whether the address range contains another address range.
[in] | that | The (possibly) contained address range. |
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.
bool crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::ContainsValue | ( | const ValueType | value | ) | const |
Returns whether the address range contains another address.
[in] | value | The (possibly) contained address. |
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
.
bool crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::IsValid |
Returns the validity of the address range.
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.
void crashpad::internal::CheckedAddressRangeGeneric< ValueType, SizeType >::SetRange | ( | bool | is_64_bit, |
ValueType | base, | ||
SizeType | size | ||
) |
Sets a range’s fields.
[in] | is_64_bit | true if base and size refer to addresses in a 64-bit process; false if they refer to addresses in a 32-bit process. |
[in] | base | The range’s base address. |
[in] | size | The range’s size. |