summaryrefslogtreecommitdiff
path: root/src/plugins/HookSystem.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-10-14 13:39:22 +0100
committerVaxry <vaxry@vaxry.net>2025-10-14 13:39:22 +0100
commitee5d05f0fc03e65f50364f5b9f4315065f9f49c2 (patch)
treef46c7187a8bd3e7fbe9ce0b36f3f4390825dac0e /src/plugins/HookSystem.cpp
parentbbb83317c03fd925862eaf4b0c2eeb06967283d4 (diff)
hookSystem: fix anchor point for mmap
Diffstat (limited to 'src/plugins/HookSystem.cpp')
-rw-r--r--src/plugins/HookSystem.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/plugins/HookSystem.cpp b/src/plugins/HookSystem.cpp
index 31124d4f..4cd82550 100644
--- a/src/plugins/HookSystem.cpp
+++ b/src/plugins/HookSystem.cpp
@@ -172,7 +172,7 @@ bool CFunctionHook::hook() {
return false;
}
- if (rc<int64_t>(m_source) - rc<int64_t>(m_destination) > 2000000000 /* 2 GB */) {
+ if (std::abs(rc<int64_t>(m_source) - rc<int64_t>(m_destination)) > 2000000000 /* 2 GB */) {
Debug::log(ERR, "[functionhook] failed, source and dest are over 2GB apart");
return false;
}
@@ -312,8 +312,11 @@ static uintptr_t seekNewPageAddr() {
continue;
}
- if (start - lastEnd > PAGESIZE_VAR * 2) {
- if (!line.contains("Hyprland") && !anchoredToHyprland) {
+ if (!anchoredToHyprland && line.contains("Hyprland")) {
+ Debug::log(LOG, "seekNewPageAddr: Anchored to hyprland at 0x{:x}", start);
+ anchoredToHyprland = true;
+ } else if (start - lastEnd > PAGESIZE_VAR * 2) {
+ if (!anchoredToHyprland) {
Debug::log(LOG, "seekNewPageAddr: skipping gap 0x{:x}-0x{:x}, not anchored to Hyprland code pages yet.", lastEnd, start);
lastStart = start;
lastEnd = end;
@@ -325,11 +328,6 @@ static uintptr_t seekNewPageAddr() {
return lastEnd;
}
- if (!anchoredToHyprland && line.contains("Hyprland")) {
- Debug::log(LOG, "seekNewPageAddr: Anchored to hyprland at 0x{:x}", start);
- anchoredToHyprland = true;
- }
-
lastStart = start;
lastEnd = end;
}