Skip to content

Commit 754eaf5

Browse files
committed
pluginapi: fix hooks with negative rip offsets
fixes #4484
1 parent df17991 commit 754eaf5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/plugins/HookSystem.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
7474
std::string code = probe.assembly.substr(lastAsmNewline, probe.assembly.find("\n", lastAsmNewline) - lastAsmNewline);
7575
if (code.contains("%rip")) {
7676
CVarList tokens{code, 0, 's'};
77-
size_t plusPresent = tokens[1][0] == '+' ? 1 : 0;
78-
std::string addr = tokens[1].substr(plusPresent, tokens[1].find("(%rip)") - plusPresent);
79-
const uint64_t OFFSET = configStringToInt(addr);
77+
size_t plusPresent = tokens[1][0] == '+' ? 1 : 0;
78+
size_t minusPresent = tokens[1][0] == '-' ? 1 : 0;
79+
std::string addr = tokens[1].substr((plusPresent || minusPresent), tokens[1].find("(%rip)") - (plusPresent || minusPresent));
80+
const uint64_t OFFSET = (minusPresent ? -1 : 1) * configStringToInt(addr);
8081
if (OFFSET == 0)
8182
return {};
8283
const uint64_t DESTINATION = currentAddress + OFFSET + len;

0 commit comments

Comments
 (0)