Document of c-modernization-kit (funcman) 1.0.0
Loading...
Searching...
No Matches
dllmain.h
Go to the documentation of this file.
1
26
27#ifndef DLLMAIN_H
28#define DLLMAIN_H
29
30#ifndef _WIN32
31 #include <syslog.h>
32#else /* _WIN32 */
33 #include <windows.h>
34#endif /* _WIN32 */
35
46#ifndef _WIN32
47 #define DLLMAIN_INFO_MSG(msg) syslog(LOG_INFO, (msg))
48#else /* _WIN32 */
49 #define DLLMAIN_INFO_MSG(msg) OutputDebugStringA(msg)
50#endif /* _WIN32 */
51
58static void onLoad(void);
59
66static void onUnload(void);
67
68#ifndef _WIN32
69
75__attribute__((constructor)) static void dllmain_on_load__(void)
76{
77 onLoad();
78}
79
85__attribute__((destructor)) static void dllmain_on_unload__(void)
86{
87 onUnload();
88}
89
90#else /* _WIN32 */
91
102BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
103{
104 (void)hinstDLL;
105 (void)lpvReserved;
106 switch (fdwReason)
107 {
108 case DLL_PROCESS_ATTACH:
109 onLoad();
110 break;
111 case DLL_PROCESS_DETACH:
112 onUnload();
113 break;
114 default:
115 break;
116 }
117 return TRUE;
118}
119
120#endif /* _WIN32 */
121
122#endif /* DLLMAIN_H */
__attribute__((constructor)) static void dllmain_on_load__(void)
共有ライブラリロード時のコンストラクタ (Linux 専用)。
Definition dllmain.h:75
static void onUnload(void)
ライブラリのアンロード時に呼び出されるフック関数。
static void onLoad(void)
ライブラリのロード時に呼び出されるフック関数。