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"
56 #include "loadorder.h"
58 DEFAULT_DEBUG_CHANNEL(server
);
60 /***********************************************************************
61 * Main initialisation routine
63 BOOL
MAIN_MainInit( int argc
, char *argv
[], BOOL win32
)
65 char szGraphicsDriver
[MAX_PATH
];
67 /* store the program name */
70 /* Create the initial process */
71 if (!PROCESS_Init( win32
)) return 0;
73 /* Initialize syslevel handling */
76 /* Parse command line arguments */
77 MAIN_WineInit( argc
, argv
);
79 /* Load the configuration file */
80 if (!PROFILE_LoadWineIni()) return FALSE
;
82 /* Initialise DOS drives */
83 if (!DRIVE_Init()) return FALSE
;
85 /* Initialise DOS directories */
86 if (!DIR_Init()) return FALSE
;
88 /* Registry initialisation */
91 /* Global boot finished, the rest is process-local */
92 CLIENT_BootDone( TRACE_ON(server
) );
94 /* Initialize module loadorder */
95 if (!MODULE_InitLoadOrder()) return FALSE
;
97 /* Initialize KERNEL */
98 if (!LoadLibraryA( "KERNEL32" )) return FALSE
;
100 if (PROFILE_GetWineIniString( "Wine", "GraphicsDriver",
101 "x11drv", szGraphicsDriver
, sizeof(szGraphicsDriver
)))
103 if (!LoadLibraryA( szGraphicsDriver
)) return FALSE
;
109 /***********************************************************************
110 * KERNEL initialisation routine
112 BOOL WINAPI
MAIN_KernelInit(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
114 static BOOL initDone
= FALSE
;
118 if ( initDone
) return TRUE
;
121 /* Initialize DOS memory */
122 if (!DOSMEM_Init(0)) return FALSE
;
124 if (!LoadLibrary16( "KRNL386.EXE" )) return FALSE
;
126 /* Initialize special KERNEL entry points */
127 hModule
= GetModuleHandle16( "KERNEL" );
130 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
131 NE_SetEntryPoint( hModule
, 178, GetWinFlags16() );
133 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
134 NE_SetEntryPoint( hModule
, 454, __get_cs() );
135 NE_SetEntryPoint( hModule
, 455, __get_ds() );
137 /* Initialize KERNEL.THHOOK */
138 TASK_InstallTHHook((THHOOK
*)PTR_SEG_TO_LIN(
139 (SEGPTR
)NE_GetEntryPoint( hModule
, 332 )));
141 /* Initialize the real-mode selector entry points */
142 #define SET_ENTRY_POINT( num, addr ) \
143 NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
144 DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
145 FALSE, FALSE, FALSE, NULL ))
147 SET_ENTRY_POINT( 183, 0x00000 ); /* KERNEL.183: __0000H */
148 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
149 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
150 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
151 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
152 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
153 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
154 NE_SetEntryPoint( hModule
, 173, DOSMEM_BiosSysSeg
); /* KERNEL.173: __ROMBIOS */
155 NE_SetEntryPoint( hModule
, 193, DOSMEM_BiosDataSeg
); /* KERNEL.193: __0040H */
156 NE_SetEntryPoint( hModule
, 194, DOSMEM_BiosSysSeg
); /* KERNEL.194: __F000H */
157 #undef SET_ENTRY_POINT
160 /* Initialize relay code */
161 if (!RELAY_Init()) return FALSE
;
163 /* Initialize communications */
166 /* Initialize IO-port permissions */
169 /* Read DOS config.sys */
170 if (!DOSCONF_ReadConfig()) return FALSE
;
176 /***********************************************************************
177 * ExitKernel16 (KERNEL.2)
179 * Clean-up everything and exit the Wine process.
182 void WINAPI
ExitKernel16( void )
184 /* Do the clean-up stuff */
186 WriteOutProfiles16();
187 TerminateProcess( GetCurrentProcess(), 0 );