Added get_page_size function.
[wine] / loader / dos / 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 "peexe.h"
26 #include "neexe.h"
27 #include "task.h"
28 #include "selectors.h"
29 #include "file.h"
30 #include "ldt.h"
31 #include "process.h"
32 #include "miscemu.h"
33 #include "debugtools.h"
34 #include "dosexe.h"
35 #include "dosmod.h"
36 #include "options.h"
37 #include "server.h"
38
39 DEFAULT_DEBUG_CHANNEL(module)
40
41 #ifdef MZ_SUPPORTED
42
43 #ifdef HAVE_SYS_MMAN_H
44 # include <sys/mman.h>
45 #endif
46
47 /* define this to try mapping through /proc/pid/mem instead of a temp file,
48    but Linus doesn't like mmapping /proc/pid/mem, so it doesn't work for me */
49 #undef MZ_MAPSELF
50
51 #define BIOS_DATA_SEGMENT 0x40
52 #define START_OFFSET 0
53 #define PSP_SIZE 0x10
54
55 #define SEG16(ptr,seg) ((LPVOID)((BYTE*)ptr+((DWORD)(seg)<<4)))
56 #define SEGPTR16(ptr,segptr) ((LPVOID)((BYTE*)ptr+((DWORD)SELECTOROF(segptr)<<4)+OFFSETOF(segptr)))
57
58 static void MZ_InitPSP( LPVOID lpPSP, LPCSTR cmdline, WORD env )
59 {
60  PDB16*psp=lpPSP;
61  const char*cmd=cmdline?strchr(cmdline,' '):NULL;
62
63  psp->int20=0x20CD; /* int 20 */
64  /* some programs use this to calculate how much memory they need */
65  psp->nextParagraph=0x9FFF;
66  psp->environment=env;
67  /* copy parameters */
68  if (cmd) {
69 #if 0
70   /* command.com doesn't do this */
71   while (*cmd == ' ') cmd++;
72 #endif
73   psp->cmdLine[0]=strlen(cmd);
74   strcpy(psp->cmdLine+1,cmd);
75   psp->cmdLine[psp->cmdLine[0]+1]='\r';
76  } else psp->cmdLine[1]='\r';
77  /* FIXME: integrate the memory stuff from Wine (msdos/dosmem.c) */
78  /* FIXME: integrate the PDB stuff from Wine (loader/task.c) */
79 }
80
81 /* default INT 08 handler: increases timer tick counter but not much more */
82 static char int08[]={
83  0xCD,0x1C,           /* int $0x1c */
84  0x50,                /* pushw %ax */
85  0x1E,                /* pushw %ds */
86  0xB8,0x40,0x00,      /* movw $0x40,%ax */
87  0x8E,0xD8,           /* movw %ax,%ds */
88 #if 0
89  0x83,0x06,0x6C,0x00,0x01, /* addw $1,(0x6c) */
90  0x83,0x16,0x6E,0x00,0x00, /* adcw $0,(0x6e) */
91 #else
92  0x66,0xFF,0x06,0x6C,0x00, /* incl (0x6c) */
93 #endif
94  0xB0,0x20,           /* movb $0x20,%al */
95  0xE6,0x20,           /* outb %al,$0x20 */
96  0x1F,                /* popw %ax */
97  0x58,                /* popw %ax */
98  0xCF                 /* iret */
99 };
100
101 static void MZ_InitHandlers( LPDOSTASK lpDosTask )
102 {
103  WORD seg;
104  LPBYTE start=DOSMEM_GetBlock(lpDosTask->hModule,sizeof(int08),&seg);
105  memcpy(start,int08,sizeof(int08));
106 /* INT 08: point it at our tick-incrementing handler */
107  ((SEGPTR*)(lpDosTask->img))[0x08]=PTR_SEG_OFF_TO_SEGPTR(seg,0);
108 /* INT 1C: just point it to IRET, we don't want to handle it ourselves */
109  ((SEGPTR*)(lpDosTask->img))[0x1C]=PTR_SEG_OFF_TO_SEGPTR(seg,sizeof(int08)-1);
110 }
111
112 static char enter_xms[]={
113 /* XMS hookable entry point */
114  0xEB,0x03,           /* jmp entry */
115  0x90,0x90,0x90,      /* nop;nop;nop */
116                       /* entry: */
117 /* real entry point */
118 /* for simplicity, we'll just use the same hook as DPMI below */
119  0xCD,0x31,           /* int $0x31 */
120  0xCB                 /* lret */
121 };
122
123 static void MZ_InitXMS( LPDOSTASK lpDosTask )
124 {
125  LPBYTE start=DOSMEM_GetBlock(lpDosTask->hModule,sizeof(enter_xms),&(lpDosTask->xms_seg));
126  memcpy(start,enter_xms,sizeof(enter_xms));
127 }
128
129 static char enter_pm[]={
130  0x50,                /* pushw %ax */
131  0x52,                /* pushw %dx */
132  0x55,                /* pushw %bp */
133  0x89,0xE5,           /* movw %sp,%bp */
134 /* get return CS */
135  0x8B,0x56,0x08,      /* movw 8(%bp),%dx */
136 /* just call int 31 here to get into protected mode... */
137 /* it'll check whether it was called from dpmi_seg... */
138  0xCD,0x31,           /* int $0x31 */
139 /* we are now in the context of a 16-bit relay call */
140 /* need to fixup our stack;
141  * 16-bit relay return address will be lost, but we won't worry quite yet */
142  0x8E,0xD0,           /* movw %ax,%ss */
143  0x66,0x0F,0xB7,0xE5, /* movzwl %bp,%esp */
144 /* set return CS */
145  0x89,0x56,0x08,      /* movw %dx,8(%bp) */
146  0x5D,                /* popw %bp */
147  0x5A,                /* popw %dx */
148  0x58,                /* popw %ax */
149  0xCB                 /* lret */
150 };
151
152 static void MZ_InitDPMI( LPDOSTASK lpDosTask )
153 {
154  unsigned size=sizeof(enter_pm);
155  LPBYTE start=DOSMEM_GetBlock(lpDosTask->hModule,size,&(lpDosTask->dpmi_seg));
156  
157  lpDosTask->dpmi_sel = SELECTOR_AllocBlock( start, size, SEGMENT_CODE, FALSE, FALSE );
158
159  memcpy(start,enter_pm,sizeof(enter_pm));
160 }
161
162 static WORD MZ_InitEnvironment( LPDOSTASK lpDosTask, LPCSTR env, LPCSTR name )
163 {
164  unsigned sz=0;
165  WORD seg;
166  LPSTR envblk;
167
168  if (env) {
169   /* get size of environment block */
170   while (env[sz++]) sz+=strlen(env+sz)+1;
171  } else sz++;
172  /* allocate it */
173  envblk=DOSMEM_GetBlock(lpDosTask->hModule,sz+sizeof(WORD)+strlen(name)+1,&seg);
174  /* fill it */
175  if (env) {
176   memcpy(envblk,env,sz);
177  } else envblk[0]=0;
178  /* DOS 3.x: the block contains 1 additional string */
179  *(WORD*)(envblk+sz)=1;
180  /* being the program name itself */
181  strcpy(envblk+sz+sizeof(WORD),name);
182  return seg;
183 }
184
185 static BOOL MZ_InitMemory( LPDOSTASK lpDosTask, NE_MODULE *pModule )
186 {
187  int x;
188
189  if (lpDosTask->img) return TRUE; /* already allocated */
190
191  /* allocate 1MB+64K shared memory */
192  lpDosTask->img_ofs=START_OFFSET;
193 #ifdef MZ_MAPSELF
194  lpDosTask->img=VirtualAlloc(NULL,0x110000,MEM_COMMIT,PAGE_READWRITE);
195  /* make sure mmap accepts it */
196  ((char*)lpDosTask->img)[0x10FFFF]=0;
197 #else
198  tmpnam(lpDosTask->mm_name);
199 /* strcpy(lpDosTask->mm_name,"/tmp/mydosimage"); */
200  lpDosTask->mm_fd=open(lpDosTask->mm_name,O_RDWR|O_CREAT /* |O_TRUNC */,S_IRUSR|S_IWUSR);
201  if (lpDosTask->mm_fd<0) ERR("file %s could not be opened\n",lpDosTask->mm_name);
202  /* expand file to 1MB+64K */
203  lseek(lpDosTask->mm_fd,0x110000-1,SEEK_SET);
204  x=0; write(lpDosTask->mm_fd,&x,1);
205  /* map it in */
206  lpDosTask->img=mmap(NULL,0x110000-START_OFFSET,PROT_READ|PROT_WRITE,MAP_SHARED,lpDosTask->mm_fd,0);
207 #endif
208  if (lpDosTask->img==(LPVOID)-1) {
209   ERR("could not map shared memory, error=%s\n",strerror(errno));
210   return FALSE;
211  }
212  TRACE("DOS VM86 image mapped at %08lx\n",(DWORD)lpDosTask->img);
213  pModule->dos_image=lpDosTask->img;
214
215  /* initialize the memory */
216  TRACE("Initializing DOS memory structures\n");
217  DOSMEM_Init(lpDosTask->hModule);
218  MZ_InitHandlers(lpDosTask);
219  MZ_InitXMS(lpDosTask);
220  MZ_InitDPMI(lpDosTask);
221  return TRUE;
222 }
223
224 static BOOL MZ_LoadImage( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmdline,
225                           LPCSTR env, LPDOSTASK lpDosTask, NE_MODULE *pModule )
226 {
227  IMAGE_DOS_HEADER mz_header;
228  DWORD image_start,image_size,min_size,max_size,avail;
229  BYTE*psp_start,*load_start;
230  int x,old_com=0;
231  SEGPTR reloc;
232  WORD env_seg;
233
234  _llseek(hFile,0,FILE_BEGIN);
235  if ((_lread(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) ||
236      (mz_header.e_magic != IMAGE_DOS_SIGNATURE)) {
237   old_com=1; /* assume .COM file */
238   image_start=0;
239   image_size=GetFileSize(hFile,NULL);
240   min_size=0x10000; max_size=0x100000;
241   mz_header.e_crlc=0;
242   mz_header.e_ss=0; mz_header.e_sp=0xFFFE;
243   mz_header.e_cs=0; mz_header.e_ip=0x100;
244  } else {
245   /* calculate load size */
246   image_start=mz_header.e_cparhdr<<4;
247   image_size=mz_header.e_cp<<9; /* pages are 512 bytes */
248   if ((mz_header.e_cblp!=0)&&(mz_header.e_cblp!=4)) image_size-=512-mz_header.e_cblp;
249   image_size-=image_start;
250   min_size=image_size+((DWORD)mz_header.e_minalloc<<4)+(PSP_SIZE<<4);
251   max_size=image_size+((DWORD)mz_header.e_maxalloc<<4)+(PSP_SIZE<<4);
252  }
253
254  MZ_InitMemory(lpDosTask,pModule);
255
256  /* allocate environment block */
257  env_seg=MZ_InitEnvironment(lpDosTask,env,ofs->szPathName);
258
259  /* allocate memory for the executable */
260  TRACE("Allocating DOS memory (min=%ld, max=%ld)\n",min_size,max_size);
261  avail=DOSMEM_Available(lpDosTask->hModule);
262  if (avail<min_size) {
263   ERR("insufficient DOS memory\n");
264   SetLastError(ERROR_NOT_ENOUGH_MEMORY);
265   return FALSE;
266  }
267  if (avail>max_size) avail=max_size;
268  psp_start=DOSMEM_GetBlock(lpDosTask->hModule,avail,&lpDosTask->psp_seg);
269  if (!psp_start) {
270   ERR("error allocating DOS memory\n");
271   SetLastError(ERROR_NOT_ENOUGH_MEMORY);
272   return FALSE;
273  }
274  lpDosTask->load_seg=lpDosTask->psp_seg+(old_com?0:PSP_SIZE);
275  load_start=psp_start+(PSP_SIZE<<4);
276  MZ_InitPSP(psp_start, cmdline, env_seg);
277
278  /* load executable image */
279  TRACE("loading DOS %s image, %08lx bytes\n",old_com?"COM":"EXE",image_size);
280  _llseek(hFile,image_start,FILE_BEGIN);
281  if ((_lread(hFile,load_start,image_size)) != image_size) {
282   SetLastError(ERROR_BAD_FORMAT);
283   return FALSE;
284  }
285
286  if (mz_header.e_crlc) {
287   /* load relocation table */
288   TRACE("loading DOS EXE relocation table, %d entries\n",mz_header.e_crlc);
289   /* FIXME: is this too slow without read buffering? */
290   _llseek(hFile,mz_header.e_lfarlc,FILE_BEGIN);
291   for (x=0; x<mz_header.e_crlc; x++) {
292    if (_lread(hFile,&reloc,sizeof(reloc)) != sizeof(reloc)) {
293     SetLastError(ERROR_BAD_FORMAT);
294     return FALSE;
295    }
296    *(WORD*)SEGPTR16(load_start,reloc)+=lpDosTask->load_seg;
297   }
298  }
299
300  lpDosTask->init_cs=lpDosTask->load_seg+mz_header.e_cs;
301  lpDosTask->init_ip=mz_header.e_ip;
302  lpDosTask->init_ss=lpDosTask->load_seg+mz_header.e_ss;
303  lpDosTask->init_sp=mz_header.e_sp;
304
305  TRACE("entry point: %04x:%04x\n",lpDosTask->init_cs,lpDosTask->init_ip);
306  return TRUE;
307 }
308
309 LPDOSTASK MZ_AllocDPMITask( HMODULE16 hModule )
310 {
311  LPDOSTASK lpDosTask = calloc(1, sizeof(DOSTASK));
312  NE_MODULE *pModule;
313
314  if (lpDosTask) {
315   lpDosTask->hModule = hModule;
316
317   pModule = (NE_MODULE *)GlobalLock16(hModule);
318   pModule->lpDosTask = lpDosTask;
319  
320   lpDosTask->img=NULL; lpDosTask->mm_name[0]=0; lpDosTask->mm_fd=-1;
321
322   MZ_InitMemory(lpDosTask, pModule);
323
324   GlobalUnlock16(hModule);
325  }
326  return lpDosTask;
327 }
328
329 static void MZ_InitTimer( LPDOSTASK lpDosTask, int ver )
330 {
331  if (ver<1) {
332   /* can't make timer ticks */
333  } else {
334   int func;
335   struct timeval tim;
336
337   /* start dosmod timer at 55ms (18.2Hz) */
338   func=DOSMOD_SET_TIMER;
339   tim.tv_sec=0; tim.tv_usec=54925;
340   write(lpDosTask->write_pipe,&func,sizeof(func));
341   write(lpDosTask->write_pipe,&tim,sizeof(tim));
342  }
343 }
344
345 BOOL MZ_InitTask( LPDOSTASK lpDosTask )
346 {
347   int write_fd[2],x_fd;
348   pid_t child;
349   char *fname,*farg,arg[16],fproc[64],path[256],*fpath;
350   SECURITY_ATTRIBUTES attr={sizeof(attr),NULL,TRUE};
351   struct get_read_fd_request *r_req = get_req_buffer();
352   struct get_write_fd_request *w_req = get_req_buffer();
353
354   if (!lpDosTask) return FALSE;
355   /* create pipes */
356   /* this happens in the wrong process context, so we have to let the new process
357      inherit it... (FIXME: call MZ_InitTask in the right process context) */
358   if (!CreatePipe(&(lpDosTask->hReadPipe),&(lpDosTask->hXPipe),&attr,0)) return FALSE;
359   if (pipe(write_fd)<0) {
360     CloseHandle(lpDosTask->hReadPipe);
361     CloseHandle(lpDosTask->hXPipe);
362     return FALSE;
363   }
364   r_req->handle = lpDosTask->hReadPipe;
365   server_call_fd( REQ_GET_READ_FD, -1, &lpDosTask->read_pipe );
366   w_req->handle = lpDosTask->hXPipe;
367   server_call_fd( REQ_GET_WRITE_FD, -1, &x_fd );
368
369   TRACE("win32 pipe: read=%d, write=%d, unix pipe: read=%d, write=%d\n",
370                lpDosTask->hReadPipe,lpDosTask->hXPipe,lpDosTask->read_pipe,x_fd);
371   TRACE("outbound unix pipe: read=%d, write=%d, pid=%d\n",write_fd[0],write_fd[1],getpid());
372
373   lpDosTask->write_pipe=write_fd[1];
374
375   lpDosTask->hConInput=GetStdHandle(STD_INPUT_HANDLE);
376   lpDosTask->hConOutput=GetStdHandle(STD_OUTPUT_HANDLE);
377
378   /* if we have a mapping file, use it */
379   fname=lpDosTask->mm_name; farg=NULL;
380   if (!fname[0]) {
381     /* otherwise, map our own memory image */
382     sprintf(fproc,"/proc/%d/mem",getpid());
383     sprintf(arg,"%ld",(unsigned long)lpDosTask->img);
384     fname=fproc; farg=arg;
385   }
386
387   TRACE("Loading DOS VM support module (hmodule=%04x)\n",lpDosTask->hModule);
388   if ((child=fork())<0) {
389     close(write_fd[0]);
390     close(lpDosTask->read_pipe);
391     close(lpDosTask->write_pipe);
392     close(x_fd);
393     CloseHandle(lpDosTask->hReadPipe);
394     CloseHandle(lpDosTask->hXPipe);
395     return FALSE;
396   }
397  if (child!=0) {
398   /* parent process */
399   int ret;
400
401   close(write_fd[0]);
402   close(x_fd);
403   lpDosTask->task=child;
404   /* wait for child process to signal readiness */
405   while (1) {
406     if (read(lpDosTask->read_pipe,&ret,sizeof(ret))==sizeof(ret)) break;
407     if ((errno==EINTR)||(errno==EAGAIN)) continue;
408     /* failure */
409     ERR("dosmod has failed to initialize\n");
410     if (lpDosTask->mm_name[0]!=0) unlink(lpDosTask->mm_name);
411     return FALSE;
412   }
413   /* the child has now mmaped the temp file, it's now safe to unlink.
414    * do it here to avoid leaving a mess in /tmp if/when Wine crashes... */
415   if (lpDosTask->mm_name[0]!=0) unlink(lpDosTask->mm_name);
416   /* start simulated system timer */
417   MZ_InitTimer(lpDosTask,ret);
418   if (ret<2) {
419     ERR("dosmod version too old! Please install newer dosmod properly\n");
420     ERR("If you don't, the new dosmod event handling system will not work\n");
421   }
422   /* all systems are now go */
423  } else {
424   /* child process */
425   close(lpDosTask->read_pipe);
426   close(lpDosTask->write_pipe);
427   /* put our pipes somewhere dosmod can find them */
428   dup2(write_fd[0],0); /* stdin */
429   dup2(x_fd,1);        /* stdout */
430   /* now load dosmod */
431   /* check argv[0]-derived paths first, since the newest dosmod is most likely there
432    * (at least it was once for Andreas Mohr, so I decided to make it easier for him) */
433   fpath=strrchr(strcpy(path,Options.argv0),'/');
434   if (fpath) {
435    strcpy(fpath,"/dosmod");
436    execl(path,fname,farg,NULL);
437    strcpy(fpath,"/loader/dos/dosmod");
438    execl(path,fname,farg,NULL);
439   }
440   /* okay, it wasn't there, try in the path */
441   execlp("dosmod",fname,farg,NULL);
442   /* last desperate attempts: current directory */
443   execl("dosmod",fname,farg,NULL);
444   /* and, just for completeness... */
445   execl("loader/dos/dosmod",fname,farg,NULL);
446   /* if failure, exit */
447   ERR("Failed to spawn dosmod, error=%s\n",strerror(errno));
448   exit(1);
449  }
450  return TRUE;
451 }
452
453 BOOL MZ_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmdline, LPCSTR env, 
454                        LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
455                        BOOL inherit, DWORD flags, LPSTARTUPINFOA startup, 
456                        LPPROCESS_INFORMATION info )
457 {
458  LPDOSTASK lpDosTask = NULL; /* keep gcc from complaining */
459  HMODULE16 hModule;
460  PDB *pdb = PROCESS_Current();
461  TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
462  NE_MODULE *pModule = pTask ? NE_GetPtr( pTask->hModule ) : NULL;
463  int alloc = !(pModule && pModule->dos_image);
464
465  if (alloc && (lpDosTask = calloc(1, sizeof(DOSTASK))) == NULL) {
466   SetLastError(ERROR_NOT_ENOUGH_MEMORY);
467   return FALSE;
468  }
469
470  if ((!env)&&pdb) env = pdb->env_db->environ;
471  if (alloc) {
472   if ((hModule = MODULE_CreateDummyModule(ofs, NULL, 0)) < 32) {
473    SetLastError(hModule);
474    return FALSE;
475   }
476   lpDosTask->hModule = hModule;
477
478   pModule = (NE_MODULE *)GlobalLock16(hModule);
479   pModule->lpDosTask = lpDosTask;
480  
481   lpDosTask->img=NULL; lpDosTask->mm_name[0]=0; lpDosTask->mm_fd=-1;
482  } else lpDosTask=pModule->lpDosTask;
483  if (!MZ_LoadImage( hFile, ofs, cmdline, env, lpDosTask, pModule )) {
484   if (alloc) {
485    if (lpDosTask->mm_name[0]!=0) {
486     if (lpDosTask->img!=NULL) munmap(lpDosTask->img,0x110000-START_OFFSET);
487     if (lpDosTask->mm_fd>=0) close(lpDosTask->mm_fd);
488     unlink(lpDosTask->mm_name);
489    } else
490     if (lpDosTask->img!=NULL) VirtualFree(lpDosTask->img,0x110000,MEM_RELEASE);
491   }
492   return FALSE;
493  }
494  if (alloc) {
495   pModule->dos_image = lpDosTask->img;
496   if (!MZ_InitTask( lpDosTask )) {
497    MZ_KillModule( lpDosTask );
498    /* FIXME: cleanup hModule */
499    SetLastError(ERROR_GEN_FAILURE);
500    return FALSE;
501   }
502   inherit = TRUE; /* bad hack for inheriting the CreatePipe... */
503   if (!PROCESS_Create( pModule, cmdline, env, 
504                        psa, tsa, inherit, flags, startup, info ))
505    return FALSE;
506  }
507  return TRUE;
508 }
509
510 void MZ_KillModule( LPDOSTASK lpDosTask )
511 {
512   DOSEVENT *event,*p_event;
513   DOSSYSTEM *sys,*p_sys;
514
515   TRACE("killing DOS task\n");
516   if (lpDosTask->mm_name[0]!=0) {
517     munmap(lpDosTask->img,0x110000-START_OFFSET);
518     close(lpDosTask->mm_fd);
519   } else VirtualFree(lpDosTask->img,0x110000,MEM_RELEASE);
520   close(lpDosTask->read_pipe);
521   close(lpDosTask->write_pipe);
522   CloseHandle(lpDosTask->hReadPipe);
523   CloseHandle(lpDosTask->hXPipe);
524   kill(lpDosTask->task,SIGTERM);
525 /* free memory allocated for events and systems */
526 #define DFREE(var,pvar,svar) \
527   var = lpDosTask->svar; \
528   while (var) { \
529     if (var->data) free(var->data); \
530     pvar = var->next; free(var); var = pvar; \
531   }
532
533   DFREE(event,p_event,pending)
534   DFREE(event,p_event,current)
535   DFREE(sys,p_sys,sys)
536
537 #undef DFREE
538
539 #if 0
540   /* FIXME: this seems to crash */
541   if (lpDosTask->dpmi_sel)
542     SELECTOR_FreeBlock(lpDosTask->dpmi_sel, 1);
543 #endif
544 }
545
546 LPDOSTASK MZ_Current( void )
547 {
548   TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
549   NE_MODULE *pModule = pTask ? NE_GetPtr( pTask->hModule ) : NULL;
550
551   GlobalUnlock16( GetCurrentTask() );
552
553   if (pModule)
554     return pModule->lpDosTask;
555
556   return NULL;
557 }
558
559 #else /* !MZ_SUPPORTED */
560
561 BOOL MZ_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmdline, LPCSTR env,
562                        LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
563                        BOOL inherit, DWORD flags, LPSTARTUPINFOA startup,
564                        LPPROCESS_INFORMATION info )
565 {
566  WARN("DOS executables not supported on this architecture\n");
567  SetLastError(ERROR_BAD_FORMAT);
568  return FALSE;
569 }
570
571 LPDOSTASK MZ_Current( void )
572 {
573   return NULL;
574 }
575
576 #endif