开发者

Hook for pthread_create

Is there (in glibc-2.5 and newer) a way to define a hook for pthread_create?

There is a lot of binary applications and I want to write a dynamic lib to be loaded via LD_PRELOAD

I can add hook on entry to main (''attribu开发者_如何学Pythontte constructor''), but how can I force my code to be executed in every thread just before the thread's function will run.


This answer shows how to interpose pthread_create. (Beware: it will work correctly in 64-bit, but not 32-bit programs.)

Once you interpose pthread_create, you can make it call your own function, which will do whatever you want, and then call the original function the user passed to pthread_create.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜