2 * Main initialization code
15 #include "wine/winbase16.h"
16 #include "wine/winuser16.h"
26 #include "sysmetrics.h"
39 #include "cursoricon.h"
48 #include "selectors.h"
51 #include "debugtools.h"
55 #include "loadorder.h"
57 DEFAULT_DEBUG_CHANNEL(server
);
59 /***********************************************************************
60 * Main initialisation routine
62 BOOL
MAIN_MainInit( char *argv
[] )
64 /* store the program name */
67 /* Create the initial process */
68 if (!PROCESS_Init()) return FALSE
;
70 /* Parse command line arguments */
71 OPTIONS_ParseOptions( argv
);
74 /* Load the configuration file */
75 if (!PROFILE_LoadWineIni()) return FALSE
;
77 /* Initialise DOS drives */
78 if (!DRIVE_Init()) return FALSE
;
80 /* Initialise DOS directories */
81 if (!DIR_Init()) return FALSE
;
83 /* Registry initialisation */
86 /* Global boot finished, the rest is process-local */
87 CLIENT_BootDone( TRACE_ON(server
) );
89 /* Initialize module loadorder */
90 if (!MODULE_InitLoadOrder()) return FALSE
;
95 /***********************************************************************
96 * KERNEL initialisation routine
98 BOOL WINAPI
MAIN_KernelInit(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
100 static BOOL initDone
= FALSE
;
104 if ( initDone
) return TRUE
;
107 /* Initialize DOS memory */
108 if (!DOSMEM_Init(0)) return FALSE
;
110 if (!LoadLibrary16( "KRNL386.EXE" )) return FALSE
;
112 /* Initialize special KERNEL entry points */
113 hModule
= GetModuleHandle16( "KERNEL" );
116 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
117 NE_SetEntryPoint( hModule
, 178, GetWinFlags16() );
119 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
120 NE_SetEntryPoint( hModule
, 454, __get_cs() );
121 NE_SetEntryPoint( hModule
, 455, __get_ds() );
123 /* Initialize KERNEL.THHOOK */
124 TASK_InstallTHHook((THHOOK
*)PTR_SEG_TO_LIN(
125 (SEGPTR
)NE_GetEntryPoint( hModule
, 332 )));
127 /* Initialize the real-mode selector entry points */
128 #define SET_ENTRY_POINT( num, addr ) \
129 NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
130 DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
131 FALSE, FALSE, FALSE, NULL ))
133 SET_ENTRY_POINT( 183, 0x00000 ); /* KERNEL.183: __0000H */
134 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
135 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
136 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
137 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
138 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
139 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
140 NE_SetEntryPoint( hModule
, 173, DOSMEM_BiosSysSeg
); /* KERNEL.173: __ROMBIOS */
141 NE_SetEntryPoint( hModule
, 193, DOSMEM_BiosDataSeg
); /* KERNEL.193: __0040H */
142 NE_SetEntryPoint( hModule
, 194, DOSMEM_BiosSysSeg
); /* KERNEL.194: __F000H */
143 #undef SET_ENTRY_POINT
146 /* Initialize relay code */
147 if (!RELAY_Init()) return FALSE
;
149 /* Initialize communications */
152 /* Initialize IO-port permissions */
155 /* Read DOS config.sys */
156 if (!DOSCONF_ReadConfig()) return FALSE
;
162 /***********************************************************************
163 * ExitKernel16 (KERNEL.2)
165 * Clean-up everything and exit the Wine process.
168 void WINAPI
ExitKernel16( void )
170 /* Do the clean-up stuff */
172 WriteOutProfiles16();
173 TerminateProcess( GetCurrentProcess(), 0 );