Is it reasonable to use SEH to protect my code from exceptions thrown by third party COM objects

StackOverflow https://stackoverflow.com/questions/10092399

  •  30-05-2021
  •  | 
  •  

Question

I'm protecting my own C++ code (Windows x86) from exceptions in a third party COM object and logging those exceptions using the following SEH pseudocode.

__try {
    hr = m_ComObj->SomeFunc();
} __except ( LogExceptionInfo(GetExceptionCode(), GetExceptionInformation()) ) {
    hr = E_UNEXPECTED;
    m_ComObjCrashed = true;
}

Is this approach likely to catch exceptions that would be handled if the SEH code wasn't present?

An MSDN article below mentions that the default unhandled exception filter will catch and fix the case where code writes to memory in loaded resources. Are there other cases where using SEH will interfere with desirable default OS behaviour?

A Crash Course on the Depths of Win32™ Structured Exception Handling

Was it helpful?

Solution

Yes it's quite reasonable.

It will catch all exceptions that are unhandled in the COM function

I don't see any interference-related problems with default OS behaviour

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top