protect.h 787 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #include "defaults.h"
  3. #include <util/generic/flags.h>
  4. enum EProtectMemoryMode {
  5. PM_NONE = 0x00, // no access allowed
  6. PM_READ = 0x01, // read access allowed
  7. PM_WRITE = 0x02, // write access allowed
  8. PM_EXEC = 0x04 // execute access allowed
  9. };
  10. Y_DECLARE_FLAGS(EProtectMemory, EProtectMemoryMode);
  11. Y_DECLARE_OPERATORS_FOR_FLAGS(EProtectMemory);
  12. /**
  13. * Set protection mode on memory block
  14. * @param addr Block address to be protected
  15. * @param length Block size in bytes
  16. * @param mode A bitwise combination of @c EProtectMemoryMode flags
  17. * @note On Windows there is no write-only protection mode,
  18. * so PM_WRITE will be translated to (PM_READ | PM_WRITE) on Windows.
  19. **/
  20. void ProtectMemory(void* addr, const size_t length, const EProtectMemory mode);