1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
|
/*
* Main initialization code
*/
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "bitmap.h"
#include "comm.h"
#include "neexe.h"
#include "main.h"
#include "menu.h"
#include "message.h"
#include "dialog.h"
#include "drive.h"
#include "queue.h"
#include "sysmetrics.h"
#include "file.h"
#include "heap.h"
#include "keyboard.h"
#include "mouse.h"
#include "input.h"
#include "display.h"
#include "miscemu.h"
#include "options.h"
#include "process.h"
#include "spy.h"
#include "tweak.h"
#include "user.h"
#include "cursoricon.h"
#include "global.h"
#include "dce.h"
#include "shell.h"
#include "win.h"
#include "winproc.h"
#include "syslevel.h"
#include "services.h"
#include "winsock.h"
#include "thread.h"
#include "task.h"
#include "debugtools.h"
#include "psdrv.h"
#include "win16drv.h"
#include "callback.h"
#include "server.h"
#include "loadorder.h"
DEFAULT_DEBUG_CHANNEL(server)
/***********************************************************************
* Main initialisation routine
*/
BOOL MAIN_MainInit( int *argc, char *argv[] )
{
/* Create the initial process */
if (!PROCESS_Init()) return 0;
/* Initialize syslevel handling */
SYSLEVEL_Init();
/* Parse command line arguments */
MAIN_WineInit( argc, argv );
/* Set server debug level */
CLIENT_SetDebug( TRACE_ON(server) );
/* Load the configuration file */
if (!PROFILE_LoadWineIni()) return FALSE;
/* Initialize module loadorder */
if (!MODULE_InitLoadOrder()) return FALSE;
/* Initialize DOS memory */
if (!DOSMEM_Init(0)) return FALSE;
/* Initialise DOS drives */
if (!DRIVE_Init()) return FALSE;
/* Initialise DOS directories */
if (!DIR_Init()) return FALSE;
/* Initialize event handling */
if (!EVENT_Init()) return FALSE;
/* Initialize communications */
COMM_Init();
/* Initialize IO-port permissions */
IO_port_init();
/* registry initialisation */
SHELL_LoadRegistry();
/* Read DOS config.sys */
if (!DOSCONF_ReadConfig()) return FALSE;
/* Initialize KERNEL */
if (!LoadLibrary16( "KRNL386.EXE" )) return FALSE;
if (!LoadLibraryA( "KERNEL32" )) return FALSE;
return TRUE;
}
/***********************************************************************
* KERNEL initialisation routine
*/
BOOL WINAPI MAIN_KernelInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
static BOOL initDone = FALSE;
HMODULE16 hModule;
if ( initDone ) return TRUE;
initDone = TRUE;
/* Initialize special KERNEL entry points */
hModule = GetModuleHandle16( "KERNEL" );
if ( hModule )
{
WORD cs, ds;
/* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
/* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
GET_CS(cs); GET_DS(ds);
NE_SetEntryPoint( hModule, 454, cs );
NE_SetEntryPoint( hModule, 455, ds );
/* Initialize KERNEL.THHOOK */
TASK_InstallTHHook((THHOOK *)PTR_SEG_TO_LIN(
(SEGPTR)NE_GetEntryPoint( hModule, 332 )));
/* Initialize the real-mode selector entry points */
#define SET_ENTRY_POINT( num, addr ) \
NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
FALSE, FALSE, FALSE, NULL ))
SET_ENTRY_POINT( 183, 0x00000 ); /* KERNEL.183: __0000H */
SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
NE_SetEntryPoint( hModule, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
#undef SET_ENTRY_POINT
}
/* Initialize relay code */
if (!RELAY_Init()) return FALSE;
return TRUE;
}
/***********************************************************************
* GDI initialisation routine
*/
BOOL WINAPI MAIN_GdiInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
NE_MODULE *pModule;
if ( GDI_HeapSel ) return TRUE;
/* Create GDI heap */
pModule = NE_GetPtr( GetModuleHandle16( "GDI" ) );
if ( pModule )
{
GDI_HeapSel = GlobalHandleToSel16( (NE_SEG_TABLE( pModule ) +
pModule->dgroup - 1)->hSeg );
}
else
{
GDI_HeapSel = GlobalAlloc16( GMEM_FIXED, GDI_HEAP_SIZE );
LocalInit16( GDI_HeapSel, 0, GDI_HEAP_SIZE-1 );
}
if (!TWEAK_Init()) return FALSE;
/* GDI initialisation */
if(!GDI_Init()) return FALSE;
/* Create the Win16 printer driver */
if (!WIN16DRV_Init()) return FALSE;
/* PSDRV initialization */
if(!PSDRV_Init()) return FALSE;
return TRUE;
}
/***********************************************************************
* USER initialisation routine
*/
BOOL WINAPI MAIN_UserInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
NE_MODULE *pModule;
int queueSize;
if ( USER_HeapSel ) return TRUE;
/* Create USER heap */
pModule = NE_GetPtr( GetModuleHandle16( "USER" ) );
if ( pModule )
{
USER_HeapSel = GlobalHandleToSel16( (NE_SEG_TABLE( pModule ) +
pModule->dgroup - 1)->hSeg );
}
else
{
USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
LocalInit16( USER_HeapSel, 0, 0xffff );
}
/* Global atom table initialisation */
if (!ATOM_Init( USER_HeapSel )) return FALSE;
/* Initialize window handling (critical section) */
WIN_Init();
/* Initialize system colors and metrics*/
SYSMETRICS_Init();
SYSCOLOR_Init();
/* Create the DCEs */
DCE_Init();
/* Initialize timers */
if (!TIMER_Init()) return FALSE;
/* Initialize window procedures */
if (!WINPROC_Init()) return FALSE;
/* Initialize cursor/icons */
CURSORICON_Init();
/* Initialize built-in window classes */
if (!WIDGETS_Init()) return FALSE;
/* Initialize dialog manager */
if (!DIALOG_Init()) return FALSE;
/* Initialize menus */
if (!MENU_Init()) return FALSE;
/* Initialize message spying */
if (!SPY_Init()) return FALSE;
/* Check wine.conf for old/bad entries */
if (!TWEAK_CheckConfiguration()) return FALSE;
/* Create system message queue */
queueSize = GetProfileIntA( "windows", "TypeAhead", 120 );
if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
/* Set double click time */
SetDoubleClickTime( GetProfileIntA("windows","DoubleClickSpeed",452) );
/* Create message queue of initial thread */
InitThreadInput16( 0, 0 );
/* Create desktop window */
if (!WIN_CreateDesktopWindow()) return FALSE;
/* Initialize keyboard driver */
KEYBOARD_Enable( keybd_event, InputKeyStateTable );
/* Initialize mouse driver */
MOUSE_Enable( mouse_event );
/* Start processing X events */
UserRepaintDisable16( FALSE );
return TRUE;
}
/***********************************************************************
* Winelib initialisation routine
*/
HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] )
{
WINE_MODREF *wm;
NE_MODULE *pModule;
HMODULE16 hModule;
/* Main initialization */
if (!MAIN_MainInit( argc, argv )) return 0;
/* Create and switch to initial task */
if (!(wm = ELF_CreateDummyModule( argv[0], argv[0] )))
return 0;
PROCESS_Current()->exe_modref = wm;
if ((hModule = MODULE_CreateDummyModule( wm->filename, 0 )) < 32) return 0;
pModule = (NE_MODULE *)GlobalLock16( hModule );
pModule->flags = NE_FFLAGS_WIN32;
pModule->module32 = wm->module;
if (!TASK_Create( pModule, FALSE )) return 0;
/* Load system DLLs into the initial process (and initialize them) */
if ( !LoadLibrary16("GDI.EXE" ) || !LoadLibraryA("GDI32.DLL" )
|| !LoadLibrary16("USER.EXE") || !LoadLibraryA("USER32.DLL"))
ExitProcess( 1 );
/* Get pointers to USER routines called by KERNEL */
THUNK_InitCallout();
return wm->module;
}
/***********************************************************************
* ExitKernel16 (KERNEL.2)
*
* Clean-up everything and exit the Wine process.
*
*/
void WINAPI ExitKernel16( void )
{
/* Do the clean-up stuff */
WriteOutProfiles16();
SHELL_SaveRegistry();
TerminateProcess( GetCurrentProcess(), 0 );
}
|