Commit 783d5bfa authored by swift_gan's avatar swift_gan

tweak native hook

parent 6348b1d4
...@@ -283,8 +283,7 @@ namespace SandHook { ...@@ -283,8 +283,7 @@ namespace SandHook {
} }
HookTrampoline* TrampolineManager::installNativeHookTrampolineNoBackup(void *origin, HookTrampoline* TrampolineManager::installNativeHookTrampolineNoBackup(void *origin,
void *hook) { void *hook) { HookTrampoline* hookTrampoline = new HookTrampoline();
HookTrampoline* hookTrampoline = new HookTrampoline();
DirectJumpTrampoline* directJumpTrampoline = new DirectJumpTrampoline(); DirectJumpTrampoline* directJumpTrampoline = new DirectJumpTrampoline();
if (!memUnprotect(reinterpret_cast<Size>(origin), directJumpTrampoline->getCodeLen())) { if (!memUnprotect(reinterpret_cast<Size>(origin), directJumpTrampoline->getCodeLen())) {
...@@ -293,10 +292,16 @@ namespace SandHook { ...@@ -293,10 +292,16 @@ namespace SandHook {
} }
directJumpTrampoline->init(); directJumpTrampoline->init();
#if defined(__arm__)
checkThumbCode(directJumpTrampoline, reinterpret_cast<Code>(origin)); checkThumbCode(directJumpTrampoline, reinterpret_cast<Code>(origin));
if (directJumpTrampoline->isThumbCode()) { if (directJumpTrampoline->isThumbCode()) {
origin = directJumpTrampoline->getThumbCodeAddress(reinterpret_cast<Code>(origin)); origin = directJumpTrampoline->getThumbCodeAddress(reinterpret_cast<Code>(origin));
} }
if (isThumbCode(reinterpret_cast<Size>(hook))) {
hook = directJumpTrampoline->getThumbCodePcAddress(reinterpret_cast<Code>(hook));
}
#endif
directJumpTrampoline->setExecuteSpace(reinterpret_cast<Code>(origin)); directJumpTrampoline->setExecuteSpace(reinterpret_cast<Code>(origin));
directJumpTrampoline->setJumpTarget(reinterpret_cast<Code>(hook)); directJumpTrampoline->setJumpTarget(reinterpret_cast<Code>(hook));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment