diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-11-18 23:53:38 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-11-18 23:53:38 +0000 |
| commit | 47a1650c4810ad3cb3e9f125cb0addf18aa7395c (patch) | |
| tree | fb95e7a329dd2fe25e585cc9f71ef2face932508 /src/plugins | |
| parent | 936dfedbadbae761cd307ba7509467b55ac5e1ae (diff) | |
miscfunctions: move configStringToInt to std::expected
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/HookSystem.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/plugins/HookSystem.cpp b/src/plugins/HookSystem.cpp index 745b2593..69ca81cb 100644 --- a/src/plugins/HookSystem.cpp +++ b/src/plugins/HookSystem.cpp @@ -90,11 +90,14 @@ 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; - size_t minusPresent = tokens[1][0] == '-' ? 1 : 0; - std::string addr = tokens[1].substr((plusPresent || minusPresent), tokens[1].find("(%rip)") - (plusPresent || minusPresent)); - const int32_t OFFSET = (minusPresent ? -1 : 1) * configStringToInt(addr); + CVarList tokens{code, 0, 's'}; + 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)); + auto addrResult = configStringToInt(addr); + if (!addrResult) + return {}; + const int32_t OFFSET = (minusPresent ? -1 : 1) * *addrResult; if (OFFSET == 0) return {}; const uint64_t DESTINATION = currentAddress + OFFSET + len; |
