How to override exit(), perhaps by throwing exception

前端 未结 3 1449
南旧
南旧 2021-01-18 01:32

We have a third-party library that was written without multithreading or exception handling in mind. Our main executable is multithreaded and uses exceptions.

The th

3条回答
  •  庸人自扰
    2021-01-18 02:06

    You can try leaving atexit() handler with longjmp. Though the behavior is undefined :) The other way is to run lib in a separate process, bridged with any IPC. Harder, tedious, but safer. Or, you can try to scan binary image and hook any exit() invocations. I know about MS detours and mhook on windows. Though I know none on linux, unfortunately.

提交回复
热议问题