-1

My C++ application is using a 3rd party DLL that provides an API to some external software. There are no other options here. This is the software, API, and DLL that I must use.

I am trying to bomb-proof my interface. When an API call goes bad, the DLL does something that immediately kills the entire process. I've wrapped the call in try/catch, I'm using an SEH translation class that I've used successfully in other projects (and /EHa is selected), and I'm even handling std::unexpected. None of that gets triggered. As soon as I call the DLL function, the process ends.

What other avenues should I look at to protect my process? I want to avoid spinning off a child process for just this API.

user2705346
  • 19
  • 1
  • 4
  • 2
    Prevent it from happening in the first place? If the killing of the process is documented to happen under certain conditions, make sure those conditions never hold. If it's not documented, contact your supplier. Other than that, without any info on what this DLL does and how it does it, all anyone here can do is make random guesses. There is not enough info in your question for anyone to know what might be wrong. –  Apr 09 '15 at 16:30
  • 1
    need under debugger look what happens. no other way – sutol Apr 09 '15 at 16:32
  • 1
    Too broad. This is a "please speculate on what might be going wrong with some code I'm not showing you, and make a list of ways I might be able to protect myself" question. This site is for specific questions, not speculation and guesswork requests. If you have an issue with a third-party DLL, contact the vendor/author of that library. – Ken White Apr 09 '15 at 16:36
  • The right solution is to fix the DLL. If you cannot do that, replace it. – David Heffernan Apr 09 '15 at 17:38
  • A /GS violation can do this. The weapon of choice here is a telephone, give them a decent repro project. – Hans Passant Apr 09 '15 at 18:45

1 Answers1

2

The only surefire way to protect yourself from a DLL API gone wrong is to fork a child process and have that process do the DLL interaction (see firefox and plugin-container). For example, if the DLL calls exit nothing you do will catch that.

Mark B
  • 95,107
  • 10
  • 109
  • 188