2 * DOS interrupt 21h handler
14 #include <sys/types.h>
29 #if defined(__svr4__) || defined(_SCO_DS)
30 /* SVR4 DOESNT do locking the same way must implement properly */
37 #define DOS_GET_DRIVE(reg) ((reg) ? (reg) - 1 : DRIVE_GetCurrentDrive())
39 /* Define the drive parameter block, as used by int21/1F
40 * and int21/32. This table can be accessed through the
41 * global 'dpb' pointer, which points into the local dos
46 BYTE drive_num; /* 0=A, etc. */
47 BYTE unit_num; /* Drive's unit number (?) */
48 WORD sector_size; /* Sector size in bytes */
49 BYTE high_sector; /* Highest sector in a cluster */
50 BYTE shift; /* Shift count (?) */
51 WORD reserved; /* Number of reserved sectors at start */
52 BYTE num_FAT; /* Number of FATs */
53 WORD dir_entries; /* Number of root dir entries */
54 WORD first_data; /* First data sector */
55 WORD high_cluster; /* Highest cluster number */
56 WORD sectors_in_FAT; /* Number of sectors per FAT */
57 WORD start_dir; /* Starting sector of first dir */
58 DWORD driver_head; /* Address of device driver header (?) */
59 BYTE media_ID; /* Media ID */
60 BYTE access_flag; /* Prev. accessed flag (0=yes,0xFF=no) */
61 DWORD next; /* Pointer to next DPB in list */
62 WORD free_search; /* Free cluster search start */
63 WORD free_clusters; /* Number of free clusters (0xFFFF=unknown) */
75 static struct DosHeap *heap;
76 static WORD DosHeapHandle;
78 WORD sharing_retries = 3; /* number of retries at sharing violation */
79 WORD sharing_pause = 1; /* pause between retries */
81 extern char TempDirectory[];
83 static BOOL32 INT21_CreateHeap(void)
85 if (!(DosHeapHandle = GlobalAlloc16(GMEM_FIXED,sizeof(struct DosHeap))))
87 fprintf( stderr, "INT21_Init: Out of memory\n");
90 heap = (struct DosHeap *) GlobalLock16(DosHeapHandle);
91 dpbsegptr = PTR_SEG_OFF_TO_SEGPTR(DosHeapHandle,(int)&heap->dpb-(int)heap);
93 strcpy(heap->biosdate, "01/01/80");
97 static BYTE *GetCurrentDTA(void)
99 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
100 return (BYTE *)PTR_SEG_TO_LIN( pTask->dta );
104 void CreateBPB(int drive, BYTE *data)
109 setword(&data[3], 0);
111 setword(&data[6], 240);
112 setword(&data[8], 64000);
114 setword(&data[0x0b], 40);
115 setword(&data[0x0d], 56);
116 setword(&data[0x0f], 2);
117 setword(&data[0x11], 0);
118 setword(&data[0x1f], 800);
120 setword(&data[0x22], 1);
121 } else { /* 1.44mb */
124 setword(&data[3], 0);
126 setword(&data[6], 240);
127 setword(&data[8], 2880);
129 setword(&data[0x0b], 6);
130 setword(&data[0x0d], 18);
131 setword(&data[0x0f], 2);
132 setword(&data[0x11], 0);
133 setword(&data[0x1f], 80);
135 setword(&data[0x22], 2);
139 static int INT21_GetFreeDiskSpace( CONTEXT *context )
141 DWORD cluster_sectors, sector_bytes, free_clusters, total_clusters;
142 char root[] = "A:\\";
144 *root += DOS_GET_DRIVE( DL_reg(context) );
145 if (!GetDiskFreeSpace32A( root, &cluster_sectors, §or_bytes,
146 &free_clusters, &total_clusters )) return 0;
147 AX_reg(context) = cluster_sectors;
148 BX_reg(context) = free_clusters;
149 CX_reg(context) = sector_bytes;
150 DX_reg(context) = total_clusters;
154 static int INT21_GetDriveAllocInfo( CONTEXT *context )
156 if (!INT21_GetFreeDiskSpace( context )) return 0;
157 if (!heap && !INT21_CreateHeap()) return 0;
158 heap->mediaID = 0xf0;
159 DS_reg(context) = DosHeapHandle;
160 BX_reg(context) = (int)&heap->mediaID - (int)heap;
164 static void GetDrivePB( CONTEXT *context, int drive )
166 if(!DRIVE_IsValid(drive))
168 DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
169 AX_reg(context) = 0x00ff;
171 else if (heap || INT21_CreateHeap())
173 dprintf_int(stddeb, "int21: GetDrivePB not fully implemented.\n");
175 /* FIXME: I have no idea what a lot of this information should
176 * say or whether it even really matters since we're not allowing
177 * direct block access. However, some programs seem to depend on
178 * getting at least _something_ back from here. The 'next' pointer
179 * does worry me, though. Should we have a complete table of
180 * separate DPBs per drive? Probably, but I'm lazy. :-) -CH
182 heap->dpb.drive_num = heap->dpb.unit_num = drive; /*The same?*/
183 heap->dpb.sector_size = 512;
184 heap->dpb.high_sector = 1;
185 heap->dpb.shift = drive < 2 ? 0 : 6; /*6 for HD, 0 for floppy*/
186 heap->dpb.reserved = 0;
187 heap->dpb.num_FAT = 1;
188 heap->dpb.dir_entries = 2;
189 heap->dpb.first_data = 2;
190 heap->dpb.high_cluster = 64000;
191 heap->dpb.sectors_in_FAT = 1;
192 heap->dpb.start_dir = 1;
193 heap->dpb.driver_head = 0;
194 heap->dpb.media_ID = (drive > 1) ? 0xF8 : 0xF0;
195 heap->dpb.access_flag = 0;
197 heap->dpb.free_search = 0;
198 heap->dpb.free_clusters = 0xFFFF; /* unknown */
200 AL_reg(context) = 0x00;
201 DS_reg(context) = SELECTOROF(dpbsegptr);
202 BX_reg(context) = OFFSETOF(dpbsegptr);
207 static void ioctlGetDeviceInfo( CONTEXT *context )
210 dprintf_int (stddeb, "int21: ioctl (%d, GetDeviceInfo)\n", BX_reg(context));
212 curr_drive = DRIVE_GetCurrentDrive();
213 DX_reg(context) = 0x0140 + curr_drive + ((curr_drive > 1) ? 0x0800 : 0); /* no floppy */
214 /* bits 0-5 are current drive
215 * bit 6 - file has NOT been written..FIXME: correct?
216 * bit 8 - generate int24 if no diskspace on write/ read past end of file
217 * bit 11 - media not removable
219 RESET_CFLAG(context);
222 static BOOL32 ioctlGenericBlkDevReq( CONTEXT *context )
224 BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
225 int drive = DOS_GET_DRIVE( BL_reg(context) );
227 if (!DRIVE_IsValid(drive))
229 DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
233 if (CH_reg(context) != 0x08)
235 INT_BARF( context, 0x21 );
239 switch (CL_reg(context))
241 case 0x4a: /* lock logical volume */
242 dprintf_int(stddeb,"int21: lock logical volume (%d) level %d mode %d\n",drive,BH_reg(context),DX_reg(context));
245 case 0x60: /* get device parameters */
246 /* used by w4wgrp's winfile */
247 memset(dataptr, 0, 0x26);
249 dataptr[6] = 0; /* media type */
252 dataptr[1] = 0x05; /* fixed disk */
253 setword(&dataptr[2], 0x01); /* non removable */
254 setword(&dataptr[4], 0x300); /* # of cylinders */
258 dataptr[1] = 0x07; /* block dev, floppy */
259 setword(&dataptr[2], 0x02); /* removable */
260 setword(&dataptr[4], 80); /* # of cylinders */
262 CreateBPB(drive, &dataptr[7]);
263 RESET_CFLAG(context);
266 case 0x66:/* get disk serial number */
268 char label[12],fsname[9],path[4];
271 strcpy(path,"x:\\");path[0]=drive+'A';
272 GetVolumeInformation32A(
273 path,label,12,&serial,NULL,NULL,fsname,9
276 memcpy(dataptr+2,&serial,4);
277 memcpy(dataptr+6,label ,11);
278 memcpy(dataptr+17,fsname,8);
283 dprintf_int(stddeb,"int21: logical volume %d unlocked.\n",drive);
287 INT_BARF( context, 0x21 );
292 static void INT21_GetSystemDate( CONTEXT *context )
295 GetLocalTime( &systime );
296 CX_reg(context) = systime.wYear;
297 DX_reg(context) = (systime.wMonth << 8) | systime.wDay;
298 AX_reg(context) = systime.wDayOfWeek;
301 static void INT21_GetSystemTime( CONTEXT *context )
304 GetLocalTime( &systime );
305 CX_reg(context) = (systime.wHour << 8) | systime.wMinute;
306 DX_reg(context) = (systime.wSecond << 8) | (systime.wMilliseconds / 10);
309 static BOOL32 INT21_CreateFile( CONTEXT *context )
311 AX_reg(context) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
312 DX_reg(context) ), CX_reg(context) );
313 return (AX_reg(context) == (WORD)HFILE_ERROR16);
317 static void OpenExistingFile( CONTEXT *context )
319 AX_reg(context) = _lopen16( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
321 if (AX_reg(context) == (WORD)HFILE_ERROR16)
323 AX_reg(context) = DOS_ExtendedError;
332 switch (AX_reg(context) & 0x0070)
334 case 0x00: /* compatability mode */
335 case 0x40: /* DENYNONE */
339 case 0x30: /* DENYREAD */
341 "OpenExistingFile (%s): DENYREAD changed to DENYALL\n",
342 (char *)PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)));
343 case 0x10: /* DENYALL */
347 case 0x20: /* DENYWRITE */
358 int result,retries=sharing_retries;
360 #if defined(__svr4__) || defined(_SCO_DS)
361 printf("Should call flock and needs porting to lockf\n");
365 result = flock(handle, lock | LOCK_NB);
367 if ( retries && (!result) )
370 for(i=0;i<32768*((int)sharing_pause);i++)
371 result++; /* stop the optimizer */
372 for(i=0;i<32768*((int)sharing_pause);i++)
376 while( (!result) && (!(retries--)) );
381 AX_reg(context) = DOS_ExtendedError;
390 AX_reg(context) = handle;
391 RESET_CFLAG(context);
396 static void CloseFile( CONTEXT *context )
398 if ((AX_reg(context) = _lclose16( BX_reg(context) )) != 0)
400 AX_reg(context) = DOS_ExtendedError;
405 static BOOL32 INT21_ExtendedOpenCreateFile(CONTEXT *context )
407 BOOL32 bExtendedError = FALSE;
408 BYTE action = DL_reg(context);
410 /* Shuffle arguments to call OpenExistingFile */
411 AL_reg(context) = BL_reg(context);
412 DX_reg(context) = SI_reg(context);
413 /* BX,CX and DX should be preserved */
414 OpenExistingFile(context);
416 if ((EFL_reg(context) & 0x0001) == 0) /* File exists */
418 UINT16 uReturnCX = 0;
420 /* Now decide what do do */
422 if ((action & 0x07) == 0)
424 BX_reg(context) = AX_reg(context);
426 AX_reg(context) = 0x0050; /*File exists*/
428 dprintf_int(stddeb, "int21: extended open/create: failed because file exists \n");
430 else if ((action & 0x07) == 2)
432 /* Truncate it, but first check if opened for write */
433 if ((BL_reg(context) & 0x0007)== 0)
435 BX_reg(context) = AX_reg(context);
437 dprintf_int(stddeb, "int21: extended open/create: failed, trunc on ro file");
438 AX_reg(context) = 0x000C; /*Access code invalid*/
443 /* Shuffle arguments to call CloseFile while
444 * preserving BX and DX */
446 dprintf_int(stddeb, "int21: extended open/create: Closing before truncate\n");
447 BX_reg(context) = AX_reg(context);
449 if (EFL_reg(context) & 0x0001)
451 dprintf_int(stddeb, "int21: extended open/create: close before trunc failed");
452 AX_reg(context) = 0x0019; /*Seek Error*/
456 /* Shuffle arguments to call CreateFile */
458 dprintf_int(stddeb, "int21: extended open/create: Truncating\n");
459 AL_reg(context) = BL_reg(context);
460 /* CX is still the same */
461 DX_reg(context) = SI_reg(context);
462 bExtendedError = INT21_CreateFile(context);
464 if (EFL_reg(context) & 0x0001) /*no file open, flags set */
466 dprintf_int(stddeb, "int21: extended open/create: trunc failed");
467 return bExtendedError;
472 else uReturnCX = 0x1;
474 CX_reg(context) = uReturnCX;
476 else /* file does not exist */
478 RESET_CFLAG(context); /* was set by OpenExistingFile(context) */
479 if ((action & 0xF0)== 0)
483 dprintf_int(stddeb, "int21: extended open/create: failed, file dosen't exist\n");
487 /* Shuffle arguments to call CreateFile */
488 dprintf_int(stddeb, "int21: extended open/create: Creating\n");
489 AL_reg(context) = BL_reg(context);
490 /* CX should still be the same */
491 DX_reg(context) = SI_reg(context);
492 bExtendedError = INT21_CreateFile(context);
493 if (EFL_reg(context) & 0x0001) /*no file open, flags set */
495 dprintf_int(stddeb, "int21: extended open/create: create failed\n");
496 return bExtendedError;
502 return bExtendedError;
506 static BOOL32 INT21_ChangeDir( CONTEXT *context )
509 char *dirname = PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context));
511 dprintf_int(stddeb,"int21: changedir %s\n", dirname);
512 if (dirname[0] && (dirname[1] == ':'))
514 drive = toupper(dirname[0]) - 'A';
517 else drive = DRIVE_GetCurrentDrive();
518 return DRIVE_Chdir( drive, dirname );
522 static int INT21_FindFirst( CONTEXT *context )
526 DOS_FULL_NAME full_name;
527 FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA();
529 path = (const char *)PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
530 dta->unixPath = NULL;
531 if (!DOSFS_GetFullName( path, FALSE, &full_name ))
533 AX_reg(context) = DOS_ExtendedError;
537 dta->unixPath = HEAP_strdupA( GetProcessHeap(), 0, full_name.long_name );
538 p = strrchr( dta->unixPath, '/' );
541 /* Note: terminating NULL in dta->mask overwrites dta->search_attr
542 * (doesn't matter as it is set below anyway)
544 if (!DOSFS_ToDosFCBFormat( p + 1, dta->mask ))
546 HeapFree( GetProcessHeap(), 0, dta->unixPath );
547 dta->unixPath = NULL;
548 DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
549 AX_reg(context) = ER_FileNotFound;
553 dta->drive = (path[0] && (path[1] == ':')) ? toupper(path[0]) - 'A'
554 : DRIVE_GetCurrentDrive();
556 dta->search_attr = CL_reg(context);
561 static int INT21_FindNext( CONTEXT *context )
563 FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA();
564 WIN32_FIND_DATA32A entry;
567 if (!dta->unixPath) return 0;
568 if (!(count = DOSFS_FindNext( dta->unixPath, dta->mask, NULL, dta->drive,
569 dta->search_attr, dta->count, &entry )))
571 HeapFree( GetProcessHeap(), 0, dta->unixPath );
572 dta->unixPath = NULL;
575 if ((int)dta->count + count > 0xffff)
577 fprintf( stderr, "Too many directory entries in %s\n", dta->unixPath );
578 HeapFree( GetProcessHeap(), 0, dta->unixPath );
579 dta->unixPath = NULL;
583 dta->fileattr = entry.dwFileAttributes;
584 dta->filesize = entry.nFileSizeLow;
585 FileTimeToDosDateTime( &entry.ftLastWriteTime,
586 &dta->filedate, &dta->filetime );
587 strcpy( dta->filename, entry.cAlternateFileName );
592 static BOOL32 INT21_CreateTempFile( CONTEXT *context )
594 static int counter = 0;
595 char *name = PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context) );
596 char *p = name + strlen(name);
600 sprintf( p, "wine%04x.%03d", (int)getpid(), counter );
601 counter = (counter + 1) % 1000;
603 if ((AX_reg(context) = _lcreat_uniq( name, 0 )) != (WORD)HFILE_ERROR16)
605 dprintf_int( stddeb, "INT21_CreateTempFile: created %s\n", name );
608 if (DOS_ExtendedError != ER_FileExists) return FALSE;
613 static BOOL32 INT21_GetCurrentDirectory( CONTEXT *context )
615 int drive = DOS_GET_DRIVE( DL_reg(context) );
616 char *ptr = (char *)PTR_SEG_OFF_TO_LIN( DS_reg(context), SI_reg(context) );
618 if (!DRIVE_IsValid(drive))
620 DOS_ERROR( ER_InvalidDrive, EC_NotFound, SA_Abort, EL_Disk );
623 lstrcpyn32A( ptr, DRIVE_GetDosCwd(drive), 64 );
624 AX_reg(context) = 0x0100; /* success return code */
629 static int INT21_GetDiskSerialNumber( CONTEXT *context )
631 BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
632 int drive = DOS_GET_DRIVE( BL_reg(context) );
634 if (!DRIVE_IsValid(drive))
636 DOS_ERROR( ER_InvalidDrive, EC_NotFound, SA_Abort, EL_Disk );
640 *(WORD *)dataptr = 0;
641 *(DWORD *)(dataptr + 2) = DRIVE_GetSerialNumber( drive );
642 memcpy( dataptr + 6, DRIVE_GetLabel( drive ), 11 );
643 strncpy(dataptr + 0x11, "FAT16 ", 8);
648 static int INT21_SetDiskSerialNumber( CONTEXT *context )
650 BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
651 int drive = DOS_GET_DRIVE( BL_reg(context) );
653 if (!DRIVE_IsValid(drive))
655 DOS_ERROR( ER_InvalidDrive, EC_NotFound, SA_Abort, EL_Disk );
659 DRIVE_SetSerialNumber( drive, *(DWORD *)(dataptr + 2) );
664 /* microsoft's programmers should be shot for using CP/M style int21
665 calls in Windows for Workgroup's winfile.exe */
667 static int INT21_FindFirstFCB( CONTEXT *context )
669 BYTE *fcb = (BYTE *)PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
674 if (*fcb == 0xff) pFCB = (FINDFILE_FCB *)(fcb + 7);
675 else pFCB = (FINDFILE_FCB *)fcb;
676 drive = DOS_GET_DRIVE( pFCB->drive );
677 root = DRIVE_GetRoot( drive );
678 cwd = DRIVE_GetUnixCwd( drive );
679 pFCB->unixPath = HeapAlloc( GetProcessHeap(), 0,
680 strlen(root)+strlen(cwd)+2 );
681 if (!pFCB->unixPath) return 0;
682 strcpy( pFCB->unixPath, root );
683 strcat( pFCB->unixPath, "/" );
684 strcat( pFCB->unixPath, cwd );
690 static int INT21_FindNextFCB( CONTEXT *context )
692 BYTE *fcb = (BYTE *)PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
694 DOS_DIRENTRY_LAYOUT *pResult = (DOS_DIRENTRY_LAYOUT *)GetCurrentDTA();
695 WIN32_FIND_DATA32A entry;
699 if (*fcb == 0xff) /* extended FCB ? */
702 pFCB = (FINDFILE_FCB *)(fcb + 7);
707 pFCB = (FINDFILE_FCB *)fcb;
710 if (!pFCB->unixPath) return 0;
711 if (!(count = DOSFS_FindNext( pFCB->unixPath, pFCB->filename, NULL,
712 DOS_GET_DRIVE( pFCB->drive ), attr,
713 pFCB->count, &entry )))
715 HeapFree( GetProcessHeap(), 0, pFCB->unixPath );
716 pFCB->unixPath = NULL;
719 pFCB->count += count;
721 if (*fcb == 0xff) { /* place extended FCB header before pResult if called with extended FCB */
722 *(BYTE *)pResult = 0xff;
723 (BYTE *)pResult +=6; /* leave reserved field behind */
724 *(BYTE *)pResult = entry.dwFileAttributes;
727 *(BYTE *)pResult = DOS_GET_DRIVE( pFCB->drive ); /* DOS_DIRENTRY_LAYOUT after current drive number */
729 pResult->fileattr = entry.dwFileAttributes;
730 pResult->cluster = 0; /* what else? */
731 pResult->filesize = entry.nFileSizeLow;
732 memset( pResult->reserved, 0, sizeof(pResult->reserved) );
733 FileTimeToDosDateTime( &entry.ftLastWriteTime,
734 &pResult->filedate, &pResult->filetime );
736 /* Convert file name to FCB format */
738 memset( pResult->filename, ' ', sizeof(pResult->filename) );
739 if (!strcmp( entry.cAlternateFileName, "." )) pResult->filename[0] = '.';
740 else if (!strcmp( entry.cAlternateFileName, ".." ))
741 pResult->filename[0] = pResult->filename[1] = '.';
744 char *p = strrchr( entry.cAlternateFileName, '.' );
745 if (p && p[1] && (p != entry.cAlternateFileName))
747 memcpy( pResult->filename, entry.cAlternateFileName,
748 MIN( (p - entry.cAlternateFileName), 8 ) );
749 memcpy( pResult->filename + 8, p + 1, MIN( strlen(p), 3 ) );
752 memcpy( pResult->filename, entry.cAlternateFileName,
753 MIN( strlen(entry.cAlternateFileName), 8 ) );
759 static void DeleteFileFCB( CONTEXT *context )
761 fprintf( stderr, "DeleteFileFCB: not implemented yet\n" );
764 static void RenameFileFCB( CONTEXT *context )
766 fprintf( stderr, "RenameFileFCB: not implemented yet\n" );
771 static void fLock( CONTEXT * context )
774 switch ( AX_reg(context) & 0xff )
776 case 0x00: /* LOCK */
777 if (!LockFile(BX_reg(context),
778 MAKELONG(DX_reg(context),CX_reg(context)), 0,
779 MAKELONG(DI_reg(context),SI_reg(context)), 0)) {
780 AX_reg(context) = DOS_ExtendedError;
785 case 0x01: /* UNLOCK */
786 if (!UnlockFile(BX_reg(context),
787 MAKELONG(DX_reg(context),CX_reg(context)), 0,
788 MAKELONG(DI_reg(context),SI_reg(context)), 0)) {
789 AX_reg(context) = DOS_ExtendedError;
794 AX_reg(context) = 0x0001;
801 extern void LOCAL_PrintHeap (WORD ds);
803 /***********************************************************************
804 * DOS3Call (KERNEL.102)
806 void WINAPI DOS3Call( CONTEXT *context )
808 BOOL32 bSetDOSExtendedError = FALSE;
810 dprintf_int( stddeb, "int21: AX=%04x BX=%04x CX=%04x DX=%04x "
811 "SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
812 AX_reg(context), BX_reg(context), CX_reg(context),
813 DX_reg(context), SI_reg(context), DI_reg(context),
814 (WORD)DS_reg(context), (WORD)ES_reg(context),
817 if (AH_reg(context) == 0x59) /* Get extended error info */
819 AX_reg(context) = DOS_ExtendedError;
820 BH_reg(context) = DOS_ErrorClass;
821 BL_reg(context) = DOS_ErrorAction;
822 CH_reg(context) = DOS_ErrorLocus;
826 DOS_ERROR( 0, 0, 0, 0 );
827 RESET_CFLAG(context); /* Not sure if this is a good idea */
829 switch(AH_reg(context))
831 case 0x00: /* TERMINATE PROGRAM */
832 TASK_KillCurrentTask( 0 );
835 case 0x01: /* READ CHARACTER FROM STANDARD INPUT, WITH ECHO */
836 case 0x02: /* WRITE CHARACTER TO STANDARD OUTPUT */
837 case 0x03: /* READ CHARACTER FROM STDAUX */
838 case 0x04: /* WRITE CHARACTER TO STDAUX */
839 case 0x05: /* WRITE CHARACTER TO PRINTER */
840 case 0x06: /* DIRECT CONSOLE IN/OUTPUT */
841 case 0x07: /* DIRECT CHARACTER INPUT, WITHOUT ECHO */
842 case 0x08: /* CHARACTER INPUT WITHOUT ECHO */
843 case 0x09: /* WRITE STRING TO STANDARD OUTPUT */
844 case 0x0a: /* BUFFERED INPUT */
845 case 0x0b: /* GET STDIN STATUS */
846 case 0x0c: /* FLUSH BUFFER AND READ STANDARD INPUT */
847 case 0x0f: /* OPEN FILE USING FCB */
848 case 0x10: /* CLOSE FILE USING FCB */
849 case 0x14: /* SEQUENTIAL READ FROM FCB FILE */
850 case 0x15: /* SEQUENTIAL WRITE TO FCB FILE */
851 case 0x16: /* CREATE OR TRUNCATE FILE USING FCB */
852 case 0x21: /* READ RANDOM RECORD FROM FCB FILE */
853 case 0x22: /* WRITE RANDOM RECORD TO FCB FILE */
854 case 0x23: /* GET FILE SIZE FOR FCB */
855 case 0x24: /* SET RANDOM RECORD NUMBER FOR FCB */
856 case 0x26: /* CREATE NEW PROGRAM SEGMENT PREFIX */
857 case 0x27: /* RANDOM BLOCK READ FROM FCB FILE */
858 case 0x28: /* RANDOM BLOCK WRITE TO FCB FILE */
859 case 0x29: /* PARSE FILENAME INTO FCB */
860 case 0x37: /* "SWITCHAR" - GET SWITCH CHARACTER
861 "SWITCHAR" - SET SWITCH CHARACTER
862 "AVAILDEV" - SPECIFY \DEV\ PREFIX USE */
863 case 0x54: /* GET VERIFY FLAG */
864 INT_BARF( context, 0x21 );
866 case 0x2e: /* SET VERIFY FLAG */
867 /* we cannot change the behaviour anyway, so just ignore it */
870 case 0x18: /* NULL FUNCTIONS FOR CP/M COMPATIBILITY */
874 case 0x6b: /* NULL FUNCTION */
878 case 0x5c: /* "FLOCK" - RECORD LOCKING */
882 case 0x0d: /* DISK BUFFER FLUSH */
883 RESET_CFLAG(context); /* dos 6+ only */
886 case 0x0e: /* SELECT DEFAULT DRIVE */
887 DRIVE_SetCurrentDrive( DL_reg(context) );
888 AL_reg(context) = MAX_DOS_DRIVES;
891 case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
892 if (!INT21_FindFirstFCB(context))
894 AL_reg(context) = 0xff;
897 /* else fall through */
899 case 0x12: /* FIND NEXT MATCHING FILE USING FCB */
900 AL_reg(context) = INT21_FindNextFCB(context) ? 0x00 : 0xff;
903 case 0x13: /* DELETE FILE USING FCB */
904 DeleteFileFCB(context);
907 case 0x17: /* RENAME FILE USING FCB */
908 RenameFileFCB(context);
911 case 0x19: /* GET CURRENT DEFAULT DRIVE */
912 AL_reg(context) = DRIVE_GetCurrentDrive();
915 case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
917 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
918 pTask->dta = PTR_SEG_OFF_TO_SEGPTR(DS_reg(context),DX_reg(context));
919 dprintf_int(stddeb, "int21: Set DTA: %08lx\n", pTask->dta);
923 case 0x1b: /* GET ALLOCATION INFORMATION FOR DEFAULT DRIVE */
925 if (!INT21_GetDriveAllocInfo(context)) AX_reg(context) = 0xffff;
928 case 0x1c: /* GET ALLOCATION INFORMATION FOR SPECIFIC DRIVE */
929 if (!INT21_GetDriveAllocInfo(context)) AX_reg(context) = 0xffff;
932 case 0x1f: /* GET DRIVE PARAMETER BLOCK FOR DEFAULT DRIVE */
933 GetDrivePB(context, DRIVE_GetCurrentDrive());
936 case 0x25: /* SET INTERRUPT VECTOR */
937 INT_SetHandler( AL_reg(context),
938 (FARPROC16)PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),
942 case 0x2a: /* GET SYSTEM DATE */
943 INT21_GetSystemDate(context);
946 case 0x2b: /* SET SYSTEM DATE */
947 fprintf( stdnimp, "SetSystemDate(%02d/%02d/%04d): not allowed\n",
948 DL_reg(context), DH_reg(context), CX_reg(context) );
949 AL_reg(context) = 0; /* Let's pretend we succeeded */
952 case 0x2c: /* GET SYSTEM TIME */
953 INT21_GetSystemTime(context);
956 case 0x2d: /* SET SYSTEM TIME */
957 fprintf( stdnimp, "SetSystemTime(%02d:%02d:%02d.%02d): not allowed\n",
958 CH_reg(context), CL_reg(context),
959 DH_reg(context), DL_reg(context) );
960 AL_reg(context) = 0; /* Let's pretend we succeeded */
963 case 0x2f: /* GET DISK TRANSFER AREA ADDRESS */
965 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
966 ES_reg(context) = SELECTOROF( pTask->dta );
967 BX_reg(context) = OFFSETOF( pTask->dta );
971 case 0x30: /* GET DOS VERSION */
972 AX_reg(context) = (HIWORD(GetVersion16()) >> 8) |
973 (HIWORD(GetVersion16()) << 8);
974 BX_reg(context) = 0x0012; /* 0x123456 is Wine's serial # */
975 CX_reg(context) = 0x3456;
978 case 0x31: /* TERMINATE AND STAY RESIDENT */
979 INT_BARF( context, 0x21 );
982 case 0x32: /* GET DOS DRIVE PARAMETER BLOCK FOR SPECIFIC DRIVE */
983 GetDrivePB(context, DOS_GET_DRIVE( DL_reg(context) ) );
986 case 0x33: /* MULTIPLEXED */
987 switch (AL_reg(context))
989 case 0x00: /* GET CURRENT EXTENDED BREAK STATE */
993 case 0x01: /* SET EXTENDED BREAK STATE */
996 case 0x02: /* GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE*/
1000 case 0x05: /* GET BOOT DRIVE */
1001 DL_reg(context) = 3;
1002 /* c: is Wine's bootdrive (a: is 1)*/
1005 case 0x06: /* GET TRUE VERSION NUMBER */
1006 BX_reg(context) = (HIWORD(GetVersion16() >> 8)) |
1007 (HIWORD(GetVersion16() << 8));
1008 DX_reg(context) = 0x00;
1012 INT_BARF( context, 0x21 );
1017 case 0x34: /* GET ADDRESS OF INDOS FLAG */
1018 if (!heap) INT21_CreateHeap();
1019 ES_reg(context) = DosHeapHandle;
1020 BX_reg(context) = (int)&heap->InDosFlag - (int)heap;
1023 case 0x35: /* GET INTERRUPT VECTOR */
1025 FARPROC16 addr = INT_GetHandler( AL_reg(context) );
1026 ES_reg(context) = SELECTOROF(addr);
1027 BX_reg(context) = OFFSETOF(addr);
1031 case 0x36: /* GET FREE DISK SPACE */
1032 if (!INT21_GetFreeDiskSpace(context)) AX_reg(context) = 0xffff;
1035 case 0x38: /* GET COUNTRY-SPECIFIC INFORMATION */
1036 AX_reg(context) = 0x02; /* no country support available */
1040 case 0x39: /* "MKDIR" - CREATE SUBDIRECTORY */
1041 bSetDOSExtendedError = (!CreateDirectory16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
1042 DX_reg(context) ), NULL));
1045 case 0x3a: /* "RMDIR" - REMOVE SUBDIRECTORY */
1046 bSetDOSExtendedError = (!RemoveDirectory16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
1047 DX_reg(context) )));
1050 case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */
1051 bSetDOSExtendedError = !INT21_ChangeDir(context);
1054 case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
1055 AX_reg(context) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
1056 DX_reg(context) ), CX_reg(context) );
1057 bSetDOSExtendedError = (AX_reg(context) == (WORD)HFILE_ERROR16);
1060 case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
1061 OpenExistingFile(context);
1064 case 0x3e: /* "CLOSE" - CLOSE FILE */
1065 bSetDOSExtendedError = ((AX_reg(context) = _lclose16( BX_reg(context) )) != 0);
1068 case 0x3f: /* "READ" - READ FROM FILE OR DEVICE */
1070 LONG result = WIN16_hread( BX_reg(context),
1071 PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),
1074 if (result == -1) bSetDOSExtendedError = TRUE;
1075 else AX_reg(context) = (WORD)result;
1079 case 0x40: /* "WRITE" - WRITE TO FILE OR DEVICE */
1081 LONG result = _hwrite16( BX_reg(context),
1082 PTR_SEG_OFF_TO_LIN( DS_reg(context),
1085 if (result == -1) bSetDOSExtendedError = TRUE;
1086 else AX_reg(context) = (WORD)result;
1090 case 0x41: /* "UNLINK" - DELETE FILE */
1091 bSetDOSExtendedError = (!DeleteFile32A( PTR_SEG_OFF_TO_LIN( DS_reg(context),
1092 DX_reg(context) )));
1095 case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
1097 LONG status = _llseek16( BX_reg(context),
1098 MAKELONG(DX_reg(context),CX_reg(context)),
1100 if (status == -1) bSetDOSExtendedError = TRUE;
1103 AX_reg(context) = LOWORD(status);
1104 DX_reg(context) = HIWORD(status);
1109 case 0x43: /* FILE ATTRIBUTES */
1110 switch (AL_reg(context))
1113 AX_reg(context) = (WORD)GetFileAttributes32A(
1114 PTR_SEG_OFF_TO_LIN(DS_reg(context),
1116 if (AX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE;
1117 else CX_reg(context) = AX_reg(context);
1121 bSetDOSExtendedError =
1122 (!SetFileAttributes32A( PTR_SEG_OFF_TO_LIN(DS_reg(context),
1129 case 0x44: /* IOCTL */
1130 switch (AL_reg(context))
1133 ioctlGetDeviceInfo(context);
1138 case 0x05:{ /* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */
1139 BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context));
1141 int drive = DOS_GET_DRIVE(BL_reg(context));
1143 fprintf(stdnimp,"int21: program tried to write to block device control channel of drive %d:\n",drive);
1144 for (i=0;i<CX_reg(context);i++)
1145 fprintf(stdnimp,"%02x ",dataptr[i]);
1146 fprintf(stdnimp,"\n");
1147 AX_reg(context)=CX_reg(context);
1150 case 0x08: /* Check if drive is removable. */
1151 switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
1153 case DRIVE_CANNOTDETERMINE:
1154 DOS_ERROR( ER_InvalidDrive, EC_NotFound, SA_Abort, EL_Disk );
1155 AX_reg(context) = ER_InvalidDrive;
1158 case DRIVE_REMOVABLE:
1159 AX_reg(context) = 0; /* removable */
1162 AX_reg(context) = 1; /* not removable */
1167 case 0x09: /* CHECK IF BLOCK DEVICE REMOTE */
1168 switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
1170 case DRIVE_CANNOTDETERMINE:
1171 DOS_ERROR( ER_InvalidDrive, EC_NotFound, SA_Abort, EL_Disk );
1172 AX_reg(context) = ER_InvalidDrive;
1176 DX_reg(context) = (1<<9) | (1<<12); /* remote */
1179 DX_reg(context) = 0; /* FIXME: use driver attr here */
1184 case 0x0a: /* check if handle (BX) is remote */
1185 /* returns DX, bit 15 set if remote, bit 14 set if date/time
1188 DX_reg(context) = 0;
1191 case 0x0b: /* SET SHARING RETRY COUNT */
1192 if (!CX_reg(context))
1194 AX_reg(context) = 1;
1198 sharing_pause = CX_reg(context);
1199 if (!DX_reg(context))
1200 sharing_retries = DX_reg(context);
1201 RESET_CFLAG(context);
1205 bSetDOSExtendedError = ioctlGenericBlkDevReq(context);
1208 case 0x0e: /* get logical drive mapping */
1209 AL_reg(context) = 0; /* drive has no mapping - FIXME: may be wrong*/
1212 case 0x0F: /* Set logical drive mapping */
1215 drive = DOS_GET_DRIVE ( BL_reg(context) );
1216 if ( ! DRIVE_SetLogicalMapping ( drive, drive+1 ) )
1219 AX_reg(context) = 0x000F; /* invalid drive */
1225 INT_BARF( context, 0x21 );
1230 case 0x45: /* "DUP" - DUPLICATE FILE HANDLE */
1231 bSetDOSExtendedError = ((AX_reg(context) = FILE_Dup(BX_reg(context))) == (WORD)HFILE_ERROR16);
1234 case 0x46: /* "DUP2", "FORCEDUP" - FORCE DUPLICATE FILE HANDLE */
1235 bSetDOSExtendedError = (FILE_Dup2( BX_reg(context), CX_reg(context) ) == HFILE_ERROR32);
1238 case 0x47: /* "CWD" - GET CURRENT DIRECTORY */
1239 bSetDOSExtendedError = !INT21_GetCurrentDirectory(context);
1242 case 0x48: /* ALLOCATE MEMORY */
1243 case 0x49: /* FREE MEMORY */
1244 case 0x4a: /* RESIZE MEMORY BLOCK */
1245 INT_BARF( context, 0x21 );
1248 case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
1249 AX_reg(context) = WinExec16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
1252 if (AX_reg(context) < 32) SET_CFLAG(context);
1255 case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
1256 TASK_KillCurrentTask( AL_reg(context) );
1259 case 0x4d: /* GET RETURN CODE */
1260 AX_reg(context) = 0; /* normal exit */
1263 case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
1264 if (!INT21_FindFirst(context)) break;
1267 case 0x4f: /* "FINDNEXT" - FIND NEXT MATCHING FILE */
1268 if (!INT21_FindNext(context))
1270 DOS_ERROR( ER_NoMoreFiles, EC_MediaError, SA_Abort, EL_Disk );
1271 AX_reg(context) = ER_NoMoreFiles;
1276 case 0x51: /* GET PSP ADDRESS */
1277 case 0x62: /* GET PSP ADDRESS */
1278 /* FIXME: should we return the original DOS PSP upon */
1279 /* Windows startup ? */
1280 BX_reg(context) = GetCurrentPDB();
1283 case 0x52: /* "SYSVARS" - GET LIST OF LISTS */
1284 ES_reg(context) = 0x0;
1285 BX_reg(context) = 0x0;
1286 INT_BARF( context, 0x21 );
1289 case 0x56: /* "RENAME" - RENAME FILE */
1290 bSetDOSExtendedError =
1291 (!MoveFile32A( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
1292 PTR_SEG_OFF_TO_LIN(ES_reg(context),DI_reg(context))));
1295 case 0x57: /* FILE DATE AND TIME */
1296 switch (AL_reg(context))
1298 case 0x00: /* Get */
1301 if (!GetFileTime( BX_reg(context), NULL, NULL, &filetime ))
1302 bSetDOSExtendedError = TRUE;
1303 else FileTimeToDosDateTime( &filetime, &DX_reg(context),
1308 case 0x01: /* Set */
1311 DosDateTimeToFileTime( DX_reg(context), CX_reg(context),
1313 bSetDOSExtendedError =
1314 (!SetFileTime( BX_reg(context), NULL, NULL, &filetime ));
1320 case 0x58: /* GET OR SET MEMORY/UMB ALLOCATION STRATEGY */
1321 switch (AL_reg(context))
1324 AX_reg(context) = 1;
1327 AX_reg(context) = 0;
1333 RESET_CFLAG(context);
1336 case 0x5a: /* CREATE TEMPORARY FILE */
1337 bSetDOSExtendedError = !INT21_CreateTempFile(context);
1340 case 0x5b: /* CREATE NEW FILE */
1341 bSetDOSExtendedError = ((AX_reg(context) =
1342 _lcreat_uniq( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)), 0 ))
1343 == (WORD)HFILE_ERROR16);
1346 case 0x5d: /* NETWORK */
1348 /* network software not installed */
1349 DOS_ERROR( ER_NoNetwork, EC_NotFound, SA_Abort, EL_Network );
1350 bSetDOSExtendedError = TRUE;
1353 case 0x5f: /* NETWORK */
1354 switch (AL_reg(context))
1356 case 0x07: /* ENABLE DRIVE */
1357 if (!DRIVE_Enable( DL_reg(context) ))
1359 DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
1360 bSetDOSExtendedError = TRUE;
1364 case 0x08: /* DISABLE DRIVE */
1365 if (!DRIVE_Disable( DL_reg(context) ))
1367 DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
1368 bSetDOSExtendedError = TRUE;
1373 /* network software not installed */
1374 DOS_ERROR( ER_NoNetwork, EC_NotFound, SA_Abort, EL_Network );
1375 bSetDOSExtendedError = TRUE;
1380 case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
1382 if (!GetFullPathName32A( PTR_SEG_OFF_TO_LIN(DS_reg(context),
1383 SI_reg(context)), 128,
1384 PTR_SEG_OFF_TO_LIN(ES_reg(context),
1385 DI_reg(context)),NULL))
1386 bSetDOSExtendedError = TRUE;
1387 else AX_reg(context) = 0;
1391 case 0x61: /* UNUSED */
1392 case 0x63: /* UNUSED */
1393 case 0x64: /* OS/2 DOS BOX */
1394 INT_BARF( context, 0x21 );
1398 case 0x65:{/* GET EXTENDED COUNTRY INFORMATION */
1399 extern WORD WINE_LanguageId;
1400 BYTE *dataptr=PTR_SEG_OFF_TO_LIN(ES_reg(context),DI_reg(context));;
1401 switch (AL_reg(context)) {
1404 *(WORD*)(dataptr+1) = 41;
1405 *(WORD*)(dataptr+3) = WINE_LanguageId;
1406 *(WORD*)(dataptr+5) = CodePage;
1410 *(DWORD*)(dataptr+1) = MAKELONG(DOSMEM_CollateTable & 0xFFFF,DOSMEM_AllocSelector(DOSMEM_CollateTable>>16));
1411 CX_reg(context) = 258;/*FIXME: size of table?*/
1414 INT_BARF( context, 0x21 );
1420 case 0x66: /* GLOBAL CODE PAGE TABLE */
1421 switch (AL_reg(context))
1424 DX_reg(context) = BX_reg(context) = CodePage;
1425 RESET_CFLAG(context);
1428 CodePage = BX_reg(context);
1429 RESET_CFLAG(context);
1434 case 0x67: /* SET HANDLE COUNT */
1435 SetHandleCount16( BX_reg(context) );
1436 if (DOS_ExtendedError) bSetDOSExtendedError = TRUE;
1439 case 0x68: /* "FFLUSH" - COMMIT FILE */
1440 case 0x6a: /* COMMIT FILE */
1441 bSetDOSExtendedError = (!FlushFileBuffers( BX_reg(context) ));
1444 case 0x69: /* DISK SERIAL NUMBER */
1445 switch (AL_reg(context))
1448 if (!INT21_GetDiskSerialNumber(context)) bSetDOSExtendedError = TRUE;
1449 else AX_reg(context) = 0;
1453 if (!INT21_SetDiskSerialNumber(context)) bSetDOSExtendedError = TRUE;
1454 else AX_reg(context) = 1;
1459 case 0x6C: /* Extended Open/Create*/
1460 bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
1463 case 0x71: /* MS-DOS 7 (Windows95) - LONG FILENAME FUNCTIONS */
1464 switch(AL_reg(context))
1466 case 0x39: /* Create directory */
1467 bSetDOSExtendedError = (!CreateDirectory32A(
1468 PTR_SEG_OFF_TO_LIN( DS_reg(context),
1469 DX_reg(context) ), NULL));
1471 case 0x3a: /* Remove directory */
1472 bSetDOSExtendedError = (!RemoveDirectory32A(
1473 PTR_SEG_OFF_TO_LIN( DS_reg(context),
1474 DX_reg(context) )));
1476 case 0x43: /* Get/Set file attributes */
1477 switch (BL_reg(context))
1479 case 0x00: /* Get file attributes */
1480 CX_reg(context) = (WORD)GetFileAttributes32A(
1481 PTR_SEG_OFF_TO_LIN(DS_reg(context),
1483 if (CX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE;
1486 bSetDOSExtendedError = (!SetFileAttributes32A(
1487 PTR_SEG_OFF_TO_LIN(DS_reg(context),
1489 CX_reg(context) ) );
1493 "Unimplemented int21 long file name function:\n");
1494 INT_BARF( context, 0x21 );
1496 AL_reg(context) = 0;
1500 case 0x47: /* Get current directory */
1501 bSetDOSExtendedError = !INT21_GetCurrentDirectory(context);
1504 case 0x4e: /* Find first file */
1505 /* FIXME: use attributes in CX */
1506 if ((AX_reg(context) = FindFirstFile16(
1507 PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
1508 (WIN32_FIND_DATA32A *)PTR_SEG_OFF_TO_LIN(ES_reg(context),
1510 == INVALID_HANDLE_VALUE16)
1511 bSetDOSExtendedError = TRUE;
1513 case 0x4f: /* Find next file */
1514 if (!FindNextFile16( BX_reg(context),
1515 (WIN32_FIND_DATA32A *)PTR_SEG_OFF_TO_LIN(ES_reg(context),
1517 bSetDOSExtendedError = TRUE;
1519 case 0xa1: /* Find close */
1520 bSetDOSExtendedError = (!FindClose16( BX_reg(context) ));
1525 switch(CL_reg(context))
1527 case 0x02: /*Get canonical long filename or path */
1528 if (!GetFullPathName32A
1529 ( PTR_SEG_OFF_TO_LIN(DS_reg(context),
1530 SI_reg(context)), 128,
1531 PTR_SEG_OFF_TO_LIN(ES_reg(context),
1532 DI_reg(context)),NULL))
1533 bSetDOSExtendedError = TRUE;
1534 else AX_reg(context) = 0;
1538 "Unimplemented int21 long file name function:\n");
1539 INT_BARF( context, 0x21 );
1541 AL_reg(context) = 0;
1545 case 0x6c: /* Create or open file */
1546 /* translate Dos 7 action to Dos 6 action */
1547 bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
1550 case 0x3b: /* Change directory */
1551 if (!SetCurrentDirectory32A(PTR_SEG_OFF_TO_LIN(
1557 AL_reg(context) = DOS_ExtendedError;
1560 case 0x41: /* Delete file */
1561 if (!DeleteFile32A(PTR_SEG_OFF_TO_LIN(
1566 AL_reg(context) = DOS_ExtendedError;
1569 case 0x56: /* Move (rename) file */
1571 fprintf( stderr, "Unimplemented int21 long file name function:\n");
1572 INT_BARF( context, 0x21 );
1574 AL_reg(context) = 0;
1579 case 0x70: /* MS-DOS 7 (Windows95) - ??? (country-specific?)*/
1580 case 0x72: /* MS-DOS 7 (Windows95) - ??? */
1581 case 0x73: /* MS-DOS 7 (Windows95) - DRIVE LOCKING ??? */
1582 dprintf_int(stddeb,"int21: windows95 function AX %04x\n",
1584 dprintf_int(stddeb, " returning unimplemented\n");
1586 AL_reg(context) = 0;
1589 case 0xdc: /* CONNECTION SERVICES - GET CONNECTION NUMBER */
1590 case 0xea: /* NOVELL NETWARE - RETURN SHELL VERSION */
1594 INT_BARF( context, 0x21 );
1597 } /* END OF SWITCH */
1599 if( bSetDOSExtendedError ) /* set general error condition */
1601 AX_reg(context) = DOS_ExtendedError;
1605 dprintf_int( stddeb, "ret21: AX=%04x BX=%04x CX=%04x DX=%04x "
1606 "SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
1607 AX_reg(context), BX_reg(context), CX_reg(context),
1608 DX_reg(context), SI_reg(context), DI_reg(context),
1609 (WORD)DS_reg(context), (WORD)ES_reg(context),