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