SMART_RCV_DRIVE_DATA DeviceIoControl ERROR_ACCESS_DENIED

有些话、适合烂在心里 提交于 2020-03-25 15:16:09

问题


When calling DeviceIoControl with SMART_RCV_DRIVE_DATA code it fails (ERROR_ACCESS_DENIED). What is the problem? Run as admin.

    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());
    }

来源:https://stackoverflow.com/questions/60737102/smart-rcv-drive-data-deviceiocontrol-error-access-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!