1 | /** @file
|
---|
2 | *
|
---|
3 | * INITDLL library interface.
|
---|
4 | *
|
---|
5 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef __INITDLL_H__
|
---|
9 | #define __INITDLL_H__
|
---|
10 |
|
---|
11 | #include <odin.h>
|
---|
12 | #include <win32type.h>
|
---|
13 |
|
---|
14 | #ifndef MAYBE_WEAK
|
---|
15 | #define MAYBE_WEAK
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Called to initialize resources of the DLL module when it is loaded.
|
---|
20 | *
|
---|
21 | * This callback function is implemented by modules that link to initldll.lib
|
---|
22 | * and want to override the default DLL initialization procedure called when the
|
---|
23 | * DLL is loaded by the system (according to the INIT/TERM policy specified in
|
---|
24 | * the LIBRARY statement in the .DEF file). See DLL_InitDefault() for more
|
---|
25 | * information about the default initialization procedure.
|
---|
26 | *
|
---|
27 | * On success, the returned value must be the DosExitList() order code (high
|
---|
28 | * byte of the low word) that defines the order in which DLL_Term() will be
|
---|
29 | * called WRT other uninitialization routines and exit list handlers. Returning
|
---|
30 | * 0 will cause DLL_Term() to be called first. Note that if several handlers
|
---|
31 | * use the same order code they are called in LIFO order. For DLLs, this means
|
---|
32 | * that DLL_Term() will be called in the order opposite to DLL_Init().
|
---|
33 | *
|
---|
34 | * @param hModule DLL module handle.
|
---|
35 | * @return Exit list order on success or -1 to indicate a failure.
|
---|
36 | */
|
---|
37 | ULONG SYSTEM DLL_Init(ULONG hModule) MAYBE_WEAK;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Called to free resources of the DLL module when it is unloaded.
|
---|
41 | *
|
---|
42 | * This callback function is implemented by modules that link to initldll.lib
|
---|
43 | * and want to override the default DLL uninitialization procedure called when
|
---|
44 | * the DLL is unloaded by the system (according to the INIT/TERM policy
|
---|
45 | * specified in the LIBRARY statement in the .DEF file). See DLL_TermDefault()
|
---|
46 | * for more information about the default uninitialization procedure.
|
---|
47 | *
|
---|
48 | * @param hModule DLL module handle.
|
---|
49 | */
|
---|
50 | void SYSTEM DLL_Term(ULONG hModule) MAYBE_WEAK;
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Default DLL initialization procedure.
|
---|
54 | *
|
---|
55 | * This procedure is called if your module does not implement the DLL_Init()
|
---|
56 | * callback function. It performs steps necessary to initializes the C/C++
|
---|
57 | * runtime.
|
---|
58 | *
|
---|
59 | * You may call this procedure from your DLL_Init() implementation to perform
|
---|
60 | * the standard initialization steps described above.
|
---|
61 | *
|
---|
62 | * @param hModule DLL module handle.
|
---|
63 | * @return 0 on success or -1 to indicate a failure.
|
---|
64 | */
|
---|
65 | ULONG SYSTEM DLL_InitDefault(ULONG hModule);
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Default DLL uninitialization procedure.
|
---|
69 | *
|
---|
70 | * This procedure is called if your module does not implement the DLL_Term()
|
---|
71 | * callback function. It performs steps necessary to terminate the C/C++
|
---|
72 | * runtime.
|
---|
73 | *
|
---|
74 | * You may call this procedure from your DLL_Uniit() implementation to perform
|
---|
75 | * the standard initialization steps described above.
|
---|
76 | *
|
---|
77 | * @param hModule DLL module handle.
|
---|
78 | */
|
---|
79 | void SYSTEM DLL_TermDefault(ULONG hModule);
|
---|
80 |
|
---|
81 | #ifdef __cplusplus
|
---|
82 | extern "C" {
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | #if defined(__IBMCPP__) || defined(__IBMC__)
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * C run-time environment initialization function.
|
---|
89 | * Returns 0 to indicate success and -1 to indicate failure.
|
---|
90 | */
|
---|
91 | int _Optlink _CRT_init(void);
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * C run-time environment termination function.
|
---|
95 | * It only needs to be called when the C run-time functions are statically
|
---|
96 | * linked.
|
---|
97 | */
|
---|
98 | void _Optlink _CRT_term(void);
|
---|
99 |
|
---|
100 | #if (__IBMCPP__ == 300) || (__IBMC__ == 300)
|
---|
101 |
|
---|
102 | void _Optlink __ctordtorInit(void);
|
---|
103 | void _Optlink __ctordtorTerm(void);
|
---|
104 |
|
---|
105 | #elif (__IBMCPP__ == 360) || (__IBMC__ == 360) || (__IBMC__ == 430)
|
---|
106 |
|
---|
107 | void _Optlink __ctordtorInit(int flag);
|
---|
108 | #define __ctordtorInit() __ctordtorInit(0)
|
---|
109 |
|
---|
110 | void _Optlink __ctordtorTerm(int flag);
|
---|
111 | #define __ctordtorTerm() __ctordtorTerm(0)
|
---|
112 |
|
---|
113 | #else
|
---|
114 | #error "Unknown VAC compiler version!"
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | #elif defined(__EMX__)
|
---|
118 |
|
---|
119 | int _CRT_init(void);
|
---|
120 | void _CRT_term(void);
|
---|
121 |
|
---|
122 | void __ctordtorInit(void);
|
---|
123 | void __ctordtorTerm(void);
|
---|
124 |
|
---|
125 | #elif defined(__WATCOMC__)
|
---|
126 |
|
---|
127 | #define _DLL_InitTerm LibMain
|
---|
128 |
|
---|
129 | int _Optlink _CRT_init(void);
|
---|
130 | void _Optlink _CRT_term(void);
|
---|
131 |
|
---|
132 | #define __ctordtorInit()
|
---|
133 | #define __ctordtorTerm()
|
---|
134 |
|
---|
135 | //prevent Watcom from mucking with this name
|
---|
136 | extern DWORD _Resource_PEResTab;
|
---|
137 | #pragma aux _Resource_PEResTab "*";
|
---|
138 |
|
---|
139 | #else
|
---|
140 | #error "Unknown compiler!"
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | BOOL APIENTRY InitializeKernel32();
|
---|
144 | VOID APIENTRY ReportFatalDllInitError(LPCSTR pszModName);
|
---|
145 |
|
---|
146 | #ifdef __cplusplus
|
---|
147 | } // extern "C"
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | #endif //__INITDLL_H__
|
---|