| 8 | #include "cstddef" |
| 9 | |
| 10 | class Rva { |
| 11 | public: |
| 12 | const void *address = nullptr; |
| 13 | size_t length = 0; |
| 14 | |
| 15 | Rva() = default; |
| 16 | |
| 17 | inline Rva(const void *addr, size_t len) : address(addr), length(len) {} |
| 18 | |
| 19 | template<class T> |
| 20 | inline T *at(size_t offset) noexcept { |
| 21 | if (offset + sizeof(T) > length) { |
| 22 | return nullptr; |
| 23 | } else { |
| 24 | return (T *) (((char *) address) + offset); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | template<class T> |
| 29 | inline const T *at(size_t offset) const noexcept { |
| 30 | if (offset + sizeof(T) > length) { |
| 31 | return nullptr; |
| 32 | } else { |
| 33 | return (const T *) (((const char *) address) + offset); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | template<class T> |
| 38 | inline bool access(size_t offset) const noexcept { |
| 39 | if (offset + sizeof(T) > length) { |
| 40 | return false; |
| 41 | } else { |
| 42 | return true; |
| 43 | } |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | #endif //RPCPROTOCOL_RVA_H |
no outgoing calls
no test coverage detected