Option Explicit'--------------------------------------------------------------------------
' 模 块: 取磁盘硬件信息处理类
' 版 本: 1.0
' 文件名: CDiskInfo.cls
' 作者: 林天炮
' 修改日期:2003-03-13
'
' 功能说明:获取硬盘序列号、型号、磁道扇区信息等
' 版权说明:此为共享代码,根据微软提供的例程改编,可以任意修改及使用,
' 作者对此模块运行所引起的错误不承担任何责任。
'
' 引用此模块时须保留作者署名,有意见或错误请发送至[email protected]
'
' 注意事项:支持Windows 95 OSR2, Windows 98, Windows NT, Windows 2000
' XP没有测试,估计没问题,在Win9X下必须保证存在SMARTVSD.vxd
'--------------------------------------------------------------------------'/****************************************************************************
'* *
'* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY *
'* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE *
'* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR *
'* PURPOSE. *
'* *
'* Copyright 1993-98 Microsoft Corporation. All Rights Reserved. *
'* *
'****************************************************************************/Private Const MAX_IDE_DRIVES As Long = 4 ' Max number of drives assuming primary/secondary, master/slave topology
Private Const READ_ATTRIBUTE_BUFFER_SIZE As Long = 512
Private Const IDENTIFY_BUFFER_SIZE As Long = 512
Private Const READ_THRESHOLD_BUFFER_SIZE As Long = 512'
' IOCTL commands
'
Private Const DFP_GET_VERSION As Long = &H74080
Private Const DFP_SEND_DRIVE_COMMAND As Long = &H7C084
Private Const DFP_RECEIVE_DRIVE_DATA As Long = &H7C088'---------------------------------------------------------------------
' GETVERSIONOUTPARAMS contains the data returned from the
' Get Driver Version function.
'---------------------------------------------------------------------
Private Type GETVERSIONOUTPARAMS
bVersion As Byte ' Binary driver version.
bRevision As Byte ' Binary driver revision.
bReserved As Byte ' Not used.
bIDEDeviceMap As Byte ' Bit map of IDE devices.
fCapabilities As Long ' Bit mask of driver capabilities.
dwReserved(3) As Long ' For future use.
End Type'
' Bits returned in the fCapabilities member of GETVERSIONOUTPARAMS
'
Private Const CAP_IDE_ID_FUNCTION As Long = 1 ' ATA ID command supported
Private Const CAP_IDE_ATAPI_ID As Long = 2 ' ATAPI ID command supported
Private Const CAP_IDE_EXECUTE_SMART_FUNCTION As Long = 4 ' SMART commannds supported'---------------------------------------------------------------------
' IDE registers
'---------------------------------------------------------------------
Private Type IDEREGS
bFeaturesReg As Byte ' Used for specifying SMART "commands".
bSectorCountReg As Byte ' IDE sector count register
bSectorNumberReg As Byte ' IDE sector number register
bCylLowReg As Byte ' IDE low order cylinder value
bCylHighReg As Byte ' IDE high order cylinder value
bDriveHeadReg As Byte ' IDE drive/head register
bCommandReg As Byte ' Actual IDE command.
bReserved As Byte ' reserved for future use. Must be zero.
End Type'---------------------------------------------------------------------
' SENDCMDINPARAMS contains the input parameters for the
' Send Command to Drive function.
'---------------------------------------------------------------------
Private Type SENDCMDINPARAMS
cBufferSize As Long ' Buffer size in bytes
irDriveRegs As IDEREGS ' Structure with drive register values.
bDriveNumber As Byte ' Physical drive number to send
' command to (0,1,2,3).
bReserved(2) As Byte ' Reserved for future expansion.
dwReserved(3) As Long ' For future use.
bBuffer(0) As Byte ' Input buffer.
End Type'
' Valid values for the bCommandReg member of IDEREGS.
'
Private Const IDE_ATAPI_ID As Long = &HA1 ' Returns ID sector for ATAPI.
Private Const IDE_ID_FUNCTION As Long = &HEC ' Returns ID sector for ATA.
Private Const IDE_EXECUTE_SMART_FUNCTION As Long = &HB0 ' Performs SMART cmd.
' Requires valid bFeaturesReg,
' bCylLowReg, and bCylHighReg
'
' Cylinder register values required when issuing SMART command
'
Private Const SMART_CYL_LOW As Long = &H4F
Private Const SMART_CYL_HI As Long = &HC2'---------------------------------------------------------------------
' Status returned from driver
'---------------------------------------------------------------------
Private Type DRIVERSTATUS
bDriverError As Byte ' Error code from driver,
' or 0 if no error.
bIDEStatus As Byte ' Contents of IDE Error register.
' Only valid when bDriverError
' is SMART_IDE_ERROR.
bReserved(1) As Byte ' Reserved for future expansion.
dwReserved(1) As Long ' Reserved for future expansion.
End Type
' 模 块: 取磁盘硬件信息处理类
' 版 本: 1.0
' 文件名: CDiskInfo.cls
' 作者: 林天炮
' 修改日期:2003-03-13
'
' 功能说明:获取硬盘序列号、型号、磁道扇区信息等
' 版权说明:此为共享代码,根据微软提供的例程改编,可以任意修改及使用,
' 作者对此模块运行所引起的错误不承担任何责任。
'
' 引用此模块时须保留作者署名,有意见或错误请发送至[email protected]
'
' 注意事项:支持Windows 95 OSR2, Windows 98, Windows NT, Windows 2000
' XP没有测试,估计没问题,在Win9X下必须保证存在SMARTVSD.vxd
'--------------------------------------------------------------------------'/****************************************************************************
'* *
'* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY *
'* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE *
'* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR *
'* PURPOSE. *
'* *
'* Copyright 1993-98 Microsoft Corporation. All Rights Reserved. *
'* *
'****************************************************************************/Private Const MAX_IDE_DRIVES As Long = 4 ' Max number of drives assuming primary/secondary, master/slave topology
Private Const READ_ATTRIBUTE_BUFFER_SIZE As Long = 512
Private Const IDENTIFY_BUFFER_SIZE As Long = 512
Private Const READ_THRESHOLD_BUFFER_SIZE As Long = 512'
' IOCTL commands
'
Private Const DFP_GET_VERSION As Long = &H74080
Private Const DFP_SEND_DRIVE_COMMAND As Long = &H7C084
Private Const DFP_RECEIVE_DRIVE_DATA As Long = &H7C088'---------------------------------------------------------------------
' GETVERSIONOUTPARAMS contains the data returned from the
' Get Driver Version function.
'---------------------------------------------------------------------
Private Type GETVERSIONOUTPARAMS
bVersion As Byte ' Binary driver version.
bRevision As Byte ' Binary driver revision.
bReserved As Byte ' Not used.
bIDEDeviceMap As Byte ' Bit map of IDE devices.
fCapabilities As Long ' Bit mask of driver capabilities.
dwReserved(3) As Long ' For future use.
End Type'
' Bits returned in the fCapabilities member of GETVERSIONOUTPARAMS
'
Private Const CAP_IDE_ID_FUNCTION As Long = 1 ' ATA ID command supported
Private Const CAP_IDE_ATAPI_ID As Long = 2 ' ATAPI ID command supported
Private Const CAP_IDE_EXECUTE_SMART_FUNCTION As Long = 4 ' SMART commannds supported'---------------------------------------------------------------------
' IDE registers
'---------------------------------------------------------------------
Private Type IDEREGS
bFeaturesReg As Byte ' Used for specifying SMART "commands".
bSectorCountReg As Byte ' IDE sector count register
bSectorNumberReg As Byte ' IDE sector number register
bCylLowReg As Byte ' IDE low order cylinder value
bCylHighReg As Byte ' IDE high order cylinder value
bDriveHeadReg As Byte ' IDE drive/head register
bCommandReg As Byte ' Actual IDE command.
bReserved As Byte ' reserved for future use. Must be zero.
End Type'---------------------------------------------------------------------
' SENDCMDINPARAMS contains the input parameters for the
' Send Command to Drive function.
'---------------------------------------------------------------------
Private Type SENDCMDINPARAMS
cBufferSize As Long ' Buffer size in bytes
irDriveRegs As IDEREGS ' Structure with drive register values.
bDriveNumber As Byte ' Physical drive number to send
' command to (0,1,2,3).
bReserved(2) As Byte ' Reserved for future expansion.
dwReserved(3) As Long ' For future use.
bBuffer(0) As Byte ' Input buffer.
End Type'
' Valid values for the bCommandReg member of IDEREGS.
'
Private Const IDE_ATAPI_ID As Long = &HA1 ' Returns ID sector for ATAPI.
Private Const IDE_ID_FUNCTION As Long = &HEC ' Returns ID sector for ATA.
Private Const IDE_EXECUTE_SMART_FUNCTION As Long = &HB0 ' Performs SMART cmd.
' Requires valid bFeaturesReg,
' bCylLowReg, and bCylHighReg
'
' Cylinder register values required when issuing SMART command
'
Private Const SMART_CYL_LOW As Long = &H4F
Private Const SMART_CYL_HI As Long = &HC2'---------------------------------------------------------------------
' Status returned from driver
'---------------------------------------------------------------------
Private Type DRIVERSTATUS
bDriverError As Byte ' Error code from driver,
' or 0 if no error.
bIDEStatus As Byte ' Contents of IDE Error register.
' Only valid when bDriverError
' is SMART_IDE_ERROR.
bReserved(1) As Byte ' Reserved for future expansion.
dwReserved(1) As Long ' Reserved for future expansion.
End Type
可以在ring3上执行ring0指令?