Changeset 8261


Ignore:
Timestamp:
Apr 13, 2002, 9:41:31 AM (23 years ago)
Author:
bird
Message:

Hot fix for 0 CDROMs. first try!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/kernel32/oslibdos.cpp

    r8259 r8261  
    1 /* $Id: oslibdos.cpp,v 1.97 2002-04-13 06:31:53 bird Exp $ */
     1/* $Id: oslibdos.cpp,v 1.98 2002-04-13 07:41:31 bird Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    1212 *
    1313 */
     14
     15
     16
     17/*******************************************************************************
     18*   Header Files                                                               *
     19*******************************************************************************/
    1420#define INCL_BASE
    1521#define INCL_DOSEXCEPTIONS
     
    3844#include "dbglocal.h"
    3945
     46
     47/*******************************************************************************
     48*   Structures and Typedefs                                                    *
     49*******************************************************************************/
     50#ifndef DEVTYPE_OPTICAL
     51#define DEVTYPE_OPTICAL                    0x0008
     52#endif
     53
     54#define IOC_CDROM_2                 0x82 /* from cdioctl.h (ddk, os2cdrom.dmd sample) */
     55#define IOCD_RETURN_DRIVE_LETTER    0x60
     56
     57
     58// used for input to logical disk Get device parms Ioctl
     59#pragma pack(1)
     60typedef struct
     61{
     62    UCHAR   Infotype;
     63    UCHAR   DriveUnit;
     64} DSKREQ;
     65
     66/*------------------------------------------------*
     67 * Cat 0x82, Func 0x60:  Return Drive Letter Info *
     68 *------------------------------------------------*/
     69typedef struct DriveLetter_Data
     70{
     71    USHORT  drive_count;
     72    USHORT  first_drive_number;
     73} CDDRVLTR;
     74#pragma pack()
     75
     76
     77/*******************************************************************************
     78*   Global Variables                                                           *
     79*******************************************************************************/
    4080static PROC_DosSetFileSizeL  DosSetFileSizeLProc = 0;
    4181static PROC_DosSetFilePtrL   DosSetFilePtrLProc   = 0;
     
    4484static BOOL f64BitIO = FALSE;
    4585
     86/* first user queries the data */
     87static  CDDRVLTR    cdDrvLtr = {0xffff, 0xffff};
     88
     89
     90/*******************************************************************************
     91*   Functions Prototypes.                                                      *
     92*******************************************************************************/
    4693BOOL WINAPI CharToOemA( LPCSTR s, LPSTR d );
    4794BOOL WINAPI OemToCharA( LPCSTR s, LPSTR d );
     95
     96
     97
    4898
    4999//******************************************************************************
     
    26312681#define DisketteCylinders 80
    26322682
    2633 #ifndef DEVTYPE_OPTICAL
    2634 #define DEVTYPE_OPTICAL                    0x0008
    2635 #endif
    2636 
    2637 // used for input to logical disk Get device parms Ioctl
    2638 #pragma pack(1)
    2639 typedef struct
    2640 {
    2641     UCHAR   Infotype;
    2642     UCHAR   DriveUnit;
    2643 } DSKREQ;
    2644 
    2645 /*------------------------------------------------*
    2646  * Cat 0x82, Func 0x60:  Return Drive Letter Info *
    2647  *------------------------------------------------*/
    2648 typedef struct DriveLetter_Data
    2649 {
    2650     USHORT  drive_count;
    2651     USHORT  first_drive_number;
    2652 } CDDRVLTR;
    2653 #pragma pack()
    26542683
    26552684
     
    27062735     * exactly very dynamic when it comes to this info.
    27072736     */
    2708     static  CDDRVLTR    cdDrvLtr = {0xffff, 0xffff};
    27092737    if (cdDrvLtr.drive_count == 0xffff)
    27102738    {
     
    27172745            == NO_ERROR)
    27182746        {
    2719             #define IOC_CDROM_2                 0x82 /* from cdioctl.h (ddk, os2cdrom.dmd sample) */
    2720             #define IOCD_RETURN_DRIVE_LETTER    0x60
    27212747            cbData = sizeof(cdDrvLtr);
    27222748            rc = DosDevIOCtl(hCDRom2,
     
    27272753            DosClose(hCDRom2);
    27282754        }
     2755        else
     2756            cdDrvLtr.drive_count = 0;
    27292757    }
    27302758
     
    29733001    memcpy(pTiledData, pData, *pdwDataLen);
    29743002
     3003#if 1
     3004    /*
     3005     * Quick and Dirty Fix!
     3006     * TO BE REMOVED!
     3007     *
     3008     * On some VPC installation without CDROM we seem to
     3009     * use a concidrable amount of time during Win2k shutdown.
     3010     * No idea why, but it has to do with CDROM we think.
     3011     *
     3012     * So, let's just fail all IOCtls to CD01 if there aren't any
     3013     * CDROMs in the system.
     3014     *
     3015     */
     3016
     3017    /*
     3018     * Check for CD drives
     3019     * We don't have to this everytime. I mean, the os2cdrom.dmd is
     3020     * exactly very dynamic when it comes to this info.
     3021     */
     3022    if (cdDrvLtr.drive_count == 0xffff)
     3023    {
     3024        HFILE           hCDRom2;
     3025        ULONG           ulAction = 0;
     3026
     3027        if (DosOpen("\\DEV\\CD-ROM2$", &hCDRom2, &ulAction, 0,
     3028                    FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
     3029                    OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL)
     3030            == NO_ERROR)
     3031        {
     3032            ULONG cbData = sizeof(cdDrvLtr);
     3033            rc = DosDevIOCtl(hCDRom2,
     3034                             IOC_CDROM_2,
     3035                             IOCD_RETURN_DRIVE_LETTER,
     3036                             NULL, 0, NULL,
     3037                             (PVOID)&cdDrvLtr, sizeof(cdDrvLtr), &cbData);
     3038            DosClose(hCDRom2);
     3039        }
     3040        else
     3041            cdDrvLtr.drive_count = 0;
     3042    }
     3043
     3044    if (    cdDrvLtr.drive_count == 0
     3045        &&  (dwCat == IOCTL_CDROMDISK
     3046             || (dwCat == IOCTL_CDROMAUDIO
     3047                 && dwParmMaxLen >= 4 && strncmp((char*)pParm, "CD01", 4))
     3048             )
     3049       )
     3050    {
     3051        /* just return some error code */
     3052        return ERROR_BAD_COMMAND;
     3053    }
     3054
     3055#endif
    29753056
    29763057  rc = DosDevIOCtl( (HFILE)hFile, dwCat, dwFunc,
Note: See TracChangeset for help on using the changeset viewer.