-
-
Save hasherezade/21d3938a3f846d988c1b030c3a713872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required (VERSION 3.0) | |
project (test_case2) | |
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | |
set (srcs | |
main.cpp | |
) | |
set (hdrs | |
) | |
add_library ( ${PROJECT_NAME} SHARED ${hdrs} ${srcs}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <stdio.h> | |
#include <string> | |
#include <mutex> | |
DWORD threadID; | |
BOOL APIENTRY DllMain( HMODULE hModule, | |
DWORD ul_reason_for_call, | |
LPVOID lpReserved | |
) | |
{ | |
switch (ul_reason_for_call) | |
{ | |
case DLL_PROCESS_ATTACH: | |
MessageBoxA(NULL, "DLLMain :D!", "We've started.", 0); | |
break; | |
case DLL_THREAD_ATTACH: | |
case DLL_THREAD_DETACH: | |
case DLL_PROCESS_DETACH: | |
break; | |
} | |
return TRUE; | |
} | |
//extern "C" to prevent C++ name mangling | |
extern "C" __declspec(dllexport) BOOL SayGoodbye(LPVOID lpUserdata, DWORD nUserdataLen) | |
{ | |
std::mutex testMutex; | |
try { | |
int i = 0, j = 1; | |
j /= i; // This will throw a SE (divide by zero). | |
} | |
catch (...) { | |
MessageBoxA(NULL, "C++ Exception Thrown!", "Caught it", 0); | |
} | |
MessageBoxA(NULL, "I'm Leaving!", "Goodbye", 0); | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment