From aeec3f60e286bcecd12661ef22ac810638531b22 Mon Sep 17 00:00:00 2001 From: Curve Date: Thu, 9 May 2024 23:51:04 +0200 Subject: [PATCH] fix(hooks): require page to be at-least readable --- include/lime/hooks/hook.hpp | 1 + src/hooks.hook.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/lime/hooks/hook.hpp b/include/lime/hooks/hook.hpp index a1fa861..9147f37 100644 --- a/include/lime/hooks/hook.hpp +++ b/include/lime/hooks/hook.hpp @@ -46,6 +46,7 @@ namespace lime protect, relocate, bad_page, + bad_prot, }; class hook_base diff --git a/src/hooks.hook.cpp b/src/hooks.hook.cpp index 5be1633..99e3442 100644 --- a/src/hooks.hook.cpp +++ b/src/hooks.hook.cpp @@ -76,6 +76,11 @@ namespace lime return tl::make_unexpected(hook_error::bad_page); } + if (!(page->prot() & lime::protection::read)) + { + return tl::make_unexpected(hook_error::bad_prot); + } + auto start = instruction::unsafe(source); if (auto follow = start.follow(); follow)