2 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
3 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
15 #include "selectors.h"
25 #include "sysmetrics.h"
48 int __winelib
= 1; /* Winelib run-time flag */
50 HANDLE32 SystemHeap
= 0;
51 HANDLE32 SegptrHeap
= 0;
53 /***********************************************************************
54 * Main initialisation routine
58 extern BOOL32
EVENT_Init(void);
59 extern BOOL32
RELAY_Init(void);
60 extern BOOL32
WIN16DRV_Init(void);
61 extern BOOL32
VIRTUAL_Init(void);
62 extern BOOL32
WIDGETS_Init(void);
66 /* Initialize virtual memory management */
67 if (!VIRTUAL_Init()) return 0;
69 /* Create the system and SEGPTR heaps */
70 if (!(SystemHeap
= HeapCreate( HEAP_GROWABLE
, 0x10000, 0 ))) return 0;
71 if (!(SegptrHeap
= HeapCreate( HEAP_WINE_SEGPTR
, 0, 0 ))) return 0;
73 /* Load the configuration file */
74 if (!PROFILE_LoadWineIni()) return 0;
76 /* Initialize DOS memory */
77 if (!DOSMEM_Init()) return 0;
79 /* Initialize signal handling */
80 if (!SIGNAL_Init()) return 0;
82 /* Initialize event handling */
83 if (!EVENT_Init()) return 0;
86 /* Create USER and GDI heap */
87 USER_HeapSel
= GlobalAlloc16( GMEM_FIXED
, 0x10000 );
88 LocalInit( USER_HeapSel
, 0, 0xffff );
89 GDI_HeapSel
= GlobalAlloc16( GMEM_FIXED
, GDI_HEAP_SIZE
);
90 LocalInit( GDI_HeapSel
, 0, GDI_HEAP_SIZE
-1 );
92 /* Initialize relay code */
93 if (!RELAY_Init()) return 0;
95 /* Create built-in modules */
96 if (!BUILTIN_Init()) return 0;
98 /* Initialize signal handling */
99 if (!SIGNAL_InitEmulator()) return 0;
101 /* Create the Win16 printer driver */
102 if (!WIN16DRV_Init()) return 0;
105 /* Initialize Wine tweaks */
106 if (!TWEAK_Init()) return 0;
108 /* Initialize OEM Bitmaps */
109 if (!OBM_Init()) return 0;
111 /* Initialise DOS drives */
112 if (!DRIVE_Init()) return 0;
114 /* Initialise DOS directories */
115 if (!DIR_Init()) return 0;
117 /* Initialize tasks */
118 if (!TASK_Init()) return 0;
120 /* Initialize communications */
123 /* Initialize IO-port permissions */
126 /* registry initialisation */
127 SHELL_LoadRegistry();
129 /* Global atom table initialisation */
130 if (!ATOM_Init()) return 0;
132 /* GDI initialisation */
133 if (!GDI_Init()) return 0;
135 /* Initialize system colors and metrics*/
139 /* Create the DCEs */
142 /* Initialize keyboard */
143 if (!KEYBOARD_Init()) return 0;
145 /* Initialize window procedures */
146 if (!WINPROC_Init()) return 0;
148 /* Initialize built-in window classes */
149 if (!WIDGETS_Init()) return 0;
151 /* Initialize dialog manager */
152 if (!DIALOG_Init()) return 0;
154 /* Initialize menus */
155 if (!MENU_Init()) return 0;
157 /* Create desktop window */
158 if (!WIN_CreateDesktopWindow()) return 0;
160 /* Initialize message spying */
161 if (!SPY_Init()) return 0;
163 /* Check wine.conf for old/bad entries */
164 if (!TWEAK_CheckConfiguration()) return 0;
166 /* Create system message queue */
167 queueSize
= GetProfileInt32A( "windows", "TypeAhead", 120 );
168 if (!QUEUE_CreateSysMsgQueue( queueSize
)) return 0;
170 /* Set double click time */
171 SetDoubleClickTime32( GetProfileInt32A("windows","DoubleClickSpeed",452) );
178 /**********************************************************************
181 int main(int argc
, char *argv
[] )
183 extern BOOL32
MAIN_WineInit( int *argc
, char *argv
[] );
184 extern void *CALL32_Init(void);
185 extern char * DEBUG_argv0
;
190 __winelib
= 0; /* First of all, clear the Winelib flag */
193 * Save this so that the internal debugger can get a hold of it if
196 DEBUG_argv0
= argv
[0];
198 if (!MAIN_WineInit( &argc
, argv
)) return 1;
199 if (!MAIN_Init()) return 1;
201 /* Initialize CALL32 routines */
202 /* This needs to be done just before task-switching starts */
203 IF1632_CallLargeStack
= (int (*)(int (*func
)(), void *arg
))CALL32_Init();
206 for (i
= 1; i
< argc
; i
++)
208 if ((handle
= WinExec32( argv
[i
], SW_SHOWNORMAL
)) < 32)
210 fprintf(stderr
, "wine: can't exec '%s': ", argv
[i
]);
213 case 2: fprintf( stderr
, "file not found\n" ); break;
214 case 11: fprintf( stderr
, "invalid exe file\n" ); break;
215 case 21: fprintf( stderr
, "win32 executable\n" ); break;
216 default: fprintf( stderr
, "error=%d\n", handle
); break;
223 if (!loaded
) { /* nothing loaded */
224 extern void MAIN_Usage(char*);
231 fprintf( stderr
, "wine: no executable file found.\n" );
235 if (Options
.debug
) DEBUG_SetBreakpoints( TRUE
); /* Setup breakpoints */
237 Yield(); /* Start the first task */
238 fprintf( stderr
, "WinMain: Should never happen: returned from Yield()\n" );
242 #endif /* #ifndef WINELIB */