aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-01-24 13:53:06 +0000
committerVaxry <[email protected]>2024-01-24 13:53:18 +0000
commit754eaf5b8b65c9764abe67ec2d599036cd51e381 (patch)
treed82a1e2ccba4eabcc328b8b8507a4971a9f4e566 /src
parentdf17991b1c3f9f5f8da546f2523e5092e266123a (diff)
downloadHyprland-754eaf5b8b65c9764abe67ec2d599036cd51e381.tar.gz
Hyprland-754eaf5b8b65c9764abe67ec2d599036cd51e381.zip
pluginapi: fix hooks with negative rip offsets
fixes #4484
Diffstat (limited to 'src')
-rw-r--r--src/plugins/HookSystem.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/HookSystem.cpp b/src/plugins/HookSystem.cpp
index a7625ffe..ca38fe95 100644
--- a/src/plugins/HookSystem.cpp
+++ b/src/plugins/HookSystem.cpp
@@ -74,9 +74,10 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
std::string code = probe.assembly.substr(lastAsmNewline, probe.assembly.find("\n", lastAsmNewline) - lastAsmNewline);
if (code.contains("%rip")) {
CVarList tokens{code, 0, 's'};
- size_t plusPresent = tokens[1][0] == '+' ? 1 : 0;
- std::string addr = tokens[1].substr(plusPresent, tokens[1].find("(%rip)") - plusPresent);
- const uint64_t OFFSET = configStringToInt(addr);
+ size_t plusPresent = tokens[1][0] == '+' ? 1 : 0;
+ size_t minusPresent = tokens[1][0] == '-' ? 1 : 0;
+ std::string addr = tokens[1].substr((plusPresent || minusPresent), tokens[1].find("(%rip)") - (plusPresent || minusPresent));
+ const uint64_t OFFSET = (minusPresent ? -1 : 1) * configStringToInt(addr);
if (OFFSET == 0)
return {};
const uint64_t DESTINATION = currentAddress + OFFSET + len;