summaryrefslogtreecommitdiff
path: root/src/plugins/HookSystem.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-12-28 13:36:09 +0100
committervaxerski <vaxry@vaxry.net>2023-12-28 13:36:09 +0100
commit6a93cee74e8f076068bea1463b95ee0374c50a3a (patch)
treee302784d078ca7685fb4ef66b201c539e522f639 /src/plugins/HookSystem.cpp
parent07132741bc02631966ca06ed54b55598a8487a5d (diff)
pluginapi: manually detect endbr64 opcodes in function hooks
ref #4277
Diffstat (limited to 'src/plugins/HookSystem.cpp')
-rw-r--r--src/plugins/HookSystem.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/HookSystem.cpp b/src/plugins/HookSystem.cpp
index d0a3aeee..e52fd749 100644
--- a/src/plugins/HookSystem.cpp
+++ b/src/plugins/HookSystem.cpp
@@ -93,6 +93,22 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
} else {
return {};
}
+ } else if (code.contains("invalid")) {
+ std::vector<uint8_t> bytes;
+ bytes.resize(len);
+ memcpy(bytes.data(), (std::byte*)currentAddress, len);
+ if (len == 4 && bytes[0] == 0xF3 && bytes[1] == 0x0F && bytes[2] == 0x1E && bytes[3] == 0xFA) {
+ // F3 0F 1E FA = endbr64, udis doesn't understand that one
+ assemblyBuilder += "endbr64\n";
+ } else {
+ // raise error, unknown op
+ std::string strBytes;
+ for (auto& b : bytes) {
+ strBytes += std::format("{:x} ", b);
+ }
+ Debug::log(ERR, "[functionhook] unknown bytes: {}", strBytes);
+ return {};
+ }
} else {
assemblyBuilder += code + "\n";
}