Click here to Skip to main content
15,896,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings!

I've ported a C-module from linux shared object to windows DLL.
All works fine except that signal trapping I'm using with linux-c apparently does not work in a windows DLL.

I tried SetUnhandledExceptionFilter() but this also does not work within a DLL.

Any hints?
Posted
Comments
Richard MacCutchan 7-Feb-15 7:20am    
You should not be setting that in the DLL. Library functions should perform services and return a status (success or fail), or (possibly) throw an exception. Exceptions should be caught and handled in your application code, so you can properly dispose of them.
WolfG1 8-Feb-15 7:55am    
Tru, but the app is not my code.
Furthermore, I need some post motrtem info from the DLL (stacks, etc.)

1 solution

SetUnhandledExceptionFilter don't work because the it will trap only exceptions that have no other handler.
Because the runtime already set the catching of all execptions for housekeeping duties you will get no trapping in your code.
It is also not wise to use in shuch DLL's that could be unloaded (like that user loaded or removable) because in this case if the library is no more in memory the handler will still refer to the address set previously resulting a call in unexistent code.
Using same care when coding a DLL, maybe you can use AddVectoredExceptionHandler().
For usage sample see here.
 
Share this answer
 
Comments
WolfG1 8-Feb-15 7:51am    
Thanks, that's exactly what I was looking for!
Frankie-C 8-Feb-15 8:31am    
You're welcome. Please take into account that this functions are available only from last XP service pack on.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900