mirror of
https://git.recroomarchive.org/Radium/libradhook.git
synced 2026-08-07 09:10:59 +00:00
fix some styling
This commit is contained in:
@@ -258,8 +258,10 @@ void RestoreProtection(void* /*addr*/, size_t /*size*/, unsigned long /*oldProte
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FlushICache(void* addr, size_t size) {
|
void FlushICache(void* addr, size_t size) {
|
||||||
__builtin___clear_cache(reinterpret_cast<char*>(addr),
|
__builtin___clear_cache(
|
||||||
reinterpret_cast<char*>(addr) + size);
|
reinterpret_cast<char*>(addr),
|
||||||
|
reinterpret_cast<char*>(addr) + size
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -493,8 +495,7 @@ RadHookResult InstallHook(RadHookOpaque* h, void* target, void* detour) {
|
|||||||
int32_t originalDisp = 0;
|
int32_t originalDisp = 0;
|
||||||
std::memcpy(&originalDisp, reinterpret_cast<const uint8_t*>(target) + off, 4);
|
std::memcpy(&originalDisp, reinterpret_cast<const uint8_t*>(target) + off, 4);
|
||||||
uintptr_t absTarget = reinterpret_cast<uintptr_t>(target) + off + 4 + static_cast<intptr_t>(originalDisp);
|
uintptr_t absTarget = reinterpret_cast<uintptr_t>(target) + off + 4 + static_cast<intptr_t>(originalDisp);
|
||||||
intptr_t newDisp = static_cast<intptr_t>(absTarget) -
|
intptr_t newDisp = static_cast<intptr_t>(absTarget) - (reinterpret_cast<intptr_t>(trampolineAlloc) + off + 4);
|
||||||
(reinterpret_cast<intptr_t>(trampolineAlloc) + off + 4);
|
|
||||||
if (newDisp < INT32_MIN || newDisp > INT32_MAX) {
|
if (newDisp < INT32_MIN || newDisp > INT32_MAX) {
|
||||||
FreeExec(trampolineAlloc, allocSize);
|
FreeExec(trampolineAlloc, allocSize);
|
||||||
return RadHookResult::TrampolineTooFar;
|
return RadHookResult::TrampolineTooFar;
|
||||||
@@ -505,8 +506,12 @@ RadHookResult InstallHook(RadHookOpaque* h, void* target, void* detour) {
|
|||||||
|
|
||||||
uint8_t* jumpBack = reinterpret_cast<uint8_t*>(trampolineAlloc) + stolenLen;
|
uint8_t* jumpBack = reinterpret_cast<uint8_t*>(trampolineAlloc) + stolenLen;
|
||||||
uintptr_t backAddr = reinterpret_cast<uintptr_t>(target) + stolenLen;
|
uintptr_t backAddr = reinterpret_cast<uintptr_t>(target) + stolenLen;
|
||||||
jumpBack[0] = 0xFF; jumpBack[1] = 0x25;
|
{
|
||||||
jumpBack[2] = 0; jumpBack[3] = 0; jumpBack[4] = 0; jumpBack[5] = 0;
|
jumpBack[0] = 0xFF;
|
||||||
|
jumpBack[1] = 0x25;
|
||||||
|
jumpBack[2] = 0; jumpBack[3] = 0;
|
||||||
|
jumpBack[4] = 0; jumpBack[5] = 0;
|
||||||
|
}
|
||||||
std::memcpy(jumpBack + 6, &backAddr, 8);
|
std::memcpy(jumpBack + 6, &backAddr, 8);
|
||||||
|
|
||||||
FlushICache(trampolineAlloc, allocSize);
|
FlushICache(trampolineAlloc, allocSize);
|
||||||
@@ -521,8 +526,13 @@ RadHookResult InstallHook(RadHookOpaque* h, void* target, void* detour) {
|
|||||||
h->originalLength = stolenLen;
|
h->originalLength = stolenLen;
|
||||||
|
|
||||||
uint8_t hookStub[kX64StubLen];
|
uint8_t hookStub[kX64StubLen];
|
||||||
hookStub[0] = 0xFF; hookStub[1] = 0x25;
|
{
|
||||||
hookStub[2] = 0; hookStub[3] = 0; hookStub[4] = 0; hookStub[5] = 0;
|
hookStub[0] = 0xFF;
|
||||||
|
hookStub[1] = 0x25;
|
||||||
|
hookStub[2] = 0; hookStub[3] = 0;
|
||||||
|
hookStub[4] = 0; hookStub[5] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
uintptr_t detourAddr = reinterpret_cast<uintptr_t>(detour);
|
uintptr_t detourAddr = reinterpret_cast<uintptr_t>(detour);
|
||||||
std::memcpy(hookStub + 6, &detourAddr, 8);
|
std::memcpy(hookStub + 6, &detourAddr, 8);
|
||||||
std::memcpy(h->stubBytes, hookStub, kX64StubLen);
|
std::memcpy(h->stubBytes, hookStub, kX64StubLen);
|
||||||
|
|||||||
Reference in New Issue
Block a user