Use IsWindowVisible instead of GetWindowLong(GWL_STYLE) & WS_VISIBLE
[wine.git] / dlls / winedos / module.c
blob70c0cc4f4e967f72f29da0da6448310deb8bd43f
1 /*
2 * DOS (MZ) loader
4 * Copyright 1998 Ove Kåven
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Note: This code hasn't been completely cleaned up yet.
23 #include "config.h"
24 #include "wine/port.h"
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <fcntl.h>
31 #include <signal.h>
32 #ifdef HAVE_UNISTD_H
33 # include <unistd.h>
34 #endif
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #ifdef HAVE_SYS_TIME_H
38 # include <sys/time.h>
39 #endif
40 #include "windef.h"
41 #include "winbase.h"
42 #include "wine/winbase16.h"
43 #include "wingdi.h"
44 #include "winuser.h"
45 #include "winerror.h"
46 #include "wine/debug.h"
47 #include "dosexe.h"
48 #include "dosvm.h"
49 #include "vga.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(module);
53 static BOOL DOSVM_isdosexe;
55 /**********************************************************************
56 * DOSVM_IsWin16
58 * Return TRUE if we are in Windows process.
60 BOOL DOSVM_IsWin16(void)
62 return DOSVM_isdosexe ? FALSE : TRUE;
65 #ifdef MZ_SUPPORTED
67 #ifdef HAVE_SYS_MMAN_H
68 # include <sys/mman.h>
69 #endif
71 /* define this to try mapping through /proc/pid/mem instead of a temp file,
72 but Linus doesn't like mmapping /proc/pid/mem, so it doesn't work for me */
73 #undef MZ_MAPSELF
75 #define BIOS_DATA_SEGMENT 0x40
76 #define PSP_SIZE 0x10
78 #define SEG16(ptr,seg) ((LPVOID)((BYTE*)ptr+((DWORD)(seg)<<4)))
79 #define SEGPTR16(ptr,segptr) ((LPVOID)((BYTE*)ptr+((DWORD)SELECTOROF(segptr)<<4)+OFFSETOF(segptr)))
81 /* structures for EXEC */
83 #include "pshpack1.h"
85 typedef struct {
86 WORD env_seg;
87 DWORD cmdline;
88 DWORD fcb1;
89 DWORD fcb2;
90 WORD init_sp;
91 WORD init_ss;
92 WORD init_ip;
93 WORD init_cs;
94 } ExecBlock;
96 typedef struct {
97 WORD load_seg;
98 WORD rel_seg;
99 } OverlayBlock;
101 #include "poppack.h"
103 /* global variables */
105 pid_t dosvm_pid;
107 static WORD init_cs,init_ip,init_ss,init_sp;
108 static HANDLE dosvm_thread, loop_thread;
109 static DWORD dosvm_tid, loop_tid;
111 static void MZ_Launch( LPCSTR cmdtail, int length );
112 static BOOL MZ_InitTask(void);
114 static void MZ_CreatePSP( LPVOID lpPSP, WORD env, WORD par )
116 PDB16*psp=lpPSP;
118 psp->int20=0x20CD; /* int 20 */
119 /* some programs use this to calculate how much memory they need */
120 psp->nextParagraph=0x9FFF; /* FIXME: use a real value */
121 /* FIXME: dispatcher */
122 psp->savedint22 = DOSVM_GetRMHandler(0x22);
123 psp->savedint23 = DOSVM_GetRMHandler(0x23);
124 psp->savedint24 = DOSVM_GetRMHandler(0x24);
125 psp->parentPSP=par;
126 psp->environment=env;
127 /* FIXME: more PSP stuff */
130 static void MZ_FillPSP( LPVOID lpPSP, LPCSTR cmdtail, int length )
132 PDB16 *psp = lpPSP;
134 if(length > 127)
136 WARN( "Command tail truncated! (length %d)\n", length );
137 length = 126;
140 psp->cmdLine[0] = length;
143 * Length of exactly 127 bytes means that full command line is
144 * stored in environment variable CMDLINE and PSP contains
145 * command tail truncated to 126 bytes.
147 if(length == 127)
148 length = 126;
150 if(length > 0)
151 memmove(psp->cmdLine+1, cmdtail, length);
153 psp->cmdLine[length+1] = '\r';
155 /* FIXME: more PSP stuff */
158 static WORD MZ_InitEnvironment( LPCSTR env, LPCSTR name )
160 unsigned sz=0;
161 unsigned i=0;
162 WORD seg;
163 LPSTR envblk;
165 if (env) {
166 /* get size of environment block */
167 while (env[sz++]) sz+=strlen(env+sz)+1;
168 } else sz++;
169 /* allocate it */
170 envblk=DOSMEM_GetBlock(sz+sizeof(WORD)+strlen(name)+1,&seg);
171 /* fill it */
172 if (env) {
173 memcpy(envblk,env,sz);
174 } else envblk[0]=0;
175 /* DOS environment variables are uppercase */
176 while (envblk[i]){
177 while (envblk[i] != '='){
178 if (envblk[i]>='a' && envblk[i] <= 'z'){
179 envblk[i] -= 32;
181 i++;
183 i += strlen(envblk+i) + 1;
185 /* DOS 3.x: the block contains 1 additional string */
186 *(WORD*)(envblk+sz)=1;
187 /* being the program name itself */
188 strcpy(envblk+sz+sizeof(WORD),name);
189 return seg;
192 static BOOL MZ_InitMemory(void)
194 /* initialize the memory */
195 TRACE("Initializing DOS memory structures\n");
196 DOSMEM_Init(TRUE);
197 DOSDEV_InstallDOSDevices();
199 return TRUE;
202 static BOOL MZ_DoLoadImage( HANDLE hFile, LPCSTR filename, OverlayBlock *oblk )
204 IMAGE_DOS_HEADER mz_header;
205 DWORD image_start,image_size,min_size,max_size,avail;
206 BYTE*psp_start,*load_start,*oldenv;
207 int x, old_com=0, alloc;
208 SEGPTR reloc;
209 WORD env_seg, load_seg, rel_seg, oldpsp_seg;
210 DWORD len;
212 if (DOSVM_psp) {
213 /* DOS process already running, inherit from it */
214 PDB16* par_psp = (PDB16*)((DWORD)DOSVM_psp << 4);
215 alloc=0;
216 oldenv = (LPBYTE)((DWORD)par_psp->environment << 4);
217 oldpsp_seg = DOSVM_psp;
218 } else {
219 /* allocate new DOS process, inheriting from Wine environment */
220 alloc=1;
221 oldenv = GetEnvironmentStringsA();
222 oldpsp_seg = 0;
225 SetFilePointer(hFile,0,NULL,FILE_BEGIN);
226 if ( !ReadFile(hFile,&mz_header,sizeof(mz_header),&len,NULL)
227 || len != sizeof(mz_header)
228 || mz_header.e_magic != IMAGE_DOS_SIGNATURE) {
229 char *p = strrchr( filename, '.' );
230 if (!p || strcasecmp( p, ".com" )) /* check for .COM extension */
232 SetLastError(ERROR_BAD_FORMAT);
233 goto load_error;
235 old_com=1; /* assume .COM file */
236 image_start=0;
237 image_size=GetFileSize(hFile,NULL);
238 min_size=0x10000; max_size=0x100000;
239 mz_header.e_crlc=0;
240 mz_header.e_ss=0; mz_header.e_sp=0xFFFE;
241 mz_header.e_cs=0; mz_header.e_ip=0x100;
242 } else {
243 /* calculate load size */
244 image_start=mz_header.e_cparhdr<<4;
245 image_size=mz_header.e_cp<<9; /* pages are 512 bytes */
246 /* From Ralf Brown Interrupt List: If the word at offset 02h is 4, it should
247 * be treated as 00h, since pre-1.10 versions of the MS linker set it that
248 * way. */
249 if ((mz_header.e_cblp!=0)&&(mz_header.e_cblp!=4)) image_size-=512-mz_header.e_cblp;
250 image_size-=image_start;
251 min_size=image_size+((DWORD)mz_header.e_minalloc<<4)+(PSP_SIZE<<4);
252 max_size=image_size+((DWORD)mz_header.e_maxalloc<<4)+(PSP_SIZE<<4);
255 if (alloc) MZ_InitMemory();
257 if (oblk) {
258 /* load overlay into preallocated memory */
259 load_seg=oblk->load_seg;
260 rel_seg=oblk->rel_seg;
261 load_start=(LPBYTE)((DWORD)load_seg<<4);
262 } else {
263 /* allocate environment block */
264 env_seg=MZ_InitEnvironment(oldenv, filename);
266 /* allocate memory for the executable */
267 TRACE("Allocating DOS memory (min=%ld, max=%ld)\n",min_size,max_size);
268 avail=DOSMEM_Available();
269 if (avail<min_size) {
270 ERR("insufficient DOS memory\n");
271 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
272 goto load_error;
274 if (avail>max_size) avail=max_size;
275 psp_start=DOSMEM_GetBlock(avail,&DOSVM_psp);
276 if (!psp_start) {
277 ERR("error allocating DOS memory\n");
278 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
279 goto load_error;
281 load_seg=DOSVM_psp+(old_com?0:PSP_SIZE);
282 rel_seg=load_seg;
283 load_start=psp_start+(PSP_SIZE<<4);
284 MZ_CreatePSP(psp_start, env_seg, oldpsp_seg);
287 /* load executable image */
288 TRACE("loading DOS %s image, %08lx bytes\n",old_com?"COM":"EXE",image_size);
289 SetFilePointer(hFile,image_start,NULL,FILE_BEGIN);
290 if (!ReadFile(hFile,load_start,image_size,&len,NULL) || len != image_size) {
291 /* check if this is due to the workaround for the pre-1.10 MS linker and we
292 realy had only 4 bytes on the last page */
293 if (mz_header.e_cblp != 4 || image_size - len != 512 - 4) {
294 SetLastError(ERROR_BAD_FORMAT);
295 goto load_error;
299 if (mz_header.e_crlc) {
300 /* load relocation table */
301 TRACE("loading DOS EXE relocation table, %d entries\n",mz_header.e_crlc);
302 /* FIXME: is this too slow without read buffering? */
303 SetFilePointer(hFile,mz_header.e_lfarlc,NULL,FILE_BEGIN);
304 for (x=0; x<mz_header.e_crlc; x++) {
305 if (!ReadFile(hFile,&reloc,sizeof(reloc),&len,NULL) || len != sizeof(reloc)) {
306 SetLastError(ERROR_BAD_FORMAT);
307 goto load_error;
309 *(WORD*)SEGPTR16(load_start,reloc)+=rel_seg;
313 if (!oblk) {
314 init_cs = load_seg+mz_header.e_cs;
315 init_ip = mz_header.e_ip;
316 init_ss = load_seg+mz_header.e_ss;
317 init_sp = mz_header.e_sp;
318 if (old_com){
319 /* .COM files exit with ret. Make sure they jump to psp start (=int 20) */
320 WORD* stack = PTR_REAL_TO_LIN(init_ss, init_sp);
321 *stack = 0;
324 TRACE("entry point: %04x:%04x\n",init_cs,init_ip);
327 if (alloc && !MZ_InitTask()) {
328 SetLastError(ERROR_GEN_FAILURE);
329 return FALSE;
332 return TRUE;
334 load_error:
335 DOSVM_psp = oldpsp_seg;
337 return FALSE;
340 /***********************************************************************
341 * wine_load_dos_exe (WINEDOS.@)
343 * Called from WineVDM when a new real-mode DOS process is started.
344 * Loads DOS program into memory and executes the program.
346 void WINAPI wine_load_dos_exe( LPCSTR filename, LPCSTR cmdline )
348 char dos_cmdtail[126];
349 int dos_length = 0;
351 HANDLE hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ,
352 NULL, OPEN_EXISTING, 0, 0 );
353 if (hFile == INVALID_HANDLE_VALUE) return;
354 DOSVM_isdosexe = TRUE;
356 if(cmdline && *cmdline)
358 dos_length = strlen(cmdline);
359 memmove( dos_cmdtail + 1, cmdline,
360 (dos_length < 125) ? dos_length : 125 );
362 /* Non-empty command tail always starts with at least one space. */
363 dos_cmdtail[0] = ' ';
364 dos_length++;
367 * If command tail is longer than 126 characters,
368 * set tail length to 127 and fill CMDLINE environment variable
369 * with full command line (this includes filename).
371 if (dos_length > 126)
373 char *cmd = HeapAlloc( GetProcessHeap(), 0,
374 dos_length + strlen(filename) + 4 );
375 char *ptr = cmd;
377 if (!cmd)
378 return;
381 * Append filename. If path includes spaces, quote the path.
383 if (strchr(filename, ' '))
385 *ptr++ = '\"';
386 strcpy( ptr, filename );
387 ptr += strlen(filename);
388 *ptr++ = '\"';
390 else
392 strcpy( ptr, filename );
393 ptr += strlen(filename);
397 * Append command tail.
399 if (cmdline[0] != ' ')
400 *ptr++ = ' ';
401 strcpy( ptr, cmdline );
404 * Set environment variable. This will be passed to
405 * new DOS process.
407 if (!SetEnvironmentVariableA( "CMDLINE", cmd ))
409 HeapFree(GetProcessHeap(), 0, cmd );
410 return;
413 HeapFree(GetProcessHeap(), 0, cmd );
414 dos_length = 127;
418 if (MZ_DoLoadImage( hFile, filename, NULL ))
419 MZ_Launch( dos_cmdtail, dos_length );
422 /***********************************************************************
423 * MZ_Exec
425 * this may only be called from existing DOS processes
427 BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk )
429 DWORD binType;
430 STARTUPINFOA st;
431 PROCESS_INFORMATION pe;
432 HANDLE hFile;
434 BOOL ret = FALSE;
436 if(!GetBinaryTypeA(filename, &binType)) /* determine what kind of binary this is */
438 return FALSE; /* binary is not an executable */
441 /* handle non-dos executables */
442 if(binType != SCS_DOS_BINARY)
444 if(func == 0) /* load and execute */
446 LPBYTE fullCmdLine;
447 WORD fullCmdLength;
448 LPBYTE psp_start = (LPBYTE)((DWORD)DOSVM_psp << 4);
449 PDB16 *psp = (PDB16 *)psp_start;
450 ExecBlock *blk = (ExecBlock *)paramblk;
451 LPBYTE cmdline = PTR_REAL_TO_LIN(SELECTOROF(blk->cmdline),OFFSETOF(blk->cmdline));
452 LPBYTE envblock = PTR_REAL_TO_LIN(psp->environment, 0);
453 int cmdLength = cmdline[0];
456 * If cmdLength is 127, command tail is truncated and environment
457 * variable CMDLINE should contain full command line
458 * (this includes filename).
460 if (cmdLength == 127)
462 FIXME( "CMDLINE argument passing is unimplemented.\n" );
463 cmdLength = 126; /* FIXME */
466 fullCmdLength = (strlen(filename) + 1) + cmdLength + 1; /* filename + space + cmdline + terminating null character */
468 fullCmdLine = HeapAlloc(GetProcessHeap(), 0, fullCmdLength);
469 if(!fullCmdLine) return FALSE; /* return false on memory alloc failure */
471 /* build the full command line from the executable file and the command line being passed in */
472 snprintf(fullCmdLine, fullCmdLength, "%s ", filename); /* start off with the executable filename and a space */
473 memcpy(fullCmdLine + strlen(fullCmdLine), cmdline + 1, cmdLength); /* append cmdline onto the end */
474 fullCmdLine[fullCmdLength - 1] = 0; /* null terminate string */
476 ZeroMemory (&st, sizeof(STARTUPINFOA));
477 st.cb = sizeof(STARTUPINFOA);
478 ret = CreateProcessA (NULL, fullCmdLine, NULL, NULL, TRUE, 0, envblock, NULL, &st, &pe);
480 /* wait for the app to finish and clean up PROCESS_INFORMATION handles */
481 if(ret)
483 WaitForSingleObject(pe.hProcess, INFINITE); /* wait here until the child process is complete */
484 CloseHandle(pe.hProcess);
485 CloseHandle(pe.hThread);
488 HeapFree(GetProcessHeap(), 0, fullCmdLine); /* free the memory we allocated */
490 else
492 FIXME("EXEC type of %d not implemented for non-dos executables\n", func);
493 ret = FALSE;
496 return ret;
497 } /* if(binType != SCS_DOS_BINARY) */
500 /* handle dos executables */
502 hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ,
503 NULL, OPEN_EXISTING, 0, 0);
504 if (hFile == INVALID_HANDLE_VALUE) return FALSE;
506 switch (func) {
507 case 0: /* load and execute */
508 case 1: /* load but don't execute */
510 /* save current process's return SS:SP now */
511 LPBYTE psp_start = (LPBYTE)((DWORD)DOSVM_psp << 4);
512 PDB16 *psp = (PDB16 *)psp_start;
513 psp->saveStack = (DWORD)MAKESEGPTR(context->SegSs, LOWORD(context->Esp));
515 ret = MZ_DoLoadImage( hFile, filename, NULL );
516 if (ret) {
517 /* MZ_LoadImage created a new PSP and loaded new values into it,
518 * let's work on the new values now */
519 LPBYTE psp_start = (LPBYTE)((DWORD)DOSVM_psp << 4);
520 ExecBlock *blk = (ExecBlock *)paramblk;
521 LPBYTE cmdline = PTR_REAL_TO_LIN(SELECTOROF(blk->cmdline),OFFSETOF(blk->cmdline));
523 /* First character contains the length of the command line. */
524 MZ_FillPSP(psp_start, cmdline + 1, cmdline[0]);
526 /* the lame MS-DOS engineers decided that the return address should be in int22 */
527 DOSVM_SetRMHandler(0x22, (FARPROC16)MAKESEGPTR(context->SegCs, LOWORD(context->Eip)));
528 if (func) {
529 /* don't execute, just return startup state */
531 * From Ralph Brown:
532 * For function 01h, the AX value to be passed to the child program
533 * is put on top of the child's stack
535 LPBYTE stack;
536 init_sp -= 2;
537 stack = (LPBYTE) CTX_SEG_OFF_TO_LIN(context, init_ss, init_sp);
538 /* FIXME: push AX correctly */
539 stack[0] = 0x00; /* push AL */
540 stack[1] = 0x00; /* push AH */
542 blk->init_cs = init_cs;
543 blk->init_ip = init_ip;
544 blk->init_ss = init_ss;
545 blk->init_sp = init_sp;
546 } else {
547 /* execute by making us return to new process */
548 context->SegCs = init_cs;
549 context->Eip = init_ip;
550 context->SegSs = init_ss;
551 context->Esp = init_sp;
552 context->SegDs = DOSVM_psp;
553 context->SegEs = DOSVM_psp;
554 context->Eax = 0;
557 break;
558 case 3: /* load overlay */
560 OverlayBlock *blk = (OverlayBlock *)paramblk;
561 ret = MZ_DoLoadImage( hFile, filename, blk );
563 break;
564 default:
565 FIXME("EXEC load type %d not implemented\n", func);
566 SetLastError(ERROR_INVALID_FUNCTION);
567 break;
569 CloseHandle(hFile);
570 return ret;
573 /***********************************************************************
574 * MZ_AllocDPMITask
576 void WINAPI MZ_AllocDPMITask( void )
578 MZ_InitMemory();
579 MZ_InitTask();
582 /***********************************************************************
583 * MZ_RunInThread
585 void WINAPI MZ_RunInThread( PAPCFUNC proc, ULONG_PTR arg )
587 if (loop_thread) {
588 DOS_SPC spc;
589 HANDLE event;
591 spc.proc = proc;
592 spc.arg = arg;
593 event = CreateEventW(NULL, TRUE, FALSE, NULL);
594 PostThreadMessageA(loop_tid, WM_USER, (WPARAM)event, (LPARAM)&spc);
595 WaitForSingleObject(event, INFINITE);
596 CloseHandle(event);
597 } else
598 proc(arg);
601 static DWORD WINAPI MZ_DOSVM( LPVOID lpExtra )
603 CONTEXT context;
604 DWORD ret;
606 dosvm_pid = getpid();
608 memset( &context, 0, sizeof(context) );
609 context.SegCs = init_cs;
610 context.Eip = init_ip;
611 context.SegSs = init_ss;
612 context.Esp = init_sp;
613 context.SegDs = DOSVM_psp;
614 context.SegEs = DOSVM_psp;
615 context.EFlags = V86_FLAG | VIF_MASK;
616 DOSVM_SetTimer(0x10000);
617 ret = DOSVM_Enter( &context );
619 dosvm_pid = 0;
620 return ret;
623 static BOOL MZ_InitTask(void)
625 if (!DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
626 GetCurrentProcess(), &loop_thread,
627 0, FALSE, DUPLICATE_SAME_ACCESS))
628 return FALSE;
629 dosvm_thread = CreateThread(NULL, 0, MZ_DOSVM, NULL, CREATE_SUSPENDED, &dosvm_tid);
630 if (!dosvm_thread) {
631 CloseHandle(loop_thread);
632 loop_thread = 0;
633 return FALSE;
635 loop_tid = GetCurrentThreadId();
636 return TRUE;
639 static void MZ_Launch( LPCSTR cmdtail, int length )
641 TDB *pTask = GlobalLock16( GetCurrentTask() );
642 BYTE *psp_start = PTR_REAL_TO_LIN( DOSVM_psp, 0 );
643 DWORD rv;
644 SYSLEVEL *lock;
646 MZ_FillPSP(psp_start, cmdtail, length);
647 pTask->flags |= TDBF_WINOLDAP;
649 /* DTA is set to PSP:0080h when a program is started. */
650 pTask->dta = MAKESEGPTR( DOSVM_psp, 0x80 );
652 GetpWin16Lock( &lock );
653 _LeaveSysLevel( lock );
655 ResumeThread(dosvm_thread);
656 rv = DOSVM_Loop(dosvm_thread);
658 CloseHandle(dosvm_thread);
659 dosvm_thread = 0; dosvm_tid = 0;
660 CloseHandle(loop_thread);
661 loop_thread = 0; loop_tid = 0;
663 VGA_Clean();
664 ExitProcess(rv);
667 /***********************************************************************
668 * MZ_Exit
670 void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval )
672 if (DOSVM_psp) {
673 WORD psp_seg = cs_psp ? context->SegCs : DOSVM_psp;
674 LPBYTE psp_start = (LPBYTE)((DWORD)psp_seg << 4);
675 PDB16 *psp = (PDB16 *)psp_start;
676 WORD parpsp = psp->parentPSP; /* check for parent DOS process */
677 if (parpsp) {
678 /* retrieve parent's return address */
679 FARPROC16 retaddr = DOSVM_GetRMHandler(0x22);
680 /* restore interrupts */
681 DOSVM_SetRMHandler(0x22, psp->savedint22);
682 DOSVM_SetRMHandler(0x23, psp->savedint23);
683 DOSVM_SetRMHandler(0x24, psp->savedint24);
684 /* FIXME: deallocate file handles etc */
685 /* free process's associated memory
686 * FIXME: walk memory and deallocate all blocks owned by process */
687 DOSMEM_FreeBlock( PTR_REAL_TO_LIN(psp->environment,0) );
688 DOSMEM_FreeBlock( PTR_REAL_TO_LIN(DOSVM_psp,0) );
689 /* switch to parent's PSP */
690 DOSVM_psp = parpsp;
691 psp_start = (LPBYTE)((DWORD)parpsp << 4);
692 psp = (PDB16 *)psp_start;
693 /* now return to parent */
694 DOSVM_retval = retval;
695 context->SegCs = SELECTOROF(retaddr);
696 context->Eip = OFFSETOF(retaddr);
697 context->SegSs = SELECTOROF(psp->saveStack);
698 context->Esp = OFFSETOF(psp->saveStack);
699 return;
700 } else
701 TRACE("killing DOS task\n");
703 ExitThread( retval );
707 /***********************************************************************
708 * MZ_Current
710 BOOL WINAPI MZ_Current( void )
712 return (dosvm_pid != 0); /* FIXME: do a better check */
715 #else /* !MZ_SUPPORTED */
717 /***********************************************************************
718 * wine_load_dos_exe (WINEDOS.@)
720 void WINAPI wine_load_dos_exe( LPCSTR filename, LPCSTR cmdline )
722 WARN("DOS executables not supported on this platform\n");
723 SetLastError(ERROR_BAD_FORMAT);
726 /***********************************************************************
727 * MZ_Exec
729 BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk )
731 /* can't happen */
732 SetLastError(ERROR_BAD_FORMAT);
733 return FALSE;
736 /***********************************************************************
737 * MZ_AllocDPMITask
739 void WINAPI MZ_AllocDPMITask( void )
741 ERR("Actual real-mode calls not supported on this platform!\n");
744 /***********************************************************************
745 * MZ_RunInThread
747 void WINAPI MZ_RunInThread( PAPCFUNC proc, ULONG_PTR arg )
749 proc(arg);
752 /***********************************************************************
753 * MZ_Exit
755 void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval )
757 ExitThread( retval );
760 /***********************************************************************
761 * MZ_Current
763 BOOL WINAPI MZ_Current( void )
765 return FALSE;
768 #endif /* !MZ_SUPPORTED */