From ff5654bddad6d116fafd9690888f842301958ccc Mon Sep 17 00:00:00 2001 From: loongs-zhang <1936978077@qq.com> Date: Mon, 11 May 2026 11:14:31 +0800 Subject: [PATCH] try support lock --- hook/src/syscall/unix.rs | 6 ++---- hook/src/syscall/windows.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/hook/src/syscall/unix.rs b/hook/src/syscall/unix.rs index 14682cbc..832bc778 100644 --- a/hook/src/syscall/unix.rs +++ b/hook/src/syscall/unix.rs @@ -79,10 +79,8 @@ impl_hook!(MKDIRAT, mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) impl_hook!(RENAMEAT, renameat(olddirfd: c_int, oldpath: *const c_char, newdirfd: c_int, newpath: *const c_char) -> c_int); #[cfg(target_os = "linux")] impl_hook!(RENAMEAT2, renameat2(olddirfd: c_int, oldpath: *const c_char, newdirfd: c_int, newpath: *const c_char, flags: c_uint) -> c_int); +impl_hook!(PTHREAD_MUTEX_LOCK, pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int); +impl_hook!(PTHREAD_MUTEX_UNLOCK, pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int); // NOTE: unhook poll due to mio's poller // impl_hook!(POLL, poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int); - -// NOTE: unhook pthread_mutex_lock/pthread_mutex_unlock due to stack overflow or bug -// impl_hook!(PTHREAD_MUTEX_LOCK, pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int); -// impl_hook!(PTHREAD_MUTEX_UNLOCK, pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int); diff --git a/hook/src/syscall/windows.rs b/hook/src/syscall/windows.rs index a4c4d477..917b7e24 100644 --- a/hook/src/syscall/windows.rs +++ b/hook/src/syscall/windows.rs @@ -89,7 +89,7 @@ unsafe fn attach() -> std::io::Result<()> { impl_hook!("ws2_32.dll", SELECT, select(nfds: c_int, readfds: *mut FD_SET, writefds: *mut FD_SET, errorfds: *mut FD_SET, timeout: *mut TIMEVAL) -> c_int); impl_hook!("ws2_32.dll", WSAPOLL, WSAPoll(fds: *mut WSAPOLLFD, nfds: c_uint, timeout: c_int) -> c_int); // NOTE: unhook WaitOnAddress due to stack overflow or bug - // impl_hook!("api-ms-win-core-synch-l1-2-0.dll", WAITONADDRESS, WaitOnAddress(address: *const c_void, compareaddress: *const c_void, addresssize: usize, dwmilliseconds: c_uint) -> BOOL); + impl_hook!("api-ms-win-core-synch-l1-2-0.dll", WAITONADDRESS, WaitOnAddress(address: *const c_void, compareaddress: *const c_void, addresssize: usize, dwmilliseconds: c_uint) -> BOOL); // Enable the hook minhook::MinHook::enable_all_hooks().map_err(|_| Error::other("init all hooks failed !"))