Added an unknown VxD error code.
[wine] / dlls / winedos / module.c
1 /*
2  * DOS (MZ) loader
3  *
4  * Copyright 1998 Ove Kåven
5  *
6  * This code hasn't been completely cleaned up yet.
7  */
8
9 #include "config.h"
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <fcntl.h>
16 #include <signal.h>
17 #include <unistd.h>
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <sys/time.h>
21 #include "windef.h"
22 #include "wine/winbase16.h"
23 #include "winerror.h"
24 #include "module.h"
25 #include "task.h"
26 #include "file.h"
27 #include "miscemu.h"
28 #include "debugtools.h"
29 #include "dosexe.h"
30 #include "../../loader/dos/dosmod.h"
31 #include "options.h"
32 #include "vga.h"
33
34 DEFAULT_DEBUG_CHANNEL(module);
35
36 static LPDOSTASK dos_current;
37
38 #ifdef MZ_SUPPORTED
39
40 #ifdef HAVE_SYS_MMAN_H
41 # include <sys/mman.h>
42 #endif
43
44 /* define this to try mapping through /proc/pid/mem instead of a temp file,
45    but Linus doesn't like mmapping /proc/pid/mem, so it doesn't work for me */
46 #undef MZ_MAPSELF
47
48 #define BIOS_DATA_SEGMENT 0x40
49 #define PSP_SIZE 0x10
50
51 #define SEG16(ptr,seg) ((LPVOID)((BYTE*)ptr+((DWORD)(seg)<<4)))
52 #define SEGPTR16(ptr,segptr) ((LPVOID)((BYTE*)ptr+((DWORD)SELECTOROF(segptr)<<4)+OFFSETOF(segptr)))
53
54 /* structures for EXEC */
55
56 typedef struct {
57   WORD env_seg;
58   DWORD cmdline WINE_PACKED;
59   DWORD fcb1 WINE_PACKED;
60   DWORD fcb2 WINE_PACKED;
61   WORD init_sp;
62   WORD init_ss;
63   WORD init_ip;
64   WORD init_cs;
65 } ExecBlock;
66
67 typedef struct {
68   WORD load_seg;
69   WORD rel_seg;
70 } OverlayBlock;
71
72 /* global variables */
73
74 static WORD init_cs,init_ip,init_ss,init_sp;
75 static char mm_name[128];
76
77 int read_pipe, write_pipe;
78 HANDLE hReadPipe, hWritePipe;
79 pid_t dosmod_pid;
80
81 static void MZ_Launch(void);
82 static BOOL MZ_InitTask(void);
83 static void MZ_KillTask(void);
84
85 static void MZ_CreatePSP( LPVOID lpPSP, WORD env, WORD par )
86 {
87   PDB16*psp=lpPSP;
88
89   psp->int20=0x20CD; /* int 20 */
90   /* some programs use this to calculate how much memory they need */
91   psp->nextParagraph=0x9FFF; /* FIXME: use a real value */
92   /* FIXME: dispatcher */
93   psp->savedint22 = INT_GetRMHandler(0x22);
94   psp->savedint23 = INT_GetRMHandler(0x23);
95   psp->savedint24 = INT_GetRMHandler(0x24);
96   psp->parentPSP=par;
97   psp->environment=env;
98   /* FIXME: more PSP stuff */
99 }
100
101 static void MZ_FillPSP( LPVOID lpPSP, LPCSTR cmdline )
102 {
103  PDB16*psp=lpPSP;
104  const char*cmd=cmdline?strchr(cmdline,' '):NULL;
105
106  /* copy parameters */
107  if (cmd) {
108 #if 0
109   /* command.com doesn't do this */
110   while (*cmd == ' ') cmd++;
111 #endif
112   psp->cmdLine[0]=strlen(cmd);
113   strcpy(psp->cmdLine+1,cmd);
114   psp->cmdLine[psp->cmdLine[0]+1]='\r';
115  } else psp->cmdLine[1]='\r';
116  /* FIXME: more PSP stuff */
117 }
118
119 /* default INT 08 handler: increases timer tick counter but not much more */
120 static char int08[]={
121  0xCD,0x1C,           /* int $0x1c */
122  0x50,                /* pushw %ax */
123  0x1E,                /* pushw %ds */
124  0xB8,0x40,0x00,      /* movw $0x40,%ax */
125  0x8E,0xD8,           /* movw %ax,%ds */
126 #if 0
127  0x83,0x06,0x6C,0x00,0x01, /* addw $1,(0x6c) */
128  0x83,0x16,0x6E,0x00,0x00, /* adcw $0,(0x6e) */
129 #else
130  0x66,0xFF,0x06,0x6C,0x00, /* incl (0x6c) */
131 #endif
132  0xB0,0x20,           /* movb $0x20,%al */
133  0xE6,0x20,           /* outb %al,$0x20 */
134  0x1F,                /* popw %ax */
135  0x58,                /* popw %ax */
136  0xCF                 /* iret */
137 };
138
139 static void MZ_InitHandlers(void)
140 {
141  WORD seg;
142  LPBYTE start=DOSMEM_GetBlock(sizeof(int08),&seg);
143  memcpy(start,int08,sizeof(int08));
144 /* INT 08: point it at our tick-incrementing handler */
145  ((SEGPTR*)0)[0x08]=MAKESEGPTR(seg,0);
146 /* INT 1C: just point it to IRET, we don't want to handle it ourselves */
147  ((SEGPTR*)0)[0x1C]=MAKESEGPTR(seg,sizeof(int08)-1);
148 }
149
150 static WORD MZ_InitEnvironment( LPCSTR env, LPCSTR name )
151 {
152  unsigned sz=0;
153  WORD seg;
154  LPSTR envblk;
155
156  if (env) {
157   /* get size of environment block */
158   while (env[sz++]) sz+=strlen(env+sz)+1;
159  } else sz++;
160  /* allocate it */
161  envblk=DOSMEM_GetBlock(sz+sizeof(WORD)+strlen(name)+1,&seg);
162  /* fill it */
163  if (env) {
164   memcpy(envblk,env,sz);
165  } else envblk[0]=0;
166  /* DOS 3.x: the block contains 1 additional string */
167  *(WORD*)(envblk+sz)=1;
168  /* being the program name itself */
169  strcpy(envblk+sz+sizeof(WORD),name);
170  return seg;
171 }
172
173 static BOOL MZ_InitMemory(void)
174 {
175     int mm_fd;
176     void *img_base;
177
178     /* initialize the memory */
179     TRACE("Initializing DOS memory structures\n");
180     DOSMEM_Init(TRUE);
181
182     /* allocate 1MB+64K shared memory */
183     tmpnam(mm_name);
184     /* strcpy(mm_name,"/tmp/mydosimage"); */
185     mm_fd = open(mm_name,O_RDWR|O_CREAT /* |O_TRUNC */,S_IRUSR|S_IWUSR);
186     if (mm_fd < 0) ERR("file %s could not be opened\n",mm_name);
187     /* fill the file with the DOS memory */
188     if (write( mm_fd, NULL, 0x110000 ) != 0x110000) ERR("cannot write DOS mem\n");
189     /* map it in */
190     img_base = mmap(NULL,0x110000,PROT_READ|PROT_WRITE|PROT_EXEC,MAP_SHARED|MAP_FIXED,mm_fd,0);
191     close( mm_fd );
192
193     if (img_base)
194     {
195         ERR("could not map shared memory, error=%s\n",strerror(errno));
196         return FALSE;
197     }
198     MZ_InitHandlers();
199     return TRUE;
200 }
201
202 static BOOL MZ_DoLoadImage( HANDLE hFile, LPCSTR filename, OverlayBlock *oblk )
203 {
204   LPDOSTASK lpDosTask = dos_current;
205   IMAGE_DOS_HEADER mz_header;
206   DWORD image_start,image_size,min_size,max_size,avail;
207   BYTE*psp_start,*load_start,*oldenv;
208   int x, old_com=0, alloc;
209   SEGPTR reloc;
210   WORD env_seg, load_seg, rel_seg, oldpsp_seg;
211   DWORD len;
212
213   if (lpDosTask) {
214     /* DOS process already running, inherit from it */
215     PDB16* par_psp = (PDB16*)((DWORD)lpDosTask->psp_seg << 4);
216     alloc=0;
217     oldenv = (LPBYTE)((DWORD)par_psp->environment << 4);
218     oldpsp_seg = lpDosTask->psp_seg;
219   } else {
220     /* allocate new DOS process, inheriting from Wine environment */
221     alloc=1;
222     lpDosTask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DOSTASK));
223     dos_current = lpDosTask;
224     oldenv = GetEnvironmentStringsA();
225     oldpsp_seg = 0;
226   }
227
228  SetFilePointer(hFile,0,NULL,FILE_BEGIN);
229  if (   !ReadFile(hFile,&mz_header,sizeof(mz_header),&len,NULL)
230      || len != sizeof(mz_header) 
231      || mz_header.e_magic != IMAGE_DOS_SIGNATURE) {
232   char *p = strrchr( filename, '.' );
233   if (!p || strcasecmp( p, ".com" ))  /* check for .COM extension */
234   {
235       SetLastError(ERROR_BAD_FORMAT);
236       goto load_error;
237   }
238   old_com=1; /* assume .COM file */
239   image_start=0;
240   image_size=GetFileSize(hFile,NULL);
241   min_size=0x10000; max_size=0x100000;
242   mz_header.e_crlc=0;
243   mz_header.e_ss=0; mz_header.e_sp=0xFFFE;
244   mz_header.e_cs=0; mz_header.e_ip=0x100;
245  } else {
246   /* calculate load size */
247   image_start=mz_header.e_cparhdr<<4;
248   image_size=mz_header.e_cp<<9; /* pages are 512 bytes */
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);
253  }
254
255   if (alloc) MZ_InitMemory();
256
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);
265
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;
273     }
274     if (avail>max_size) avail=max_size;
275     psp_start=DOSMEM_GetBlock(avail,&lpDosTask->psp_seg);
276     if (!psp_start) {
277       ERR("error allocating DOS memory\n");
278       SetLastError(ERROR_NOT_ENOUGH_MEMORY);
279       goto load_error;
280     }
281     load_seg=lpDosTask->psp_seg+(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);
285   }
286
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   SetLastError(ERROR_BAD_FORMAT);
292   goto load_error;
293  }
294
295  if (mz_header.e_crlc) {
296   /* load relocation table */
297   TRACE("loading DOS EXE relocation table, %d entries\n",mz_header.e_crlc);
298   /* FIXME: is this too slow without read buffering? */
299   SetFilePointer(hFile,mz_header.e_lfarlc,NULL,FILE_BEGIN);
300   for (x=0; x<mz_header.e_crlc; x++) {
301    if (!ReadFile(hFile,&reloc,sizeof(reloc),&len,NULL) || len != sizeof(reloc)) {
302     SetLastError(ERROR_BAD_FORMAT);
303     goto load_error;
304    }
305    *(WORD*)SEGPTR16(load_start,reloc)+=rel_seg;
306   }
307  }
308
309   if (!oblk) {
310     init_cs = load_seg+mz_header.e_cs;
311     init_ip = mz_header.e_ip;
312     init_ss = load_seg+mz_header.e_ss;
313     init_sp = mz_header.e_sp;
314
315     TRACE("entry point: %04x:%04x\n",init_cs,init_ip);
316   }
317
318   if (alloc && !MZ_InitTask()) {
319     MZ_KillTask();
320     SetLastError(ERROR_GEN_FAILURE);
321     return FALSE;
322   }
323
324   return TRUE;
325
326 load_error:
327   lpDosTask->psp_seg = oldpsp_seg;
328   if (alloc) {
329     dos_current = NULL;
330     if (mm_name[0]!=0) unlink(mm_name);
331   }
332
333   return FALSE;
334 }
335
336 /***********************************************************************
337  *              LoadDosExe (WINEDOS.@)
338  */
339 void WINAPI MZ_LoadImage( LPCSTR filename, HANDLE hFile )
340 {
341     if (MZ_DoLoadImage( hFile, filename, NULL )) MZ_Launch();
342 }
343
344 /***********************************************************************
345  *              Exec (WINEDOS.@)
346  */
347 BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk )
348 {
349   /* this may only be called from existing DOS processes
350    * (i.e. one DOS app spawning another) */
351   /* FIXME: do we want to check binary type first, to check
352    * whether it's a NE/PE executable? */
353   LPDOSTASK lpDosTask = MZ_Current();
354   HFILE hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ,
355                              NULL, OPEN_EXISTING, 0, 0);
356   BOOL ret = FALSE;
357   if (hFile == INVALID_HANDLE_VALUE) return FALSE;
358   switch (func) {
359   case 0: /* load and execute */
360   case 1: /* load but don't execute */
361     {
362       /* save current process's return SS:SP now */
363       LPBYTE psp_start = (LPBYTE)((DWORD)lpDosTask->psp_seg << 4);
364       PDB16 *psp = (PDB16 *)psp_start;
365       psp->saveStack = (DWORD)MAKESEGPTR(context->SegSs, LOWORD(context->Esp));
366     }
367     ret = MZ_DoLoadImage( hFile, filename, NULL );
368     if (ret) {
369       /* MZ_LoadImage created a new PSP and loaded new values into lpDosTask,
370        * let's work on the new values now */
371       LPBYTE psp_start = (LPBYTE)((DWORD)lpDosTask->psp_seg << 4);
372       ExecBlock *blk = (ExecBlock *)paramblk;
373       MZ_FillPSP(psp_start, DOSMEM_MapRealToLinear(blk->cmdline));
374       /* the lame MS-DOS engineers decided that the return address should be in int22 */
375       INT_SetRMHandler(0x22, (FARPROC16)MAKESEGPTR(context->SegCs, LOWORD(context->Eip)));
376       if (func) {
377         /* don't execute, just return startup state */
378         blk->init_cs = init_cs;
379         blk->init_ip = init_ip;
380         blk->init_ss = init_ss;
381         blk->init_sp = init_sp;
382       } else {
383         /* execute by making us return to new process */
384         context->SegCs = init_cs;
385         context->Eip   = init_ip;
386         context->SegSs = init_ss;
387         context->Esp   = init_sp;
388         context->SegDs = lpDosTask->psp_seg;
389         context->SegEs = lpDosTask->psp_seg;
390         context->Eax   = 0;
391       }
392     }
393     break;
394   case 3: /* load overlay */
395     {
396       OverlayBlock *blk = (OverlayBlock *)paramblk;
397       ret = MZ_DoLoadImage( hFile, filename, blk );
398     }
399     break;
400   default:
401     FIXME("EXEC load type %d not implemented\n", func);
402     SetLastError(ERROR_INVALID_FUNCTION);
403     break;
404   }
405   CloseHandle(hFile);
406   return ret;
407 }
408
409 /***********************************************************************
410  *              LoadDPMI (WINEDOS.@)
411  */
412 LPDOSTASK WINAPI MZ_AllocDPMITask( void )
413 {
414   LPDOSTASK lpDosTask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DOSTASK));
415
416   if (lpDosTask) {
417     dos_current = lpDosTask;
418     MZ_InitMemory();
419     MZ_InitTask();
420   }
421   return lpDosTask;
422 }
423
424 static void MZ_InitTimer( int ver )
425 {
426  if (ver<1) {
427   /* can't make timer ticks */
428  } else {
429   int func;
430   struct timeval tim;
431
432   /* start dosmod timer at 55ms (18.2Hz) */
433   func=DOSMOD_SET_TIMER;
434   tim.tv_sec=0; tim.tv_usec=54925;
435   write(write_pipe,&func,sizeof(func));
436   write(write_pipe,&tim,sizeof(tim));
437  }
438 }
439
440 static BOOL MZ_InitTask(void)
441 {
442   int write_fd[2],x_fd;
443   pid_t child;
444   char path[256],*fpath;
445
446   /* create pipes */
447   if (!CreatePipe(&hReadPipe,&hWritePipe,NULL,0)) return FALSE;
448   if (pipe(write_fd)<0) {
449     CloseHandle(hReadPipe);
450     CloseHandle(hWritePipe);
451     return FALSE;
452   }
453
454   read_pipe = FILE_GetUnixHandle( hReadPipe, GENERIC_READ );
455   x_fd = FILE_GetUnixHandle( hWritePipe, GENERIC_WRITE );
456
457   TRACE("win32 pipe: read=%d, write=%d, unix pipe: read=%d, write=%d\n",
458         hReadPipe,hWritePipe,read_pipe,x_fd);
459   TRACE("outbound unix pipe: read=%d, write=%d, pid=%d\n",write_fd[0],write_fd[1],getpid());
460
461   write_pipe=write_fd[1];
462
463   TRACE("Loading DOS VM support module\n");
464   if ((child=fork())<0) {
465     close(write_fd[0]);
466     close(read_pipe);
467     close(write_pipe);
468     close(x_fd);
469     CloseHandle(hReadPipe);
470     CloseHandle(hWritePipe);
471     return FALSE;
472   }
473  if (child!=0) {
474   /* parent process */
475   int ret;
476
477   close(write_fd[0]);
478   close(x_fd);
479   dosmod_pid = child;
480   /* wait for child process to signal readiness */
481   while (1) {
482     if (read(read_pipe,&ret,sizeof(ret))==sizeof(ret)) break;
483     if ((errno==EINTR)||(errno==EAGAIN)) continue;
484     /* failure */
485     ERR("dosmod has failed to initialize\n");
486     if (mm_name[0]!=0) unlink(mm_name);
487     return FALSE;
488   }
489   /* the child has now mmaped the temp file, it's now safe to unlink.
490    * do it here to avoid leaving a mess in /tmp if/when Wine crashes... */
491   if (mm_name[0]!=0) unlink(mm_name);
492   /* start simulated system timer */
493   MZ_InitTimer(ret);
494   if (ret<2) {
495     ERR("dosmod version too old! Please install newer dosmod properly\n");
496     ERR("If you don't, the new dosmod event handling system will not work\n");
497   }
498   /* all systems are now go */
499  } else {
500   /* child process */
501   close(read_pipe);
502   close(write_pipe);
503   /* put our pipes somewhere dosmod can find them */
504   dup2(write_fd[0],0); /* stdin */
505   dup2(x_fd,1);        /* stdout */
506   /* now load dosmod */
507   /* check argv[0]-derived paths first, since the newest dosmod is most likely there
508    * (at least it was once for Andreas Mohr, so I decided to make it easier for him) */
509   fpath=strrchr(strcpy(path,full_argv0),'/');
510   if (fpath) {
511    strcpy(fpath,"/dosmod");
512    execl(path,mm_name,NULL);
513    strcpy(fpath,"/loader/dos/dosmod");
514    execl(path,mm_name,NULL);
515   }
516   /* okay, it wasn't there, try in the path */
517   execlp("dosmod",mm_name,NULL);
518   /* last desperate attempts: current directory */
519   execl("dosmod",mm_name,NULL);
520   /* and, just for completeness... */
521   execl("loader/dos/dosmod",mm_name,NULL);
522   /* if failure, exit */
523   ERR("Failed to spawn dosmod, error=%s\n",strerror(errno));
524   exit(1);
525  }
526  return TRUE;
527 }
528
529 static void MZ_Launch(void)
530 {
531   LPDOSTASK lpDosTask = MZ_Current();
532   CONTEXT context;
533   TDB *pTask = TASK_GetCurrent();
534   BYTE *psp_start = PTR_REAL_TO_LIN( lpDosTask->psp_seg, 0 );
535
536   MZ_FillPSP(psp_start, GetCommandLineA());
537   pTask->flags |= TDBF_WINOLDAP;
538
539   memset( &context, 0, sizeof(context) );
540   context.SegCs  = init_cs;
541   context.Eip    = init_ip;
542   context.SegSs  = init_ss;
543   context.Esp    = init_sp;
544   context.SegDs  = lpDosTask->psp_seg;
545   context.SegEs  = lpDosTask->psp_seg;
546   context.EFlags = 0x00080000;  /* virtual interrupt flag */
547   _LeaveWin16Lock();
548   DOSVM_Enter( &context );
549 }
550
551 static void MZ_KillTask(void)
552 {
553   TRACE("killing DOS task\n");
554   VGA_Clean();
555   kill(dosmod_pid,SIGTERM);
556 }
557
558 /***********************************************************************
559  *              Exit (WINEDOS.@)
560  */
561 void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval )
562 {
563   LPDOSTASK lpDosTask = MZ_Current();
564   if (lpDosTask) {
565     WORD psp_seg = cs_psp ? context->SegCs : lpDosTask->psp_seg;
566     LPBYTE psp_start = (LPBYTE)((DWORD)psp_seg << 4);
567     PDB16 *psp = (PDB16 *)psp_start;
568     WORD parpsp = psp->parentPSP; /* check for parent DOS process */
569     if (parpsp) {
570       /* retrieve parent's return address */
571       FARPROC16 retaddr = INT_GetRMHandler(0x22);
572       /* restore interrupts */
573       INT_SetRMHandler(0x22, psp->savedint22);
574       INT_SetRMHandler(0x23, psp->savedint23);
575       INT_SetRMHandler(0x24, psp->savedint24);
576       /* FIXME: deallocate file handles etc */
577       /* free process's associated memory
578        * FIXME: walk memory and deallocate all blocks owned by process */
579       DOSMEM_FreeBlock(DOSMEM_MapRealToLinear(MAKELONG(0,psp->environment)));
580       DOSMEM_FreeBlock(DOSMEM_MapRealToLinear(MAKELONG(0,lpDosTask->psp_seg)));
581       /* switch to parent's PSP */
582       lpDosTask->psp_seg = parpsp;
583       psp_start = (LPBYTE)((DWORD)parpsp << 4);
584       psp = (PDB16 *)psp_start;
585       /* now return to parent */
586       lpDosTask->retval = retval;
587       context->SegCs = SELECTOROF(retaddr);
588       context->Eip   = OFFSETOF(retaddr);
589       context->SegSs = SELECTOROF(psp->saveStack);
590       context->Esp   = OFFSETOF(psp->saveStack);
591       return;
592     } else
593       MZ_KillTask();
594   }
595   ExitThread( retval );
596 }
597
598 #else /* !MZ_SUPPORTED */
599
600 void WINAPI MZ_LoadImage( LPCSTR filename, HANDLE hFile )
601 {
602   WARN("DOS executables not supported on this platform\n");
603   SetLastError(ERROR_BAD_FORMAT);
604 }
605
606 BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk )
607 {
608   /* can't happen */
609   SetLastError(ERROR_BAD_FORMAT);
610   return FALSE;
611 }
612
613 LPDOSTASK WINAPI MZ_AllocDPMITask( void )
614 {
615     ERR("Actual real-mode calls not supported on this platform!\n");
616     return NULL;
617 }
618
619 void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval )
620 {
621   ExitThread( retval );
622 }
623
624 #endif /* !MZ_SUPPORTED */
625
626 /***********************************************************************
627  *              GetCurrent (WINEDOS.@)
628  */
629 LPDOSTASK WINAPI MZ_Current( void )
630 {
631   return dos_current;
632 }