Changeset 8258 for trunk/src


Ignore:
Timestamp:
Apr 13, 2002, 8:21:39 AM (23 years ago)
Author:
bird
Message:

Corrected call to GetDriveType. (paranoia)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmdisk.cpp

    r8195 r8258  
    1 /* $Id: hmdisk.cpp,v 1.41 2002-04-06 14:58:35 sandervl Exp $ */
     1/* $Id: hmdisk.cpp,v 1.42 2002-04-13 06:21:39 bird Exp $ */
    22
    33/*
     
    3030#define BIT_11    (1<<11)
    3131
    32 typedef struct 
     32typedef struct
    3333{
    3434    HINSTANCE hInstAspi;
     
    7979    return TRUE;
    8080  }
    81  
     81
    8282    //\\.\x:                -> length 6
    8383    //\\.\PHYSICALDRIVEn    -> length 18
     
    123123    }
    124124
    125     dwDriveType = GetDriveTypeA(lpFileName);
     125    char szDrive[4];
     126    szDrive[0] = *lpFileName;
     127    szDrive[1] = ':';
     128    szDrive[2] = '\0';
     129    dwDriveType = GetDriveTypeA(szDrive);
    126130
    127131    //Disable error popus. NT allows an app to open a cdrom/dvd drive without a disk inside
     
    136140                               hTemplate);
    137141
    138     //It is not allowed to open a readonly device with GENERIC_WRITE in OS/2; 
     142    //It is not allowed to open a readonly device with GENERIC_WRITE in OS/2;
    139143    //try with readonly again if that happened
    140144    //NOTE: Some applications open it with GENERIC_WRITE as Windows 2000 requires
    141145    //      this for some aspi functions
    142     if(hFile == INVALID_HANDLE_ERROR && dwDriveType == DRIVE_CDROM && 
    143        (pHMHandleData->dwAccess & GENERIC_WRITE)) 
     146    if(hFile == INVALID_HANDLE_ERROR && dwDriveType == DRIVE_CDROM &&
     147       (pHMHandleData->dwAccess & GENERIC_WRITE))
    144148    {
    145149        pHMHandleData->dwAccess &= ~GENERIC_WRITE;
     
    185189
    186190        drvInfo->driveType = dwDriveType;
    187         if(drvInfo->driveType == DRIVE_CDROM) 
     191        if(drvInfo->driveType == DRIVE_CDROM)
    188192        {
    189193            drvInfo->hInstAspi = LoadLibraryA("WNASPI32.DLL");
     
    200204                drvInfo->hInstAspi = 0;
    201205            }
    202    
     206
    203207            //get cdrom signature
    204208            DWORD parsize = 4;
     
    248252        if(hFile == INVALID_HANDLE_ERROR) {
    249253             dprintf(("Drive not ready"));
    250              return 0; 
     254             return 0;
    251255        }
    252256        OSLibDosQueryVolumeSerialAndName(1 + drvInfo->driveLetter - 'A', &drvInfo->dwVolumelabel, NULL, 0);
     
    319323  } ParameterBlock;
    320324#pragma pack()
    321  
     325
    322326  DWORD dwParameterSize = sizeof( ParameterBlock );
    323327  DWORD dwDataSize      = 0;
    324328  DWORD ret;
    325  
     329
    326330  ParameterBlock.ucCommand = dwCommand;
    327331  ParameterBlock.ucHandle  = dwDiskHandle;
    328  
     332
    329333  if(lpBytesReturned)
    330334    *lpBytesReturned = 0;
     
    588592        UCHAR  uchFileData[1] = {'0'};    /* Data to write to file */
    589593
    590         if(!pHMHandleData->hHMHandle) 
     594        if(!pHMHandleData->hHMHandle)
    591595        {
    592596            pHMHandleData->hHMHandle = OpenDisk(drvInfo);
     
    604608
    605609        OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_LOCKDRIVE,0,0,0,0,0,0);
    606          
     610
    607611        ULONG oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);
    608612
     
    629633            goto writecheckfail;
    630634        }
    631  
     635
    632636        rc =  OSLibDosWrite(pHMHandleData->hHMHandle,   /* File handle */
    633637                            (PVOID) uchFileData,        /* String to be written */
     
    678682            }
    679683        }
    680        
     684
    681685        //Applications can use this IOCTL to check if the floppy has been changed
    682686        //OSLibDosGetDiskGeometry won't fail when that happens so we read the
     
    718722    case IOCTL_SERIAL_LSRMST_INSERT:
    719723        break;
    720      
    721      
     724
     725
    722726    // -----------
    723727    // CDROM class
     
    737741            BYTE  ucTrackControl;
    738742        } AudioTrackInfo;
    739         typedef struct 
     743        typedef struct
    740744        {
    741745            BYTE  signature[4];
     
    778782
    779783        //numtracks+1, because we have to add a track at the end
    780         int length = 4 + (numtracks+1)*sizeof(TRACK_DATA); 
     784        int length = 4 + (numtracks+1)*sizeof(TRACK_DATA);
    781785        //big endian format
    782786        pTOC->Length[0] = HIBYTE((length-2));  //minus length itself;
     
    787791            return FALSE;
    788792        }
    789        
    790         for(int i=0;i<numtracks;i++) 
     793
     794        for(int i=0;i<numtracks;i++)
    791795        {
    792796            parsize = sizeof(parm);
     
    839843    case IOCTL_CDROM_GET_CONTROL:
    840844        break;
    841    
     845
    842846    case IOCTL_CDROM_PLAY_AUDIO_MSF:
    843847    {
    844848      dprintf(("Play CDROM audio playback"));
    845      
     849
    846850#pragma pack(1)
    847851      struct
     
    853857      } ParameterBlock;
    854858#pragma pack()
    855      
     859
    856860      PCDROM_PLAY_AUDIO_MSF pPlay = (PCDROM_PLAY_AUDIO_MSF)lpInBuffer;
    857      
     861
    858862      // setup the parameter block
    859      
     863
    860864      memcpy(&ParameterBlock.ucSignature, drvInfo->signature, 4);
    861865      ParameterBlock.ucAddressingMode = 1;     // MSF format
    862      
     866
    863867      // @@@PH unknown if this kind of MSF conversion is correct!
    864868      ParameterBlock.ulStartingMSF    = pPlay->StartingM << 16 |
     
    868872                                        pPlay->EndingS << 8  |
    869873                                        pPlay->EndingF;
    870        
     874
    871875      DWORD dwParameterSize = sizeof( ParameterBlock );
    872876      DWORD dwDataSize      = 0;
    873877      DWORD ret;
    874    
     878
    875879      if(lpBytesReturned)
    876880        *lpBytesReturned = 0;
    877    
     881
    878882      ret = OSLibDosDevIOCtl(pHMHandleData->hHMHandle,
    879883                             0x81,  // IOCTL_CDROMAUDIO
     
    887891      return (ret == ERROR_SUCCESS);
    888892    }
    889      
     893
    890894    case IOCTL_CDROM_SEEK_AUDIO_MSF:
    891895        break;
     
    894898      // NO BREAK CASE
    895899      // Note: for OS/2, pause and stop seems to be the same!
    896      
     900
    897901    case IOCTL_CDROM_STOP_AUDIO:
    898902    {
    899903      dprintf(("Stop / pause CDROM audio playback"));
    900       return ioctlCDROMSimple(pHMHandleData, 
     904      return ioctlCDROMSimple(pHMHandleData,
    901905                              0x81,   // IOCTL_CDROMAUDIO
    902906                              0x51,   // CDROMAUDIO_STOPAUDIO
    903907                              lpBytesReturned, drvInfo);
    904908    }
    905      
     909
    906910    case IOCTL_CDROM_RESUME_AUDIO:
    907911    {
    908912      dprintf(("Resume CDROM audio playback"));
    909       return ioctlCDROMSimple(pHMHandleData, 
     913      return ioctlCDROMSimple(pHMHandleData,
    910914                              0x81,   // IOCTL_CDROMAUDIO
    911915                              0x52,   // CDROMAUDIO_RESUMEAUDIO
     
    985989    case IOCTL_CDROM_MEDIA_REMOVAL:
    986990        break;
    987      
     991
    988992    case IOCTL_CDROM_EJECT_MEDIA:
    989993    {
    990994      dprintf(("Eject CDROM media"));
    991       return ioctlCDROMSimple(pHMHandleData, 
     995      return ioctlCDROMSimple(pHMHandleData,
    992996                              0x80,   // IOCTL_CDROM
    993997                              0x44,   // CDROMDISK_EJECTDISK
    994998                              lpBytesReturned, drvInfo);
    995999    }
    996      
     1000
    9971001    case IOCTL_CDROM_LOAD_MEDIA:
    9981002    {
    9991003      dprintf(("Loading CDROM media"));
    1000       return ioctlCDROMSimple(pHMHandleData, 
     1004      return ioctlCDROMSimple(pHMHandleData,
    10011005                              0x80,   // IOCTL_CDROM
    10021006                              0x45,   // CDROMDISK_CLOSETRAY
    10031007                              lpBytesReturned, drvInfo);
    10041008    }
    1005      
     1009
    10061010    case IOCTL_CDROM_RESERVE:
    10071011    case IOCTL_CDROM_RELEASE:
    10081012    case IOCTL_CDROM_FIND_NEW_DEVICES:
    10091013        break;
    1010      
    1011      
     1014
     1015
    10121016    // -------------
    10131017    // STORAGE class
    10141018    // -------------
    1015      
     1019
    10161020    case IOCTL_CDROM_CHECK_VERIFY:
    10171021        if(drvInfo->driveType != DRIVE_CDROM) {
     
    10801084                                  lpBytesReturned);
    10811085    }
    1082            
     1086
    10831087    case IOCTL_STORAGE_LOAD_MEDIA:
    10841088    // case IOCTL_STORAGE_LOAD_MEDIA2:
     
    10901094                                  lpBytesReturned);
    10911095    }
    1092      
     1096
    10931097    // case IOCTL_STORAGE_EJECTION_CONTROL:
    10941098    case IOCTL_STORAGE_MEDIA_REMOVAL:
    10951099         break;
    1096      
    1097      
     1100
     1101
    10981102    // -------------------
    10991103    // SCSI passthru class
    11001104    // -------------------
    1101      
     1105
    11021106    case IOCTL_SCSI_PASS_THROUGH:
    11031107    case IOCTL_SCSI_MINIPORT:
     
    11111115        SRB_ExecSCSICmd *psrb;
    11121116
    1113         if(drvInfo->hInstAspi == NULL) 
     1117        if(drvInfo->hInstAspi == NULL)
    11141118        {
    11151119            SetLastError(ERROR_ACCESS_DENIED);
Note: See TracChangeset for help on using the changeset viewer.