12 #include "prototypes.h"
17 #define HELP_CONTEXT 0x0001
18 #define HELP_QUIT 0x0002
19 #define HELP_INDEX 0x0003
20 #define HELP_CONTENTS 0x0003
21 #define HELP_HELPONHELP 0x0004
22 #define HELP_SETINDEX 0x0005
23 #define HELP_SETCONTENTS 0x0005
24 #define HELP_CONTEXTPOPUP 0x0008
25 #define HELP_FORCEFILE 0x0009
26 #define HELP_KEY 0x0101
27 #define HELP_COMMAND 0x0102
28 #define HELP_PARTIALKEY 0x0105
29 #define HELP_MULTIKEY 0x0201
30 #define HELP_SETWINPOS 0x0203
32 extern struct w_files
* wine_files
;
41 typedef BOOL (CALLBACK
* LPFNWINMAIN
)(HANDLE
, HANDLE
, LPSTR
, int);
44 extern int CallToInit16(unsigned long csip
, unsigned long sssp
,
46 HANDLE
CreateNewTask(HINSTANCE hInst
);
49 void InitializeLoadedNewDLLs(HINSTANCE hInst
)
52 struct w_files
* wpnt
;
53 int cs_reg
, ds_reg
, ip_reg
;
56 fprintf(stderr
, "Initializing New DLLs\n");
59 * Initialize libraries
61 printf("InitializeLoadedNewDLLs() before searching hInst=%04X !\n", hInst
);
63 while (w
&& w
->hinstance
!= hInst
) w
= w
->next
;
64 if (w
== NULL
) return;
65 printf("InitializeLoadedNewDLLs() // before InitLoop !\n");
66 for(wpnt
= w
; wpnt
; wpnt
= wpnt
->next
)
71 if (wpnt
->ne_header
->format_flags
& 0x8000)
73 if (!(wpnt
->ne_header
->format_flags
& 0x0001))
76 fprintf(stderr
, "Library is not marked SINGLEDATA\n");
80 ds_reg
= wpnt
->selector_table
[wpnt
->
81 ne_header
->auto_data_seg
-1].selector
;
82 cs_reg
= wpnt
->selector_table
[wpnt
->ne_header
->cs
-1].selector
;
83 ip_reg
= wpnt
->ne_header
->ip
;
85 fprintf(stderr
, "Initializing %s, cs:ip %04x:%04x, ds %04x\n",
86 wpnt
->name
, cs_reg
, ip_reg
, ds_reg
);
88 rv
= CallTo16(cs_reg
<< 16 | ip_reg
, ds_reg
);
89 printf ("rv = %x\n", rv
);
95 void StartNewTask(HINSTANCE hInst
)
97 struct w_files
* wpnt
;
99 int cs_reg
, ds_reg
, ss_reg
, ip_reg
, sp_reg
;
103 printf("StartNewTask() before searching hInst=%04X !\n", hInst
);
105 while (wpnt
&& wpnt
->hinstance
!= hInst
) wpnt
= wpnt
->next
;
106 if (wpnt
== NULL
) return;
107 printf("StartNewTask() // before FixupSegment !\n");
108 for(w
= wpnt
; w
; w
= w
->next
) {
109 for (segment
= 0; segment
< w
->ne_header
->n_segment_tab
; segment
++) {
110 if (FixupSegment(w
, segment
) < 0) {
111 myerror("fixup failed.");
115 printf("StartNewTask() before InitializeLoadedNewDLLs !\n");
116 InitializeLoadedNewDLLs(hInst
);
117 printf("StartNewTask() before setup register !\n");
118 ds_reg
= (wpnt
->selector_table
[wpnt
->ne_header
->auto_data_seg
-1].selector
);
119 cs_reg
= wpnt
->selector_table
[wpnt
->ne_header
->cs
-1].selector
;
120 ip_reg
= wpnt
->ne_header
->ip
;
121 ss_reg
= wpnt
->selector_table
[wpnt
->ne_header
->ss
-1].selector
;
122 sp_reg
= wpnt
->ne_header
->sp
;
124 printf("StartNewTask() before CallToInit16() !\n");
125 rv
= CallToInit16(cs_reg
<< 16 | ip_reg
, ss_reg
<< 16 | sp_reg
, ds_reg
);
126 printf ("rv = %x\n", rv
);
131 void StartNewTask (HINSTANCE hInst
)
133 printf ("Not yet implemented\n");
137 /**********************************************************************
138 * LoadModule [KERNEL.45]
140 HANDLE
LoadModule(LPSTR modulefile
, LPVOID lpParamBlk
)
142 PARAMBLOCK
*pblk
= lpParamBlk
;
144 printf("LoadModule '%s' %08X\n", modulefile
, lpParamBlk
);
145 if (lpParamBlk
== NULL
) return 0;
146 lpCmdShow
= (WORD
*)pblk
->lpCmdShow
;
147 return WinExec(pblk
->lpCmdLine
, lpCmdShow
[1]);
151 /**********************************************************************
152 * WinExec [KERNEL.166]
154 WORD
WinExec(LPSTR lpCmdLine
, WORD nCmdShow
)
159 LPFNWINMAIN lpfnMain
;
162 printf("WinExec('%s', %04X)\n", lpCmdLine
, nCmdShow
);
165 for (x
= x2
= 0; x
< strlen(lpCmdLine
) + 1; x
++) {
166 if ((lpCmdLine
[x
] == ' ') || (lpCmdLine
[x
] == '\0')) {
167 ArgV
[c
] = (char *)malloc(x
- x2
+ 1);
168 strncpy(ArgV
[c
], &lpCmdLine
[x2
], x
- x2
);
169 ArgV
[c
][x
- x2
] = '\0';
174 for (c
= 0; ArgV
[c
] != NULL
; c
++) printf("--> '%s' \n", ArgV
[c
]);
177 printf("Can't 'fork' process !\n");
180 if ((hInst
= LoadImage(ArgV
[0], EXE
, 1)) == (HINSTANCE
) NULL
) {
181 fprintf(stderr
, "wine: can't find %s!.\n", ArgV
[0]);
182 printf("Child process died !\n");
185 hTask
= CreateNewTask(hInst
);
186 printf("WinExec // hTask=%04X hInst=%04X !\n", hTask
, hInst
);
189 lpfnMain = (LPFNWINMAIN)GetProcAddress(hInst, (LPSTR)0L);
190 printf("WineExec() // lpfnMain=%08X\n", (LONG)lpfnMain);
191 if (lpfnMain != NULL) {
192 (lpfnMain)(hInst, 0, lpCmdLine, nCmdShow);
193 printf("WineExec() // after lpfnMain\n");
196 /* hTask = CreateNewTask(0);
197 printf("WinExec // New Task hTask=%04X !\n", hTask);
198 execvp(ArgV[0], ArgV); */
200 printf("Child process died !\n");
203 printf("WinExec (Main process stay alive) hTask=%04X !\n", hTask
);
206 for (c
= 0; ArgV
[c
] != NULL
; c
++) free(ArgV
[c
]);
211 /**********************************************************************
212 * ExitWindows [USER.7]
214 BOOL
ExitWindows(DWORD dwReserved
, WORD wRetCode
)
216 printf("EMPTY STUB !!! ExitWindows(%08X, %04X) !\n", dwReserved
, wRetCode
);
220 /**********************************************************************
223 BOOL
WinHelp(HWND hWnd
, LPSTR lpHelpFile
, WORD wCommand
, DWORD dwData
)
226 printf("WinHelp(%s, %u, %lu)\n", lpHelpFile
, wCommand
, dwData
);
229 case HELP_HELPONHELP
:
230 GetWindowsDirectory(str
, sizeof(str
));
231 strcat(str
, "\\winhelp.exe");
232 printf("'%s'\n", str
);
235 GetWindowsDirectory(str
, sizeof(str
));
236 strcat(str
, "\\winhelp.exe");
237 printf("'%s'\n", str
);
242 WinExec(str
, SW_SHOWNORMAL
);