Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
|
prog:lazarus:cas:disks:deviceiocontrol [25/03/2020 19:20] thierry [A etudier] |
prog:lazarus:cas:disks:deviceiocontrol [11/04/2023 16:42] (Version actuelle) thierry [Sources] |
||
|---|---|---|---|
| Ligne 2: | Ligne 2: | ||
| ===== Commandes ===== | ===== Commandes ===== | ||
| ==== SMART_SEND_DRIVE_COMMAND ==== | ==== SMART_SEND_DRIVE_COMMAND ==== | ||
| + | <note important>Pour pouvoir utiliser SMART il faut que le fichier soit ouvert avec GENERIC_WRITE | ||
| + | <code pascal> | ||
| + | CreateFile(PChar(AFile), GENERIC_READ or GENERIC_WRITE, | ||
| + | FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0) | ||
| + | </code> | ||
| + | </note> | ||
| === Types utiles === | === Types utiles === | ||
| == TSendCmdInParams == | == TSendCmdInParams == | ||
| Ligne 103: | Ligne 109: | ||
| } | } | ||
| </code> | </code> | ||
| + | [[http://mojolabs.nz/posts.php?topic=105995|Source de ci-dessous]] | ||
| <code c++> | <code c++> | ||
| /* | /* | ||
| Ligne 285: | Ligne 291: | ||
| } | } | ||
| </code> | </code> | ||
| + | |||
| + | ---- | ||
| + | <code c++> | ||
| + | SENDCMDINPARAMS stCIP={0}; | ||
| + | SENDCMDOUTPARAMS stCOP={0}; | ||
| + | DWORD dwRet=0; | ||
| + | BOOL bRet=FALSE; | ||
| + | BYTE szAttributes[sizeof(SENDCMDOUTPARAMS) + READ_ATTRIBUTE_BUFFER_SIZE - 1]; | ||
| + | |||
| + | stCIP.cBufferSize=0; | ||
| + | stCIP.bDriveNumber = drive; | ||
| + | stCIP.irDriveRegs.bFeaturesReg= 0xD0; | ||
| + | stCIP.irDriveRegs.bSectorCountReg = 1; | ||
| + | stCIP.irDriveRegs.bSectorNumberReg = 1; | ||
| + | stCIP.irDriveRegs.bCylLowReg = 0x4F; | ||
| + | stCIP.irDriveRegs.bCylHighReg = 0xC2; | ||
| + | stCIP.irDriveRegs.bDriveHeadReg = 0xA0 | ((drive & 1) << 4); | ||
| + | stCIP.irDriveRegs.bCommandReg = 0xB0; | ||
| + | |||
| + | bRet=DeviceIoControl(handle,SMART_RCV_DRIVE_DATA,&stCIP,sizeof(stCIP),szAttributes,sizeof(SENDCMDOUTPARAMS)+ READ_ATTRIBUTE_BUFFER_SIZE - 1,&dwRet,NULL); | ||
| + | //std::cout<<"output="<<dwRet<<std::endl; | ||
| + | //printf("\n"); | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Projet Delphi : [[https://www.delphipraxis.net/97172-s-m-r-t-figured-out.html]] | ||
| === Sources === | === Sources === | ||
| Ligne 291: | Ligne 323: | ||
| - | ===== Sources ===== | + | ====== Sources & Ressources====== |
| * [[https://docs.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-deviceiocontrol|DeviceIOControl chez Doc Microsoft]] | * [[https://docs.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-deviceiocontrol|DeviceIOControl chez Doc Microsoft]] | ||
| * [[https://www.smartmontools.org/static/doxygen/atacmds_8cpp_source.html]] | * [[https://www.smartmontools.org/static/doxygen/atacmds_8cpp_source.html]] | ||
| + | * [[https://www.delphipraxis.net/97172-s-m-r-t-figured-out.html]] | ||