Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / mini-windows-dllmain.c
1 /**
2  * \file
3  * DllMain entry point.
4  *
5  * (C) 2002-2003 Ximian, Inc.
6  * (C) 2003-2006 Novell, Inc.
7  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
8  */
9
10 #include <mono/metadata/coree.h>
11 #include <mono/metadata/gc-internals.h>
12 #include <mono/metadata/domain-internals.h>
13 #include <mono/utils/mono-threads.h>
14 #include "mini.h"
15
16 #ifdef HOST_WIN32
17 #include <windows.h>
18
19 BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved)
20 {
21         if (!mono_gc_dllmain (module_handle, reason, reserved))
22                 return FALSE;
23
24         switch (reason)
25         {
26         case DLL_PROCESS_ATTACH:
27                 mono_install_runtime_load (mini_init);
28                 break;
29         case DLL_PROCESS_DETACH:
30                 if (coree_module_handle)
31                         FreeLibrary (coree_module_handle);
32                 break;
33         case DLL_THREAD_DETACH:
34                 mono_thread_info_detach ();
35                 break;
36         
37         }
38         return TRUE;
39 }
40 #endif
41