Skip to content

Commit

Permalink
Hide CS_DEBUGGED on arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Feb 23, 2024
1 parent bd9ae00 commit 8475c7f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions BaseBin/systemhook/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,29 @@ int daemon_hook(int __nochdir, int __noclose)
}

// Always set CS_VALID in csflag to avoid causing a crash when hooking a c function on arm64
int csops_hook(pid_t pid, unsigned int ops, void * useraddr, size_t usersize)
int csops_hook(pid_t pid, unsigned int ops, void *useraddr, size_t usersize)
{
int rv = syscall(SYSCALL_CSOPS, pid, ops, useraddr, usersize);
if (rv != 0) return rv;
if (ops == CS_OPS_STATUS) {
if (useraddr) {
uint32_t* csflag = (uint32_t*)useraddr;
csflag[0] |= CS_VALID;
uint32_t* csflag = (uint32_t *)useraddr;
*csflag |= CS_VALID;
*csflag &= ~CS_DEBUGGED;
}
}
return rv;
}

int csops_audittoken_hook(pid_t pid, unsigned int ops, void * useraddr, size_t usersize, audit_token_t * token)
int csops_audittoken_hook(pid_t pid, unsigned int ops, void *useraddr, size_t usersize, audit_token_t *token)
{
int rv = syscall(SYSCALL_CSOPS_AUDITTOKEN, pid, ops, useraddr, usersize, token);
if (rv != 0) return rv;
if (ops == CS_OPS_STATUS) {
if (useraddr) {
uint32_t* csflag = (uint32_t*)useraddr;
csflag[0] |= CS_VALID;
uint32_t* csflag = (uint32_t *)useraddr;
*csflag |= CS_VALID;
*csflag &= ~CS_DEBUGGED;
}
}
return rv;
Expand Down

0 comments on commit 8475c7f

Please sign in to comment.