问题
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