2 * Emulator initialisation code
8 #include "wine/winbase16.h"
18 #include "stackframe.h"
19 #include "wine/exception.h"
20 #include "debugtools.h"
23 static char **MAIN_argv
;
26 /***********************************************************************
27 * Main loop of initial task
29 void MAIN_EmulatorRun( void )
31 char startProg
[256], defProg
[256];
36 /* Load system DLLs into the initial process (and initialize them) */
37 if ( !LoadLibrary16("GDI.EXE" ) || !LoadLibraryA("GDI32.DLL" )
38 || !LoadLibrary16("USER.EXE") || !LoadLibraryA("USER32.DLL"))
41 /* Get pointers to USER routines called by KERNEL */
44 /* Call FinalUserInit routine */
45 Callout
.FinalUserInit16();
47 /* Call InitApp for initial task */
48 Callout
.InitApp16( MapHModuleLS( 0 ) );
50 /* Add the Default Program if no program on the command line */
53 PROFILE_GetWineIniString( "programs", "Default", "",
54 defProg
, sizeof(defProg
) );
55 if (defProg
[0]) MAIN_argv
[MAIN_argc
++] = defProg
;
58 /* Add the Startup Program to the run list */
59 PROFILE_GetWineIniString( "programs", "Startup", "",
60 startProg
, sizeof(startProg
) );
61 if (startProg
[0]) MAIN_argv
[MAIN_argc
++] = startProg
;
63 /* Abort if no executable on command line */
66 MAIN_Usage(MAIN_argv
[0]);
70 /* Load and run executables given on command line */
71 for (i
= 1; i
< MAIN_argc
; i
++)
73 if ((handle
= WinExec( MAIN_argv
[i
], SW_SHOWNORMAL
)) < 32)
75 MESSAGE("wine: can't exec '%s': ", MAIN_argv
[i
]);
78 case 2: MESSAGE("file not found\n" ); break;
79 case 11: MESSAGE("invalid exe file\n" ); break;
80 default: MESSAGE("error=%d\n", handle
); break;
88 MESSAGE("wine: no executable file found.\n" );
92 /* Start message loop for desktop window */
94 while ( GetNumTasks16() > 1 && Callout
.GetMessageA( &msg
, 0, 0, 0 ) )
96 Callout
.TranslateMessage( &msg
);
97 Callout
.DispatchMessageA( &msg
);
104 /**********************************************************************
107 int main( int argc
, char *argv
[] )
111 /* Initialize everything */
112 if (!MAIN_MainInit( &argc
, argv
, FALSE
)) return 1;
113 MAIN_argc
= argc
; MAIN_argv
= argv
;
115 /* Create initial task */
116 if ( !(pModule
= NE_GetPtr( GetModuleHandle16( "KERNEL" ) )) ) return 1;
117 if ( !TASK_Create( pModule
, FALSE
) ) return 1;
119 /* Switch to initial task */
120 PostEvent16( PROCESS_Current()->task
);
123 /* Switch stacks and jump to MAIN_EmulatorRun */
124 CALL32_Init( &IF1632_CallLargeStack
, MAIN_EmulatorRun
, NtCurrentTeb()->stack_top
);
126 MESSAGE( "main: Should never happen: returned from CALL32_Init()\n" );