Re: retrieve harddisk`s modell,serial,firmware (Windows only
Posted: Thu Sep 18, 2014 6:50 pm
@IdeasVacuum: test this please and post the data returned. Admin rights are needed.
Code: Select all
Structure DeviceData
GeneralConfiguration.w; ; 0
LogicalCylinders.w; ; 1 Obsolete
SpecificConfiguration.w; ; 2
LogicalHeads.w; ; 3 Obsolete
Retired1.w[2]; ; 4-5
LogicalSectors.w; ; 6 Obsolete
ReservedForCompactFlash.l; ; 7-8
Retired2.w; ; 9
SerialNumber.a[20]; ; 10-19
Retired3.w; ; 20
BufferSize.w; ; 21 Obsolete
ECCSize.w; ; 22
FirmwareRev.a[8]; ; 23-26
ModelNumber.a[40]; ; 27-46
MaxNumPerInterupt.w; ; 47
Reserved1.w; ; 48
Capabilities1.w; ; 49
Capabilities2.w; ; 50
Obsolute5.l; ; 51-52
Field88and7064.w; ; 53
Obsolute6.w[5]; ; 54-58
MultSectorStuff.w; ; 59
TotalAddressableSectors.l; ; 60-61
Obsolute7.w; ; 62
MultiWordDma.w; ; 63
PioMode.w; ; 64
MinMultiwordDmaCycleTime.w; ; 65
RecommendedMultiwordDmaCycleTime.w; ; 66
MinPioCycleTimewoFlowCtrl.w; ; 67
MinPioCycleTimeWithFlowCtrl.w; ; 68
Reserved2.w[6]; ; 69-74
QueueDepth.w; ; 75
SerialAtaCapabilities.w; ; 76
ReservedForFutureSerialAta.w; ; 77
SerialAtaFeaturesSupported.w; ; 78
SerialAtaFeaturesEnabled.w; ; 79
MajorVersion.w; ; 80
MinorVersion.w; ; 81
CommandSetSupported1.w; ; 82
CommandSetSupported2.w; ; 83
CommandSetSupported3.w; ; 84
CommandSetEnabled1.w; ; 85
CommandSetEnabled2.w; ; 86
CommandSetDefault.w; ; 87
UltraDmaMode.w; ; 88
TimeReqForSecurityErase.w; ; 89
TimeReqForEnhancedSecure.w; ; 90
CurrentPowerManagement.w; ; 91
MasterPasswordRevision.w; ; 92
HardwareResetResult.w; ; 93
Acoustricmanagement.w; ; 94
StreamMinRequestSize.w; ; 95
StreamingTimeDma.w; ; 96
StreamingAccessLatency.w; ; 97
StreamingPerformance.l; ; 98-99
MaxUserLba.q; ; 100-103
StremingTimePio.w; ; 104
Reserved3.w; ; 105
SectorSize.w; ; 106
InterSeekDelay.w; ; 107
IeeeOui.w; ; 108
UniqueId3.w; ; 109
UniqueId2.w; ; 110
UniqueId1.w; ; 111
Reserved4.w[4]; ; 112-115
Reserved5.w; ; 116
WordsPerLogicalSector.l; ; 117-118
Reserved6.w[8]; ; 119-126
RemovableMediaStatus.w; ; 127
SecurityStatus.w; ; 128
VendorSpecific.w[31]; ; 129-159
CfaPowerMode1.w; ; 160
Reserved7.w[7]; ; 161-167
DeviceNominalFormFactor.w; ; 168
DataSetManagement.w; ; 169
AdditionalProductIdentifier.w[4] ; 170-173
ReservedForCompactFlashAssociation.w[2]; 174-175
CurrentMediaSerialNo.a[60]; ; 176-205
SctCommandTransport.w; ; 206 254
ReservedForCeAta1.w[2]; ; 207-208
AlignmentOfLogicalBlocks.w; ; 209
WriteReadVerifySectorCountMode3.l; ; 210-211
WriteReadVerifySectorCountMode2.l; ; 212-213
NvCacheCapabilities.w; ; 214
NvCacheSizeLogicalBlocks.l; ; 215-216
NominalMediaRotationRate.w; ; 217
Reserved8.w; ; 218
NvCacheOptions1.w; ; 219
NvCacheOptions2.w; ; 220
Reserved9.w; ; 221
TransportMajorVersionNumber.w; ; 222
TransportMinorVersionNumber.w; ; 223
ReservedForCeAta2.w[10]; ; 224-233
MinimumBlocksPerDownloadMicrocode.w; ; 234
MaximumBlocksPerDownloadMicrocode.w; ; 235
Reserved10.w[19]; ; 236-254
IntegrityWord.w; ; 255
EndStructure
Structure t_SPTD
Length.w ; data len
ScsiStatus.a ; SCSI Status
PathId.a ; Bus Number
TargetId.a ; Target
Lun.a ; Logical Unit Number
CdbLength.a ; CDB (Command Descriptor Block)
SenseInfoLength.a ; Sense Info len
DataIn.a ; data direction
padding0.a[3]
DataTransferLength.l ; data transfer length
TimeOutValue.i ; command timeout
DataBufferOffset.i ; Pointer to the data buffer
SenseInfoOffset.l ; Sense Info Offset
Cdb.a[16] ; Command Descriptor Block
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
Fill.a[4] ;
CompilerEndIf
EndStructure
Structure t_SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER
spt.t_SPTD ; SPTD structure
;Fill.l ;
SenseBuffer.a[32] ; Debugging-Info from the drive
DataBuffer.a[512]
EndStructure
pswb.t_SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER: OL.OVERLAPPED
Length.l: returned.l: i.l
status.l
With pswb\spt
\length = SizeOf(t_SPTD) ; size of the substructure
\PathId = 0
\TargetId = 0
\Lun = 0
\DataIn = 1 ; data dir
\TimeOutValue = 2 ; Timeout
\senseInfoLength = 24;SizeOf(pswb\SenseBuffer)-1 ; Sense Info size
\senseInfoOffset = OffsetOf(t_SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER\SenseBuffer) ; Sense Info Offset
\DataTransferLength = 512 ; data len
\DataBufferOffset = OffsetOf(t_SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER\DataBuffer) ; data buffer pointer
\Cdb[0] = $A1
\Cdb[1] = (4 << 1) | 0
\Cdb[2] = (1 << 3) | (1 << 2) | 2
\Cdb[3] = 0
;\Cdb[4] = 1
;\Cdb[5] = 0
;\Cdb[6] = 0
\Cdb[7] = 0
\Cdb[8] = $A0
\Cdb[9] = $EC;7
\CdbLength = 12 ; CDB len
EndWith
Length = OffsetOf(t_SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER\DataBuffer) + pswb\spt\DataTransferLength;;SizeOf(pswb) ; size of the structure
hdh = CreateFile_("\\.\PhysicalDrive2",#GENERIC_READ | #GENERIC_WRITE, #FILE_SHARE_READ | #FILE_SHARE_WRITE,0, #OPEN_EXISTING, 0, 0)
status = DeviceIoControl_(hdh, $4d004, @pswb, SizeOf(t_SPTD), @pswb, Length, @returned, @OL)
CloseHandle_(hdh)
Debug GetLastError_()
Debug returned
ShowMemoryViewer(@pswb,SizeOf(DeviceData))
;CallDebugger
;dev_data.DeviceData
;CopyMemory(@pswb\DataBuffer,@dev_data,SizeOf(t_SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER))
;Debug SizeOf(t_SPTD)
;ShowMemoryViewer(@dev_data,SizeOf(DeviceData))