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];
37 /* Load system DLLs into the initial process (and initialize them) */
38 if ( !LoadLibrary16("GDI.EXE" ) || !LoadLibraryA("GDI32.DLL" )
39 || !LoadLibrary16("USER.EXE") || !LoadLibraryA("USER32.DLL"))
42 /* Get pointers to USER routines called by KERNEL */
45 /* Call FinalUserInit routine */
46 Callout
.FinalUserInit16();
48 /* Call InitApp for initial task */
49 Callout
.InitApp16( MapHModuleLS( 0 ) );
51 /* Add the Default Program if no program on the command line */
54 PROFILE_GetWineIniString( "programs", "Default", "",
55 defProg
, sizeof(defProg
) );
56 if (defProg
[0]) MAIN_argv
[MAIN_argc
++] = defProg
;
59 /* Add the Startup Program to the run list */
60 PROFILE_GetWineIniString( "programs", "Startup", "",
61 startProg
, sizeof(startProg
) );
62 if (startProg
[0]) MAIN_argv
[MAIN_argc
++] = startProg
;
64 /* Abort if no executable on command line */
67 MAIN_Usage(MAIN_argv
[0]);
71 /* Load and run executables given on command line */
72 for (i
= 1; i
< MAIN_argc
; i
++)
74 if ((handle
= WinExec( MAIN_argv
[i
], SW_SHOWNORMAL
)) < 32)
77 MESSAGE("wine: can't exec '%s': ", MAIN_argv
[i
]);
80 case 2: MESSAGE("main executable or required DLL not found\n" ); break;
81 case 11: MESSAGE("invalid exe file\n" ); break;
82 default: MESSAGE("error=%d\n", handle
); break;
90 if (!err_msg
) MESSAGE("wine: no executable file found.\n" );
94 /* Start message loop for desktop window */
96 while ( GetNumTasks16() > 1 && Callout
.GetMessageA( &msg
, 0, 0, 0 ) )
98 Callout
.TranslateMessage( &msg
);
99 Callout
.DispatchMessageA( &msg
);
106 /**********************************************************************
109 int main( int argc
, char *argv
[] )
113 /* Initialize everything */
114 if (!MAIN_MainInit( &argc
, argv
, FALSE
)) return 1;
115 MAIN_argc
= argc
; MAIN_argv
= argv
;
117 /* Create initial task */
118 if ( !(pModule
= NE_GetPtr( GetModuleHandle16( "KERNEL" ) )) ) return 1;
119 if ( !TASK_Create( pModule
, FALSE
) ) return 1;
121 /* Switch to initial task */
122 PostEvent16( PROCESS_Current()->task
);
125 /* Switch stacks and jump to MAIN_EmulatorRun */
126 CALL32_Init( &IF1632_CallLargeStack
, MAIN_EmulatorRun
, NtCurrentTeb()->stack_top
);
128 MESSAGE( "main: Should never happen: returned from CALL32_Init()\n" );