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"
33 #ifdef HAVE_SYS_FILE_H
34 # include <sys/file.h>
37 #ifdef HAVE_SYS_TIME_H
38 # include <sys/time.h>
40 #include <sys/types.h>
53 #include "winuser.h" /* SW_NORMAL */
54 #include "wine/winbase16.h"
62 #include "wine/unicode.h"
63 #include "wine/debug.h"
65 WINE_DEFAULT_DEBUG_CHANNEL(int21
);
66 #if defined(__svr4__) || defined(_SCO_DS)
67 /* SVR4 DOESNT do locking the same way must implement properly */
74 #define DOS_GET_DRIVE(reg) ((reg) ? (reg) - 1 : DRIVE_GetCurrentDrive())
80 static struct DosHeap
*heap
;
81 static WORD DosHeapHandle
;
83 extern char TempDirectory
[];
85 static BOOL
INT21_CreateHeap(void)
87 if (!(DosHeapHandle
= GlobalAlloc16(GMEM_FIXED
,sizeof(struct DosHeap
))))
89 WARN("Out of memory\n");
92 heap
= (struct DosHeap
*) GlobalLock16(DosHeapHandle
);
93 strcpy(heap
->biosdate
, "01/01/80");
97 static BYTE
*GetCurrentDTA( CONTEXT86
*context
)
99 TDB
*pTask
= GlobalLock16(GetCurrentTask());
101 /* FIXME: This assumes DTA was set correctly! */
102 return (BYTE
*)CTX_SEG_OFF_TO_LIN( context
, SELECTOROF(pTask
->dta
),
103 (DWORD
)OFFSETOF(pTask
->dta
) );
107 static void CreateBPB(int drive
, BYTE
*data
, BOOL16 limited
)
108 /* limited == TRUE is used with INT 0x21/0x440d */
113 setword(&data
[3], 0);
115 setword(&data
[6], 240);
116 setword(&data
[8], 64000);
118 setword(&data
[0x0b], 40);
119 setword(&data
[0x0d], 56);
120 setword(&data
[0x0f], 2);
121 setword(&data
[0x11], 0);
123 setword(&data
[0x1f], 800);
125 setword(&data
[0x22], 1);
127 } else { /* 1.44mb */
130 setword(&data
[3], 0);
132 setword(&data
[6], 240);
133 setword(&data
[8], 2880);
135 setword(&data
[0x0b], 6);
136 setword(&data
[0x0d], 18);
137 setword(&data
[0x0f], 2);
138 setword(&data
[0x11], 0);
140 setword(&data
[0x1f], 80);
142 setword(&data
[0x22], 2);
147 static int INT21_GetFreeDiskSpace( CONTEXT86
*context
)
149 DWORD cluster_sectors
, sector_bytes
, free_clusters
, total_clusters
;
150 char root
[] = "A:\\";
152 *root
+= DOS_GET_DRIVE( DL_reg(context
) );
153 if (!GetDiskFreeSpaceA( root
, &cluster_sectors
, §or_bytes
,
154 &free_clusters
, &total_clusters
)) return 0;
155 SET_AX( context
, cluster_sectors
);
156 SET_BX( context
, free_clusters
);
157 SET_CX( context
, sector_bytes
);
158 SET_DX( context
, total_clusters
);
162 static int INT21_GetDriveAllocInfo( CONTEXT86
*context
)
164 if (!INT21_GetFreeDiskSpace( context
)) return 0;
165 if (!heap
&& !INT21_CreateHeap()) return 0;
166 heap
->mediaID
= 0xf0;
167 context
->SegDs
= DosHeapHandle
;
168 SET_BX( context
, (int)&heap
->mediaID
- (int)heap
);
172 static BOOL
ioctlGenericBlkDevReq( CONTEXT86
*context
)
174 BYTE
*dataptr
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
175 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
177 if (!DRIVE_IsValid(drive
))
179 SetLastError( ERROR_FILE_NOT_FOUND
);
183 if (CH_reg(context
) != 0x08)
185 INT_BARF( context
, 0x21 );
189 switch (CL_reg(context
))
191 case 0x60: /* get device parameters */
192 /* used by w4wgrp's winfile */
193 memset(dataptr
, 0, 0x20); /* DOS 6.22 uses 0x20 bytes */
195 dataptr
[6] = 0; /* media type */
198 dataptr
[1] = 0x05; /* fixed disk */
199 setword(&dataptr
[2], 0x01); /* non removable */
200 setword(&dataptr
[4], 0x300); /* # of cylinders */
204 dataptr
[1] = 0x07; /* block dev, floppy */
205 setword(&dataptr
[2], 0x02); /* removable */
206 setword(&dataptr
[4], 80); /* # of cylinders */
208 CreateBPB(drive
, &dataptr
[7], TRUE
);
209 RESET_CFLAG(context
);
212 case 0x66:/* get disk serial number */
214 char label
[12],fsname
[9],path
[4];
217 strcpy(path
,"x:\\");path
[0]=drive
+'A';
218 GetVolumeInformationA(
219 path
,label
,12,&serial
,NULL
,NULL
,fsname
,9
222 memcpy(dataptr
+2,&serial
,4);
223 memcpy(dataptr
+6,label
,11);
224 memcpy(dataptr
+17,fsname
,8);
229 memset(dataptr
+1, '\0', dataptr
[0]-1);
230 dataptr
[1] = dataptr
[0];
231 dataptr
[2] = 0x07; /* protected mode driver; no eject; no notification */
232 dataptr
[3] = 0xFF; /* no physical drive */
236 /* Trail on error implementation */
237 SET_AX( context
, GetDriveType16(BL_reg(context
)) == DRIVE_UNKNOWN
? 0x0f : 0x01 );
238 SET_CFLAG(context
); /* Seems to be set all the time */
242 INT_BARF( context
, 0x21 );
247 static void INT21_ParseFileNameIntoFCB( CONTEXT86
*context
)
250 CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Esi
);
252 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Edi
);
258 SET_AL( context
, 0xff ); /* failed */
260 TRACE("filename: '%s'\n", filename
);
266 if ((*s
!= ' ') && (*s
!= '\r') && (*s
!= '\n'))
275 buffer_len
= MultiByteToWideChar(CP_OEMCP
, 0, filename
, len
, NULL
, 0);
276 buffer
= HeapAlloc( GetProcessHeap(), 0, (buffer_len
+ 1) * sizeof(WCHAR
));
277 len
= MultiByteToWideChar(CP_OEMCP
, 0, filename
, len
, buffer
, buffer_len
);
279 DOSFS_ToDosFCBFormat(buffer
, fcbW
);
280 HeapFree(GetProcessHeap(), 0, buffer
);
281 WideCharToMultiByte(CP_OEMCP
, 0, fcbW
, 12, fcb
+ 1, 12, NULL
, NULL
);
283 TRACE("FCB: '%s'\n", fcb
+ 1);
285 SET_AL( context
, ((strchr(filename
, '*')) || (strchr(filename
, '$'))) != 0 );
287 /* point DS:SI to first unparsed character */
288 SET_SI( context
, context
->Esi
+ (int)s
- (int)filename
);
292 /* Many calls translate a drive argument like this:
293 drive number (00h = default, 01h = A:, etc)
295 static const char *INT21_DriveName(int drive
)
297 if (drive
> 0) return wine_dbg_sprintf( "%c:", 'A' + drive
- 1 );
301 static HFILE16
_lcreat16_uniq( LPCSTR path
, INT attr
)
303 /* Mask off all flags not explicitly allowed by the doc */
304 attr
&= FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
| FILE_ATTRIBUTE_SYSTEM
;
305 return Win32HandleToDosFileHandle( CreateFileA( path
, GENERIC_READ
| GENERIC_WRITE
,
306 FILE_SHARE_READ
| FILE_SHARE_WRITE
, NULL
,
307 CREATE_NEW
, attr
, 0 ));
311 static int INT21_FindFirst( CONTEXT86
*context
)
315 DOS_FULL_NAME full_name
;
316 FINDFILE_DTA
*dta
= (FINDFILE_DTA
*)GetCurrentDTA(context
);
317 WCHAR pathW
[MAX_PATH
];
320 path
= (const char *)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
321 MultiByteToWideChar(CP_OEMCP
, 0, path
, -1, pathW
, MAX_PATH
);
323 dta
->unixPath
= NULL
;
324 if (!DOSFS_GetFullName( pathW
, FALSE
, &full_name
))
326 SET_AX( context
, GetLastError() );
330 dta
->unixPath
= HeapAlloc( GetProcessHeap(), 0, strlen(full_name
.long_name
)+1 );
331 strcpy( dta
->unixPath
, full_name
.long_name
);
332 p
= strrchr( dta
->unixPath
, '/' );
335 MultiByteToWideChar(CP_OEMCP
, 0, p
+ 1, -1, pathW
, MAX_PATH
);
337 /* Note: terminating NULL in dta->mask overwrites dta->search_attr
338 * (doesn't matter as it is set below anyway)
340 if (!DOSFS_ToDosFCBFormat( pathW
, maskW
))
342 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
343 dta
->unixPath
= NULL
;
344 SetLastError( ERROR_FILE_NOT_FOUND
);
345 SET_AX( context
, ERROR_FILE_NOT_FOUND
);
349 WideCharToMultiByte(CP_OEMCP
, 0, maskW
, 12, dta
->mask
, sizeof(dta
->mask
), NULL
, NULL
);
350 dta
->drive
= (path
[0] && (path
[1] == ':')) ? toupper(path
[0]) - 'A'
351 : DRIVE_GetCurrentDrive();
353 dta
->search_attr
= CL_reg(context
);
358 static int INT21_FindNext( CONTEXT86
*context
)
360 FINDFILE_DTA
*dta
= (FINDFILE_DTA
*)GetCurrentDTA(context
);
361 WIN32_FIND_DATAA entry
;
364 if (!dta
->unixPath
) return 0;
365 if (!(count
= DOSFS_FindNext( dta
->unixPath
, dta
->mask
, NULL
, dta
->drive
,
366 dta
->search_attr
, dta
->count
, &entry
)))
368 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
369 dta
->unixPath
= NULL
;
372 if ((int)dta
->count
+ count
> 0xffff)
374 WARN("Too many directory entries in %s\n", dta
->unixPath
);
375 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
376 dta
->unixPath
= NULL
;
380 dta
->fileattr
= entry
.dwFileAttributes
;
381 dta
->filesize
= entry
.nFileSizeLow
;
382 FileTimeToDosDateTime( &entry
.ftLastWriteTime
,
383 &dta
->filedate
, &dta
->filetime
);
384 strcpy( dta
->filename
, entry
.cAlternateFileName
);
385 if (!memchr(dta
->mask
,'?',11)) {
386 /* wildcardless search, release resources in case no findnext will
387 * be issued, and as a workaround in case file creation messes up
388 * findnext, as sometimes happens with pkunzip */
389 HeapFree( GetProcessHeap(), 0, dta
->unixPath
);
390 dta
->unixPath
= NULL
;
396 static BOOL
INT21_CreateTempFile( CONTEXT86
*context
)
398 static int counter
= 0;
399 char *name
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
400 char *p
= name
+ strlen(name
);
402 /* despite what Ralf Brown says, some programs seem to call without
403 * ending backslash (DOS accepts that, so we accept it too) */
404 if ((p
== name
) || (p
[-1] != '\\')) *p
++ = '\\';
408 sprintf( p
, "wine%04x.%03d", (int)getpid(), counter
);
409 counter
= (counter
+ 1) % 1000;
411 SET_AX( context
, _lcreat16_uniq( name
, 0 ) );
412 if (AX_reg(context
) != HFILE_ERROR16
)
414 TRACE("created %s\n", name
);
417 if (GetLastError() != ERROR_FILE_EXISTS
) return FALSE
;
422 static int INT21_GetDiskSerialNumber( CONTEXT86
*context
)
424 BYTE
*dataptr
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
425 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
427 if (!DRIVE_IsValid(drive
))
429 SetLastError( ERROR_INVALID_DRIVE
);
433 *(WORD
*)dataptr
= 0;
434 *(DWORD
*)(dataptr
+ 2) = DRIVE_GetSerialNumber( drive
);
435 memcpy( dataptr
+ 6, DRIVE_GetLabel( drive
), 11 );
436 strncpy(dataptr
+ 0x11, "FAT16 ", 8);
441 static int INT21_SetDiskSerialNumber( CONTEXT86
*context
)
443 BYTE
*dataptr
= CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
444 int drive
= DOS_GET_DRIVE( BL_reg(context
) );
446 if (!DRIVE_IsValid(drive
))
448 SetLastError( ERROR_INVALID_DRIVE
);
452 DRIVE_SetSerialNumber( drive
, *(DWORD
*)(dataptr
+ 2) );
457 /* microsoft's programmers should be shot for using CP/M style int21
458 calls in Windows for Workgroup's winfile.exe */
460 static int INT21_FindFirstFCB( CONTEXT86
*context
)
462 BYTE
*fcb
= (BYTE
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
467 if (*fcb
== 0xff) pFCB
= (FINDFILE_FCB
*)(fcb
+ 7);
468 else pFCB
= (FINDFILE_FCB
*)fcb
;
469 drive
= DOS_GET_DRIVE( pFCB
->drive
);
470 if (!DRIVE_IsValid( drive
)) return 0;
471 root
= DRIVE_GetRoot( drive
);
472 cwd
= DRIVE_GetUnixCwd( drive
);
473 pFCB
->unixPath
= HeapAlloc( GetProcessHeap(), 0,
474 strlen(root
)+strlen(cwd
)+2 );
475 if (!pFCB
->unixPath
) return 0;
476 strcpy( pFCB
->unixPath
, root
);
477 strcat( pFCB
->unixPath
, "/" );
478 strcat( pFCB
->unixPath
, cwd
);
484 static int INT21_FindNextFCB( CONTEXT86
*context
)
486 BYTE
*fcb
= (BYTE
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
);
488 DOS_DIRENTRY_LAYOUT
*pResult
= (DOS_DIRENTRY_LAYOUT
*)GetCurrentDTA(context
);
489 WIN32_FIND_DATAA entry
;
493 if (*fcb
== 0xff) /* extended FCB ? */
496 pFCB
= (FINDFILE_FCB
*)(fcb
+ 7);
501 pFCB
= (FINDFILE_FCB
*)fcb
;
504 if (!pFCB
->unixPath
) return 0;
505 if (!(count
= DOSFS_FindNext( pFCB
->unixPath
, pFCB
->filename
, NULL
,
506 DOS_GET_DRIVE( pFCB
->drive
), attr
,
507 pFCB
->count
, &entry
)))
509 HeapFree( GetProcessHeap(), 0, pFCB
->unixPath
);
510 pFCB
->unixPath
= NULL
;
513 pFCB
->count
+= count
;
515 if (*fcb
== 0xff) { /* place extended FCB header before pResult if called with extended FCB */
516 *(BYTE
*)pResult
= 0xff;
517 (BYTE
*)pResult
+=6; /* leave reserved field behind */
518 *(BYTE
*)pResult
= entry
.dwFileAttributes
;
521 *(BYTE
*)pResult
= DOS_GET_DRIVE( pFCB
->drive
); /* DOS_DIRENTRY_LAYOUT after current drive number */
523 pResult
->fileattr
= entry
.dwFileAttributes
;
524 pResult
->cluster
= 0; /* what else? */
525 pResult
->filesize
= entry
.nFileSizeLow
;
526 memset( pResult
->reserved
, 0, sizeof(pResult
->reserved
) );
527 FileTimeToDosDateTime( &entry
.ftLastWriteTime
,
528 &pResult
->filedate
, &pResult
->filetime
);
530 /* Convert file name to FCB format */
532 memset( pResult
->filename
, ' ', sizeof(pResult
->filename
) );
533 if (!strcmp( entry
.cAlternateFileName
, "." )) pResult
->filename
[0] = '.';
534 else if (!strcmp( entry
.cAlternateFileName
, ".." ))
535 pResult
->filename
[0] = pResult
->filename
[1] = '.';
538 char *p
= strrchr( entry
.cAlternateFileName
, '.' );
539 if (p
&& p
[1] && (p
!= entry
.cAlternateFileName
))
541 memcpy( pResult
->filename
, entry
.cAlternateFileName
,
542 min( (p
- entry
.cAlternateFileName
), 8 ) );
543 memcpy( pResult
->filename
+ 8, p
+ 1, min( strlen(p
), 3 ) );
546 memcpy( pResult
->filename
, entry
.cAlternateFileName
,
547 min( strlen(entry
.cAlternateFileName
), 8 ) );
554 INT21_networkfunc (CONTEXT86
*context
)
556 switch (AL_reg(context
)) {
557 case 0x00: /* Get machine name. */
559 char *dst
= CTX_SEG_OFF_TO_LIN (context
,context
->SegDs
,context
->Edx
);
560 TRACE("getting machine name to %p\n", dst
);
561 if (gethostname (dst
, 15))
564 SetLastError( ER_NoNetwork
);
567 int len
= strlen (dst
);
571 SET_CH( context
, 1 ); /* Valid */
572 SET_CL( context
, 1 ); /* NETbios number??? */
573 TRACE("returning %s\n", debugstr_an (dst
, 16));
579 SetLastError( ER_NoNetwork
);
585 /***********************************************************************
588 void WINAPI
INT_Int21Handler( CONTEXT86
*context
)
590 BOOL bSetDOSExtendedError
= FALSE
;
592 switch(AH_reg(context
))
594 case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
595 TRACE("FIND FIRST MATCHING FILE USING FCB %p\n",
596 CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
597 if (!INT21_FindFirstFCB(context
))
599 SET_AL( context
, 0xff );
602 /* else fall through */
604 case 0x12: /* FIND NEXT MATCHING FILE USING FCB */
605 SET_AL( context
, INT21_FindNextFCB(context
) ? 0x00 : 0xff );
608 case 0x1b: /* GET ALLOCATION INFORMATION FOR DEFAULT DRIVE */
609 SET_DL( context
, 0 );
610 if (!INT21_GetDriveAllocInfo(context
)) SET_AX( context
, 0xffff );
613 case 0x1c: /* GET ALLOCATION INFORMATION FOR SPECIFIC DRIVE */
614 if (!INT21_GetDriveAllocInfo(context
)) SET_AX( context
, 0xffff );
617 case 0x29: /* PARSE FILENAME INTO FCB */
618 INT21_ParseFileNameIntoFCB(context
);
621 case 0x36: /* GET FREE DISK SPACE */
622 TRACE("GET FREE DISK SPACE FOR DRIVE %s\n",
623 INT21_DriveName( DL_reg(context
)));
624 if (!INT21_GetFreeDiskSpace(context
)) SET_AX( context
, 0xffff );
627 case 0x44: /* IOCTL */
628 switch (AL_reg(context
))
631 TRACE("IOCTL - GENERIC BLOCK DEVICE REQUEST %s\n",
632 INT21_DriveName( BL_reg(context
)));
633 bSetDOSExtendedError
= ioctlGenericBlkDevReq(context
);
636 case 0x0F: /* Set logical drive mapping */
639 TRACE("IOCTL - SET LOGICAL DRIVE MAP for drive %s\n",
640 INT21_DriveName( BL_reg(context
)));
641 drive
= DOS_GET_DRIVE ( BL_reg(context
) );
642 if ( ! DRIVE_SetLogicalMapping ( drive
, drive
+1 ) )
645 SET_AX( context
, 0x000F ); /* invalid drive */
652 case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
653 TRACE("FINDFIRST mask 0x%04x spec %s\n",CX_reg(context
),
654 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
, context
->Edx
));
655 if (!INT21_FindFirst(context
)) break;
658 case 0x4f: /* "FINDNEXT" - FIND NEXT MATCHING FILE */
660 if (!INT21_FindNext(context
))
662 SetLastError( ERROR_NO_MORE_FILES
);
663 SET_AX( context
, ERROR_NO_MORE_FILES
);
666 else SET_AX( context
, 0 ); /* OK */
669 case 0x5a: /* CREATE TEMPORARY FILE */
670 TRACE("CREATE TEMPORARY FILE\n");
671 bSetDOSExtendedError
= !INT21_CreateTempFile(context
);
675 bSetDOSExtendedError
= INT21_networkfunc (context
);
678 case 0x5f: /* NETWORK */
679 switch (AL_reg(context
))
681 case 0x07: /* ENABLE DRIVE */
682 TRACE("ENABLE DRIVE %c:\n",(DL_reg(context
)+'A'));
683 if (!DRIVE_Enable( DL_reg(context
) ))
685 SetLastError( ERROR_INVALID_DRIVE
);
686 bSetDOSExtendedError
= TRUE
;
690 case 0x08: /* DISABLE DRIVE */
691 TRACE("DISABLE DRIVE %c:\n",(DL_reg(context
)+'A'));
692 if (!DRIVE_Disable( DL_reg(context
) ))
694 SetLastError( ERROR_INVALID_DRIVE
);
695 bSetDOSExtendedError
= TRUE
;
700 /* network software not installed */
701 TRACE("NETWORK function AX=%04x not implemented\n",AX_reg(context
));
702 SetLastError( ER_NoNetwork
);
703 bSetDOSExtendedError
= TRUE
;
708 case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
709 TRACE("TRUENAME %s\n",
710 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Esi
));
712 if (!GetFullPathNameA( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,
714 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
716 bSetDOSExtendedError
= TRUE
;
717 else SET_AX( context
, 0 );
721 case 0x69: /* DISK SERIAL NUMBER */
722 switch (AL_reg(context
))
725 TRACE("GET DISK SERIAL NUMBER for drive %s\n",
726 INT21_DriveName(BL_reg(context
)));
727 if (!INT21_GetDiskSerialNumber(context
)) bSetDOSExtendedError
= TRUE
;
728 else SET_AX( context
, 0 );
732 TRACE("SET DISK SERIAL NUMBER for drive %s\n",
733 INT21_DriveName(BL_reg(context
)));
734 if (!INT21_SetDiskSerialNumber(context
)) bSetDOSExtendedError
= TRUE
;
735 else SET_AX( context
, 1 );
740 case 0x71: /* MS-DOS 7 (Windows95) - LONG FILENAME FUNCTIONS */
741 switch(AL_reg(context
))
743 case 0x4e: /* Find first file */
744 TRACE(" LONG FILENAME - FIND FIRST MATCHING FILE for %s\n",
745 (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
));
746 /* FIXME: use attributes in CX */
747 SET_AX( context
, FindFirstFile16(
748 CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
),
749 (WIN32_FIND_DATAA
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
751 if (AX_reg(context
) == INVALID_HANDLE_VALUE16
)
752 bSetDOSExtendedError
= TRUE
;
754 case 0x4f: /* Find next file */
755 TRACE("LONG FILENAME - FIND NEXT MATCHING FILE for handle %d\n",
757 if (!FindNextFile16( BX_reg(context
),
758 (WIN32_FIND_DATAA
*)CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
760 bSetDOSExtendedError
= TRUE
;
764 LPCSTR driveroot
= (LPCSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,context
->Edx
);
765 LPSTR buffer
= (LPSTR
)CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,context
->Edi
);
766 DWORD filename_len
, flags
;
768 TRACE("LONG FILENAME - GET VOLUME INFORMATION for drive having root dir '%s'.\n", driveroot
);
769 SET_AX( context
, 0 );
770 if (!GetVolumeInformationA( driveroot
, NULL
, 0, NULL
, &filename_len
,
773 INT_BARF( context
, 0x21 );
777 SET_BX( context
, flags
| 0x4000 ); /* support for LFN functions */
778 SET_CX( context
, filename_len
);
779 SET_DX( context
, MAX_PATH
); /* FIXME: which len if DRIVE_SHORT_NAMES ? */
782 case 0xa1: /* Find close */
783 TRACE("LONG FILENAME - FINDCLOSE for handle %d\n",
785 bSetDOSExtendedError
= (!FindClose16( BX_reg(context
) ));
788 switch(CL_reg(context
))
790 case 0x01: /* Get short filename or path */
791 if (!GetShortPathNameA
792 ( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,
794 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
796 bSetDOSExtendedError
= TRUE
;
797 else SET_AX( context
, 0 );
799 case 0x02: /* Get canonical long filename or path */
800 if (!GetFullPathNameA
801 ( CTX_SEG_OFF_TO_LIN(context
, context
->SegDs
,
803 CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
,
805 bSetDOSExtendedError
= TRUE
;
806 else SET_AX( context
, 0 );
809 FIXME("Unimplemented long file name function:\n");
810 INT_BARF( context
, 0x21 );
812 SET_AL( context
, 0 );
818 FIXME("Unimplemented long file name function:\n");
819 INT_BARF( context
, 0x21 );
821 SET_AL( context
, 0 );
827 INT_BARF( context
, 0x21 );
830 } /* END OF SWITCH */
832 if( bSetDOSExtendedError
) /* set general error condition */
834 SET_AX( context
, GetLastError() );