Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the function _hook_determine_start so the monitor works on modern win10 OS #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/hooking.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,17 @@ static int _hook_determine_start(hook_t *h)
continue;
}

// jmp dword [addr]
if(*addr == 0xff && addr[1] == 0x25) {
unhook_detect_add_region(h->funcname, addr, addr, addr, 6);

// jmp dword [addr] / jmp qword [addr]
if((*addr == 0xff && addr[1] == 0x25) || (*addr == 0x48 && addr[1] == 0xff && addr[2] == 0x25)) {
if(*addr == 0xff)
unhook_detect_add_region(h->funcname, addr, addr, addr, 6);
else
unhook_detect_add_region(h->funcname, addr, addr, addr, 7);
#if __x86_64__
addr += *(int32_t *)(addr + 2) + 6;
if(*addr == 0xff)
addr += *(int32_t *)(addr + 2) + 6;
else
addr += *(int32_t *)(addr + 3) + 7;
#else
addr = *(uint8_t **)(addr + 2);
#endif
Expand Down
4 changes: 2 additions & 2 deletions utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def process(self):
sigs.append({
"library": insn["module_clean"],
"apiname": insn["funcname"],
"ignore": last == insn["funcname"],
"ignore": last == insn["module"] + insn["funcname"],
"is_insn": True,
"is_hook": True,
"signature": {
Expand All @@ -479,7 +479,7 @@ def process(self):
},
"logging": logging,
})
last = insn["funcname"]
last = insn["module"] + insn["funcname"]

# Assign hook indices accordingly (in a sorted manner).
for idx, sig in enumerate(sigs):
Expand Down