Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
BitchX
GitHub Repository: BitchX/BitchX1.3
Path: blob/master/dll/dllinit.c
1069 views
1
#ifdef WINNT
2
/* dllinit.c -- Portable DLL initialization.
3
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
4
Contributed by Mumit Khan ([email protected]).
5
6
I've used DllMain as the DLL "main" since that's the most common
7
usage. MSVC and Mingw32 both default to DllMain as the standard
8
callback from the linker entry point. Cygwin, as of b20.1, also
9
uses DllMain as the default callback from the entry point.
10
11
The real entry point is typically always defined by the runtime
12
library, and usually never overridden by (casual) user. What you can
13
override however is the callback routine that the entry point calls,
14
and this file provides such a callback function, DllMain.
15
16
Mingw32: The default entry point for mingw32 is DllMainCRTStartup
17
which is defined in libmingw32.a This in turn calls DllMain which is
18
defined here. If not defined, there is a stub in libmingw32.a which
19
does nothing.
20
21
Cygwin: The default entry point for Cygwin b20.1 or newer is
22
__cygwin_dll_entry which is defined in libcygwin.a. This in turn
23
calls the routine DllMain. If not defined, there is a stub in
24
libcygwin.a which does nothing.
25
26
MSVC: MSVC runtime calls DllMain, just like Mingw32.
27
28
Summary: If you need to do anything special in DllMain, just add it
29
here. Otherwise, the default setup should be just fine for 99%+ of
30
the time. I strongly suggest that you *not* change the entry point,
31
but rather change DllMain as appropriate.
32
33
*/
34
35
36
#define WIN32_LEAN_AND_MEAN
37
#include <windows.h>
38
#undef WIN32_LEAN_AND_MEAN
39
#include <stdio.h>
40
41
BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason,
42
LPVOID reserved /* Not used. */ );
43
44
/*
45
*----------------------------------------------------------------------
46
*
47
* DllMain --
48
*
49
* This routine is called by the Mingw32, Cygwin32 or VC++ C run
50
* time library init code, or the Borland DllEntryPoint routine. It
51
* is responsible for initializing various dynamically loaded
52
* libraries.
53
*
54
* Results:
55
* TRUE on sucess, FALSE on failure.
56
*
57
* Side effects:
58
*
59
*----------------------------------------------------------------------
60
*/
61
BOOL APIENTRY
62
DllMain (
63
HINSTANCE hInst /* Library instance handle. */ ,
64
DWORD reason /* Reason this function is being called. */ ,
65
LPVOID reserved /* Not used. */ )
66
{
67
68
switch (reason)
69
{
70
case DLL_PROCESS_ATTACH:
71
break;
72
73
case DLL_PROCESS_DETACH:
74
break;
75
76
case DLL_THREAD_ATTACH:
77
break;
78
79
case DLL_THREAD_DETACH:
80
break;
81
}
82
return TRUE;
83
}
84
#endif
85
86