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