Source code of Windows XP (NT5)
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.

176 lines
5.6 KiB

  1. #include "namellst.h"
  2. #include "hwdev.h"
  3. #include "cmmn.h"
  4. #include "misc.h"
  5. #include <objbase.h>
  6. #include <shpriv.h>
  7. ///////////////////////////////////////////////////////////////////////////////
  8. //
  9. //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. class CVolume : public CNamedElem, public CHandleNotifTarget
  12. {
  13. public:
  14. // CNamedElem
  15. HRESULT Init(LPCWSTR pszElemName);
  16. // CHandleNotifTarget
  17. HRESULT HNTHandleEvent(DEV_BROADCAST_HANDLE* pdbh, DWORD dwEventType);
  18. // CVolume
  19. // Returns S_FALSE if can't find it
  20. HRESULT GetHWDeviceInst(CHWDeviceInst** pphwdevinst);
  21. HRESULT GetDeviceType(DEVICE_TYPE* pdevtype);
  22. HRESULT GetDeviceNumber(ULONG* puldeviceNumber);
  23. HRESULT GetVolumeConstInfo(LPWSTR pszVolumeGUID, DWORD cchVolumeGUID,
  24. DWORD* pdwVolumeFlags, DWORD* pdwDriveType, DWORD* pdwDriveCap);
  25. HRESULT GetVolumeMediaInfo(LPWSTR pszLabel, DWORD cchLabel,
  26. LPWSTR pszFileSystem, DWORD cchFileSystem, DWORD* pdwFileSystemFlags,
  27. DWORD* pdwMaxFileNameLen, DWORD* pdwRootAttributes,
  28. DWORD* pdwSerialNumber, DWORD* pdwDriveState, DWORD* pdwMediaState,
  29. DWORD* pdwMediaCap);
  30. HRESULT GetIconAndLabelInfo(LPWSTR pszAutorunIconLocation,
  31. DWORD cchAutorunIconLocation, LPWSTR pszAutorunLabel, DWORD cchAutorunLabel,
  32. LPWSTR pszIconLocationFromService, DWORD cchIconLocationFromService,
  33. LPWSTR pszNoMediaIconLocationFromService,
  34. DWORD cchNoMediaIconLocationFromService,
  35. LPWSTR pszLabelFromService, DWORD cchLabelFromService);
  36. HRESULT HandleArrival();
  37. HRESULT HandleRemoval();
  38. // Caller needs to free the returned ppsz
  39. HRESULT GetAllMountPoints(LPWSTR* ppsz);
  40. HRESULT MediaIsAccessible(BOOL* pfAccessible);
  41. public:
  42. static HRESULT Create(CNamedElem** ppelem);
  43. static HRESULT GetFillEnum(CFillEnum** ppfillenum);
  44. public:
  45. CVolume();
  46. ~CVolume();
  47. private:
  48. HRESULT _InitHelper(LPCWSTR pszElemName);
  49. void _HandleAccessDenied();
  50. HRESULT _CreateMountPoints();
  51. HRESULT _UpdateMountPoints();
  52. HRESULT _GetMountPoints(LPWSTR* ppsz, DWORD* pcch);
  53. HRESULT _CreateMtPt(LPWSTR pszMtPt);
  54. HRESULT _RemoveMtPt(LPWSTR pszMtPt);
  55. HRESULT _RegisterNotif();
  56. HRESULT _UnregisterNotif();
  57. HRESULT _InitDriveType(HANDLE hDevice);
  58. HRESULT _InitHWDeviceInst();
  59. HRESULT _UpdateConstInfo(HANDLE hDevice);
  60. HRESULT _UpdateMediaInfo(HANDLE hDevice, BOOL fImpersonate);
  61. HRESULT _UpdateMediaInfoOnRemove();
  62. HRESULT _UpdateSoftEjectCaps();
  63. HRESULT _UpdateRemovableDevice();
  64. HRESULT _UpdateHasMedia(HANDLE hDevice);
  65. HRESULT _UpdateSpecialFilePresence();
  66. HRESULT _UpdateTrackInfo(HANDLE hDevice);
  67. HRESULT _FillMMC2CD(HANDLE hDevice);
  68. HRESULT _UpdateMMC2CDInfo(HANDLE hDevice);
  69. HRESULT _ExtractAutorunIconAndLabel();
  70. HRESULT _GetDeviceHandleSafe(HANDLE* phDevice, BOOL fGenericReadRequired);
  71. HRESULT _CloseDeviceHandleSafe(HANDLE hDevice);
  72. HRESULT _HandleMediaArrival();
  73. HRESULT _HandleMediaRemoval();
  74. HRESULT _HandleVolumeChange();
  75. HRESULT _AdviseVolumeChangeHelper(BOOL fAdded);
  76. HRESULT _AdviseMountPointHelper(LPCWSTR pszMountPoint, BOOL fAdded);
  77. HRESULT _AdviseVolumeMountingEvent(DWORD dwEvent);
  78. HRESULT _GetVOLUMEINFO2(VOLUMEINFO2** ppvolinfo2);
  79. HRESULT _ShouldTryAutoplay(BOOL* pfTry);
  80. HRESULT _GetDeviceIDDisk(LPWSTR pszDeviceIDDisk,
  81. DWORD cchDeviceIDDisk);
  82. HRESULT _DVDRAMHack(HANDLE hDevice);
  83. public:
  84. DWORD _dwState;
  85. private:
  86. DWORD _dwMediaPresentFromEvent;
  87. DWORD _dwMediaState;
  88. DWORD _dwMediaCap;
  89. WCHAR _szVolumeGUID[50];
  90. DWORD _dwVolumeFlags;
  91. DWORD _dwDriveType;
  92. DWORD _dwDriveCap;
  93. DWORD _dwDriveState;
  94. WCHAR _szDeviceIDDisk[MAX_DEVICEID];
  95. WCHAR _szLabel[MAX_LABEL];
  96. DWORD _dwSerialNumber;
  97. DWORD _dwMaxFileNameLen;
  98. DWORD _dwFileSystemFlags;
  99. WCHAR _szFileSystem[MAX_FILESYSNAME];
  100. DWORD _dwRootAttributes;
  101. DEVICE_TYPE _devtype;
  102. ULONG _ulDeviceNumber;
  103. ULONG _ulPartitionNumber;
  104. LPWSTR _pszMountPoints;
  105. DWORD _cchMountPoints;
  106. CHWDeviceInst _hwdevinst;
  107. BOOL _fHWDevInstInited;
  108. DWORD* _prgMMC2Features;
  109. BOOL _fFirstTime;
  110. CCriticalSection _cs;
  111. DEVINST _devinst;
  112. HDEVNOTIFY _hdevnotify;
  113. #ifdef DEBUG
  114. BOOL _fGenericReadRequired;
  115. #endif
  116. BOOL _fProcessMediaArrived;
  117. public: //for now, and for CStorageInfoImpl only
  118. WCHAR _szAutorunIconLocation[MAX_ICONLOCATION];
  119. WCHAR _szAutorunLabel[MAX_LABEL];
  120. };
  121. class CVolumeFillEnum : public CFillEnum
  122. {
  123. public:
  124. HRESULT Next(LPWSTR pszElemName, DWORD cchElemName, DWORD* pcchRequired);
  125. public:
  126. HRESULT _Init();
  127. private:
  128. CIntfFillEnum _intffillenum;
  129. };