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

修正 hook 时遇到偶发的段错误 #4

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion docs/overview/code/main/jni/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void hook()
addr = base_addr + 0x3f90;

//add write permission
mprotect((void *)PAGE_START(addr), PAGE_SIZE, PROT_READ | PROT_WRITE);
mprotect((void *)PAGE_START(addr), PAGE_SIZE * 2, PROT_READ | PROT_WRITE);

//replace the function address
*(void **)addr = my_malloc;
Expand Down
2 changes: 1 addition & 1 deletion libxhook/jni/xh_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int xh_util_get_addr_protect(uintptr_t addr, const char *pathname, unsigned int

int xh_util_set_addr_protect(uintptr_t addr, unsigned int prot)
{
if(0 != mprotect((void *)PAGE_START(addr), PAGE_SIZE, (int)prot))
if(0 != mprotect((void *)PAGE_START(addr), PAGE_SIZE * 2, (int)prot))
return 0 == errno ? XH_ERRNO_UNKNOWN : errno;

return 0;
Expand Down