12 #include "prototypes.h"
22 #define HELP_CONTEXT 0x0001
23 #define HELP_QUIT 0x0002
24 #define HELP_INDEX 0x0003
25 #define HELP_CONTENTS 0x0003
26 #define HELP_HELPONHELP 0x0004
27 #define HELP_SETINDEX 0x0005
28 #define HELP_SETCONTENTS 0x0005
29 #define HELP_CONTEXTPOPUP 0x0008
30 #define HELP_FORCEFILE 0x0009
31 #define HELP_KEY 0x0101
32 #define HELP_COMMAND 0x0102
33 #define HELP_PARTIALKEY 0x0105
34 #define HELP_MULTIKEY 0x0201
35 #define HELP_SETWINPOS 0x0203
44 typedef BOOL (CALLBACK
* LPFNWINMAIN
)(HANDLE
, HANDLE
, LPSTR
, int);
46 HANDLE
CreateNewTask(HINSTANCE hInst
);
49 void InitializeLoadedNewDLLs(HINSTANCE hInst
)
52 struct w_files
* wpnt
;
53 int cs_reg
, ds_reg
, ip_reg
;
56 dprintf_exec(stddeb
, "Initializing New DLLs\n");
59 * Initialize libraries
62 "InitializeLoadedNewDLLs() before searching hInst=%04X !\n", hInst
);
64 while (w
&& w
->hinstance
!= hInst
) w
= w
->next
;
65 if (w
== NULL
) return;
66 dprintf_exec(stddeb
,"InitializeLoadedNewDLLs() // before InitLoop !\n");
67 for(wpnt
= w
; wpnt
; wpnt
= wpnt
->next
)
72 if (wpnt
->ne
->ne_header
->format_flags
& 0x8000)
74 if (!(wpnt
->ne
->ne_header
->format_flags
& 0x0001))
77 fprintf(stderr
, "Library is not marked SINGLEDATA\n");
81 ds_reg
= wpnt
->ne
->selector_table
[wpnt
->ne
->
82 ne_header
->auto_data_seg
-1].selector
;
83 cs_reg
= wpnt
->ne
->selector_table
[wpnt
->ne
->ne_header
->cs
-1].selector
;
84 ip_reg
= wpnt
->ne
->ne_header
->ip
;
86 dprintf_exec(stddeb
, "Initializing %s, cs:ip %04x:%04x, ds %04x\n",
87 wpnt
->name
, cs_reg
, ip_reg
, ds_reg
);
89 rv
= CallTo16(cs_reg
<< 16 | ip_reg
, ds_reg
);
90 dprintf_exec(stddeb
,"rv = %x\n", rv
);
96 void StartNewTask(HINSTANCE hInst
)
98 struct w_files
* wpnt
;
100 int cs_reg
, ds_reg
, ss_reg
, ip_reg
, sp_reg
;
105 "StartNewTask() before searching hInst=%04X !\n", hInst
);
107 while (wpnt
&& wpnt
->hinstance
!= hInst
) wpnt
= wpnt
->next
;
108 if (wpnt
== NULL
) return;
109 dprintf_exec(stddeb
,"StartNewTask() // before FixupSegment !\n");
110 for(w
= wpnt
; w
; w
= w
->next
) {
111 for (segment
= 0; segment
< w
->ne
->ne_header
->n_segment_tab
; segment
++) {
112 if (NE_FixupSegment(w
, segment
) < 0) {
113 myerror("fixup failed.");
117 dprintf_exec(stddeb
,"StartNewTask() before InitializeLoadedNewDLLs !\n");
118 InitializeLoadedNewDLLs(hInst
);
119 dprintf_exec(stddeb
,"StartNewTask() before setup register !\n");
120 ds_reg
= (wpnt
->ne
->selector_table
[wpnt
->ne
->ne_header
->auto_data_seg
-1].selector
);
121 cs_reg
= wpnt
->ne
->selector_table
[wpnt
->ne
->ne_header
->cs
-1].selector
;
122 ip_reg
= wpnt
->ne
->ne_header
->ip
;
123 ss_reg
= wpnt
->ne
->selector_table
[wpnt
->ne
->ne_header
->ss
-1].selector
;
124 sp_reg
= wpnt
->ne
->ne_header
->sp
;
126 dprintf_exec(stddeb
,"StartNewTask() before CallToInit16() !\n");
127 rv
= CallToInit16(cs_reg
<< 16 | ip_reg
, ss_reg
<< 16 | sp_reg
, ds_reg
);
128 dprintf_exec(stddeb
,"rv = %x\n", rv
);
133 void StartNewTask (HINSTANCE hInst
)
135 fprintf(stdnimp
, "StartNewTask(): Not yet implemented\n");
139 /**********************************************************************
140 * LoadModule [KERNEL.45]
142 HANDLE
LoadModule(LPSTR modulefile
, LPVOID lpParamBlk
)
144 PARAMBLOCK
*pblk
= lpParamBlk
;
146 dprintf_exec(stddeb
,"LoadModule '%s' %p\n", modulefile
, lpParamBlk
);
147 if (lpParamBlk
== NULL
) return 0;
148 lpCmdShow
= (WORD
*)pblk
->lpCmdShow
;
149 return WinExec(pblk
->lpCmdLine
, lpCmdShow
[1]);
153 /**********************************************************************
154 * WinExec [KERNEL.166]
156 WORD
WinExec(LPSTR lpCmdLine
, WORD nCmdShow
)
163 dprintf_exec(stddeb
,"WinExec('%s', %04X)\n", lpCmdLine
, nCmdShow
);
166 for (x
= x2
= 0; x
< strlen(lpCmdLine
) + 1; x
++) {
167 if ((lpCmdLine
[x
] == ' ') || (lpCmdLine
[x
] == '\0')) {
168 ArgV
[c
] = (char *)malloc(x
- x2
+ 1);
169 strncpy(ArgV
[c
], &lpCmdLine
[x2
], x
- x2
);
170 ArgV
[c
][x
- x2
] = '\0';
175 for (c
= 0; ArgV
[c
] != NULL
; c
++)
176 dprintf_exec(stddeb
,"--> '%s' \n", ArgV
[c
]);
179 fprintf(stderr
,"Can't 'fork' process !\n");
182 if ((hInst
= LoadImage(ArgV
[0], EXE
, 1)) == (HINSTANCE
) NULL
) {
183 fprintf(stderr
, "wine: can't find %s!.\n", ArgV
[0]);
184 fprintf(stderr
,"Child process died !\n");
187 hTask
= CreateNewTask(hInst
);
189 "WinExec // hTask=%04X hInst=%04X !\n", hTask
, hInst
);
192 lpfnMain = (LPFNWINMAIN)GetProcAddress(hInst, (LPSTR)0L);
194 "WineExec() // lpfnMain=%08X\n", (LONG)lpfnMain);
195 if (lpfnMain != NULL) {
196 (lpfnMain)(hInst, 0, lpCmdLine, nCmdShow);
198 "WineExec() // after lpfnMain\n");
201 /* hTask = CreateNewTask(0);
203 "WinExec // New Task hTask=%04X !\n", hTask);
204 execvp(ArgV[0], ArgV); */
206 fprintf(stderr
,"Child process died !\n");
210 "WinExec (Main process stay alive) hTask=%04X !\n",
214 for (c
= 0; ArgV
[c
] != NULL
; c
++) free(ArgV
[c
]);
219 /**********************************************************************
220 * ExitWindows [USER.7]
222 BOOL
ExitWindows(DWORD dwReserved
, WORD wRetCode
)
224 dprintf_exec(stdnimp
,"EMPTY STUB !!! ExitWindows(%08lX, %04X) !\n",
225 dwReserved
, wRetCode
);
231 /**********************************************************************
234 BOOL
WinHelp(HWND hWnd
, LPSTR lpHelpFile
, WORD wCommand
, DWORD dwData
)
237 dprintf_exec(stddeb
,"WinHelp(%s, %u, %lu)\n",
238 lpHelpFile
, wCommand
, dwData
);
241 case HELP_HELPONHELP
:
242 GetWindowsDirectory(str
, sizeof(str
));
243 strcat(str
, "\\winhelp.exe");
244 dprintf_exec(stddeb
,"'%s'\n", str
);
247 GetWindowsDirectory(str
, sizeof(str
));
248 strcat(str
, "\\winhelp.exe");
249 dprintf_exec(stddeb
,"'%s'\n", str
);
254 WinExec(str
, SW_SHOWNORMAL
);