| 217 | } |
| 218 | |
| 219 | BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved) |
| 220 | { |
| 221 | g_myDllModule = hDll; |
| 222 | if (dwReason == DLL_PROCESS_ATTACH) |
| 223 | { |
| 224 | LoadClr(); |
| 225 | } |
| 226 | else if (dwReason == DLL_PROCESS_DETACH) |
| 227 | { |
| 228 | if (g_clrHost) |
| 229 | { |
| 230 | // We eventually 'die' so we make sure we stop the CLR. |
| 231 | g_clrHost->Stop(); |
| 232 | // And release it. |
| 233 | g_clrHost->Release(); |
| 234 | } |
| 235 | |
| 236 | // Yes yes, I know. I should be using _endthread(ex) |
| 237 | // however, I can't. Since we don't want the thread killed until we exit. |
| 238 | if (g_hThread) |
| 239 | { |
| 240 | TerminateThread(g_hThread, 0); |
| 241 | CloseHandle(g_hThread); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | return TRUE; |
| 246 | } |