A+ -- Eric Pouech
Name: opdrv ChangeLog: Got rid of DRIVE_OpenDevice, and replaced it with Win32 equivalents License: X11 GenDate: 2003/11/22 13:05:21 UTC ModifiedFiles: dlls/kernel/kernel32.spec dlls/winedos/int13.c dlls/winedos/int25.c dlls/winedos/int26.c files/drive.c include/drive.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/kernel32.spec,v retrieving revision 1.119 diff -u -u -r1.119 kernel32.spec --- dlls/kernel/kernel32.spec 18 Nov 2003 00:06:15 -0000 1.119 +++ dlls/kernel/kernel32.spec 22 Nov 2003 13:01:53 -0000 @@ -1140,14 +1140,13 @@ ################################################################ # Wine dll separation hacks, these will go away, don't use them # @ cdecl DOSFS_GetDeviceByHandle(long) @ cdecl DOSMEM_AllocSelector(long) @ cdecl DOSMEM_Available() @ cdecl DOSMEM_FreeBlock(ptr) @ cdecl DOSMEM_GetBlock(long ptr) @ cdecl DOSMEM_Init(long) @ cdecl DOSMEM_ResizeBlock(ptr long long) -@ cdecl DRIVE_OpenDevice(long long) @ cdecl FILE_Dup2(long long) @ cdecl LOCAL_Alloc(long long long) @ cdecl LOCAL_Compact(long long long) Index: dlls/winedos/int13.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/winedos/int13.c,v retrieving revision 1.4 diff -u -u -r1.4 int13.c --- dlls/winedos/int13.c 15 Nov 2003 00:13:21 -0000 1.4 +++ dlls/winedos/int13.c 22 Nov 2003 12:54:34 -0000 @@ -35,8 +35,8 @@ #endif #include "dosexe.h" +#include "wine/server.h" #include "wine/debug.h" -#include "drive.h" WINE_DEFAULT_DEBUG_CHANNEL(int); @@ -98,7 +98,8 @@ int floppy_fd; int r; struct floppy_drive_params floppy_parm; - char root[] = "A:\\"; + WCHAR root[] = {'A',':','\\',0}, drive_root[] = {'\\','\\','.','\\','A',':',0}; + HANDLE h; TRACE("in [ EDX=%08lx ]\n", context->Edx ); @@ -108,7 +109,7 @@ SET_DH( context, 0 ); for (i = 0; i < MAX_DOS_DRIVES; i++, root[0]++) - if (GetDriveTypeA(root) == DRIVE_REMOVABLE) nr_of_drives++; + if (GetDriveTypeW(root) == DRIVE_REMOVABLE) nr_of_drives++; SET_DL( context, nr_of_drives ); if (drive_nr > 1) { @@ -117,15 +118,20 @@ return; } - if ( (floppy_fd = DRIVE_OpenDevice( drive_nr, O_RDONLY|O_NONBLOCK)) == -1) + drive_root[4] = 'A' + drive_nr; + h = CreateFileW(drive_root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (h == INVALID_HANDLE_VALUE || + wine_server_handle_to_fd(h, GENERIC_READ, &floppy_fd, NULL, NULL)) { WARN("Can't determine floppy geometry !\n"); INT13_SetStatus( context, 0x07 ); /* drive parameter activity failed */ return; } r = ioctl(floppy_fd, FDGETDRVPRM, &floppy_parm); - + close(floppy_fd); + CloseHandle(h); if(r<0) { Index: dlls/winedos/int25.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/winedos/int25.c,v retrieving revision 1.2 diff -u -u -r1.2 int25.c --- dlls/winedos/int25.c 15 Nov 2003 00:13:21 -0000 1.2 +++ dlls/winedos/int25.c 22 Nov 2003 13:04:11 -0000 @@ -27,7 +27,6 @@ # include <unistd.h> #endif #include "dosexe.h" -#include "drive.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(int); @@ -40,17 +39,22 @@ */ BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success) { - int fd; + WCHAR root[] = {'\\','\\','.','\\','A',':',0}; + HANDLE h; - if ((fd = DRIVE_OpenDevice( drive, O_RDONLY )) != -1) + root[4] += drive; + h = CreateFileW(root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (h != INVALID_HANDLE_VALUE) { - lseek( fd, begin * 512, SEEK_SET ); + SetFilePointer(h, begin * 512, NULL, SEEK_SET ); /* FIXME: check errors */ - read( fd, dataptr, nr_sect * 512 ); - close( fd ); + ReadFile(h, dataptr, nr_sect * 512, NULL, NULL ); + CloseHandle(h); } else { + if (h != INVALID_HANDLE_VALUE) CloseHandle(h); memset( dataptr, 0, nr_sect * 512 ); if (fake_success) { Index: dlls/winedos/int26.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/winedos/int26.c,v retrieving revision 1.2 diff -u -u -r1.2 int26.c --- dlls/winedos/int26.c 15 Nov 2003 00:13:21 -0000 1.2 +++ dlls/winedos/int26.c 22 Nov 2003 13:00:29 -0000 @@ -26,7 +26,6 @@ # include <unistd.h> #endif #include "dosexe.h" -#include "drive.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(int); @@ -39,14 +38,18 @@ */ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success) { - int fd; + WCHAR root[] = {'\\','\\','.','\\','A',':',0}; + HANDLE h; - if ((fd = DRIVE_OpenDevice( drive, O_RDONLY )) != -1) + root[4] += drive; + h = CreateFileW(root, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, + 0, NULL); + if (h != INVALID_HANDLE_VALUE) { - lseek( fd, begin * 512, SEEK_SET ); + SetFilePointer(h, begin * 512, NULL, SEEK_SET ); /* FIXME: check errors */ - write( fd, dataptr, nr_sect * 512 ); - close( fd ); + WriteFile( h, dataptr, nr_sect * 512, NULL, NULL ); + CloseHandle( h ); } else if (!fake_success) return FALSE; Index: files/drive.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/files/drive.c,v retrieving revision 1.102 diff -u -u -r1.102 drive.c --- files/drive.c 15 Nov 2003 00:13:21 -0000 1.102 +++ files/drive.c 22 Nov 2003 13:01:38 -0000 @@ -1366,18 +1046,6 @@ /*********************************************************************** - * DRIVE_OpenDevice - * - * Open the drive raw device and return a Unix fd (or -1 on error). - */ -int DRIVE_OpenDevice( int drive, int flags ) -{ - if (!DRIVE_IsValid( drive )) return -1; - return open( DOSDrives[drive].device, flags ); -} - - -/*********************************************************************** * DRIVE_GetFreeSpace */ static int DRIVE_GetFreeSpace( int drive, PULARGE_INTEGER size, Index: include/drive.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/include/drive.h,v retrieving revision 1.15 diff -u -u -r1.15 drive.h --- include/drive.h 14 Nov 2003 04:54:40 -0000 1.15 +++ include/drive.h 22 Nov 2003 13:01:22 -0000 @@ -44,14 +44,13 @@ extern LPCWSTR DRIVE_GetDosCwd( int drive ); extern const char * DRIVE_GetUnixCwd( int drive ); extern const char * DRIVE_GetDevice( int drive ); extern LPCWSTR DRIVE_GetLabel( int drive ); extern DWORD DRIVE_GetSerialNumber( int drive ); extern int DRIVE_SetSerialNumber( int drive, DWORD serial ); extern UINT DRIVE_GetFlags( int drive ); extern int DRIVE_Chdir( int drive, LPCWSTR path ); extern int DRIVE_Disable( int drive ); extern int DRIVE_Enable( int drive ); -extern int DRIVE_OpenDevice( int drive, int flags ); extern WCHAR *DRIVE_BuildEnv(void); #endif /* __WINE_DRIVE_H */