Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.5 KiB

  1. /******************************************************************
  2. PhysicalMedia.H -- WMI provider class definition
  3. Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  4. *******************************************************************/
  5. #ifndef _CPHYSICALMEDIA_H_
  6. #define _CPHYSICALMEDIA_H_
  7. #define PROVIDER_NAME_PHYSICALMEDIA L"Win32_PhysicalMedia"
  8. #define ERROR_CLASSPATH L"\\\\.\\root\\cimv2:__ExtendedStatus"
  9. #define TAG L"Tag"
  10. #define SERIALNUMBER L"SerialNumber"
  11. //
  12. // Valid values for the bCommandReg member of IDEREGS.
  13. //
  14. #define IDE_ATAPI_ID 0xA1 // Returns ID sector for ATAPI.
  15. #define IDE_ID_FUNCTION 0xEC // Returns ID sector for ATA.
  16. #define IDE_EXECUTE_SMART_FUNCTION 0xB0 // Performs SMART cmd.
  17. // Requires valid bFeaturesReg,
  18. #if(_WIN32_WINNT >= 0x0400)
  19. #define IOCTL_DISK_CONTROLLER_NUMBER CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  20. // IOCTL support for SMART drive fault prediction.
  21. #define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  22. #define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  23. #define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  24. #endif /* _WIN32_WINNT >= 0x0400 */ // bCylLowReg, and bCylHighReg
  25. //---------------------------------------------------------------------
  26. // The following struct defines the interesting part of the IDENTIFY
  27. // buffer:
  28. //---------------------------------------------------------------------
  29. typedef struct _IDSECTOR {
  30. USHORT wGenConfig;
  31. USHORT wNumCyls;
  32. USHORT wReserved;
  33. USHORT wNumHeads;
  34. USHORT wBytesPerTrack;
  35. USHORT wBytesPerSector;
  36. USHORT wSectorsPerTrack;
  37. USHORT wVendorUnique[3];
  38. CHAR sSerialNumber[20];
  39. USHORT wBufferType;
  40. USHORT wBufferSize;
  41. USHORT wECCSize;
  42. CHAR sFirmwareRev[8];
  43. CHAR sModelNumber[40];
  44. USHORT wMoreVendorUnique;
  45. USHORT wDoubleWordIO;
  46. USHORT wCapabilities;
  47. USHORT wReserved1;
  48. USHORT wPIOTiming;
  49. USHORT wDMATiming;
  50. USHORT wBS;
  51. USHORT wNumCurrentCyls;
  52. USHORT wNumCurrentHeads;
  53. USHORT wNumCurrentSectorsPerTrack;
  54. ULONG ulCurrentSectorCapacity;
  55. USHORT wMultSectorStuff;
  56. ULONG ulTotalAddressableSectors;
  57. USHORT wSingleWordDMA;
  58. USHORT wMultiWordDMA;
  59. BYTE bReserved[128];
  60. } IDSECTOR, *PIDSECTOR;
  61. class CPhysicalMedia : public Provider
  62. {
  63. private:
  64. HRESULT Enumerate( MethodContext *pMethodContext );
  65. HRESULT GetPhysDiskInfoNT ( CInstance *pInstance, LPCWSTR lpwszDiskSpec, BYTE bIndex );
  66. void ChangeByteOrder(char *szString, USHORT uscStrSize);
  67. HRESULT GetIdentifyData( HANDLE hDrive, BYTE bDriveNumber, BYTE bDfpDriveMap, BYTE bIDCmd, CHString &a_SerialNumber );
  68. HRESULT EnableSmart( HANDLE hDrive, BYTE bDriveNum, BYTE & bDfpDriveMap );
  69. HRESULT GetSmartVersion( HANDLE Handle, BYTE bDriveNumber, CHString &a_SerialNumber );
  70. HRESULT GetSCSIVersion(
  71. HANDLE h,
  72. BYTE bDriveNumber,
  73. CHString &a_SerialNumber);
  74. protected:
  75. HRESULT EnumerateInstances (
  76. MethodContext *pMethodContext,
  77. long lFlags = 0L
  78. ) ;
  79. HRESULT GetObject (
  80. CInstance *pInstance,
  81. long lFlags,
  82. CFrameworkQuery &Query
  83. ) ;
  84. public:
  85. CPhysicalMedia (
  86. LPCWSTR lpwszClassName,
  87. LPCWSTR lpwszNameSpace
  88. ) ;
  89. virtual ~CPhysicalMedia () ;
  90. private:
  91. };
  92. #endif