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.

185 lines
4.9 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. LPCTSTR _GetUNCName();
  35. BOOL _IsConnected();
  36. BOOL _IsUnavailableNetDrive();
  37. BOOL _IsUnavailableNetDriveFromStateVar();
  38. BOOL _IsRemote();
  39. BOOL _IsSlow();
  40. BOOL _IsAutorun();
  41. // returns DT_* defined above
  42. DWORD _GetMTPTDriveType();
  43. // returns CT_* defined above
  44. DWORD _GetMTPTContentType();
  45. DWORD _GetPathSpeed();
  46. void _CalcPathSpeed();
  47. BOOL _GetFileAttributes(DWORD* pdwAttrib);
  48. BOOL _GetFileSystemName(LPTSTR pszFileSysName, DWORD cchFileSysName);
  49. BOOL _GetGVILabelOrMixedCaseFromReg(LPTSTR pszLabel, DWORD cchLabel);
  50. BOOL _GetGVILabel(LPTSTR pszLabel, DWORD cchLabel);
  51. BOOL _GetSerialNumber(DWORD* pdwSerialNumber);
  52. BOOL _GetFileSystemFlags(DWORD* pdwFlags);
  53. int _GetGVIDriveFlags();
  54. int _GetDriveType();
  55. DWORD _GetAutorunContentType();
  56. UINT _GetAutorunIcon(LPTSTR pszModule, DWORD cchModule);
  57. struct GFAGVICALL* _PrepareThreadParam(HANDLE* phEventBegun,
  58. HANDLE* phEventFinish);
  59. BOOL _HaveGFAAndGVIExpired(DWORD dwNow);
  60. BOOL _UpdateGFAAndGVIInfo();
  61. void _UpdateWNetGCStatus();
  62. BOOL _IsMountedOnDriveLetter();
  63. void _InitOnlyOnceStuff();
  64. void _UpdateLabelFromDesktopINI();
  65. void _UpdateAutorunInfo();
  66. public:
  67. static HRESULT _CreateMtPtRemote(LPCWSTR pszMountPoint,
  68. LPCWSTR pszShareName, BOOL fUnavailable);
  69. static HRESULT _CreateMtPtRemoteWithoutShareName(LPCWSTR pszMountPoint);
  70. static CShare* _GetOrCreateShareFromID(LPCWSTR pszShareName);
  71. static HRESULT _DeleteAllMtPtsAndShares();
  72. static HRESULT _RemoveShareFromHDPA(CShare* pshare);
  73. ///////////////////////////////////////////////////////////////////////////////
  74. // Data
  75. ///////////////////////////////////////////////////////////////////////////////
  76. private:
  77. class CShare* _pshare;
  78. DWORD _dwWNetGCStatus;
  79. DWORD _dwWNetGC3Status;
  80. WNGC_CONNECTION_STATE _wngcs;
  81. DWORD _dwSpeed;
  82. #ifdef DEBUG
  83. private:
  84. static DWORD _cMtPtRemote;
  85. #endif
  86. };
  87. class CShare
  88. {
  89. public:
  90. DWORD dwGetFileAttributes;
  91. WCHAR szLabel[MAX_LABEL];
  92. DWORD dwSerialNumber;
  93. DWORD dwMaxFileNameLen;
  94. DWORD dwFileSystemFlags;
  95. WCHAR szFileSysName[MAX_FILESYSNAME];
  96. BOOL fGVIRetValue;
  97. DWORD dwGFAGVILastCall;
  98. BOOL fConnected;
  99. LPWSTR pszRemoteName;
  100. LPWSTR pszKeyName;
  101. BOOL fAutorun;
  102. BOOL fFake;
  103. public:
  104. ULONG AddRef()
  105. { return InterlockedIncrement(&_cRef); }
  106. ULONG Release()
  107. {
  108. ASSERT( 0 != _cRef );
  109. ULONG cRef = InterlockedDecrement(&_cRef);
  110. if ( 0 == cRef )
  111. {
  112. delete this;
  113. }
  114. return cRef;
  115. }
  116. private:
  117. LONG _cRef;
  118. public:
  119. CShare() : _cRef(1)
  120. {
  121. #ifdef DEBUG
  122. ++_cShare;
  123. #endif
  124. }
  125. ~CShare()
  126. {
  127. CMtPtRemote::_RemoveShareFromHDPA(this);
  128. if (pszRemoteName)
  129. {
  130. LocalFree(pszRemoteName);
  131. }
  132. if (pszKeyName)
  133. {
  134. LocalFree(pszKeyName);
  135. }
  136. #ifdef DEBUG
  137. --_cShare;
  138. #endif
  139. }
  140. #ifdef DEBUG
  141. private:
  142. static DWORD _cShare;
  143. #endif
  144. };