2 * DOS interrupt 21h handler
14 #include <sys/types.h>
30 #if defined(__svr4__) || defined(_SCO_DS)
31 /* SVR4 DOESNT do locking the same way must implement properly */
38 #define DOS_GET_DRIVE(reg) ((reg) ? (reg) - 1 : DRIVE_GetCurrentDrive())
40 /* Define the drive parameter block, as used by int21/1F
41 * and int21/32. This table can be accessed through the
42 * global 'dpb' pointer, which points into the local dos
47 BYTE drive_num
; /* 0=A, etc. */
48 BYTE unit_num
; /* Drive's unit number (?) */
49 WORD sector_size
; /* Sector size in bytes */
50 BYTE high_sector
; /* Highest sector in a cluster */
51 BYTE shift
; /* Shift count (?) */
52 WORD reserved
; /* Number of reserved sectors at start */
53 BYTE num_FAT
; /* Number of FATs */
54 WORD dir_entries
; /* Number of root dir entries */
55 WORD first_data
; /* First data sector */
56 WORD high_cluster
; /* Highest cluster number */
57 WORD sectors_in_FAT
; /* Number of sectors per FAT */
58 WORD start_dir
; /* Starting sector of first dir */
59 DWORD driver_head
; /* Address of device driver header (?) */
60 BYTE media_ID
; /* Media ID */
61 BYTE access_flag
; /* Prev. accessed flag (0=yes,0xFF=no) */
62 DWORD next
; /* Pointer to next DPB in list */
63 WORD free_search
; /* Free cluster search start */
64 WORD free_clusters
; /* Number of free clusters (0xFFFF=unknown) */
76 static struct DosHeap
*heap
;
77 static WORD DosHeapHandle
;
79 WORD sharing_retries
= 3; /* number of retries at sharing violation */
80 WORD sharing_pause
= 1; /* pause between retries */
82 extern char TempDirectory
[];
84 static BOOL32
INT21_CreateHeap(void)
86 if (!(DosHeapHandle
= GlobalAlloc16(GMEM_FIXED
,sizeof(struct DosHeap
))))
88 fprintf( stderr
, "INT21_Init: Out of memory\n");
91 heap
= (struct DosHeap
*) GlobalLock16(DosHeapHandle
);
92 dpbsegptr
= PTR_SEG_OFF_TO_SEGPTR(DosHeapHandle
,(int)&heap
->dpb
-(int)heap
);
94 strcpy(heap
->biosdate
, "01/01/80");
98 static BYTE
*GetCurrentDTA(void)
100 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
101 return (BYTE
*)PTR_SEG_TO_LIN( pTask
->dta
);
105 void CreateBPB(int drive
, BYTE
*data
)
110 setword(&data
[3], 0);
112 setword(&data
[6], 240);
113 setword(&data
[8], 64000);
115 setword(&data
[0x0b], 40);
116 setword(&data
[0x0d], 56);
117 setword(&data
[0x0f], 2);
118 setword(&data
[0x11], 0);
119 setword(&data
[0x1f], 800);
121 setword(&data
[0x22], 1);
122 } else { /* 1.44mb */
125 setword(&data
[3], 0);
127 setword(&data
[6], 240);
128 setword(&data
[8], 2880);
130 setword(&data
[0x0b], 6);
131 setword(&data
[0x0d], 18);
132 setword(&data
[0x0f], 2);
133 setword(&data
[0x11], 0);
134 setword(&data
[0x1f], 80);
136 setword(&data
[0x22], 2);
140 static int INT21_GetFreeDiskSpace( CONTEXT
*context
)
142 DWORD cluster_sectors
, sector_bytes
, free_clusters
, total_clusters
;
143 char root
[] = "A:\\";
145 *root
+= DOS_GET_DRIVE( DL_reg(context
) );
146 if (!GetDiskFreeSpace32A( root
, &cluster_sectors
, §or_bytes
,
147 &free_clusters
, &total_clusters
)) return 0;
148 AX_reg(context
) = cluster_sectors
;
149 BX_reg(context
) = free_clusters
;
150 CX_reg(context
) = sector_bytes
;
151 DX_reg(context
) = total_clusters
;
155 static int INT21_GetDriveAllocInfo( CONTEXT
*context
)
157 if (!INT21_GetFreeDiskSpace( context
)) return 0;
158 if (!heap
&& !INT21_CreateHeap()) return 0;
159 heap
->mediaID
= 0xf0;
160 DS_reg(context
) = DosHeapHandle
;
161 BX_reg(context
) = (int)&heap
->mediaID
- (int)heap
;
165 static void GetDrivePB( CONTEXT
*context
, int drive
)
167 if(!DRIVE_IsValid(drive
))
169 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
170 AX_reg(context
) = 0x00ff;
172 else if (heap
|| INT21_CreateHeap())
174 dprintf_int(stddeb
, "int21: GetDrivePB not fully implemented.\n");
176 /* FIXME: I have no idea what a lot of this information should
177 * say or whether it even really matters since we're not allowing
178 * direct block access. However, some programs seem to depend on
179 * getting at least _something_ back from here. The 'next' pointer
180 * does worry me, though. Should we have a complete table of
181 * separate DPBs per drive? Probably, but I'm lazy. :-) -CH
183 heap
->dpb
.drive_num
= heap
->dpb
.unit_num
= drive
; /*The same?*/
184 heap
->dpb
.sector_size
= 512;
185 heap
->dpb
.high_sector
= 1;
186 heap
->dpb
.shift
= drive
< 2 ? 0 : 6; /*6 for HD, 0 for floppy*/
187 heap
->dpb
.reserved
= 0;
188 heap
->dpb
.num_FAT
= 1;
189 heap
->dpb
.dir_entries
= 2;
190 heap
->dpb
.first_data
= 2;
191 heap
->dpb
.high_cluster
= 64000;
192 heap
->dpb
.sectors_in_FAT
= 1;
193 heap
->dpb
.start_dir
= 1;
194 heap
->dpb
.driver_head
= 0;
195 heap
->dpb
.media_ID
= (drive
> 1) ? 0xF8 : 0xF0;
196 heap
->dpb
.access_flag
= 0;
198 heap
->dpb
.free_search
= 0;
199 heap
->dpb
.free_clusters
= 0xFFFF; /* unknown */
201 AL_reg(context
) = 0x00;
202 DS_reg(context
) = SELECTOROF(dpbsegptr
);
203 BX_reg(context
) = OFFSETOF(dpbsegptr
);
208 static void ioctlGetDeviceInfo( CONTEXT
*context
)
211 dprintf_int (stddeb
, "int21: ioctl (%d, GetDeviceInfo)\n", BX_reg(context
));
213 curr_drive
= DRIVE_GetCurrentDrive();
214 DX_reg(context
) = 0x0140 + curr_drive
+ ((curr_drive
> 1) ? 0x0800 : 0); /* no floppy */
215 /* bits 0-5 are current drive
216 * bit 6 - file has NOT been written..FIXME: correct?
217 * bit 8 - generate int24 if no diskspace on write/ read past end of file
218 * bit 11 - media not removable
220 RESET_CFLAG(context
);
223 static BOOL32
ioctlGenericBlkDevReq( CONTEXT
*context
)
225 BYTE
*dataptr
= PTR_SEG_OFF_TO_LIN(DS_reg(context
), DX_reg(context
));
226 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
228 if (!DRIVE_IsValid(drive
))
230 DOS_ERROR( ER_FileNotFound
, EC_NotFound
, SA_Abort
, EL_Disk
);
234 if (CH_reg(context
) != 0x08)
236 INT_BARF( context
, 0x21 );
240 switch (CL_reg(context
))
242 case 0x4a: /* lock logical volume */
243 dprintf_int(stddeb
,"int21: lock logical volume (%d) level %d mode %d\n",drive
,BH_reg(context
),DX_reg(context
));
246 case 0x60: /* get device parameters */
247 /* used by w4wgrp's winfile */
248 memset(dataptr
, 0, 0x26);
250 dataptr
[6] = 0; /* media type */
253 dataptr
[1] = 0x05; /* fixed disk */
254 setword(&dataptr
[2], 0x01); /* non removable */
255 setword(&dataptr
[4], 0x300); /* # of cylinders */
259 dataptr
[1] = 0x07; /* block dev, floppy */
260 setword(&dataptr
[2], 0x02); /* removable */
261 setword(&dataptr
[4], 80); /* # of cylinders */
263 CreateBPB(drive
, &dataptr
[7]);
264 RESET_CFLAG(context
);
267 case 0x66:/* get disk serial number */
269 char label
[12],fsname
[9],path
[4];
272 strcpy(path
,"x:\\");path
[0]=drive
+'A';
273 GetVolumeInformation32A(
274 path
,label
,12,&serial
,NULL
,NULL
,fsname
,9
277 memcpy(dataptr
+2,&serial
,4);
278 memcpy(dataptr
+6,label
,11);
279 memcpy(dataptr
+17,fsname
,8);
284 dprintf_int(stddeb
,"int21: logical volume %d unlocked.\n",drive
);
288 INT_BARF( context
, 0x21 );
293 static void INT21_GetSystemDate( CONTEXT
*context
)
296 GetLocalTime( &systime
);
297 CX_reg(context
) = systime
.wYear
;
298 DX_reg(context
) = (systime
.wMonth
<< 8) | systime
.wDay
;
299 AX_reg(context
) = systime
.wDayOfWeek
;
302 static void INT21_GetSystemTime( CONTEXT
*context
)
305 GetLocalTime( &systime
);
306 CX_reg(context
) = (systime
.wHour
<< 8) | systime
.wMinute
;
307 DX_reg(context
) = (systime
.wSecond
<< 8) | (systime
.wMilliseconds
/ 10);
310 static BOOL32
INT21_CreateFile( CONTEXT
*context
)
312 AX_reg(context
) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context
),
313 DX_reg(context
) ), CX_reg(context
) );
314 return (AX_reg(context
) == (WORD
)HFILE_ERROR16
);
318 static void OpenExistingFile( CONTEXT
*context
)
320 AX_reg(context
) = _lopen16( PTR_SEG_OFF_TO_LIN(DS_reg(context
),DX_reg(context
)),
322 if (AX_reg(context
) == (WORD
)HFILE_ERROR16
)
324 AX_reg(context
) = DOS_ExtendedError
;
333 switch (AX_reg(context
) & 0x0070)
335 case 0x00: /* compatability mode */
336 case 0x40: /* DENYNONE */
340 case 0x30: /* DENYREAD */
342 "OpenExistingFile (%s): DENYREAD changed to DENYALL\n",
343 (char *)PTR_SEG_OFF_TO_LIN(DS_reg(context
),DX_reg(context
)));
344 case 0x10: /* DENYALL */
348 case 0x20: /* DENYWRITE */
359 int result
,retries
=sharing_retries
;
361 #if defined(__svr4__) || defined(_SCO_DS)
362 printf("Should call flock and needs porting to lockf\n");
366 result
= flock(handle
, lock
| LOCK_NB
);
368 if ( retries
&& (!result
) )
371 for(i
=0;i
<32768*((int)sharing_pause
);i
++)
372 result
++; /* stop the optimizer */
373 for(i
=0;i
<32768*((int)sharing_pause
);i
++)
377 while( (!result
) && (!(retries
--)) );
382 AX_reg(context
) = DOS_ExtendedError
;
391 AX_reg(context
) = handle
;
392 RESET_CFLAG(context
);
397 static void CloseFile( CONTEXT
*context
)
399 if ((AX_reg(context
) = _lclose16( BX_reg(context
) )) != 0)
401 AX_reg(context
) = DOS_ExtendedError
;
406 static BOOL32
INT21_ExtendedOpenCreateFile(CONTEXT
*context
)
408 BOOL32 bExtendedError
= FALSE
;
409 BYTE action
= DL_reg(context
);
411 /* Shuffle arguments to call OpenExistingFile */
412 AL_reg(context
) = BL_reg(context
);
413 DX_reg(context
) = SI_reg(context
);
414 /* BX,CX and DX should be preserved */
415 OpenExistingFile(context
);
417 if ((EFL_reg(context
) & 0x0001) == 0) /* File exists */
419 UINT16 uReturnCX
= 0;
421 /* Now decide what do do */
423 if ((action
& 0x07) == 0)
425 BX_reg(context
) = AX_reg(context
);
427 AX_reg(context
) = 0x0050; /*File exists*/
429 dprintf_int(stddeb
, "int21: extended open/create: failed because file exists \n");
431 else if ((action
& 0x07) == 2)
433 /* Truncate it, but first check if opened for write */
434 if ((BL_reg(context
) & 0x0007)== 0)
436 BX_reg(context
) = AX_reg(context
);
438 dprintf_int(stddeb
, "int21: extended open/create: failed, trunc on ro file");
439 AX_reg(context
) = 0x000C; /*Access code invalid*/
444 /* Shuffle arguments to call CloseFile while
445 * preserving BX and DX */
447 dprintf_int(stddeb
, "int21: extended open/create: Closing before truncate\n");
448 BX_reg(context
) = AX_reg(context
);
450 if (EFL_reg(context
) & 0x0001)
452 dprintf_int(stddeb
, "int21: extended open/create: close before trunc failed");
453 AX_reg(context
) = 0x0019; /*Seek Error*/
457 /* Shuffle arguments to call CreateFile */
459 dprintf_int(stddeb
, "int21: extended open/create: Truncating\n");
460 AL_reg(context
) = BL_reg(context
);
461 /* CX is still the same */
462 DX_reg(context
) = SI_reg(context
);
463 bExtendedError
= INT21_CreateFile(context
);
465 if (EFL_reg(context
) & 0x0001) /*no file open, flags set */
467 dprintf_int(stddeb
, "int21: extended open/create: trunc failed");
468 return bExtendedError
;
473 else uReturnCX
= 0x1;
475 CX_reg(context
) = uReturnCX
;
477 else /* file does not exist */
479 RESET_CFLAG(context
); /* was set by OpenExistingFile(context) */
480 if ((action
& 0xF0)== 0)
484 dprintf_int(stddeb
, "int21: extended open/create: failed, file dosen't exist\n");
488 /* Shuffle arguments to call CreateFile */
489 dprintf_int(stddeb
, "int21: extended open/create: Creating\n");
490 AL_reg(context
) = BL_reg(context
);
491 /* CX should still be the same */
492 DX_reg(context
) = SI_reg(context
);
493 bExtendedError
= INT21_CreateFile(context
);
494 if (EFL_reg(context
) & 0x0001) /*no file open, flags set */
496 dprintf_int(stddeb
, "int21: extended open/create: create failed\n");
497 return bExtendedError
;
503 return bExtendedError
;
507 static BOOL32
INT21_ChangeDir( CONTEXT
*context
)
510 char *dirname
= PTR_SEG_OFF_TO_LIN(DS_reg(context
),DX_reg(context
));
512 dprintf_int(stddeb
,"int21: changedir %s\n", dirname
);
513 if (dirname
[0] && (dirname
[1] == ':'))
515 drive
= toupper(dirname
[0]) - 'A';
518 else drive
= DRIVE_GetCurrentDrive();
519 return DRIVE_Chdir( drive
, dirname
);
523 static int INT21_FindFirst( CONTEXT
*context
)
527 DOS_FULL_NAME full_name
;
528 FINDFILE_DTA
*dta
= (FINDFILE_DTA
*)GetCurrentDTA();
530 path
= (const char *)PTR_SEG_OFF_TO_LIN(DS_reg(context
), DX_reg(context
));
531 dta
->unixPath
= NULL
;
532 if (!DOSFS_GetFullName( path
, FALSE
, &full_name
))
534 AX_reg(context
) = DOS_ExtendedError
;
538 dta
->unixPath
= xstrdup( full_name
.long_name
);
539 p
= strrchr( dta
->unixPath
, '/' );
542 /* Note: terminating NULL in dta->mask overwrites dta->search_attr
543 * (doesn't matter as it is set below anyway)
545 if (!DOSFS_ToDosFCBFormat( p
+ 1, dta
->mask
))
547 free( dta
->unixPath
);
548 dta
->unixPath
= NULL
;
549 DOS_ERROR( ER_FileNotFound
, EC_NotFound
, SA_Abort
, EL_Disk
);
550 AX_reg(context
) = ER_FileNotFound
;
554 dta
->drive
= (path
[0] && (path
[1] == ':')) ? toupper(path
[0]) - 'A'
555 : DRIVE_GetCurrentDrive();
557 dta
->search_attr
= CL_reg(context
);
562 static int INT21_FindNext( CONTEXT
*context
)
564 FINDFILE_DTA
*dta
= (FINDFILE_DTA
*)GetCurrentDTA();
565 WIN32_FIND_DATA32A entry
;
568 if (!dta
->unixPath
) return 0;
569 if (!(count
= DOSFS_FindNext( dta
->unixPath
, dta
->mask
, NULL
, dta
->drive
,
570 dta
->search_attr
, dta
->count
, &entry
)))
572 free( dta
->unixPath
);
573 dta
->unixPath
= NULL
;
576 if ((int)dta
->count
+ count
> 0xffff)
578 fprintf( stderr
, "Too many directory entries in %s\n", dta
->unixPath
);
579 free( dta
->unixPath
);
580 dta
->unixPath
= NULL
;
584 dta
->fileattr
= entry
.dwFileAttributes
;
585 dta
->filesize
= entry
.nFileSizeLow
;
586 FileTimeToDosDateTime( &entry
.ftLastWriteTime
,
587 &dta
->filedate
, &dta
->filetime
);
588 strcpy( dta
->filename
, entry
.cAlternateFileName
);
593 static BOOL32
INT21_CreateTempFile( CONTEXT
*context
)
595 static int counter
= 0;
596 char *name
= PTR_SEG_OFF_TO_LIN( DS_reg(context
), DX_reg(context
) );
597 char *p
= name
+ strlen(name
);
601 sprintf( p
, "wine%04x.%03d", (int)getpid(), counter
);
602 counter
= (counter
+ 1) % 1000;
604 if ((AX_reg(context
) = _lcreat_uniq( name
, 0 )) != (WORD
)HFILE_ERROR16
)
606 dprintf_int( stddeb
, "INT21_CreateTempFile: created %s\n", name
);
609 if (DOS_ExtendedError
!= ER_FileExists
) return FALSE
;
614 static BOOL32
INT21_GetCurrentDirectory( CONTEXT
*context
)
616 int drive
= DOS_GET_DRIVE( DL_reg(context
) );
617 char *ptr
= (char *)PTR_SEG_OFF_TO_LIN( DS_reg(context
), SI_reg(context
) );
619 if (!DRIVE_IsValid(drive
))
621 DOS_ERROR( ER_InvalidDrive
, EC_NotFound
, SA_Abort
, EL_Disk
);
624 lstrcpyn32A( ptr
, DRIVE_GetDosCwd(drive
), 64 );
625 AX_reg(context
) = 0x0100; /* success return code */
630 static int INT21_GetDiskSerialNumber( CONTEXT
*context
)
632 BYTE
*dataptr
= PTR_SEG_OFF_TO_LIN(DS_reg(context
), DX_reg(context
));
633 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
635 if (!DRIVE_IsValid(drive
))
637 DOS_ERROR( ER_InvalidDrive
, EC_NotFound
, SA_Abort
, EL_Disk
);
641 *(WORD
*)dataptr
= 0;
642 *(DWORD
*)(dataptr
+ 2) = DRIVE_GetSerialNumber( drive
);
643 memcpy( dataptr
+ 6, DRIVE_GetLabel( drive
), 11 );
644 strncpy(dataptr
+ 0x11, "FAT16 ", 8);
649 static int INT21_SetDiskSerialNumber( CONTEXT
*context
)
651 BYTE
*dataptr
= PTR_SEG_OFF_TO_LIN(DS_reg(context
), DX_reg(context
));
652 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
654 if (!DRIVE_IsValid(drive
))
656 DOS_ERROR( ER_InvalidDrive
, EC_NotFound
, SA_Abort
, EL_Disk
);
660 DRIVE_SetSerialNumber( drive
, *(DWORD
*)(dataptr
+ 2) );
665 /* microsoft's programmers should be shot for using CP/M style int21
666 calls in Windows for Workgroup's winfile.exe */
668 static int INT21_FindFirstFCB( CONTEXT
*context
)
670 BYTE
*fcb
= (BYTE
*)PTR_SEG_OFF_TO_LIN(DS_reg(context
), DX_reg(context
));
675 if (*fcb
== 0xff) pFCB
= (FINDFILE_FCB
*)(fcb
+ 7);
676 else pFCB
= (FINDFILE_FCB
*)fcb
;
677 drive
= DOS_GET_DRIVE( pFCB
->drive
);
678 root
= DRIVE_GetRoot( drive
);
679 cwd
= DRIVE_GetUnixCwd( drive
);
680 pFCB
->unixPath
= HeapAlloc( GetProcessHeap(), 0,
681 strlen(root
)+strlen(cwd
)+2 );
682 if (!pFCB
->unixPath
) return 0;
683 strcpy( pFCB
->unixPath
, root
);
684 strcat( pFCB
->unixPath
, "/" );
685 strcat( pFCB
->unixPath
, cwd
);
691 static int INT21_FindNextFCB( CONTEXT
*context
)
693 BYTE
*fcb
= (BYTE
*)PTR_SEG_OFF_TO_LIN(DS_reg(context
), DX_reg(context
));
695 DOS_DIRENTRY_LAYOUT
*pResult
= (DOS_DIRENTRY_LAYOUT
*)GetCurrentDTA();
696 WIN32_FIND_DATA32A entry
;
703 pFCB
= (FINDFILE_FCB
*)(fcb
+ 7);
708 pFCB
= (FINDFILE_FCB
*)fcb
;
711 if (!pFCB
->unixPath
) return 0;
712 if (!(count
= DOSFS_FindNext( pFCB
->unixPath
, pFCB
->filename
, NULL
,
713 DOS_GET_DRIVE( pFCB
->drive
), attr
,
714 pFCB
->count
, &entry
)))
716 HeapFree( GetProcessHeap(), 0, pFCB
->unixPath
);
717 pFCB
->unixPath
= NULL
;
720 pFCB
->count
+= count
;
722 pResult
->fileattr
= entry
.dwFileAttributes
;
723 pResult
->cluster
= 0; /* what else? */
724 pResult
->filesize
= entry
.nFileSizeLow
;
725 memset( pResult
->reserved
, 0, sizeof(pResult
->reserved
) );
726 FileTimeToDosDateTime( &entry
.ftLastWriteTime
,
727 &pResult
->filedate
, &pResult
->filetime
);
729 /* Convert file name to FCB format */
731 memset( pResult
->filename
, ' ', sizeof(pResult
->filename
) );
732 if (!strcmp( entry
.cAlternateFileName
, "." )) pResult
->filename
[0] = '.';
733 else if (!strcmp( entry
.cAlternateFileName
, ".." ))
734 pResult
->filename
[0] = pResult
->filename
[1] = '.';
737 char *p
= strrchr( entry
.cAlternateFileName
, '.' );
738 if (p
&& p
[1] && (p
!= entry
.cAlternateFileName
))
740 memcpy( pResult
->filename
, entry
.cAlternateFileName
,
741 MIN( (p
- entry
.cAlternateFileName
), 8 ) );
742 memcpy( pResult
->filename
+ 8, p
+ 1, MIN( strlen(p
), 3 ) );
745 memcpy( pResult
->filename
, entry
.cAlternateFileName
,
746 MIN( strlen(entry
.cAlternateFileName
), 8 ) );
752 static void DeleteFileFCB( CONTEXT
*context
)
754 fprintf( stderr
, "DeleteFileFCB: not implemented yet\n" );
757 static void RenameFileFCB( CONTEXT
*context
)
759 fprintf( stderr
, "RenameFileFCB: not implemented yet\n" );
764 static void fLock( CONTEXT
* context
)
767 switch ( AX_reg(context
) & 0xff )
769 case 0x00: /* LOCK */
770 if (!LockFile(BX_reg(context
),
771 MAKELONG(DX_reg(context
),CX_reg(context
)), 0,
772 MAKELONG(DI_reg(context
),SI_reg(context
)), 0)) {
773 AX_reg(context
) = DOS_ExtendedError
;
778 case 0x01: /* UNLOCK */
779 if (!UnlockFile(BX_reg(context
),
780 MAKELONG(DX_reg(context
),CX_reg(context
)), 0,
781 MAKELONG(DI_reg(context
),SI_reg(context
)), 0)) {
782 AX_reg(context
) = DOS_ExtendedError
;
787 AX_reg(context
) = 0x0001;
794 extern void LOCAL_PrintHeap (WORD ds
);
796 /***********************************************************************
797 * DOS3Call (KERNEL.102)
799 void WINAPI
DOS3Call( CONTEXT
*context
)
801 BOOL32 bSetDOSExtendedError
= FALSE
;
803 dprintf_int( stddeb
, "int21: AX=%04x BX=%04x CX=%04x DX=%04x "
804 "SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
805 AX_reg(context
), BX_reg(context
), CX_reg(context
),
806 DX_reg(context
), SI_reg(context
), DI_reg(context
),
807 (WORD
)DS_reg(context
), (WORD
)ES_reg(context
),
810 if (AH_reg(context
) == 0x59) /* Get extended error info */
812 AX_reg(context
) = DOS_ExtendedError
;
813 BH_reg(context
) = DOS_ErrorClass
;
814 BL_reg(context
) = DOS_ErrorAction
;
815 CH_reg(context
) = DOS_ErrorLocus
;
819 DOS_ERROR( 0, 0, 0, 0 );
820 RESET_CFLAG(context
); /* Not sure if this is a good idea */
822 switch(AH_reg(context
))
824 case 0x00: /* TERMINATE PROGRAM */
825 TASK_KillCurrentTask( 0 );
828 case 0x01: /* READ CHARACTER FROM STANDARD INPUT, WITH ECHO */
829 case 0x02: /* WRITE CHARACTER TO STANDARD OUTPUT */
830 case 0x03: /* READ CHARACTER FROM STDAUX */
831 case 0x04: /* WRITE CHARACTER TO STDAUX */
832 case 0x05: /* WRITE CHARACTER TO PRINTER */
833 case 0x06: /* DIRECT CONSOLE IN/OUTPUT */
834 case 0x07: /* DIRECT CHARACTER INPUT, WITHOUT ECHO */
835 case 0x08: /* CHARACTER INPUT WITHOUT ECHO */
836 case 0x09: /* WRITE STRING TO STANDARD OUTPUT */
837 case 0x0a: /* BUFFERED INPUT */
838 case 0x0b: /* GET STDIN STATUS */
839 case 0x0c: /* FLUSH BUFFER AND READ STANDARD INPUT */
840 case 0x0f: /* OPEN FILE USING FCB */
841 case 0x10: /* CLOSE FILE USING FCB */
842 case 0x14: /* SEQUENTIAL READ FROM FCB FILE */
843 case 0x15: /* SEQUENTIAL WRITE TO FCB FILE */
844 case 0x16: /* CREATE OR TRUNCATE FILE USING FCB */
845 case 0x21: /* READ RANDOM RECORD FROM FCB FILE */
846 case 0x22: /* WRITE RANDOM RECORD TO FCB FILE */
847 case 0x23: /* GET FILE SIZE FOR FCB */
848 case 0x24: /* SET RANDOM RECORD NUMBER FOR FCB */
849 case 0x26: /* CREATE NEW PROGRAM SEGMENT PREFIX */
850 case 0x27: /* RANDOM BLOCK READ FROM FCB FILE */
851 case 0x28: /* RANDOM BLOCK WRITE TO FCB FILE */
852 case 0x29: /* PARSE FILENAME INTO FCB */
853 case 0x2e: /* SET VERIFY FLAG */
854 case 0x37: /* "SWITCHAR" - GET SWITCH CHARACTER
855 "SWITCHAR" - SET SWITCH CHARACTER
856 "AVAILDEV" - SPECIFY \DEV\ PREFIX USE */
857 case 0x54: /* GET VERIFY FLAG */
858 INT_BARF( context
, 0x21 );
861 case 0x18: /* NULL FUNCTIONS FOR CP/M COMPATIBILITY */
865 case 0x6b: /* NULL FUNCTION */
869 case 0x5c: /* "FLOCK" - RECORD LOCKING */
873 case 0x0d: /* DISK BUFFER FLUSH */
874 RESET_CFLAG(context
); /* dos 6+ only */
877 case 0x0e: /* SELECT DEFAULT DRIVE */
878 DRIVE_SetCurrentDrive( DL_reg(context
) );
879 AL_reg(context
) = MAX_DOS_DRIVES
;
882 case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
883 if (!INT21_FindFirstFCB(context
))
885 AL_reg(context
) = 0xff;
888 /* else fall through */
890 case 0x12: /* FIND NEXT MATCHING FILE USING FCB */
891 AL_reg(context
) = INT21_FindNextFCB(context
) ? 0x00 : 0xff;
894 case 0x13: /* DELETE FILE USING FCB */
895 DeleteFileFCB(context
);
898 case 0x17: /* RENAME FILE USING FCB */
899 RenameFileFCB(context
);
902 case 0x19: /* GET CURRENT DEFAULT DRIVE */
903 AL_reg(context
) = DRIVE_GetCurrentDrive();
906 case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
908 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
909 pTask
->dta
= PTR_SEG_OFF_TO_SEGPTR(DS_reg(context
),DX_reg(context
));
910 dprintf_int(stddeb
, "int21: Set DTA: %08lx\n", pTask
->dta
);
914 case 0x1b: /* GET ALLOCATION INFORMATION FOR DEFAULT DRIVE */
916 if (!INT21_GetDriveAllocInfo(context
)) AX_reg(context
) = 0xffff;
919 case 0x1c: /* GET ALLOCATION INFORMATION FOR SPECIFIC DRIVE */
920 if (!INT21_GetDriveAllocInfo(context
)) AX_reg(context
) = 0xffff;
923 case 0x1f: /* GET DRIVE PARAMETER BLOCK FOR DEFAULT DRIVE */
924 GetDrivePB(context
, DRIVE_GetCurrentDrive());
927 case 0x25: /* SET INTERRUPT VECTOR */
928 INT_SetHandler( AL_reg(context
),
929 (FARPROC16
)PTR_SEG_OFF_TO_SEGPTR( DS_reg(context
),
933 case 0x2a: /* GET SYSTEM DATE */
934 INT21_GetSystemDate(context
);
937 case 0x2b: /* SET SYSTEM DATE */
938 fprintf( stdnimp
, "SetSystemDate(%02d/%02d/%04d): not allowed\n",
939 DL_reg(context
), DH_reg(context
), CX_reg(context
) );
940 AL_reg(context
) = 0; /* Let's pretend we succeeded */
943 case 0x2c: /* GET SYSTEM TIME */
944 INT21_GetSystemTime(context
);
947 case 0x2d: /* SET SYSTEM TIME */
948 fprintf( stdnimp
, "SetSystemTime(%02d:%02d:%02d.%02d): not allowed\n",
949 CH_reg(context
), CL_reg(context
),
950 DH_reg(context
), DL_reg(context
) );
951 AL_reg(context
) = 0; /* Let's pretend we succeeded */
954 case 0x2f: /* GET DISK TRANSFER AREA ADDRESS */
956 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
957 ES_reg(context
) = SELECTOROF( pTask
->dta
);
958 BX_reg(context
) = OFFSETOF( pTask
->dta
);
962 case 0x30: /* GET DOS VERSION */
963 AX_reg(context
) = (HIWORD(GetVersion16()) >> 8) |
964 (HIWORD(GetVersion16()) << 8);
965 BX_reg(context
) = 0x0012; /* 0x123456 is Wine's serial # */
966 CX_reg(context
) = 0x3456;
969 case 0x31: /* TERMINATE AND STAY RESIDENT */
970 INT_BARF( context
, 0x21 );
973 case 0x32: /* GET DOS DRIVE PARAMETER BLOCK FOR SPECIFIC DRIVE */
974 GetDrivePB(context
, DOS_GET_DRIVE( DL_reg(context
) ) );
977 case 0x33: /* MULTIPLEXED */
978 switch (AL_reg(context
))
980 case 0x00: /* GET CURRENT EXTENDED BREAK STATE */
984 case 0x01: /* SET EXTENDED BREAK STATE */
987 case 0x02: /* GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE*/
991 case 0x05: /* GET BOOT DRIVE */
993 /* c: is Wine's bootdrive (a: is 1)*/
996 case 0x06: /* GET TRUE VERSION NUMBER */
997 BX_reg(context
) = (HIWORD(GetVersion16() >> 8)) |
998 (HIWORD(GetVersion16() << 8));
999 DX_reg(context
) = 0x00;
1003 INT_BARF( context
, 0x21 );
1008 case 0x34: /* GET ADDRESS OF INDOS FLAG */
1009 if (!heap
) INT21_CreateHeap();
1010 ES_reg(context
) = DosHeapHandle
;
1011 BX_reg(context
) = (int)&heap
->InDosFlag
- (int)heap
;
1014 case 0x35: /* GET INTERRUPT VECTOR */
1016 FARPROC16 addr
= INT_GetHandler( AL_reg(context
) );
1017 ES_reg(context
) = SELECTOROF(addr
);
1018 BX_reg(context
) = OFFSETOF(addr
);
1022 case 0x36: /* GET FREE DISK SPACE */
1023 if (!INT21_GetFreeDiskSpace(context
)) AX_reg(context
) = 0xffff;
1026 case 0x38: /* GET COUNTRY-SPECIFIC INFORMATION */
1027 AX_reg(context
) = 0x02; /* no country support available */
1031 case 0x39: /* "MKDIR" - CREATE SUBDIRECTORY */
1032 bSetDOSExtendedError
= (!CreateDirectory16( PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1033 DX_reg(context
) ), NULL
));
1036 case 0x3a: /* "RMDIR" - REMOVE SUBDIRECTORY */
1037 bSetDOSExtendedError
= (!RemoveDirectory16( PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1038 DX_reg(context
) )));
1041 case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */
1042 bSetDOSExtendedError
= !INT21_ChangeDir(context
);
1045 case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
1046 AX_reg(context
) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1047 DX_reg(context
) ), CX_reg(context
) );
1048 bSetDOSExtendedError
= (AX_reg(context
) == (WORD
)HFILE_ERROR16
);
1051 case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
1052 OpenExistingFile(context
);
1055 case 0x3e: /* "CLOSE" - CLOSE FILE */
1056 bSetDOSExtendedError
= ((AX_reg(context
) = _lclose16( BX_reg(context
) )) != 0);
1059 case 0x3f: /* "READ" - READ FROM FILE OR DEVICE */
1061 LONG result
= WIN16_hread( BX_reg(context
),
1062 PTR_SEG_OFF_TO_SEGPTR( DS_reg(context
),
1065 if (result
== -1) bSetDOSExtendedError
= TRUE
;
1066 else AX_reg(context
) = (WORD
)result
;
1070 case 0x40: /* "WRITE" - WRITE TO FILE OR DEVICE */
1072 LONG result
= _hwrite16( BX_reg(context
),
1073 PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1076 if (result
== -1) bSetDOSExtendedError
= TRUE
;
1077 else AX_reg(context
) = (WORD
)result
;
1081 case 0x41: /* "UNLINK" - DELETE FILE */
1082 bSetDOSExtendedError
= (!DeleteFile32A( PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1083 DX_reg(context
) )));
1086 case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
1088 LONG status
= _llseek16( BX_reg(context
),
1089 MAKELONG(DX_reg(context
),CX_reg(context
)),
1091 if (status
== -1) bSetDOSExtendedError
= TRUE
;
1094 AX_reg(context
) = LOWORD(status
);
1095 DX_reg(context
) = HIWORD(status
);
1100 case 0x43: /* FILE ATTRIBUTES */
1101 switch (AL_reg(context
))
1104 AX_reg(context
) = (WORD
)GetFileAttributes32A(
1105 PTR_SEG_OFF_TO_LIN(DS_reg(context
),
1107 if (AX_reg(context
) == 0xffff) bSetDOSExtendedError
= TRUE
;
1108 else CX_reg(context
) = AX_reg(context
);
1112 bSetDOSExtendedError
=
1113 (!SetFileAttributes32A( PTR_SEG_OFF_TO_LIN(DS_reg(context
),
1120 case 0x44: /* IOCTL */
1121 switch (AL_reg(context
))
1124 ioctlGetDeviceInfo(context
);
1129 case 0x05:{ /* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */
1130 BYTE
*dataptr
= PTR_SEG_OFF_TO_LIN(DS_reg(context
),DX_reg(context
));
1132 int drive
= DOS_GET_DRIVE(BL_reg(context
));
1134 fprintf(stdnimp
,"int21: program tried to write to block device control channel of drive %d:\n",drive
);
1135 for (i
=0;i
<CX_reg(context
);i
++)
1136 fprintf(stdnimp
,"%02x ",dataptr
[i
]);
1137 fprintf(stdnimp
,"\n");
1138 AX_reg(context
)=CX_reg(context
);
1141 case 0x08: /* Check if drive is removable. */
1142 switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context
) )))
1144 case DRIVE_CANNOTDETERMINE
:
1145 DOS_ERROR( ER_InvalidDrive
, EC_NotFound
, SA_Abort
, EL_Disk
);
1146 AX_reg(context
) = ER_InvalidDrive
;
1149 case DRIVE_REMOVABLE
:
1150 AX_reg(context
) = 0; /* removable */
1153 AX_reg(context
) = 1; /* not removable */
1158 case 0x09: /* CHECK IF BLOCK DEVICE REMOTE */
1159 switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context
) )))
1161 case DRIVE_CANNOTDETERMINE
:
1162 DOS_ERROR( ER_InvalidDrive
, EC_NotFound
, SA_Abort
, EL_Disk
);
1163 AX_reg(context
) = ER_InvalidDrive
;
1167 DX_reg(context
) = (1<<9) | (1<<12); /* remote */
1170 DX_reg(context
) = 0; /* FIXME: use driver attr here */
1175 case 0x0a: /* check if handle (BX) is remote */
1176 /* returns DX, bit 15 set if remote, bit 14 set if date/time
1179 DX_reg(context
) = 0;
1182 case 0x0b: /* SET SHARING RETRY COUNT */
1183 if (!CX_reg(context
))
1185 AX_reg(context
) = 1;
1189 sharing_pause
= CX_reg(context
);
1190 if (!DX_reg(context
))
1191 sharing_retries
= DX_reg(context
);
1192 RESET_CFLAG(context
);
1196 bSetDOSExtendedError
= ioctlGenericBlkDevReq(context
);
1199 case 0x0e: /* get logical drive mapping */
1200 AL_reg(context
) = 0; /* drive has no mapping */
1203 case 0x0F: /* Set logical drive mapping */
1204 /* FIXME: Not implemented at the moment, always returns error
1206 INT_BARF( context
, 0x21 );
1207 AX_reg(context
) = 0x0001; /* invalid function */
1212 INT_BARF( context
, 0x21 );
1217 case 0x45: /* "DUP" - DUPLICATE FILE HANDLE */
1218 bSetDOSExtendedError
= ((AX_reg(context
) = FILE_Dup(BX_reg(context
))) == (WORD
)HFILE_ERROR16
);
1221 case 0x46: /* "DUP2", "FORCEDUP" - FORCE DUPLICATE FILE HANDLE */
1222 bSetDOSExtendedError
= (FILE_Dup2( BX_reg(context
), CX_reg(context
) ) == HFILE_ERROR32
);
1225 case 0x47: /* "CWD" - GET CURRENT DIRECTORY */
1226 bSetDOSExtendedError
= !INT21_GetCurrentDirectory(context
);
1229 case 0x48: /* ALLOCATE MEMORY */
1230 case 0x49: /* FREE MEMORY */
1231 case 0x4a: /* RESIZE MEMORY BLOCK */
1232 INT_BARF( context
, 0x21 );
1235 case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
1236 AX_reg(context
) = WinExec16( PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1239 if (AX_reg(context
) < 32) SET_CFLAG(context
);
1242 case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
1243 TASK_KillCurrentTask( AL_reg(context
) );
1246 case 0x4d: /* GET RETURN CODE */
1247 AX_reg(context
) = 0; /* normal exit */
1250 case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
1251 if (!INT21_FindFirst(context
)) break;
1254 case 0x4f: /* "FINDNEXT" - FIND NEXT MATCHING FILE */
1255 if (!INT21_FindNext(context
))
1257 DOS_ERROR( ER_NoMoreFiles
, EC_MediaError
, SA_Abort
, EL_Disk
);
1258 AX_reg(context
) = ER_NoMoreFiles
;
1263 case 0x51: /* GET PSP ADDRESS */
1264 case 0x62: /* GET PSP ADDRESS */
1265 /* FIXME: should we return the original DOS PSP upon */
1266 /* Windows startup ? */
1267 BX_reg(context
) = GetCurrentPDB();
1270 case 0x52: /* "SYSVARS" - GET LIST OF LISTS */
1271 ES_reg(context
) = 0x0;
1272 BX_reg(context
) = 0x0;
1273 INT_BARF( context
, 0x21 );
1276 case 0x56: /* "RENAME" - RENAME FILE */
1277 bSetDOSExtendedError
=
1278 (!MoveFile32A( PTR_SEG_OFF_TO_LIN(DS_reg(context
),DX_reg(context
)),
1279 PTR_SEG_OFF_TO_LIN(ES_reg(context
),DI_reg(context
))));
1282 case 0x57: /* FILE DATE AND TIME */
1283 switch (AL_reg(context
))
1285 case 0x00: /* Get */
1288 if (!GetFileTime( BX_reg(context
), NULL
, NULL
, &filetime
))
1289 bSetDOSExtendedError
= TRUE
;
1290 else FileTimeToDosDateTime( &filetime
, &DX_reg(context
),
1295 case 0x01: /* Set */
1298 DosDateTimeToFileTime( DX_reg(context
), CX_reg(context
),
1300 bSetDOSExtendedError
=
1301 (!SetFileTime( BX_reg(context
), NULL
, NULL
, &filetime
));
1307 case 0x58: /* GET OR SET MEMORY/UMB ALLOCATION STRATEGY */
1308 switch (AL_reg(context
))
1311 AX_reg(context
) = 1;
1314 AX_reg(context
) = 0;
1320 RESET_CFLAG(context
);
1323 case 0x5a: /* CREATE TEMPORARY FILE */
1324 bSetDOSExtendedError
= !INT21_CreateTempFile(context
);
1327 case 0x5b: /* CREATE NEW FILE */
1328 bSetDOSExtendedError
= ((AX_reg(context
) =
1329 _lcreat_uniq( PTR_SEG_OFF_TO_LIN(DS_reg(context
),DX_reg(context
)), 0 ))
1330 == (WORD
)HFILE_ERROR16
);
1333 case 0x5d: /* NETWORK */
1335 /* network software not installed */
1336 DOS_ERROR( ER_NoNetwork
, EC_NotFound
, SA_Abort
, EL_Network
);
1337 bSetDOSExtendedError
= TRUE
;
1340 case 0x5f: /* NETWORK */
1341 switch (AL_reg(context
))
1343 case 0x07: /* ENABLE DRIVE */
1344 if (!DRIVE_Enable( DL_reg(context
) ))
1346 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
1347 bSetDOSExtendedError
= TRUE
;
1351 case 0x08: /* DISABLE DRIVE */
1352 if (!DRIVE_Disable( DL_reg(context
) ))
1354 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
1355 bSetDOSExtendedError
= TRUE
;
1360 /* network software not installed */
1361 DOS_ERROR( ER_NoNetwork
, EC_NotFound
, SA_Abort
, EL_Network
);
1362 bSetDOSExtendedError
= TRUE
;
1367 case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
1369 if (!GetFullPathName32A( PTR_SEG_OFF_TO_LIN(DS_reg(context
),
1370 SI_reg(context
)), 128,
1371 PTR_SEG_OFF_TO_LIN(ES_reg(context
),
1372 DI_reg(context
)),NULL
))
1373 bSetDOSExtendedError
= TRUE
;
1374 else AX_reg(context
) = 0;
1378 case 0x61: /* UNUSED */
1379 case 0x63: /* UNUSED */
1380 case 0x64: /* OS/2 DOS BOX */
1381 INT_BARF( context
, 0x21 );
1385 case 0x65:{/* GET EXTENDED COUNTRY INFORMATION */
1386 extern WORD WINE_LanguageId
;
1387 BYTE
*dataptr
=PTR_SEG_OFF_TO_LIN(ES_reg(context
),DI_reg(context
));;
1388 switch (AL_reg(context
)) {
1391 *(WORD
*)(dataptr
+1) = 41;
1392 *(WORD
*)(dataptr
+3) = WINE_LanguageId
;
1393 *(WORD
*)(dataptr
+5) = CodePage
;
1397 *(DWORD
*)(dataptr
+1) = MAKELONG(DOSMEM_CollateTable
& 0xFFFF,DOSMEM_AllocSelector(DOSMEM_CollateTable
>>16));
1398 CX_reg(context
) = 258;/*FIXME: size of table?*/
1401 INT_BARF( context
, 0x21 );
1407 case 0x66: /* GLOBAL CODE PAGE TABLE */
1408 switch (AL_reg(context
))
1411 DX_reg(context
) = BX_reg(context
) = CodePage
;
1412 RESET_CFLAG(context
);
1415 CodePage
= BX_reg(context
);
1416 RESET_CFLAG(context
);
1421 case 0x67: /* SET HANDLE COUNT */
1422 SetHandleCount16( BX_reg(context
) );
1423 if (DOS_ExtendedError
) bSetDOSExtendedError
= TRUE
;
1426 case 0x68: /* "FFLUSH" - COMMIT FILE */
1427 case 0x6a: /* COMMIT FILE */
1428 bSetDOSExtendedError
= (!FlushFileBuffers( BX_reg(context
) ));
1431 case 0x69: /* DISK SERIAL NUMBER */
1432 switch (AL_reg(context
))
1435 if (!INT21_GetDiskSerialNumber(context
)) bSetDOSExtendedError
= TRUE
;
1436 else AX_reg(context
) = 0;
1440 if (!INT21_SetDiskSerialNumber(context
)) bSetDOSExtendedError
= TRUE
;
1441 else AX_reg(context
) = 1;
1446 case 0x6C: /* Extended Open/Create*/
1447 bSetDOSExtendedError
= INT21_ExtendedOpenCreateFile(context
);
1450 case 0x71: /* MS-DOS 7 (Windows95) - LONG FILENAME FUNCTIONS */
1451 switch(AL_reg(context
))
1453 case 0x39: /* Create directory */
1454 bSetDOSExtendedError
= (!CreateDirectory32A(
1455 PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1456 DX_reg(context
) ), NULL
));
1458 case 0x3a: /* Remove directory */
1459 bSetDOSExtendedError
= (!RemoveDirectory32A(
1460 PTR_SEG_OFF_TO_LIN( DS_reg(context
),
1461 DX_reg(context
) )));
1463 case 0x43: /* Get/Set file attributes */
1464 switch (BL_reg(context
))
1466 case 0x00: /* Get file attributes */
1467 CX_reg(context
) = (WORD
)GetFileAttributes32A(
1468 PTR_SEG_OFF_TO_LIN(DS_reg(context
),
1470 if (CX_reg(context
) == 0xffff) bSetDOSExtendedError
= TRUE
;
1473 bSetDOSExtendedError
= (!SetFileAttributes32A(
1474 PTR_SEG_OFF_TO_LIN(DS_reg(context
),
1476 CX_reg(context
) ) );
1480 "Unimplemented int21 long file name function:\n");
1481 INT_BARF( context
, 0x21 );
1483 AL_reg(context
) = 0;
1487 case 0x47: /* Get current directory */
1488 bSetDOSExtendedError
= !INT21_GetCurrentDirectory(context
);
1491 case 0x4e: /* Find first file */
1492 /* FIXME: use attributes in CX */
1493 if ((AX_reg(context
) = FindFirstFile16(
1494 PTR_SEG_OFF_TO_LIN(DS_reg(context
),DX_reg(context
)),
1495 (WIN32_FIND_DATA32A
*)PTR_SEG_OFF_TO_LIN(ES_reg(context
),
1497 == INVALID_HANDLE_VALUE16
)
1498 bSetDOSExtendedError
= TRUE
;
1500 case 0x4f: /* Find next file */
1501 if (!FindNextFile16( BX_reg(context
),
1502 (WIN32_FIND_DATA32A
*)PTR_SEG_OFF_TO_LIN(ES_reg(context
),
1504 bSetDOSExtendedError
= TRUE
;
1506 case 0xa1: /* Find close */
1507 bSetDOSExtendedError
= (!FindClose16( BX_reg(context
) ));
1512 switch(CL_reg(context
))
1514 case 0x02: /*Get canonical long filename or path */
1515 if (!GetFullPathName32A
1516 ( PTR_SEG_OFF_TO_LIN(DS_reg(context
),
1517 SI_reg(context
)), 128,
1518 PTR_SEG_OFF_TO_LIN(ES_reg(context
),
1519 DI_reg(context
)),NULL
))
1520 bSetDOSExtendedError
= TRUE
;
1521 else AX_reg(context
) = 0;
1525 "Unimplemented int21 long file name function:\n");
1526 INT_BARF( context
, 0x21 );
1528 AL_reg(context
) = 0;
1532 case 0x6c: /* Create or open file */
1533 /* translate Dos 7 action to Dos 6 action */
1534 bSetDOSExtendedError
= INT21_ExtendedOpenCreateFile(context
);
1537 case 0x3b: /* Change directory */
1538 if (!SetCurrentDirectory32A(PTR_SEG_OFF_TO_LIN(
1544 AL_reg(context
) = DOS_ExtendedError
;
1547 case 0x41: /* Delete file */
1548 if (!DeleteFile32A(PTR_SEG_OFF_TO_LIN(
1553 AL_reg(context
) = DOS_ExtendedError
;
1556 case 0x56: /* Move (rename) file */
1558 fprintf( stderr
, "Unimplemented int21 long file name function:\n");
1559 INT_BARF( context
, 0x21 );
1561 AL_reg(context
) = 0;
1566 case 0x70: /* MS-DOS 7 (Windows95) - ??? (country-specific?)*/
1567 case 0x72: /* MS-DOS 7 (Windows95) - ??? */
1568 case 0x73: /* MS-DOS 7 (Windows95) - DRIVE LOCKING ??? */
1569 dprintf_int(stddeb
,"int21: windows95 function AX %04x\n",
1571 dprintf_int(stddeb
, " returning unimplemented\n");
1573 AL_reg(context
) = 0;
1576 case 0xdc: /* CONNECTION SERVICES - GET CONNECTION NUMBER */
1577 case 0xea: /* NOVELL NETWARE - RETURN SHELL VERSION */
1581 INT_BARF( context
, 0x21 );
1584 } /* END OF SWITCH */
1586 if( bSetDOSExtendedError
) /* set general error condition */
1588 AX_reg(context
) = DOS_ExtendedError
;
1592 dprintf_int( stddeb
, "ret21: AX=%04x BX=%04x CX=%04x DX=%04x "
1593 "SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
1594 AX_reg(context
), BX_reg(context
), CX_reg(context
),
1595 DX_reg(context
), SI_reg(context
), DI_reg(context
),
1596 (WORD
)DS_reg(context
), (WORD
)ES_reg(context
),