Changeset 7585 for trunk/src


Ignore:
Timestamp:
Dec 8, 2001, 5:06:49 PM (24 years ago)
Author:
sandervl
Message:

Clear GENERIC_WRITE flag if application tries to open readonly device (e.g. cdrom). This is not allowed in OS/2

File:
1 edited

Legend:

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

    r7575 r7585  
    1 /* $Id: hmdisk.cpp,v 1.36 2001-12-08 14:28:53 sandervl Exp $ */
     1/* $Id: hmdisk.cpp,v 1.37 2001-12-08 16:06:49 sandervl Exp $ */
    22
    33/*
     
    108108    HFILE hFile;
    109109    HFILE hTemplate;
     110    DWORD dwDriveType;
    110111
    111112    dprintf2(("KERNEL32: HMDeviceDiskClass::CreateFile %s(%s,%08x,%08x,%08x)\n",
     
    121122        return ERROR_INVALID_PARAMETER;
    122123    }
    123  
     124
     125    dwDriveType = GetDriveTypeA(lpFileName);
     126
    124127    //Disable error popus. NT allows an app to open a cdrom/dvd drive without a disk inside
    125128    //OS/2 fails in that case with error ERROR_NOT_READY
     
    132135                               pHMHandleData->dwFlags,
    133136                               hTemplate);
     137
     138    //It is not allowed to open a readonly device with GENERIC_WRITE in OS/2;
     139    //try with readonly again if that happened
     140    //NOTE: Some applications open it with GENERIC_WRITE as Windows 2000 requires
     141    //      this for some aspi functions
     142    if(hFile == INVALID_HANDLE_ERROR && dwDriveType == DRIVE_CDROM &&
     143       (pHMHandleData->dwAccess & GENERIC_WRITE))
     144    {
     145        pHMHandleData->dwAccess &= ~GENERIC_WRITE;
     146        hFile = OSLibDosCreateFile((LPSTR)lpFileName,
     147                                   pHMHandleData->dwAccess,
     148                                   pHMHandleData->dwShare,
     149                                   (LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
     150                                   pHMHandleData->dwCreation,
     151                                   pHMHandleData->dwFlags,
     152                                   hTemplate);
     153    }
    134154    SetErrorMode(oldmode);
    135155
     
    164184        }
    165185
    166         drvInfo->driveType = GetDriveTypeA(lpFileName);
     186        drvInfo->driveType = dwDriveType;
    167187        if(drvInfo->driveType == DRIVE_CDROM)
    168188        {
Note: See TracChangeset for help on using the changeset viewer.