mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 21:49:49 +01:00
functionhooks: throw an exception on unsupported %rip usage
ref #2479, now will actually tell you what's wrong instead of crashing
This commit is contained in:
parent
adeb20ea11
commit
1778fb77e2
1 changed files with 8 additions and 1 deletions
|
@ -45,6 +45,10 @@ size_t CFunctionHook::getInstructionLenAt(void* start) {
|
|||
// I don't have an assembler. I don't think udis provides one. Besides, variables might be tricky.
|
||||
if (((uint8_t*)start)[0] == 0xFF && ((uint8_t*)start)[1] == 0x15)
|
||||
m_vTrampolineRIPUses.emplace_back(std::make_pair<>((uint64_t)start - (uint64_t)m_pSource, ins));
|
||||
else {
|
||||
Debug::log(ERR, "[CFunctionHook] Cannot hook: unsupported %rip usage: {}", ins);
|
||||
throw std::runtime_error("unsupported %rip usage");
|
||||
}
|
||||
}
|
||||
|
||||
return insSize;
|
||||
|
@ -90,7 +94,10 @@ bool CFunctionHook::hook() {
|
|||
static constexpr size_t CALL_WITH_RAX_ADDRESS_OFFSET = 2;
|
||||
|
||||
// get minimum size to overwrite
|
||||
const auto HOOKSIZE = probeMinimumJumpSize(m_pSource, sizeof(ABSOLUTE_JMP_ADDRESS) + sizeof(PUSH_RAX) + sizeof(POP_RAX));
|
||||
size_t HOOKSIZE = 0;
|
||||
try {
|
||||
HOOKSIZE = probeMinimumJumpSize(m_pSource, sizeof(ABSOLUTE_JMP_ADDRESS) + sizeof(PUSH_RAX) + sizeof(POP_RAX));
|
||||
} catch (std::exception& e) { return false; }
|
||||
|
||||
// alloc trampoline
|
||||
const auto TRAMPOLINE_SIZE = sizeof(ABSOLUTE_JMP_ADDRESS) + HOOKSIZE + sizeof(PUSH_RAX) + m_vTrampolineRIPUses.size() * (sizeof(CALL_WITH_RAX) - 6);
|
||||
|
|
Loading…
Reference in a new issue