fancycode / MemoryModule

Library to load a DLL from memory.
http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/
Mozilla Public License 2.0
2.8k stars 755 forks source link

Added x64 exception handling #91

Open DaLynX opened 5 years ago

DaLynX commented 5 years ago

Fixes #4 for x64.

Exception-handling code can be added to the loading process using Windows exceptions blocks:

__try {
    proc();
}
__except(EXCEPTION_EXECUTE_HANDLER) {
    // Exception-handling code.
}
Elmue commented 4 years ago

In the execption handler you should return ERROR_NOACCESS. Windows returns this error code when there was internally a crash in a function that has been caught.

Your comment // Exception-handling code. is useless. This missing code is just the important part !!

Because if you don't implement a good exception handler, your idea is not good. You are hiding the reason for the crash! If debugging in Visual Studio you will not see anymore why the exception occurred. It should be thought very well why an exception can occur at all and what to do if an exception has occurred. Hiding exceptions is generally a bad idea.