2 * Emulator initialisation code
21 /***********************************************************************
22 * Emulator initialisation
24 BOOL32
MAIN_EmulatorInit(void)
26 /* Main initialization */
27 if (!MAIN_MainInit()) return FALSE
;
29 /* Initialize relay code */
30 if (!RELAY_Init()) return FALSE
;
32 /* Initialize signal handling */
33 if (!SIGNAL_InitEmulator()) return FALSE
;
35 /* Create the Win16 printer driver */
36 if (!WIN16DRV_Init()) return FALSE
;
38 /* Create the Postscript printer driver (FIXME: should be in Winelib) */
39 if (!PSDRV_Init()) return FALSE
;
41 /* Load system DLLs into the initial process (and initialize them) */
42 if (!LoadLibrary16( "KERNEL" )) return FALSE
; /* always built-in */
43 if (!LoadLibrary32A( "KERNEL32" )) return FALSE
; /* always built-in */
45 if (!LoadLibrary16( "GDI.EXE" )) return FALSE
;
46 if (!LoadLibrary32A( "GDI32.DLL" )) return FALSE
;
48 if (!LoadLibrary16( "USER.EXE" )) return FALSE
;
49 if (!LoadLibrary32A( "USER32.DLL" )) return FALSE
;
55 /***********************************************************************
56 * Main loop of initial task
58 void MAIN_EmulatorRun( void )
60 BOOL32 (*WINAPI pGetMessage
)(MSG32
* lpmsg
,HWND32 hwnd
,UINT32 min
,UINT32 max
);
61 BOOL32 (*WINAPI pTranslateMessage
)( const MSG32
* msg
);
62 LONG (*WINAPI pDispatchMessage
)( const MSG32
* msg
);
65 HMODULE32 hModule
= GetModuleHandle32A( "USER32" );
66 pGetMessage
= GetProcAddress32( hModule
, "GetMessageA" );
67 pTranslateMessage
= GetProcAddress32( hModule
, "TranslateMessage" );
68 pDispatchMessage
= GetProcAddress32( hModule
, "DispatchMessageA" );
70 assert( pGetMessage
);
71 assert( pTranslateMessage
);
72 assert( pDispatchMessage
);
74 while ( GetNumTasks() > 1 && pGetMessage( &msg
, 0, 0, 0 ) )
76 pTranslateMessage( &msg
);
77 pDispatchMessage( &msg
);
84 /**********************************************************************
87 int main( int argc
, char *argv
[] )
89 extern char * DEBUG_argv0
;
90 char startProg
[256], defProg
[256];
94 __winelib
= 0; /* First of all, clear the Winelib flag */
97 * Save this so that the internal debugger can get a hold of it if
100 DEBUG_argv0
= argv
[0];
102 /* Create the initial process */
103 if (!PROCESS_Init()) return FALSE
;
105 /* Parse command-line */
106 if (!MAIN_WineInit( &argc
, argv
)) return 1;
108 /* Handle -dll option (hack) */
110 if (Options
.dllFlags
)
112 if (!BUILTIN_ParseDLLOptions( Options
.dllFlags
))
114 MSG("%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",
121 /* Initialize everything */
123 if (!MAIN_EmulatorInit()) return 1;
125 /* Initialize CALL32 routines */
126 /* This needs to be done just before task-switching starts */
130 /* Add the Default Program if no program on the command line */
133 PROFILE_GetWineIniString( "programs", "Default", "",
134 defProg
, sizeof(defProg
) );
135 if (defProg
[0]) argv
[argc
++] = defProg
;
138 /* Add the Startup Program to the run list */
139 PROFILE_GetWineIniString( "programs", "Startup", "",
140 startProg
, sizeof(startProg
) );
141 if (startProg
[0]) argv
[argc
++] = startProg
;
143 for (i
= 1; i
< argc
; i
++)
145 if ((handle
= WinExec32( argv
[i
], SW_SHOWNORMAL
)) < 32)
147 MSG("wine: can't exec '%s': ", argv
[i
]);
150 case 2: MSG("file not found\n" ); break;
151 case 11: MSG("invalid exe file\n" ); break;
152 case 21: MSG("win32 executable\n" ); break; /* FIXME: Obsolete? */
153 default: MSG("error=%d\n", handle
); break;
160 if (!loaded
) { /* nothing loaded */
167 MSG("wine: no executable file found.\n" );
171 if (Options
.debug
) DEBUG_AddModuleBreakpoints();
173 ctx_debug_call
= ctx_debug
;
175 IF1632_CallLargeStack
= (int (*)(int (*func
)(), void *arg
))CALL32_Init();
178 MSG("WinMain: Should never happen: returned from Yield16()\n" );