Hook for pthread_create
Is there (in glibc-2.5 and newer) a way to define a hook for pthread_create?
There are many binaries out there and I want to write a dynamic lib to load via LD_PRELOAD
I can add an attachment to the entry in main ('' attributte constructor ''), but how can I get my code to run in each thread just before the thread function starts.
+1
source to share
1 answer
This answer shows how to insert pthread_create. (Beware: it will work correctly in 64-bit programs, but not 32-bit programs.)
Once you insert pthread_create, you can make it call its own function that will do whatever you want, and then call the original function that the user passed to pthread_create.
+2
source to share