Skip to content

Commit

Permalink
pluginapi: fix hooks with negative rip offsets
Browse files Browse the repository at this point in the history
fixes #4484
  • Loading branch information
vaxerski committed Jan 24, 2024
1 parent df17991 commit 754eaf5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/plugins/HookSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 754eaf5

Please sign in to comment.