Here's the problem. My application calls CoCreateInstance()
to create a COM object implemented in a third-party DLL. That DLL calls set_terminate()
to change the terminate()
handler and passes an address of its own terminate()
handler there.
The initial terminate()
handler address is not saved by that library - it doesn't care and simply changes the handler and never restores it. As soon as the DLL gets unloaded its code is no longer in the process memory, so if now terminate()
is called the program runs into undefined behavior.
I'd like to retrieve and store the address of initial terminate()
handler to be able to restore it. How can I do it?