1- PLTHook
2- =======
1+ # PLTHook
32
43[ ![ tests] ( https://github.com/kubo/plthook/actions/workflows/run-tests.yml/badge.svg )] ( https://github.com/kubo/plthook/actions/workflows/run-tests.yml )
54
6- What is plthook.
7- ----------------
5+ ## What is plthook.
86
97A utility library to hook library function calls issued by
108specified object files (executable and libraries). This modifies
@@ -68,8 +66,15 @@ Unixes. The fourth argument of `plthook_replace()` isn't available on Unixes
6866because it doesn't set the address of the original before the address in the PLT
6967entry is resolved.
7068
71- Changes
72- -------
69+ ## Changes
70+
71+ ** 2025-05-14:** Add support again for macOS 10.14 Mojave or before.
72+
73+ ** 2025-05-09:** Add loongarch64 support. (plthook_elf.c)
74+
75+ ** 2025-04-15:** Add s390x support. (plthook_elf.c)
76+
77+ ** 2025-03-07:** Add support for hooking delayed load libraries on Windows.
7378
7479** 2024-09-02:** Fix issues on macOS ([ #48 ] )
7580
@@ -81,7 +86,7 @@ Changes
8186
8287** 2022-08-12:** Support LC_DYLD_CHAINED_FIXUPS on macOS intel
8388
84- ** 2020-03-30:** Check _ start also in plthook_open_by_handle() (plthook_elf.c) ([ #29 ] )
89+ ** 2020-03-30:** Check \ _ start also in plthook_open_by_handle() (plthook_elf.c) ([ #29 ] )
8590
8691** 2020-03-09:** Add support for uClibc. ([ #28 ] )
8792
@@ -112,8 +117,7 @@ hooking a [prelinked file](https://en.wikipedia.org/wiki/Prelink#Linux) on Linux
112117
113118** 2017-09-18:** Fixed for processes on [ valgrind] ( https://valgrind.org ) on Linux.
114119
115- Usage
116- -----
120+ ## Usage
117121
118122If you have a library ` libfoo.so.1 ` and want to intercept
119123a function call ` recv() ` without modifying the library,
@@ -127,17 +131,17 @@ in your source tree and add the following code.
127131static ssize_t my_recv (int sockfd, void * buf, size_t len, int flags)
128132{
129133 ssize_t rv;
130-
134+
131135 ... do your task: logging, etc. ...
132136 rv = recv(sockfd, buf, len, flags); /* call real recv(). */
133137 ... do your task: logging, check received data, etc. ...
134138 return rv;
135139}
136-
140+
137141int install_hook_function()
138142{
139143 plthook_t * plthook;
140-
144+
141145 if (plthook_open(&plthook, "libfoo.so.1") != 0) {
142146 printf("plthook_open error: %s\n", plthook_error());
143147 return -1;
@@ -163,17 +167,17 @@ static ssize_t (*recv_func)(int sockfd, void *buf, size_t len, int flags);
163167static ssize_t my_recv(int sockfd, void *buf, size_t len, int flags)
164168{
165169 ssize_t rv;
166-
170+
167171 ... do your task: logging, etc. ...
168172 rv = (*recv_func)(sockfd, buf, len, flags); /* call real recv(). */
169173 ... do your task: logging, check received data, etc. ...
170174 return rv;
171175}
172-
176+
173177int install_hook_function()
174178{
175179 plthook_t *plthook;
176-
180+
177181 if (plthook_open_by_address(&plthook, &recv_func) != 0) {
178182 printf("plthook_open error: %s\n", plthook_error());
179183 return -1;
@@ -203,8 +207,7 @@ For example `api-ms-win-shcore-path-l1-1-0.dll:@170`.
203207
204208[ ordinal ] : https://msdn.microsoft.com/en-us/library/e7tsx612.aspx
205209
206- Another Usage
207- -------------
210+ ## Another Usage
208211
209212PLTHook provides a function enumerating PLT/IAT entries.
210213
@@ -228,25 +231,23 @@ void print_plt_entries(const char *filename)
228231}
229232```
230233
231- Supported Platforms
232- -------------------
233-
234- | Platform | source file | status |
235- | -------- | ----------- | ------ |
236- | Linux i386 and x86_64 | plthook_elf.c | tested using [github actions] |
237- | Linux arm, aarch64, powerpc and powerpc64le | plthook_elf.c | tested on [QEMU][] using [github actions] |
238- | Windows 32-bit and x64 (MSVC) | plthook_win32.c | tested using [github actions] |
239- | macOS (intel) (*4) | plthook_osx.c | tested using [github actions] |
240- | macOS (arm) | plthook_osx.c | tested using [github actions] |
241- | Windows 32-bit and x64 (Mingw32 and Cygwin) | plthook_win32.c | perhaps(*2) |
242- | Solaris x86_64 | plthook_elf.c | perhaps(*1) |
243- | FreeBSD i386 and x86_64 except i386 program on x86_64 OS | plthook_elf.c | perhaps(*1) |
244- | Android(*3) | plthook_elf.c | perhaps(*2) |
234+ ## Supported Platforms
235+
236+ | Platform | source file | status |
237+ | --------------------------------------------------------------------- | --------------- | ----------------------------------------- |
238+ | Linux i386 and x86_64 | plthook_elf.c | tested using [github actions] |
239+ | Linux arm, armhf, arm64, ppc, ppc64le, riscv64, s390x and loongarch64 | plthook_elf.c | tested on [QEMU][] using [github actions] |
240+ | Windows 32-bit and x64 (MSVC) | plthook_win32.c | tested using [github actions] |
241+ | macOS (intel) | plthook_osx.c | tested using [github actions] |
242+ | macOS (arm) | plthook_osx.c | tested using [github actions] |
243+ | Windows 32-bit and x64 (Mingw32 and Cygwin) | plthook_win32.c | perhaps(\*2) |
244+ | Solaris x86_64 | plthook_elf.c | perhaps(\*1) |
245+ | FreeBSD i386 and x86_64 except i386 program on x86_64 OS | plthook_elf.c | perhaps(\*1) |
246+ | Android(\*3) | plthook_elf.c | perhaps(\*2) |
245247
246248*1 Tested on a local VM before.
247249*2 Tested on travis-ci.org before.
248- *3 Contributed by [Daniel Deptford][].
249- *4 macOS 10.14 Mojave support was dropped on 2022-09-19.
250+ \*3 Contributed by [Daniel Deptford][].
250251
251252[QEMU]: http://www.qemu.org/
252253[Daniel Deptford]: https://github.com/redmercury
@@ -262,7 +263,6 @@ Supported Platforms
262263[#48]: https://github.com/kubo/plthook/issues/48
263264[github actions]: https://github.com/kubo/plthook/actions/workflows/run-tests.yml
264265
265- License
266- -------
266+ ## License
267267
2682682-clause BSD-style license.
0 commit comments