SMART_RCV_DRIVE_DATA DeviceIoControl ERROR_ACCESS_DENIED - PullRequest
0 голосов
/ 18 марта 2020

При вызове DeviceIoControl с кодом SMART_RCV_DRIVE_DATA происходит сбой (ERROR_ACCESS_DENIED). В чем проблема? Запуск от имени администратора.

    STORAGE_DEVICE_NUMBER sdn;
    DeviceIoControl(hDevice, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn), &cbReaded, NULL);

    SENDCMDINPARAMS scip;
    scip.cBufferSize = READ_ATTRIBUTE_BUFFER_SIZE;
    scip.irDriveRegs.bFeaturesReg = READ_ATTRIBUTES;
    scip.irDriveRegs.bSectorCountReg = 1;
    scip.irDriveRegs.bSectorNumberReg = 1;
    scip.irDriveRegs.bCylLowReg = SMART_CYL_LOW;
    scip.irDriveRegs.bCylHighReg = SMART_CYL_HI;
    scip.irDriveRegs.bDriveHeadReg = 0xA0 | (((BYTE)sdn.DeviceNumber & 1) << 4);
    scip.irDriveRegs.bCommandReg = SMART_CMD;

    BYTE bOutAttributes[sizeof(SENDCMDOUTPARAMS) + READ_ATTRIBUTE_BUFFER_SIZE - 1];

    if (!DeviceIoControl(hDevice, SMART_RCV_DRIVE_DATA, 
        &scip, sizeof(scip), bOutAttributes, sizeof(bOutAttributes),
        &cbReaded, NULL))
    {
        printf("GLE: %d\n", GetLastError());
    }
...