Changeset 18584
- Timestamp:
- Feb 28, 2002, 8:27:48 PM (23 years ago)
- Location:
- tags/trunk/src/kernel32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tags/trunk/src/kernel32/hmdisk.cpp ¶
r18580 r18584 1 /* $Id: hmdisk.cpp,v 1. 39 2002-02-27 15:23:06sandervl Exp $ */1 /* $Id: hmdisk.cpp,v 1.40 2002-02-28 19:27:48 sandervl Exp $ */ 2 2 3 3 /* … … 331 331 332 332 ret = OSLibDosDevIOCtl(pHMHandleData->hHMHandle, 333 0x08, // IOCTL_DISK334 0x40, // DSK_UNLOCKEJECTMEDIA333 IOCTL_DISK, 334 DSK_UNLOCKEJECTMEDIA, 335 335 &ParameterBlock, 336 336 sizeof( ParameterBlock ), … … 398 398 case IOCTL_DISK_GET_DRIVE_GEOMETRY: 399 399 msg = "IOCTL_DISK_GET_DRIVE_GEOMETRY"; 400 break; 401 case IOCTL_DISK_IS_WRITABLE: 402 msg = "IOCTL_DISK_IS_WRITABLE"; 400 403 break; 401 404 case IOCTL_DISK_GET_DRIVE_LAYOUT: … … 576 579 break; 577 580 581 case IOCTL_DISK_IS_WRITABLE: 582 { 583 APIRET rc; 584 DWORD ret; 585 ULONG ulBytesRead = 0; /* Number of bytes read by DosRead */ 586 ULONG ulWrote = 0; /* Number of bytes written by DosWrite */ 587 ULONG ulLocal = 0; /* File pointer position after DosSetFilePtr */ 588 UCHAR uchFileData[1] = {'0'}; /* Data to write to file */ 589 590 if(!pHMHandleData->hHMHandle) 591 { 592 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 593 if(!pHMHandleData->hHMHandle) { 594 dprintf(("No disk inserted; aborting")); 595 SetLastError(ERROR_NOT_READY); 596 return FALSE; 597 } 598 } 599 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_LOCKDRIVE,0,0,0,0,0,0); 600 601 ULONG oldmode = SetErrorMode(SEM_FAILCRITICALERRORS); 602 603 /* Read the first byte of the disk */ 604 rc = OSLibDosRead(pHMHandleData->hHMHandle, /* File Handle */ 605 uchFileData, /* String to be read */ 606 1L, /* Length of string to be read */ 607 &ulBytesRead); /* Bytes actually read */ 608 609 if (rc == 0) 610 { 611 dprintf(("IOCTL_DISK_IS_WRITABLE:OSLibDosRead failed with rc %08xh %x", rc,GetLastError())); 612 SetLastError(ERROR_ACCESS_DENIED); 613 goto writecheckfail; 614 } 615 616 /* Move the file pointer back */ 617 rc = OSLibDosSetFilePtr (pHMHandleData->hHMHandle, /* File Handle */ 618 -1,OSLIB_SETPTR_FILE_CURRENT); 619 if (rc == -1) 620 { 621 dprintf(("IOCTL_DISK_IS_WRITABLE:OSLibDosSetFilePtr failed with rc %d", rc)); 622 SetLastError(ERROR_ACCESS_DENIED); 623 goto writecheckfail; 624 } 625 626 rc = OSLibDosWrite(pHMHandleData->hHMHandle, /* File handle */ 627 (PVOID) uchFileData, /* String to be written */ 628 1, /* Size of string to be written */ 629 &ulWrote); /* Bytes actually written */ 630 631 dprintf2(("IOCTL_DISK_IS_WRITABLE:OSLibDosWrite returned with rc %x %x", rc,GetLastError())); 632 if (rc == 0) 633 { 634 if (GetLastError() == ERROR_WRITE_PROTECT) 635 { 636 SetLastError(ERROR_WRITE_PROTECT); 637 goto writecheckfail; 638 } 639 } 640 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_UNLOCKDRIVE,0,0,0,0,0,0); 641 SetErrorMode(oldmode); 642 SetLastError(ERROR_SUCCESS); 643 return TRUE; 644 645 writecheckfail: 646 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_UNLOCKDRIVE,0,0,0,0,0,0); 647 SetErrorMode(oldmode); 648 return FALSE; 649 } 578 650 case IOCTL_DISK_GET_DRIVE_GEOMETRY: 579 651 case IOCTL_STORAGE_GET_MEDIA_TYPES: … … 600 672 } 601 673 } 602 674 603 675 //Applications can use this IOCTL to check if the floppy has been changed 604 676 //OSLibDosGetDiskGeometry won't fail when that happens so we read the … … 975 1047 parm.ucCommandInfo = 0; 976 1048 parm.usDriveUnit = drvInfo->driveLetter - 'A'; 977 //IOCTL_DISK (0x08), DSK_GETLOCKSTATUS (0x66)978 1049 // rc = OSLibDosDevIOCtl(pHMHandleData->hHMHandle, 0x08, 0x66, &parm, sizeof(parm), &parsize, 979 1050 //TODO: this doesn't work for floppies for some reason... 980 rc = OSLibDosDevIOCtl(-1, 0x08, 0x66, &parm, sizeof(parm), &parsize,1051 rc = OSLibDosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize, 981 1052 &status, sizeof(status), &datasize); 982 1053 if(rc != NO_ERROR) { … … 1360 1431 BOOL bRC; 1361 1432 1362 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",1433 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n", 1363 1434 lpHMDeviceName, 1364 1435 pHMHandleData, … … 1388 1459 } 1389 1460 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 1390 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation"));1461 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 1391 1462 } 1392 1463 if(lpCompletionRoutine) { … … 1429 1500 else lpRealBuf = (LPVOID)lpBuffer; 1430 1501 1502 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_LOCKDRIVE,0,0,0,0,0,0); 1503 1431 1504 if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) { 1432 1505 dprintf(("ERROR: Overlapped IO not yet implememented!!")); … … 1439 1512 // } 1440 1513 1514 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_UNLOCKDRIVE,0,0,0,0,0,0); 1441 1515 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile returned %08xh\n", 1442 1516 bRC)); -
TabularUnified tags/trunk/src/kernel32/oslibdos.h ¶
r18278 r18584 1 /* $Id: oslibdos.h,v 1.4 3 2002-01-04 14:11:23sandervl Exp $ */1 /* $Id: oslibdos.h,v 1.44 2002-02-28 19:27:48 sandervl Exp $ */ 2 2 3 3 /* … … 213 213 DWORD OSLibDosQueryVolumeFS(int drive, LPSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize); 214 214 DWORD OSLibDosQueryVolumeSerialAndName(int drive, LPDWORD lpVolumeSerialNumber, LPSTR lpVolumeNameBuffer, DWORD nVolumeNameSize); 215 216 /* Disk/Diskette Control */ 217 218 #ifndef __OS2_H__ 219 #define IOCTL_DISK 8 220 221 #define DSK_LOCKDRIVE 0x0000 222 #define DSK_UNLOCKDRIVE 0x0001 223 #define DSK_REDETERMINEMEDIA 0x0002 224 #define DSK_SETLOGICALMAP 0x0003 225 #define DSK_BEGINFORMAT 0X0004 226 #define DSK_BLOCKREMOVABLE 0x0020 227 #define DSK_GETLOGICALMAP 0x0021 228 #define DSK_UNLOCKEJECTMEDIA 0X0040 229 #define DSK_SETDEVICEPARAMS 0x0043 230 #define DSK_WRITETRACK 0x0044 231 #define DSK_FORMATVERIFY 0x0045 232 #define DSK_DISKETTECONTROL 0X005D 233 #define DSK_QUERYMEDIASENSE 0X0060 234 #define DSK_GETDEVICEPARAMS 0x0063 235 #define DSK_READTRACK 0x0064 236 #define DSK_VERIFYTRACK 0x0065 237 #define DSK_GETLOCKSTATUS 0X0066 238 #endif 239 215 240 DWORD OSLibDosDevIOCtl( DWORD hFile, DWORD dwCat, DWORD dwFunc, 216 241 PVOID pParm, DWORD dwParmMaxLen, DWORD *pdwParmLen,
Note:
See TracChangeset
for help on using the changeset viewer.