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.

184 lines
4.8 KiB

  1. #include "mtpt.h"
  2. class CShare;
  3. class CMtPtRemote : public CMountPoint
  4. {
  5. ///////////////////////////////////////////////////////////////////////////////
  6. // Public methods
  7. ///////////////////////////////////////////////////////////////////////////////
  8. public:
  9. CMtPtRemote();
  10. ~CMtPtRemote();
  11. // virtual override
  12. BOOL IsUnavailableNetDrive();
  13. BOOL IsDisconnectedNetDrive();
  14. BOOL IsFormatted();
  15. HRESULT GetLabel(LPTSTR pszLabel, DWORD cchLabel);
  16. HRESULT GetLabelNoFancy(LPTSTR pszLabel, DWORD cchLabel);
  17. HRESULT SetLabel(HWND hwnd, LPCTSTR pszLabel);
  18. HRESULT ChangeNotifyRegisterAlias(void);
  19. HRESULT GetRemotePath(LPWSTR pszPath, DWORD cchPath);
  20. UINT GetIcon(LPTSTR pszModule, DWORD cchModule);
  21. HRESULT GetAssocSystemElement(IAssociationElement **ppae);
  22. DWORD GetShellDescriptionID();
  23. int GetDriveFlags();
  24. void GetTypeString(LPTSTR pszType, DWORD cchType);
  25. HKEY GetRegKey();
  26. static void _NotifyReconnectedNetDrive(LPCWSTR pszMountPoint);
  27. ///////////////////////////////////////////////////////////////////////////////
  28. // Miscellaneous helpers
  29. ///////////////////////////////////////////////////////////////////////////////
  30. private:
  31. HRESULT _Init(LPCWSTR pszName, LPCWSTR pszShareName, BOOL fUnavailable);
  32. HRESULT _InitWithoutShareName(LPCWSTR pszName);
  33. HRESULT _GetDefaultUNCDisplayName(LPTSTR pszLabel, DWORD cchLabel);
  34. BOOL _GetComputerDisplayNameFromReg(LPTSTR pszLabel, DWORD cchLabel);
  35. LPCTSTR _GetUNCName();
  36. BOOL _IsConnected();
  37. BOOL _IsUnavailableNetDrive();
  38. BOOL _IsUnavailableNetDriveFromStateVar();
  39. BOOL _IsRemote();
  40. BOOL _IsSlow();
  41. BOOL _IsAutorun();
  42. // returns DT_* defined above
  43. DWORD _GetMTPTDriveType();
  44. // returns CT_* defined above
  45. DWORD _GetMTPTContentType();
  46. DWORD _GetPathSpeed();
  47. void _CalcPathSpeed();
  48. BOOL _GetFileAttributes(DWORD* pdwAttrib);
  49. BOOL _GetFileSystemName(LPTSTR pszFileSysName, DWORD cchFileSysName);
  50. BOOL _GetGVILabelOrMixedCaseFromReg(LPTSTR pszLabel, DWORD cchLabel);
  51. BOOL _GetGVILabel(LPTSTR pszLabel, DWORD cchLabel);
  52. BOOL _GetSerialNumber(DWORD* pdwSerialNumber);
  53. BOOL _GetFileSystemFlags(DWORD* pdwFlags);
  54. int _GetGVIDriveFlags();
  55. int _GetDriveType();
  56. DWORD _GetAutorunContentType();
  57. UINT _GetAutorunIcon(LPTSTR pszModule, DWORD cchModule);
  58. struct GFAGVICALL* _PrepareThreadParam(HANDLE* phEventBegun,
  59. HANDLE* phEventFinish);
  60. BOOL _HaveGFAAndGVIExpired(DWORD dwNow);
  61. BOOL _UpdateGFAAndGVIInfo();
  62. void _UpdateWNetGCStatus();
  63. BOOL _IsMountedOnDriveLetter();
  64. void _InitOnlyOnceStuff();
  65. void _UpdateLabelFromDesktopINI();
  66. void _UpdateAutorunInfo();
  67. public:
  68. static HRESULT _CreateMtPtRemote(LPCWSTR pszMountPoint,
  69. LPCWSTR pszShareName, BOOL fUnavailable);
  70. static HRESULT _CreateMtPtRemoteWithoutShareName(LPCWSTR pszMountPoint);
  71. static CShare* _GetOrCreateShareFromID(LPCWSTR pszShareName);
  72. static HRESULT _DeleteAllMtPtsAndShares();
  73. static HRESULT _RemoveShareFromHDPA(CShare* pshare);
  74. ///////////////////////////////////////////////////////////////////////////////
  75. // Data
  76. ///////////////////////////////////////////////////////////////////////////////
  77. private:
  78. class CShare* _pshare;
  79. DWORD _dwWNetGCStatus;
  80. DWORD _dwWNetGC3Status;
  81. WNGC_CONNECTION_STATE _wngcs;
  82. DWORD _dwSpeed;
  83. #ifdef DEBUG
  84. private:
  85. static DWORD _cMtPtRemote;
  86. #endif
  87. };
  88. class CShare
  89. {
  90. public:
  91. DWORD dwGetFileAttributes;
  92. WCHAR szLabel[MAX_LABEL];
  93. DWORD dwSerialNumber;
  94. DWORD dwMaxFileNameLen;
  95. DWORD dwFileSystemFlags;
  96. WCHAR szFileSysName[MAX_FILESYSNAME];
  97. BOOL fGVIRetValue;
  98. DWORD dwGFAGVILastCall;
  99. BOOL fConnected;
  100. LPWSTR pszRemoteName;
  101. LPWSTR pszKeyName;
  102. BOOL fAutorun;
  103. BOOL fFake;
  104. public:
  105. ULONG AddRef()
  106. { return InterlockedIncrement(&_cRef); }
  107. ULONG Release()
  108. {
  109. if (InterlockedDecrement(&_cRef) > 0)
  110. return _cRef;
  111. delete this;
  112. return 0;
  113. }
  114. private:
  115. LONG _cRef;
  116. public:
  117. CShare() : _cRef(1)
  118. {
  119. #ifdef DEBUG
  120. ++_cShare;
  121. #endif
  122. }
  123. ~CShare()
  124. {
  125. CMtPtRemote::_RemoveShareFromHDPA(this);
  126. if (pszRemoteName)
  127. {
  128. LocalFree(pszRemoteName);
  129. }
  130. if (pszKeyName)
  131. {
  132. LocalFree(pszKeyName);
  133. }
  134. #ifdef DEBUG
  135. --_cShare;
  136. #endif
  137. }
  138. #ifdef DEBUG
  139. private:
  140. static DWORD _cShare;
  141. #endif
  142. };