24template <
typename _ResultType,
typename _PtrType>
26 using _basic_resulttype = std::remove_extent_t<_ResultType>;
27 using _basic_ptrtype = std::remove_extent_t<_PtrType>;
29 static_assert(std::is_same_v<_basic_ptrtype, uint32_t> ||
30 std::is_same_v<_basic_ptrtype, uint64_t>,
33 static constexpr bool _is_result_array = std::is_array_v<_ResultType>;
34 static constexpr bool _is_ptrtype_array = std::is_array_v<_PtrType>;
35 static constexpr bool _is_pointer = std::is_pointer_v<_basic_resulttype>;
36 static constexpr bool _is_cstring = std::is_same_v<std::remove_const_t<_ResultType>,
char[]>;
37 static constexpr bool _is_wstring =
38 std::is_same_v<std::remove_const_t<_ResultType>,
char16_t[]>;
43 inline void _check_bounds(
size_t index)
const {
44 constexpr bool length =
sizeof(_PtrType) /
sizeof(_basic_ptrtype);
49 explicit inline operator bool()
const {
return raw_ != 0; }
50 constexpr bool x64()
const {
return std::is_same_v<_basic_ptrtype, uint64_t>; }
53 void set(_basic_ptrtype in) {
54 static_assert(!_is_ptrtype_array,
"set() requires a length for array types");
57 void set(_basic_ptrtype in,
size_t index) {
58 static_assert(_is_ptrtype_array,
"set() only requires a length for array types");
62 template <
typename Tp,
typename PtrType>
64 static_assert(!_is_ptrtype_array,
"set() requires a length for array types");
67 template <
typename Tp,
typename PtrType>
69 static_assert(_is_ptrtype_array,
"set() only requires a length for array types");
77 static_assert(!_is_result_array,
"length is needed for arrays");
78 static_assert(!_is_ptrtype_array,
"index needed for arrays");
84 static_assert(_is_result_array,
"length is only needed for arrays");
85 static_assert(!_is_ptrtype_array,
"index needed for arrays");
91 static_assert(!_is_result_array,
"length is needed for arrays");
92 static_assert(_is_ptrtype_array,
"index only needed for non arrays");
94 context.
reset(raw_[index]);
99 static_assert(_is_result_array,
"length only needed for arrays");
100 static_assert(_is_ptrtype_array,
"index only needed for non arrays");
101 _check_bounds(index);
102 context.
reset(raw_[index]);
108 static_assert(_is_cstring,
"cstring() is only valid for char[]");
109 static_assert(!_is_ptrtype_array,
"index is required for cstring() arrays");
114 size_t max_length = 0xFFFF)
const {
115 static_assert(_is_cstring,
"cstring() is only valid for char[]");
116 static_assert(_is_ptrtype_array,
"index is only required for cstring() arrays");
117 _check_bounds(index);
118 context.
reset(raw_[index]);
123 static_assert(_is_wstring,
"wstring() is only valid for char16_t[]");
124 static_assert(!_is_ptrtype_array,
"index is required for cstring() arrays");
129 size_t max_length = 0xFFFF)
const {
130 static_assert(_is_wstring,
"wstring() is only valid for char16_t[]");
131 static_assert(_is_ptrtype_array,
"index is only required for cstring() arrays");
132 _check_bounds(index);
133 context.
reset(raw_[index]);
137 _basic_ptrtype
raw()
const {
138 static_assert(!_is_ptrtype_array,
"Index required for arrays");
142 _basic_ptrtype
raw(
size_t index)
const {
143 static_assert(_is_ptrtype_array,
"Index only required for arrays");
144 _check_bounds(index);
152static_assert(
sizeof(guest_member_ptr<void, uint32_t>) ==
sizeof(uint32_t),
153 "guest_ptr_member size mismatch");
154static_assert(
sizeof(guest_member_ptr<void, uint64_t>) ==
sizeof(uint64_t),
155 "guest_ptr_member size mismatch");
Definition guest_ptr.hh:88
uint64_t address() const
Functions for getting the underlying address.
Definition guest_ptr.hh:124
void reset()
Definition guest_ptr.hh:345
Helper class to embed in structs.
Definition guest_member_ptr.hh:25
void set(const guest_ptr< Tp, PtrType > &in, size_t index)
Definition guest_member_ptr.hh:68
guest_ptr< char[]> cstring(size_t index, guest_ptr< void > context, size_t max_length=0xFFFF) const
Definition guest_member_ptr.hh:113
_outptr_type get(size_t index, guest_ptr< void > context) const
Definition guest_member_ptr.hh:89
guest_ptr< char16_t[]> wstring(size_t index, guest_ptr< void > context, size_t max_length=0xFFFF) const
Definition guest_member_ptr.hh:128
void set(_basic_ptrtype in)
setters
Definition guest_member_ptr.hh:53
_basic_ptrtype raw() const
Definition guest_member_ptr.hh:137
void set(_basic_ptrtype in, size_t index)
Definition guest_member_ptr.hh:57
_outptr_type get(size_t index, guest_ptr< void > context, size_t length) const
Definition guest_member_ptr.hh:97
guest_ptr< char[]> cstring(guest_ptr< void > context, size_t max_length=0xFFFF) const
cstring helpers
Definition guest_member_ptr.hh:107
constexpr bool x64() const
Definition guest_member_ptr.hh:50
_outptr_type get(guest_ptr< void > context) const
Getters.
Definition guest_member_ptr.hh:75
_outptr_type get(guest_ptr< void > context, size_t length) const
Definition guest_member_ptr.hh:82
void set(const guest_ptr< Tp, PtrType > &in)
Definition guest_member_ptr.hh:63
guest_ptr< char16_t[]> wstring(guest_ptr< void > context, size_t max_length=0xFFFF) const
wstring helpers
Definition guest_member_ptr.hh:122
_basic_ptrtype raw(size_t index) const
Definition guest_member_ptr.hh:142
Type-safe guest virtual address pointer and guest_ptr template.
#define introvirt_assert(condition, msg)
Definition introvirt_assert.hh:32
Core IntroVirt classes.
Definition Cr0.hh:20
basic_guest_ptr< char16_t[], void, _Physical > map_guest_wstring(const basic_guest_ptr< _Tp, _PtrType, _Physical > &ptr, size_t max_length=0xFFFF)
Helper function for map_guest_str<char16_t>
Definition guest_ptr.hh:1417
basic_guest_ptr< char[], void, _Physical > map_guest_cstring(const basic_guest_ptr< _Tp, _PtrType, _Physical > &ptr, size_t max_length=0xFFFF)
Helper function for map_guest_str<char>
Definition guest_ptr.hh:1404