Ra
а создавать ее или брать существующую - решать уже тебе
Size: a a a
Ra
ox
Ra
Ra
ox
Func MemView($size, $ptr = 0)ну я так выделяю, а не системным алоком, что бы когда ссылки на переменные закончатся автоматом удалило(хотя я не уверен, хз как устроено в аите это, но надеюсь что так)
Local $ret[]
$ret.struct = _DllStructCreate("align 1; byte bytes[" & $size & "];", $ptr)
$ret.ptr = DllStructGetPtr($ret.struct)
$ret.size = $size
return $ret
EndFunc
Func MemAlloc($size)
return MemView($size)
EndFunc
Ra
ox
Func SmartReadAttributes($hDevice, $bDriveNumber = 0)
Local $cip = SENDCMDINPARAMS()
$cip.cBufferSize = $READ_ATTRIBUTE_BUFFER_SIZE
$cip.bDriveNumber = $bDriveNumber
$cip.irDriveRegs_bFeaturesReg = $READ_ATTRIBUTES
$cip.irDriveRegs_bSectorCountReg = 1
$cip.irDriveRegs_bSectorNumberReg = 1
$cip.irDriveRegs_bCylLowReg = $SMART_CYL_LOW
$cip.irDriveRegs_bCylHighReg = $SMART_CYL_HI
$cip.irDriveRegs_bDriveHeadReg = $DRIVE_HEAD_REG
$cip.irDriveRegs_bCommandReg = $SMART_CMD
Local $mem = MemAlloc( ST_ATAOUTPARAM()._size + $READ_ATTRIBUTE_BUFFER_SIZE - 1 )
Local $ret = GetBaseObj()
Local $smartInfoRawList[]
Local $smartInfoThresholdsRawList[]
Local $smartInfoList[]
Local $smartInfoMap[]
if ( not( WinAPI_DeviceIoControl($hDevice, $SMART_RCV_DRIVE_DATA, ObjToStruct($cip), $mem.struct) ) ) then
return $ret
endif
$ret._isResult = true
Local $ptr = $mem.ptr + 16 + 2
Local $sii = 0
Local $i
for $i = 0 to 30 - 1
Local $smartRecordRaw = ObjRead(SMART_RECORD(), $ptr, true)
$ptr += SMART_RECORD()._size
if ( $smartRecordRaw.attribIndex <> 0 ) then
$smartInfoRawList[$sii] = $smartRecordRaw
Local $sir = SMART_INFO_RECORD()
$sir.attribIndex = $smartRecordRaw.attribIndex
$sir.attribValue = $smartRecordRaw.attribValue
$sir.attribWorst = $smartRecordRaw.attribWorst
$sir.attribRaw = $smartRecordRaw.attribRaw
$sir.threshold = 0xFFFF
$smartInfoMap[ $smartRecordRaw.attribIndex ] = $sir
$sii = $sii + 1
endif
next
$cip.irDriveRegs_bFeaturesReg = $READ_THRESHOLDS
$cip.cBufferSize = $READ_THRESHOLD_BUFFER_SIZE
if ( WinAPI_DeviceIoControl($hDevice, $SMART_RCV_DRIVE_DATA, ObjToStruct($cip), $mem.struct) ) then
Local $ptr = $mem.ptr + 16 + 2
Local $sii = 0
Local $i
for $i = 0 to 30 - 1
Local $smartRecordRaw = ObjRead(SMART_RECORD(), $ptr, true)
$ptr += SMART_RECORD()._size
if ( $smartRecordRaw.attribIndex <> 0 ) then
$smartInfoThresholdsRawList[$sii] = $smartRecordRaw
if ( $smartInfoMap[ $smartRecordRaw.attribIndex ] <> null ) then
$smartInfoMap[ $smartRecordRaw.attribIndex ].threshold = $smartRecordRaw.attribRaw
endif
$sii = $sii + 1
endif
next
endif
Local $i = 0
Local $j = 0
for $i = 0 to 256 - 1
if ( $smartInfoMap[$i] <> null ) then
$smartInfoList[$j] = $smartInfoMap[$i]
$j += 1
endif
next
$ret._isResult = true
$ret.smartInfoList = $smartInfoList
$ret.smartInfoMap = $smartInfoMap
$ret.smartInfoRawList = $smartInfoRawList
$ret.smartInfoThresholdsRawList = $smartInfoThresholdsRawList
return $ret
EndFunc
Ra
Ra
Ra
Ra
Ra
Ra
Ra