GetHardDriveID.h
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:6k
源码类别:

交通/航空行业

开发平台:

Visual C++

  1. // GetScsiHardDriveID.h: interface for the CGetScsiHardDriveID class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_GETSCSIHARDDRIVEID_H__8D509B02_5C45_4C4F_82C3_C55C498D545E__INCLUDED_)
  5. #define AFX_GETSCSIHARDDRIVEID_H__8D509B02_5C45_4C4F_82C3_C55C498D545E__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. class CGetScsiHardDriveID  
  10. {
  11. public:
  12. CGetScsiHardDriveID();
  13. virtual ~CGetScsiHardDriveID();
  14. };
  15. #endif // !defined(AFX_GETSCSIHARDDRIVEID_H__8D509B02_5C45_4C4F_82C3_C55C498D545E__INCLUDED_)
  16. ////////////////////////////////////////////////////////////////////////////////
  17. //
  18. //                        自加的
  19. //
  20. ////////////////////////////////////////////////////////////////////////////////
  21. // HWID.h: interface for the HWID class.
  22. //
  23. //////////////////////////////////////////////////////////////////////
  24. #if !defined(AFX_HWID_H__015DD532_2C83_40E6_9308_35CC79CAE29A__INCLUDED_)
  25. #define AFX_HWID_H__015DD532_2C83_40E6_9308_35CC79CAE29A__INCLUDED_
  26. #if _MSC_VER > 1000
  27. #pragma once
  28. #endif // _MSC_VER > 1000
  29. #pragma pack(1)
  30.    //  Max number of drives assuming primary/secondary, master/slave topology
  31. #define  MAX_IDE_DRIVES  4
  32. #define  IDENTIFY_BUFFER_SIZE  512
  33.    //  IOCTL commands
  34. #define  DFP_GET_VERSION          0x00074080
  35. #define  DFP_SEND_DRIVE_COMMAND   0x0007c084
  36. #define  DFP_RECEIVE_DRIVE_DATA   0x0007c088
  37. #define  FILE_DEVICE_SCSI              0x0000001b
  38. #define  IOCTL_SCSI_MINIPORT_IDENTIFY  ((FILE_DEVICE_SCSI << 16) + 0x0501)
  39. #define  IOCTL_SCSI_MINIPORT 0x0004D008  //  see NTDDSCSI.H for definition
  40.    //  GETVERSIONOUTPARAMS contains the data returned from the 
  41.    //  Get Driver Version function.
  42. typedef struct _GETVERSIONOUTPARAMS
  43. {
  44.    BYTE bVersion;      // Binary driver version.
  45.    BYTE bRevision;     // Binary driver revision.
  46.    BYTE bReserved;     // Not used.
  47.    BYTE bIDEDeviceMap; // Bit map of IDE devices.
  48.    DWORD fCapabilities; // Bit mask of driver capabilities.
  49.    DWORD dwReserved[4]; // For future use.
  50. } GETVERSIONOUTPARAMS, *PGETVERSIONOUTPARAMS, *LPGETVERSIONOUTPARAMS;
  51.    //  Bits returned in the fCapabilities member of GETVERSIONOUTPARAMS 
  52. #define  CAP_IDE_ID_FUNCTION             1  // ATA ID command supported
  53. #define  CAP_IDE_ATAPI_ID                2  // ATAPI ID command supported
  54. #define  CAP_IDE_EXECUTE_SMART_FUNCTION  4  // SMART commannds supported
  55.    //  IDE registers
  56. typedef struct _IDEREGS
  57. {
  58.    BYTE bFeaturesReg;       // Used for specifying SMART "commands".
  59.    BYTE bSectorCountReg;    // IDE sector count register
  60.    BYTE bSectorNumberReg;   // IDE sector number register
  61.    BYTE bCylLowReg;         // IDE low order cylinder value
  62.    BYTE bCylHighReg;        // IDE high order cylinder value
  63.    BYTE bDriveHeadReg;      // IDE drive/head register
  64.    BYTE bCommandReg;        // Actual IDE command.
  65.    BYTE bReserved;          // reserved for future use.  Must be zero.
  66. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  67.    //  SENDCMDINPARAMS contains the input parameters for the 
  68.    //  Send Command to Drive function.
  69. typedef struct _SENDCMDINPARAMS
  70. {
  71.    DWORD     cBufferSize;   //  Buffer size in bytes
  72.    IDEREGS   irDriveRegs;   //  Structure with drive register values.
  73.    BYTE bDriveNumber;       //  Physical drive number to send 
  74.                             //  command to (0,1,2,3).
  75.    BYTE bReserved[3];       //  Reserved for future expansion.
  76.    DWORD     dwReserved[4]; //  For future use.
  77.    BYTE      bBuffer[1];    //  Input buffer.
  78. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  79.    //  Valid values for the bCommandReg member of IDEREGS.
  80. #define  IDE_ATAPI_IDENTIFY  0xA1  //  Returns ID sector for ATAPI.
  81. #define  IDE_ATA_IDENTIFY    0xEC  //  Returns ID sector for ATA.
  82.    // Status returned from driver
  83. typedef struct _DRIVERSTATUS
  84. {
  85.    BYTE  bDriverError;  //  Error code from driver, or 0 if no error.
  86.    BYTE  bIDEStatus;    //  Contents of IDE Error register.
  87.                         //  Only valid when bDriverError is SMART_IDE_ERROR.
  88.    BYTE  bReserved[2];  //  Reserved for future expansion.
  89.    DWORD  dwReserved[2];  //  Reserved for future expansion.
  90. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  91.    // Structure returned by PhysicalDrive IOCTL for several commands
  92. typedef struct _SENDCMDOUTPARAMS
  93. {
  94.    DWORD         cBufferSize;   //  Size of bBuffer in bytes
  95.    DRIVERSTATUS  DriverStatus;  //  Driver status structure.
  96.    BYTE          bBuffer[1];    //  Buffer of arbitrary length in which to store the data read from the                                                       // drive.
  97. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  98.    // The following struct defines the interesting part of the IDENTIFY
  99.    // buffer:
  100. typedef struct _IDSECTOR
  101. {
  102.    USHORT  wGenConfig;
  103.    USHORT  wNumCyls;
  104.    USHORT  wReserved;
  105.    USHORT  wNumHeads;
  106.    USHORT  wBytesPerTrack;
  107.    USHORT  wBytesPerSector;
  108.    USHORT  wSectorsPerTrack;
  109.    USHORT  wVendorUnique[3];
  110.    CHAR    sSerialNumber[20];
  111.    USHORT  wBufferType;
  112.    USHORT  wBufferSize;
  113.    USHORT  wECCSize;
  114.    CHAR    sFirmwareRev[8];
  115.    CHAR    sModelNumber[40];
  116.    USHORT  wMoreVendorUnique;
  117.    USHORT  wDoubleWordIO;
  118.    USHORT  wCapabilities;
  119.    USHORT  wReserved1;
  120.    USHORT  wPIOTiming;
  121.    USHORT  wDMATiming;
  122.    USHORT  wBS;
  123.    USHORT  wNumCurrentCyls;
  124.    USHORT  wNumCurrentHeads;
  125.    USHORT  wNumCurrentSectorsPerTrack;
  126.    ULONG   ulCurrentSectorCapacity;
  127.    USHORT  wMultSectorStuff;
  128.    ULONG   ulTotalAddressableSectors;
  129.    USHORT  wSingleWordDMA;
  130.    USHORT  wMultiWordDMA;
  131.    BYTE    bReserved[128];
  132. } IDSECTOR, *PIDSECTOR;
  133. typedef struct _SRB_IO_CONTROL
  134. {
  135.    ULONG HeaderLength;
  136.    UCHAR Signature[8];
  137.    ULONG Timeout;
  138.    ULONG ControlCode;
  139.    ULONG ReturnCode;
  140.    ULONG Length;
  141. } SRB_IO_CONTROL, *PSRB_IO_CONTROL;
  142. typedef struct _DRIVER_INFO_OK
  143. {
  144. char ModalNumber[40];
  145. char SerialNumber[20];
  146. char ControlNum[8];
  147. DWORD DriveType;
  148. DWORD Cylinders;
  149. DWORD Heads;
  150. DWORD Sectors;
  151. } DRIVER_INFO_OK, *PDRIVE_INFO_OK;
  152. BOOL  IsWinNT();
  153. BOOL  ReadIdeDriveAsScsiDriveInNT(const int idrive,PDRIVE_INFO_OK buf);
  154. BOOL  ReadPhysicalDriveInNT(const int idrive,PDRIVE_INFO_OK buf);
  155. BOOL  ReadDrivePortsInWin9X (int idrive, PDRIVE_INFO_OK buf);
  156. BOOL GetHardDiskID(char szBuff[128]);
  157. void TrimRight(char * psString);
  158. #endif // !defined(AFX_HWID_H__015DD532_2C83_40E6_9308_35CC79CAE29A__INCLUDED_)