/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/yt/memory/safe_memory_reader.h
38 строк
943 B
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#pragma once #include "public.h" namespace NYT { //////////////////////////////////////////////////////////////////////////////// //! Enables safe read-only access to the address space of the current process. /*! * Inaccessible memory locations will not cause any traps but rather report * failure via return value. */ class TSafeMemoryReader { public: TSafeMemoryReader(); TSafeMemoryReader(const TSafeMemoryReader&) = delete; ~TSafeMemoryReader(); //! Attempts to read #value at address #addr. //! Returns |true| on success, |false| on failure. template <class T> bool Read(const void* addr, T* value); private: int FD_ = -1; bool ReadRaw(const void* addr, void* ptr, size_t size); }; //////////////////////////////////////////////////////////////////////////////// } // namespace NYT #define SAFE_MEMORY_READER_INL_H_ #include "safe_memory_reader-inl.h" #undef SAFE_MEMORY_READER_INL_H_