2 * DOS interrupt 21h handler
4 * Copyright 1993, 1994 Erik Bos
5 * Copyright 1996 Alexandre Julliard
6 * Copyright 1997 Andreas Mohr
7 * Copyright 1998 Uwe Bonnes
8 * Copyright 1998, 1999 Ove Kaaven
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/port.h"
32 #ifdef HAVE_SYS_FILE_H
33 # include <sys/file.h>
36 #ifdef HAVE_SYS_TIME_H
37 # include <sys/time.h>
39 #include <sys/types.h>
51 #include "winuser.h" /* SW_NORMAL */
52 #include "wine/winbase16.h"
60 #include "wine/unicode.h"
61 #include "wine/debug.h"
63 WINE_DEFAULT_DEBUG_CHANNEL(int21
);
64 #if defined(__svr4__) || defined(_SCO_DS)
65 /* SVR4 DOESNT do locking the same way must implement properly */
72 #define DOS_GET_DRIVE(reg) ((reg) ? (reg) - 1 : DRIVE_GetCurrentDrive())
74 /* Define the drive parameter block, as used by int21/1F
75 * and int21/32. This table can be accessed through the
76 * global 'dpb' pointer, which points into the local dos
81 BYTE drive_num
; /* 0=A, etc. */
82 BYTE unit_num
; /* Drive's unit number (?) */
83 WORD sector_size
; /* Sector size in bytes */
84 BYTE high_sector
; /* Highest sector in a cluster */
85 BYTE shift
; /* Shift count (?) */
86 WORD reserved
; /* Number of reserved sectors at start */
87 BYTE num_FAT
; /* Number of FATs */
88 WORD dir_entries
; /* Number of root dir entries */
89 WORD first_data
; /* First data sector */
90 WORD high_cluster
; /* Highest cluster number */
91 WORD sectors_in_FAT
; /* Number of sectors per FAT */
92 WORD start_dir
; /* Starting sector of first dir */
93 DWORD driver_head
; /* Address of device driver header (?) */
94 BYTE media_ID
; /* Media ID */
95 BYTE access_flag
; /* Prev. accessed flag (0=yes,0xFF=no) */
96 DWORD next
; /* Pointer to next DPB in list */
97 WORD free_search
; /* Free cluster search start */
98 WORD free_clusters
; /* Number of free clusters (0xFFFF=unknown) */
101 struct EDPB
/* FAT32 extended Drive Parameter Block */
102 { /* from Ralf Brown's Interrupt List */
103 struct DPB dpb
; /* first 24 bytes = original DPB */
105 BYTE edpb_flags
; /* undocumented/unknown flags */
106 DWORD next_edpb
; /* pointer to next EDPB */
107 WORD free_cluster
; /* cluster to start search for free space on write, typically
108 the last cluster allocated */
109 WORD clusters_free
; /* number of free clusters on drive or FFFF = unknown */
110 WORD clusters_free_hi
; /* hiword of clusters_free */
111 WORD mirroring_flags
; /* mirroring flags: bit 7 set = do not mirror active FAT */
112 /* bits 0-3 = 0-based number of the active FAT */
113 WORD info_sector
; /* sector number of file system info sector, or FFFF for none */
114 WORD spare_boot_sector
; /* sector number of backup boot sector, or FFFF for none */
115 DWORD first_cluster
; /* sector number of the first cluster */
116 DWORD max_cluster
; /* sector number of the last cluster */
117 DWORD fat_clusters
; /* number of clusters occupied by FAT */
118 DWORD root_cluster
; /* cluster number of start of root directory */
119 DWORD free_cluster2
; /* same as free_cluster: cluster at which to start
120 search for free space when writing */
131 static struct DosHeap
*heap
;
132 static WORD DosHeapHandle
;
134 extern char TempDirectory
[];
136 static BOOL
INT21_CreateHeap(void)
138 if (!(DosHeapHandle
= GlobalAlloc16(GMEM_FIXED
,sizeof(struct DosHeap
))))
140 WARN("Out of memory\n");
143 heap
= (struct DosHeap
*) GlobalLock16(DosHeapHandle
);
144 dpbsegptr
= MAKESEGPTR(DosHeapHandle
,(int)&heap
->dpb
-(int)heap
);
145 strcpy(heap
->biosdate
, "01/01/80");
149 static BYTE
*GetCurrentDTA( CONTEXT86
*context
)
151 TDB
*pTask
= TASK_GetCurrent();
153 /* FIXME: This assumes DTA was set correctly! */
154 return (BYTE
*)CTX_SEG_OFF_TO_LIN( context
, SELECTOROF(pTask
->dta
),
155 (DWORD
)OFFSETOF(pTask
->dta
) );
159 void CreateBPB(int drive
, BYTE
*data
, BOOL16 limited
)
160 /* limited == TRUE is used with INT 0x21/0x440d */
165 setword(&data
[3], 0);
167 setword(&data
[6], 240);
168 setword(&data
[8], 64000);
170 setword(&data
[0x0b], 40);
171 setword(&data
[0x0d], 56);
172 setword(&data
[0x0f], 2);
173 setword(&data
[0x11], 0);
175 setword(&data
[0x1f], 800);
177 setword(&data
[0x22], 1);
179 } else { /* 1.44mb */
182 setword(&data
[3], 0);
184 setword(&data
[6], 240);
185 setword(&data
[8], 2880);
187 setword(&data
[0x0b], 6);
188 setword(&data
[0x0d], 18);
189 setword(&data
[0x0f], 2);
190 setword(&data
[0x11], 0);
192 setword(&data
[0x1f], 80);
194 setword(&data
[0x22], 2);
199 static int INT21_GetFreeDiskSpace( CONTEXT86
*context
)
201 DWORD cluster_sectors
, sector_bytes
, free_clusters
, total_clusters
;
202 char root
[] = "A:\\";
204 *root
+= DOS_GET_DRIVE( DL_reg(context
) );
205 if (!GetDiskFreeSpaceA( root
, &cluster_sectors
, §or_bytes
,
206 &free_clusters
, &total_clusters
)) return 0;
207 SET_AX( context
, cluster_sectors
);
208 SET_BX( context
, free_clusters
);
209 SET_CX( context
, sector_bytes
);
210 SET_DX( context
, total_clusters
);
214 static int INT21_GetDriveAllocInfo( CONTEXT86
*context
)
216 if (!INT21_GetFreeDiskSpace( context
)) return 0;
217 if (!heap
&& !INT21_CreateHeap()) return 0;
218 heap
->mediaID
= 0xf0;
219 context
->SegDs
= DosHeapHandle
;
220 SET_BX( context
, (int)&heap
->mediaID
- (int)heap
);
224 static int FillInDrivePB( int drive
)
226 if(!DRIVE_IsValid(drive
))
228 SetLastError( ERROR_INVALID_DRIVE
);
231 else if (heap
|| INT21_CreateHeap())
233 /* FIXME: I have no idea what a lot of this information should
234 * say or whether it even really matters since we're not allowing
235 * direct block access. However, some programs seem to depend on
236 * getting at least _something_ back from here. The 'next' pointer
237 * does worry me, though. Should we have a complete table of
238 * separate DPBs per drive? Probably, but I'm lazy. :-) -CH
240 heap
->dpb
.drive_num
= heap
->dpb
.unit_num
= drive
; /*The same?*/
241 heap
->dpb
.sector_size
= 512;
242 heap
->dpb
.high_sector
= 1;
243 heap
->dpb
.shift
= drive
< 2 ? 0 : 6; /*6 for HD, 0 for floppy*/
244 heap
->dpb
.reserved
= 0;
245 heap
->dpb
.num_FAT
= 1;
246 heap
->dpb
.dir_entries
= 2;
247 heap
->dpb
.first_data
= 2;
248 heap
->dpb
.high_cluster
= 64000;
249 heap
->dpb
.sectors_in_FAT
= 1;
250 heap
->dpb
.start_dir
= 1;
251 heap
->dpb
.driver_head
= 0;
252 heap
->dpb
.media_ID
= (drive
> 1) ? 0xF8 : 0xF0;
253 heap
->dpb
.access_flag
= 0;
255 heap
->dpb
.free_search
= 0;
256 heap
->dpb
.free_clusters
= 0xFFFF; /* unknown */
263 static void GetDrivePB( CONTEXT86
*context
, int drive
)
265 if (FillInDrivePB( drive
))
267 SET_AL( context
, 0x00 );
268 context
->SegDs
= SELECTOROF(dpbsegptr
);
269 SET_BX( context
, OFFSETOF(dpbsegptr
) );
273 SET_AX( context
, 0x00ff );
278 static void ioctlGetDeviceInfo( CONTEXT86
*context
)
281 const DOS_DEVICE
*dev
;
283 TRACE("(%d)\n", BX_reg(context
));
285 RESET_CFLAG(context
);
288 if ((dev
= DOSFS_GetDeviceByHandle( DosFileHandleToWin32Handle(BX_reg(context
)) )))
290 SET_DX( context
, dev
->flags
);
294 /* it seems to be a file */
295 curr_drive
= DRIVE_GetCurrentDrive();
296 SET_DX( context
, 0x0140 + curr_drive
+ ((curr_drive
> 1) ? 0x0800 : 0) );
298 /* bits 0-5 are current drive
299 * bit 6 - file has NOT been written..FIXME: correct?
300 * bit 8 - generate int24 if no diskspace on write/ read past end of file
301 * bit 11 - media not removable
302 * bit 14 - don't set file date/time on closing
303 * bit 15 - file is remote
307 static BOOL
ioctlGenericBlkDevReq( CONTEXT86
*context
)
309 BYTE
*dataptr
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
310 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
312 if (!DRIVE_IsValid(drive
))
314 SetLastError( ERROR_FILE_NOT_FOUND
);
318 if (CH_reg(context
) != 0x08)
320 INT_BARF( context
, 0x21 );
324 switch (CL_reg(context
))
326 case 0x4a: /* lock logical volume */
327 TRACE("lock logical volume (%d) level %d mode %d\n",drive
,BH_reg(context
),DX_reg(context
));
330 case 0x60: /* get device parameters */
331 /* used by w4wgrp's winfile */
332 memset(dataptr
, 0, 0x20); /* DOS 6.22 uses 0x20 bytes */
334 dataptr
[6] = 0; /* media type */
337 dataptr
[1] = 0x05; /* fixed disk */
338 setword(&dataptr
[2], 0x01); /* non removable */
339 setword(&dataptr
[4], 0x300); /* # of cylinders */
343 dataptr
[1] = 0x07; /* block dev, floppy */
344 setword(&dataptr
[2], 0x02); /* removable */
345 setword(&dataptr
[4], 80); /* # of cylinders */
347 CreateBPB(drive
, &dataptr
[7], TRUE
);
348 RESET_CFLAG(context
);
351 case 0x41: /* write logical device track */
352 case 0x61: /* read logical device track */
354 BYTE drive
= BL_reg(context
) ?
355 BL_reg(context
) : DRIVE_GetCurrentDrive();
356 WORD head
= *(WORD
*)dataptr
+1;
357 WORD cyl
= *(WORD
*)dataptr
+3;
358 WORD sect
= *(WORD
*)dataptr
+5;
359 WORD nrsect
= *(WORD
*)dataptr
+7;
360 BYTE
*data
= (BYTE
*)dataptr
+9;
361 int (*raw_func
)(BYTE
, DWORD
, DWORD
, BYTE
*, BOOL
);
363 raw_func
= (CL_reg(context
) == 0x41) ?
364 DRIVE_RawWrite
: DRIVE_RawRead
;
366 if (raw_func(drive
, head
*cyl
*sect
, nrsect
, data
, FALSE
))
367 RESET_CFLAG(context
);
370 SET_AX( context
, 0x1e ); /* read fault */
375 case 0x66:/* get disk serial number */
377 char label
[12],fsname
[9],path
[4];
380 strcpy(path
,"x:\\");path
[0]=drive
+'A';
381 GetVolumeInformationA(
382 path
,label
,12,&serial
,NULL
,NULL
,fsname
,9
385 memcpy(dataptr
+2,&serial
,4);
386 memcpy(dataptr
+6,label
,11);
387 memcpy(dataptr
+17,fsname
,8);
392 TRACE("logical volume %d unlocked.\n",drive
);
396 memset(dataptr
+1, '\0', dataptr
[0]-1);
397 dataptr
[1] = dataptr
[0];
398 dataptr
[2] = 0x07; /* protected mode driver; no eject; no notification */
399 dataptr
[3] = 0xFF; /* no physical drive */
403 /* Trail on error implementation */
404 SET_AX( context
, GetDriveType16(BL_reg(context
)) == DRIVE_UNKNOWN
? 0x0f : 0x01 );
405 SET_CFLAG(context
); /* Seems to be set all the time */
409 INT_BARF( context
, 0x21 );
414 static void INT21_ParseFileNameIntoFCB( CONTEXT86
*context
)
417 CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Esi
);
419 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Edi
);
425 SET_AL( context
, 0xff ); /* failed */
427 TRACE("filename: '%s'\n", filename
);
433 if ((*s
!= ' ') && (*s
!= '\r') && (*s
!= '\n'))
442 buffer_len
= MultiByteToWideChar(CP_OEMCP
, 0, filename
, len
, NULL
, 0);
443 buffer
= HeapAlloc( GetProcessHeap(), 0, (buffer_len
+ 1) * sizeof(WCHAR
));
444 len
= MultiByteToWideChar(CP_OEMCP
, 0, filename
, len
, buffer
, buffer_len
);
446 DOSFS_ToDosFCBFormat(buffer
, fcbW
);
447 HeapFree(GetProcessHeap(), 0, buffer
);
448 WideCharToMultiByte(CP_OEMCP
, 0, fcbW
, 12, fcb
+ 1, 12, NULL
, NULL
);
450 TRACE("FCB: '%s'\n", fcb
+ 1);
452 SET_AL( context
, ((strchr(filename
, '*')) || (strchr(filename
, '$'))) != 0 );
454 /* point DS:SI to first unparsed character */
455 SET_SI( context
, context
->Esi
+ (int)s
- (int)filename
);
459 /* Many calls translate a drive argument like this:
460 drive number (00h = default, 01h = A:, etc)
462 static char drivestring
[]="default";
464 char *INT21_DriveName(int drive
)
469 drivestring
[0]= (unsigned char)drive
+ '@';
475 static BOOL
INT21_CreateFile( CONTEXT86
*context
)
477 SET_AX( context
, _lcreat16( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,
478 context
->Edx
), CX_reg(context
) ) );
479 return (AX_reg(context
) == (WORD
)HFILE_ERROR16
);
482 static HFILE16
_lcreat16_uniq( LPCSTR path
, INT attr
)
484 /* Mask off all flags not explicitly allowed by the doc */
485 attr
&= FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
| FILE_ATTRIBUTE_SYSTEM
;
486 return Win32HandleToDosFileHandle( CreateFileA( path
, GENERIC_READ
| GENERIC_WRITE
,
487 FILE_SHARE_READ
| FILE_SHARE_WRITE
, NULL
,
488 CREATE_NEW
, attr
, 0 ));
491 static void OpenExistingFile( CONTEXT86
*context
)
493 SET_AX( context
, _lopen16( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
),
495 if (AX_reg(context
) == (WORD
)HFILE_ERROR16
)
497 SET_AX( context
, GetLastError() );
502 static BOOL
INT21_ExtendedOpenCreateFile(CONTEXT86
*context
)
504 BOOL bExtendedError
= FALSE
;
505 BYTE action
= DL_reg(context
);
507 /* Shuffle arguments to call OpenExistingFile */
508 SET_AL( context
, BL_reg(context
) );
509 SET_DX( context
, SI_reg(context
) );
510 /* BX,CX and DX should be preserved */
511 OpenExistingFile(context
);
513 if ((context
->EFlags
& 0x0001) == 0) /* File exists */
515 UINT16 uReturnCX
= 0;
517 /* Now decide what do do */
519 if ((action
& 0x07) == 0)
521 _lclose16( AX_reg(context
) );
522 SET_AX( context
, 0x0050 ); /*File exists*/
524 WARN("extended open/create: failed because file exists \n");
526 else if ((action
& 0x07) == 2)
528 /* Truncate it, but first check if opened for write */
529 if ((BL_reg(context
) & 0x0007)== 0)
531 _lclose16( AX_reg(context
) );
532 WARN("extended open/create: failed, trunc on ro file\n");
533 SET_AX( context
, 0x000C ); /*Access code invalid*/
538 TRACE("extended open/create: Closing before truncate\n");
539 if (_lclose16( AX_reg(context
) ))
541 WARN("extended open/create: close before trunc failed\n");
542 SET_AX( context
, 0x0019 ); /*Seek Error*/
543 SET_CX( context
, 0 );
546 /* Shuffle arguments to call CreateFile */
548 TRACE("extended open/create: Truncating\n");
549 SET_AL( context
, BL_reg(context
) );
550 /* CX is still the same */
551 SET_DX( context
, SI_reg(context
) );
552 bExtendedError
= INT21_CreateFile(context
);
554 if (context
->EFlags
& 0x0001) /*no file open, flags set */
556 WARN("extended open/create: trunc failed\n");
557 return bExtendedError
;
562 else uReturnCX
= 0x1;
564 SET_CX( context
, uReturnCX
);
566 else /* file does not exist */
568 RESET_CFLAG(context
); /* was set by OpenExistingFile(context) */
569 if ((action
& 0xF0)== 0)
571 SET_CX( context
, 0 );
573 WARN("extended open/create: failed, file dosen't exist\n");
577 /* Shuffle arguments to call CreateFile */
578 TRACE("extended open/create: Creating\n");
579 SET_AL( context
, BL_reg(context
) );
580 /* CX should still be the same */
581 SET_DX( context
, SI_reg(context
) );
582 bExtendedError
= INT21_CreateFile(context
);
583 if (context
->EFlags
& 0x0001) /*no file open, flags set */
585 WARN("extended open/create: create failed\n");
586 return bExtendedError
;
588 SET_CX( context
, 2 );
592 return bExtendedError
;
596 static BOOL
INT21_ChangeDir( CONTEXT86
*context
)
599 char *dirname
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
);
600 WCHAR dirnameW
[MAX_PATH
];
602 TRACE("changedir %s\n", dirname
);
603 if (dirname
[0] && (dirname
[1] == ':'))
605 drive
= toupper(dirname
[0]) - 'A';
608 else drive
= DRIVE_GetCurrentDrive();
609 MultiByteToWideChar(CP_OEMCP
, 0, dirname
, -1, dirnameW
, MAX_PATH
);
610 return DRIVE_Chdir( drive
, dirnameW
);
614 static int INT21_FindFirst( CONTEXT86
*context
)
618 DOS_FULL_NAME full_name
;
619 FINDFILE_DTA
*dta
= (FINDFILE_DTA
*)GetCurrentDTA(context
);
620 WCHAR pathW
[MAX_PATH
];
623 path
= (const char *)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
624 MultiByteToWideChar(CP_OEMCP
, 0, path
, -1, pathW
, MAX_PATH
);
626 dta
->unixPath
= NULL
;
627 if (!DOSFS_GetFullName( pathW
, FALSE
, &full_name
))
629 SET_AX( context
, GetLastError() );
633 dta
->unixPath
= HeapAlloc( GetProcessHeap(), 0, strlen(full_name
.long_name
)+1 );
634 strcpy( dta
->unixPath
, full_name
.long_name
);
635 p
= strrchr( dta
->unixPath
, '/' );
638 MultiByteToWideChar(CP_OEMCP
, 0, p
+ 1, -1, pathW
, MAX_PATH
);
640 /* Note: terminating NULL in dta->mask overwrites dta->search_attr
641 * (doesn't matter as it is set below anyway)
643 if (!DOSFS_ToDosFCBFormat( pathW
, maskW
))
645 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
646 dta
->unixPath
= NULL
;
647 SetLastError( ERROR_FILE_NOT_FOUND
);
648 SET_AX( context
, ERROR_FILE_NOT_FOUND
);
652 WideCharToMultiByte(CP_OEMCP
, 0, maskW
, 12, dta
->mask
, sizeof(dta
->mask
), NULL
, NULL
);
653 dta
->drive
= (path
[0] && (path
[1] == ':')) ? toupper(path
[0]) - 'A'
654 : DRIVE_GetCurrentDrive();
656 dta
->search_attr
= CL_reg(context
);
661 static int INT21_FindNext( CONTEXT86
*context
)
663 FINDFILE_DTA
*dta
= (FINDFILE_DTA
*)GetCurrentDTA(context
);
664 WIN32_FIND_DATAA entry
;
667 if (!dta
->unixPath
) return 0;
668 if (!(count
= DOSFS_FindNext( dta
->unixPath
, dta
->mask
, NULL
, dta
->drive
,
669 dta
->search_attr
, dta
->count
, &entry
)))
671 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
672 dta
->unixPath
= NULL
;
675 if ((int)dta
->count
+ count
> 0xffff)
677 WARN("Too many directory entries in %s\n", dta
->unixPath
);
678 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
679 dta
->unixPath
= NULL
;
683 dta
->fileattr
= entry
.dwFileAttributes
;
684 dta
->filesize
= entry
.nFileSizeLow
;
685 FileTimeToDosDateTime( &entry
.ftLastWriteTime
,
686 &dta
->filedate
, &dta
->filetime
);
687 strcpy( dta
->filename
, entry
.cAlternateFileName
);
688 if (!memchr(dta
->mask
,'?',11)) {
689 /* wildcardless search, release resources in case no findnext will
690 * be issued, and as a workaround in case file creation messes up
691 * findnext, as sometimes happens with pkunzip */
692 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
693 dta
->unixPath
= NULL
;
699 static BOOL
INT21_CreateTempFile( CONTEXT86
*context
)
701 static int counter
= 0;
702 char *name
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
703 char *p
= name
+ strlen(name
);
705 /* despite what Ralf Brown says, some programs seem to call without
706 * ending backslash (DOS accepts that, so we accept it too) */
707 if ((p
== name
) || (p
[-1] != '\\')) *p
++ = '\\';
711 sprintf( p
, "wine%04x.%03d", (int)getpid(), counter
);
712 counter
= (counter
+ 1) % 1000;
714 SET_AX( context
, _lcreat16_uniq( name
, 0 ) );
715 if (AX_reg(context
) != HFILE_ERROR16
)
717 TRACE("created %s\n", name
);
720 if (GetLastError() != ERROR_FILE_EXISTS
) return FALSE
;
725 static BOOL
INT21_GetCurrentDirectory( CONTEXT86
*context
)
727 int drive
= DOS_GET_DRIVE( DL_reg(context
) );
728 char *ptr
= (char *)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Esi
);
730 if (!DRIVE_IsValid(drive
))
732 SetLastError( ERROR_INVALID_DRIVE
);
735 WideCharToMultiByte(CP_OEMCP
, 0, DRIVE_GetDosCwd(drive
), -1, ptr
, 64, NULL
, NULL
);
736 ptr
[63] = 0; /* ensure 0 termination */
737 SET_AX( context
, 0x0100 ); /* success return code */
742 static int INT21_GetDiskSerialNumber( CONTEXT86
*context
)
744 BYTE
*dataptr
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
745 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
747 if (!DRIVE_IsValid(drive
))
749 SetLastError( ERROR_INVALID_DRIVE
);
753 *(WORD
*)dataptr
= 0;
754 *(DWORD
*)(dataptr
+ 2) = DRIVE_GetSerialNumber( drive
);
755 memcpy( dataptr
+ 6, DRIVE_GetLabel( drive
), 11 );
756 strncpy(dataptr
+ 0x11, "FAT16 ", 8);
761 static int INT21_SetDiskSerialNumber( CONTEXT86
*context
)
763 BYTE
*dataptr
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
764 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
766 if (!DRIVE_IsValid(drive
))
768 SetLastError( ERROR_INVALID_DRIVE
);
772 DRIVE_SetSerialNumber( drive
, *(DWORD
*)(dataptr
+ 2) );
777 /* microsoft's programmers should be shot for using CP/M style int21
778 calls in Windows for Workgroup's winfile.exe */
780 static int INT21_FindFirstFCB( CONTEXT86
*context
)
782 BYTE
*fcb
= (BYTE
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
787 if (*fcb
== 0xff) pFCB
= (FINDFILE_FCB
*)(fcb
+ 7);
788 else pFCB
= (FINDFILE_FCB
*)fcb
;
789 drive
= DOS_GET_DRIVE( pFCB
->drive
);
790 if (!DRIVE_IsValid( drive
)) return 0;
791 root
= DRIVE_GetRoot( drive
);
792 cwd
= DRIVE_GetUnixCwd( drive
);
793 pFCB
->unixPath
= HeapAlloc( GetProcessHeap(), 0,
794 strlen(root
)+strlen(cwd
)+2 );
795 if (!pFCB
->unixPath
) return 0;
796 strcpy( pFCB
->unixPath
, root
);
797 strcat( pFCB
->unixPath
, "/" );
798 strcat( pFCB
->unixPath
, cwd
);
804 static int INT21_FindNextFCB( CONTEXT86
*context
)
806 BYTE
*fcb
= (BYTE
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
808 DOS_DIRENTRY_LAYOUT
*pResult
= (DOS_DIRENTRY_LAYOUT
*)GetCurrentDTA(context
);
809 WIN32_FIND_DATAA entry
;
813 if (*fcb
== 0xff) /* extended FCB ? */
816 pFCB
= (FINDFILE_FCB
*)(fcb
+ 7);
821 pFCB
= (FINDFILE_FCB
*)fcb
;
824 if (!pFCB
->unixPath
) return 0;
825 if (!(count
= DOSFS_FindNext( pFCB
->unixPath
, pFCB
->filename
, NULL
,
826 DOS_GET_DRIVE( pFCB
->drive
), attr
,
827 pFCB
->count
, &entry
)))
829 HeapFree( GetProcessHeap(), 0, pFCB
->unixPath
);
830 pFCB
->unixPath
= NULL
;
833 pFCB
->count
+= count
;
835 if (*fcb
== 0xff) { /* place extended FCB header before pResult if called with extended FCB */
836 *(BYTE
*)pResult
= 0xff;
837 (BYTE
*)pResult
+=6; /* leave reserved field behind */
838 *(BYTE
*)pResult
= entry
.dwFileAttributes
;
841 *(BYTE
*)pResult
= DOS_GET_DRIVE( pFCB
->drive
); /* DOS_DIRENTRY_LAYOUT after current drive number */
843 pResult
->fileattr
= entry
.dwFileAttributes
;
844 pResult
->cluster
= 0; /* what else? */
845 pResult
->filesize
= entry
.nFileSizeLow
;
846 memset( pResult
->reserved
, 0, sizeof(pResult
->reserved
) );
847 FileTimeToDosDateTime( &entry
.ftLastWriteTime
,
848 &pResult
->filedate
, &pResult
->filetime
);
850 /* Convert file name to FCB format */
852 memset( pResult
->filename
, ' ', sizeof(pResult
->filename
) );
853 if (!strcmp( entry
.cAlternateFileName
, "." )) pResult
->filename
[0] = '.';
854 else if (!strcmp( entry
.cAlternateFileName
, ".." ))
855 pResult
->filename
[0] = pResult
->filename
[1] = '.';
858 char *p
= strrchr( entry
.cAlternateFileName
, '.' );
859 if (p
&& p
[1] && (p
!= entry
.cAlternateFileName
))
861 memcpy( pResult
->filename
, entry
.cAlternateFileName
,
862 min( (p
- entry
.cAlternateFileName
), 8 ) );
863 memcpy( pResult
->filename
+ 8, p
+ 1, min( strlen(p
), 3 ) );
866 memcpy( pResult
->filename
, entry
.cAlternateFileName
,
867 min( strlen(entry
.cAlternateFileName
), 8 ) );
874 INT21_networkfunc (CONTEXT86
*context
)
876 switch (AL_reg(context
)) {
877 case 0x00: /* Get machine name. */
879 char *dst
= CTX_SEG_OFF_TO_LIN (context
,context
->SegDs
,context
->Edx
);
880 TRACE("getting machine name to %p\n", dst
);
881 if (gethostname (dst
, 15))
884 SetLastError( ER_NoNetwork
);
887 int len
= strlen (dst
);
891 SET_CH( context
, 1 ); /* Valid */
892 SET_CL( context
, 1 ); /* NETbios number??? */
893 TRACE("returning %s\n", debugstr_an (dst
, 16));
899 SetLastError( ER_NoNetwork
);
905 /***********************************************************************
908 void WINAPI
INT_Int21Handler( CONTEXT86
*context
)
910 BOOL bSetDOSExtendedError
= FALSE
;
912 switch(AH_reg(context
))
914 case 0x0e: /* SELECT DEFAULT DRIVE */
915 TRACE("SELECT DEFAULT DRIVE %d\n", DL_reg(context
));
916 DRIVE_SetCurrentDrive( DL_reg(context
) );
917 SET_AL( context
, MAX_DOS_DRIVES
);
920 case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
921 TRACE("FIND FIRST MATCHING FILE USING FCB %p\n",
922 CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
923 if (!INT21_FindFirstFCB(context
))
925 SET_AL( context
, 0xff );
928 /* else fall through */
930 case 0x12: /* FIND NEXT MATCHING FILE USING FCB */
931 SET_AL( context
, INT21_FindNextFCB(context
) ? 0x00 : 0xff );
934 case 0x19: /* GET CURRENT DEFAULT DRIVE */
935 SET_AL( context
, DRIVE_GetCurrentDrive() );
938 case 0x1b: /* GET ALLOCATION INFORMATION FOR DEFAULT DRIVE */
939 SET_DL( context
, 0 );
940 if (!INT21_GetDriveAllocInfo(context
)) SET_AX( context
, 0xffff );
943 case 0x1c: /* GET ALLOCATION INFORMATION FOR SPECIFIC DRIVE */
944 if (!INT21_GetDriveAllocInfo(context
)) SET_AX( context
, 0xffff );
947 case 0x1f: /* GET DRIVE PARAMETER BLOCK FOR DEFAULT DRIVE */
948 GetDrivePB(context
, DRIVE_GetCurrentDrive());
951 case 0x29: /* PARSE FILENAME INTO FCB */
952 INT21_ParseFileNameIntoFCB(context
);
955 case 0x32: /* GET DOS DRIVE PARAMETER BLOCK FOR SPECIFIC DRIVE */
956 TRACE("GET DOS DRIVE PARAMETER BLOCK FOR DRIVE %s\n",
957 INT21_DriveName( DL_reg(context
)));
958 GetDrivePB(context
, DOS_GET_DRIVE( DL_reg(context
) ) );
961 case 0x36: /* GET FREE DISK SPACE */
962 TRACE("GET FREE DISK SPACE FOR DRIVE %s\n",
963 INT21_DriveName( DL_reg(context
)));
964 if (!INT21_GetFreeDiskSpace(context
)) SET_AX( context
, 0xffff );
967 case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */
969 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
970 bSetDOSExtendedError
= !INT21_ChangeDir(context
);
973 case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
974 TRACE("CREAT flag 0x%02x %s\n",CX_reg(context
),
975 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
976 bSetDOSExtendedError
= INT21_CreateFile( context
);
979 case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
980 TRACE("OPEN mode 0x%02x %s\n",AL_reg(context
),
981 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
982 OpenExistingFile(context
);
985 case 0x44: /* IOCTL */
986 switch (AL_reg(context
))
989 ioctlGetDeviceInfo(context
);
995 case 0x05:{ /* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */
996 /*BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);*/
997 int drive
= DOS_GET_DRIVE(BL_reg(context
));
999 FIXME("program tried to write to block device control channel of drive %d:\n",drive
);
1000 /* for (i=0;i<CX_reg(context);i++)
1001 fprintf(stdnimp,"%02x ",dataptr[i]);
1002 fprintf(stdnimp,"\n");*/
1003 SET_AX( context
, context
->Ecx
);
1006 case 0x08: /* Check if drive is removable. */
1007 TRACE("IOCTL - CHECK IF BLOCK DEVICE REMOVABLE for drive %s\n",
1008 INT21_DriveName( BL_reg(context
)));
1009 switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context
) )))
1012 SetLastError( ERROR_INVALID_DRIVE
);
1013 SET_AX( context
, ERROR_INVALID_DRIVE
);
1016 case DRIVE_REMOVABLE
:
1017 SET_AX( context
, 0 ); /* removable */
1020 SET_AX( context
, 1 ); /* not removable */
1025 case 0x09: /* CHECK IF BLOCK DEVICE REMOTE */
1026 TRACE("IOCTL - CHECK IF BLOCK DEVICE REMOTE for drive %s\n",
1027 INT21_DriveName( BL_reg(context
)));
1028 switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context
) )))
1031 SetLastError( ERROR_INVALID_DRIVE
);
1032 SET_AX( context
, ERROR_INVALID_DRIVE
);
1036 SET_DX( context
, (1<<9) | (1<<12) ); /* remote */
1039 SET_DX( context
, 0 ); /* FIXME: use driver attr here */
1044 case 0x0a: /* check if handle (BX) is remote */
1045 TRACE("IOCTL - CHECK IF HANDLE %d IS REMOTE\n",BX_reg(context
));
1046 /* returns DX, bit 15 set if remote, bit 14 set if date/time
1049 SET_DX( context
, 0 );
1053 TRACE("IOCTL - GENERIC BLOCK DEVICE REQUEST %s\n",
1054 INT21_DriveName( BL_reg(context
)));
1055 bSetDOSExtendedError
= ioctlGenericBlkDevReq(context
);
1058 case 0x0e: /* get logical drive mapping */
1059 TRACE("IOCTL - GET LOGICAL DRIVE MAP for drive %s\n",
1060 INT21_DriveName( BL_reg(context
)));
1061 SET_AL( context
, 0 ); /* drive has no mapping - FIXME: may be wrong*/
1064 case 0x0F: /* Set logical drive mapping */
1067 TRACE("IOCTL - SET LOGICAL DRIVE MAP for drive %s\n",
1068 INT21_DriveName( BL_reg(context
)));
1069 drive
= DOS_GET_DRIVE ( BL_reg(context
) );
1070 if ( ! DRIVE_SetLogicalMapping ( drive
, drive
+1 ) )
1073 SET_AX( context
, 0x000F ); /* invalid drive */
1079 INT_BARF( context
, 0x21 );
1084 case 0x47: /* "CWD" - GET CURRENT DIRECTORY */
1085 TRACE("CWD - GET CURRENT DIRECTORY for drive %s\n",
1086 INT21_DriveName( DL_reg(context
)));
1087 bSetDOSExtendedError
= !INT21_GetCurrentDirectory(context
);
1090 case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
1091 TRACE("FINDFIRST mask 0x%04x spec %s\n",CX_reg(context
),
1092 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
1093 if (!INT21_FindFirst(context
)) break;
1096 case 0x4f: /* "FINDNEXT" - FIND NEXT MATCHING FILE */
1097 TRACE("FINDNEXT\n");
1098 if (!INT21_FindNext(context
))
1100 SetLastError( ERROR_NO_MORE_FILES
);
1101 SET_AX( context
, ERROR_NO_MORE_FILES
);
1104 else SET_AX( context
, 0 ); /* OK */
1107 case 0x5a: /* CREATE TEMPORARY FILE */
1108 TRACE("CREATE TEMPORARY FILE\n");
1109 bSetDOSExtendedError
= !INT21_CreateTempFile(context
);
1112 case 0x5b: /* CREATE NEW FILE */
1113 TRACE("CREATE NEW FILE 0x%02x for %s\n", CX_reg(context
),
1114 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
1116 _lcreat16_uniq( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
),
1118 bSetDOSExtendedError
= (AX_reg(context
) != 0);
1122 bSetDOSExtendedError
= INT21_networkfunc (context
);
1125 case 0x5f: /* NETWORK */
1126 switch (AL_reg(context
))
1128 case 0x07: /* ENABLE DRIVE */
1129 TRACE("ENABLE DRIVE %c:\n",(DL_reg(context
)+'A'));
1130 if (!DRIVE_Enable( DL_reg(context
) ))
1132 SetLastError( ERROR_INVALID_DRIVE
);
1133 bSetDOSExtendedError
= TRUE
;
1137 case 0x08: /* DISABLE DRIVE */
1138 TRACE("DISABLE DRIVE %c:\n",(DL_reg(context
)+'A'));
1139 if (!DRIVE_Disable( DL_reg(context
) ))
1141 SetLastError( ERROR_INVALID_DRIVE
);
1142 bSetDOSExtendedError
= TRUE
;
1147 /* network software not installed */
1148 TRACE("NETWORK function AX=%04x not implemented\n",AX_reg(context
));
1149 SetLastError( ER_NoNetwork
);
1150 bSetDOSExtendedError
= TRUE
;
1155 case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
1156 TRACE("TRUENAME %s\n",
1157 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Esi
));
1159 if (!GetFullPathNameA( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,
1161 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
1162 context
->Edi
),NULL
))
1163 bSetDOSExtendedError
= TRUE
;
1164 else SET_AX( context
, 0 );
1168 case 0x69: /* DISK SERIAL NUMBER */
1169 switch (AL_reg(context
))
1172 TRACE("GET DISK SERIAL NUMBER for drive %s\n",
1173 INT21_DriveName(BL_reg(context
)));
1174 if (!INT21_GetDiskSerialNumber(context
)) bSetDOSExtendedError
= TRUE
;
1175 else SET_AX( context
, 0 );
1179 TRACE("SET DISK SERIAL NUMBER for drive %s\n",
1180 INT21_DriveName(BL_reg(context
)));
1181 if (!INT21_SetDiskSerialNumber(context
)) bSetDOSExtendedError
= TRUE
;
1182 else SET_AX( context
, 1 );
1187 case 0x6C: /* Extended Open/Create*/
1188 TRACE("EXTENDED OPEN/CREATE %s\n",
1189 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edi
));
1190 bSetDOSExtendedError
= INT21_ExtendedOpenCreateFile(context
);
1193 case 0x71: /* MS-DOS 7 (Windows95) - LONG FILENAME FUNCTIONS */
1194 switch(AL_reg(context
))
1196 case 0x47: /* Get current directory */
1197 TRACE(" LONG FILENAME - GET CURRENT DIRECTORY for drive %s\n",
1198 INT21_DriveName(DL_reg(context
)));
1199 bSetDOSExtendedError
= !INT21_GetCurrentDirectory(context
);
1202 case 0x4e: /* Find first file */
1203 TRACE(" LONG FILENAME - FIND FIRST MATCHING FILE for %s\n",
1204 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
));
1205 /* FIXME: use attributes in CX */
1206 SET_AX( context
, FindFirstFile16(
1207 CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
),
1208 (WIN32_FIND_DATAA
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
1210 if (AX_reg(context
) == INVALID_HANDLE_VALUE16
)
1211 bSetDOSExtendedError
= TRUE
;
1213 case 0x4f: /* Find next file */
1214 TRACE("LONG FILENAME - FIND NEXT MATCHING FILE for handle %d\n",
1216 if (!FindNextFile16( BX_reg(context
),
1217 (WIN32_FIND_DATAA
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
1219 bSetDOSExtendedError
= TRUE
;
1223 LPCSTR driveroot
= (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
);
1224 LPSTR buffer
= (LPSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,context
->Edi
);
1225 DWORD filename_len
, flags
;
1227 TRACE("LONG FILENAME - GET VOLUME INFORMATION for drive having root dir '%s'.\n", driveroot
);
1228 SET_AX( context
, 0 );
1229 if (!GetVolumeInformationA( driveroot
, NULL
, 0, NULL
, &filename_len
,
1230 &flags
, buffer
, 8 ))
1232 INT_BARF( context
, 0x21 );
1236 SET_BX( context
, flags
| 0x4000 ); /* support for LFN functions */
1237 SET_CX( context
, filename_len
);
1238 SET_DX( context
, MAX_PATH
); /* FIXME: which len if DRIVE_SHORT_NAMES ? */
1241 case 0xa1: /* Find close */
1242 TRACE("LONG FILENAME - FINDCLOSE for handle %d\n",
1244 bSetDOSExtendedError
= (!FindClose16( BX_reg(context
) ));
1247 switch(CL_reg(context
))
1249 case 0x01: /* Get short filename or path */
1250 if (!GetShortPathNameA
1251 ( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,
1253 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
1255 bSetDOSExtendedError
= TRUE
;
1256 else SET_AX( context
, 0 );
1258 case 0x02: /* Get canonical long filename or path */
1259 if (!GetFullPathNameA
1260 ( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,
1262 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
1263 context
->Edi
),NULL
))
1264 bSetDOSExtendedError
= TRUE
;
1265 else SET_AX( context
, 0 );
1268 FIXME("Unimplemented long file name function:\n");
1269 INT_BARF( context
, 0x21 );
1271 SET_AL( context
, 0 );
1275 case 0x6c: /* Create or open file */
1276 TRACE("LONG FILENAME - CREATE OR OPEN FILE %s\n",
1277 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Esi
));
1278 /* translate Dos 7 action to Dos 6 action */
1279 bSetDOSExtendedError
= INT21_ExtendedOpenCreateFile(context
);
1282 case 0x3b: /* Change directory */
1283 TRACE("LONG FILENAME - CHANGE DIRECTORY %s\n",
1284 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
1285 if (!SetCurrentDirectoryA(CTX_SEG_OFF_TO_LIN(context
,
1291 SET_AL( context
, GetLastError() );
1296 FIXME("Unimplemented long file name function:\n");
1297 INT_BARF( context
, 0x21 );
1299 SET_AL( context
, 0 );
1305 case 0x73: /* MULTIPLEXED: Win95 OSR2/Win98 FAT32 calls */
1306 TRACE("windows95 function AX %04x\n",
1309 switch (AL_reg(context
))
1311 case 0x02: /* Get Extended Drive Parameter Block for specific drive */
1312 /* ES:DI points to word with length of data (should be 0x3d) */
1316 DWORD cluster_sectors
, sector_bytes
, free_clusters
, total_clusters
;
1317 char root
[] = "A:\\";
1319 buffer
= (WORD
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Edi
);
1321 TRACE("Get Extended DPB: linear buffer address is %p\n", buffer
);
1323 /* validate passed-in buffer lengths */
1324 if ((*buffer
!= 0x3d) || (context
->Ecx
!= 0x3f))
1326 WARN("Get Extended DPB: buffer lengths incorrect\n");
1327 WARN("CX = %lx, buffer[0] = %x\n", context
->Ecx
, *buffer
);
1329 SET_AL( context
, 0x18 ); /* bad buffer length */
1332 /* buffer checks out */
1333 buffer
++; /* skip over length word now */
1334 if (FillInDrivePB( DX_reg(context
) ) )
1336 edpb
= (struct EDPB
*)buffer
;
1338 /* copy down the old-style DPB portion first */
1339 memcpy(&edpb
->dpb
, &heap
->dpb
, sizeof(struct DPB
));
1341 /* now fill in the extended entries */
1342 edpb
->edpb_flags
= 0;
1343 edpb
->next_edpb
= 0;
1344 edpb
->free_cluster
= edpb
->free_cluster2
= 0;
1346 /* determine free disk space */
1347 *root
+= DOS_GET_DRIVE( DX_reg(context
) );
1348 GetDiskFreeSpaceA( root
, &cluster_sectors
, §or_bytes
,
1349 &free_clusters
, &total_clusters
);
1351 edpb
->clusters_free
= (free_clusters
&0xffff);
1353 edpb
->clusters_free_hi
= free_clusters
>> 16;
1354 edpb
->mirroring_flags
= 0;
1355 edpb
->info_sector
= 0xffff;
1356 edpb
->spare_boot_sector
= 0xffff;
1357 edpb
->first_cluster
= 0;
1358 edpb
->max_cluster
= total_clusters
;
1359 edpb
->fat_clusters
= 32; /* made-up value */
1360 edpb
->root_cluster
= 0;
1362 RESET_CFLAG(context
); /* clear carry */
1363 SET_AX( context
, 0 );
1367 SET_AX( context
, 0x00ff );
1373 case 0x03: /* Get Extended free space on drive */
1374 case 0x04: /* Set DPB for formatting */
1375 case 0x05: /* extended absolute disk read/write */
1376 FIXME("Unimplemented FAT32 int32 function %04x\n", AX_reg(context
));
1378 SET_AL( context
, 0 );
1385 INT_BARF( context
, 0x21 );
1388 } /* END OF SWITCH */
1390 if( bSetDOSExtendedError
) /* set general error condition */
1392 SET_AX( context
, GetLastError() );