DLL crash detection in C / C ++

I call a function from a DLL, for example:

__declspec ( dllimport ) bool dll_function(...);

int main() {
  [...]
  if (dll_function(...)) {
    [...]
  }
}

In some cases, the data that I pass to the DLL function will cause the DLL to crash. Is it possible to catch this, so my application also does not crash (without changing the DLL that I did not create)?

+3
source share
4 answers

You can catch AVs with __try and __except keywords in the MSVC compiler. Not all of this is useful; you have no idea what damage was done. Your program status may be corrupted. For example, the heap could explode, resulting in a subsequent random failure. Hosting a DLL in its own process and using IPC to communicate with it is the only decent approach.

+4
source

, DLL DLL. ? , ?

dll, ? , , , DLL . , "" ...

+2
+1

, , . (__stdcall, __cdecl ..).

, , , , , .

0

Source: https://habr.com/ru/post/1790842/


All Articles