[21916] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * INITDLL library interface.
|
---|
| 4 | *
|
---|
| 5 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[21299] | 8 | #ifndef __INITDLL_H__
|
---|
| 9 | #define __INITDLL_H__
|
---|
| 10 |
|
---|
[21916] | 11 | #include <odin.h>
|
---|
| 12 | #include <win32type.h>
|
---|
[21299] | 13 |
|
---|
[21916] | 14 | #ifndef MAYBE_WEAK
|
---|
| 15 | #define MAYBE_WEAK
|
---|
| 16 | #endif
|
---|
[21299] | 17 |
|
---|
[21916] | 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 |
|
---|
[21299] | 81 | #ifdef __cplusplus
|
---|
| 82 | extern "C" {
|
---|
| 83 | #endif
|
---|
| 84 |
|
---|
[21916] | 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 |
|
---|
[21299] | 100 | #if (__IBMCPP__ == 300) || (__IBMC__ == 300)
|
---|
| 101 |
|
---|
[21916] | 102 | void _Optlink __ctordtorInit(void);
|
---|
| 103 | void _Optlink __ctordtorTerm(void);
|
---|
[21299] | 104 |
|
---|
[21301] | 105 | #elif (__IBMCPP__ == 360) || (__IBMC__ == 360) || (__IBMC__ == 430)
|
---|
[21299] | 106 |
|
---|
[21916] | 107 | void _Optlink __ctordtorInit(int flag);
|
---|
| 108 | #define __ctordtorInit() __ctordtorInit(0)
|
---|
[21299] | 109 |
|
---|
[21916] | 110 | void _Optlink __ctordtorTerm(int flag);
|
---|
| 111 | #define __ctordtorTerm() __ctordtorTerm(0)
|
---|
[21299] | 112 |
|
---|
| 113 | #else
|
---|
[21916] | 114 | #error "Unknown VAC compiler version!"
|
---|
[21299] | 115 | #endif
|
---|
| 116 |
|
---|
[21916] | 117 | #elif defined(__EMX__)
|
---|
[21299] | 118 |
|
---|
[21916] | 119 | int _CRT_init(void);
|
---|
| 120 | void _CRT_term(void);
|
---|
[21299] | 121 |
|
---|
[21916] | 122 | void __ctordtorInit(void);
|
---|
| 123 | void __ctordtorTerm(void);
|
---|
[21299] | 124 |
|
---|
[21916] | 125 | #elif defined(__WATCOMC__)
|
---|
[21299] | 126 |
|
---|
[21916] | 127 | #define _DLL_InitTerm LibMain
|
---|
[21299] | 128 |
|
---|
[21916] | 129 | int _Optlink _CRT_init(void);
|
---|
| 130 | void _Optlink _CRT_term(void);
|
---|
[21299] | 131 |
|
---|
[21916] | 132 | #define __ctordtorInit()
|
---|
| 133 | #define __ctordtorTerm()
|
---|
[21299] | 134 |
|
---|
| 135 | //prevent Watcom from mucking with this name
|
---|
| 136 | extern DWORD _Resource_PEResTab;
|
---|
| 137 | #pragma aux _Resource_PEResTab "*";
|
---|
| 138 |
|
---|
[21916] | 139 | #else
|
---|
| 140 | #error "Unknown compiler!"
|
---|
[21299] | 141 | #endif
|
---|
| 142 |
|
---|
[21916] | 143 | BOOL APIENTRY InitializeKernel32();
|
---|
| 144 | VOID APIENTRY ReportFatalDllInitError(LPCSTR pszModName);
|
---|
[21299] | 145 |
|
---|
| 146 | #ifdef __cplusplus
|
---|
[21916] | 147 | } // extern "C"
|
---|
[21299] | 148 | #endif
|
---|
| 149 |
|
---|
| 150 | #endif //__INITDLL_H__
|
---|