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.

207 lines
7.0 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1998.
  5. //
  6. // File: propret.hxx
  7. //
  8. // Contents: Generic property retriever
  9. //
  10. // Classes: CGenericPropRetriever
  11. //
  12. // History: 12-Dec-96 SitaramR Created
  13. //
  14. //-------------------------------------------------------------------
  15. #pragma once
  16. #include <ciintf.h>
  17. #include <fsciexps.hxx>
  18. #include <catalog.hxx>
  19. #include <imprsnat.hxx>
  20. #include <oleprop.hxx>
  21. #include <pidremap.hxx>
  22. #include <seccache.hxx>
  23. class CPidRemapper;
  24. class CCompositePropRecord;
  25. const USHORT flagNoValueYet = 0xffff;
  26. const USHORT flagNoValue = 0xfffe;
  27. //+---------------------------------------------------------------------------
  28. //
  29. // Class: CGenericPropRetriever
  30. //
  31. // Purpose: Retrieves properties from file systems
  32. //
  33. // History: 12-Dec-96 SitaramR Created
  34. //
  35. //----------------------------------------------------------------------------
  36. class CGenericPropRetriever : public ICiCPropRetriever
  37. {
  38. public:
  39. //
  40. // From IUnknown
  41. //
  42. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid, void **ppvObject );
  43. virtual ULONG STDMETHODCALLTYPE AddRef();
  44. virtual ULONG STDMETHODCALLTYPE Release();
  45. //
  46. // From ICiCPropRetriever
  47. //
  48. virtual SCODE STDMETHODCALLTYPE BeginPropertyRetrieval( WORKID wid ) = 0;
  49. virtual SCODE STDMETHODCALLTYPE RetrieveValueByPid( PROPID pid,
  50. PROPVARIANT *pbData,
  51. ULONG *pcb );
  52. virtual SCODE STDMETHODCALLTYPE RetrieveValueByPropSpec( const FULLPROPSPEC *pPropSpec,
  53. PROPVARIANT *pbData,
  54. ULONG *pcb)
  55. {
  56. return E_NOTIMPL;
  57. }
  58. virtual SCODE STDMETHODCALLTYPE FetchSDID( SDID *pSDID) { return E_NOTIMPL; }
  59. virtual SCODE STDMETHODCALLTYPE CheckSecurity( ACCESS_MASK am, BOOL *pfGranted);
  60. virtual SCODE STDMETHODCALLTYPE IsInScope( BOOL *pfInScope) = 0;
  61. virtual SCODE STDMETHODCALLTYPE EndPropertyRetrieval();
  62. //
  63. // Local methods
  64. //
  65. CGenericPropRetriever( PCatalog & cat,
  66. ICiQueryPropertyMapper *pQueryPropMapper,
  67. CSecurityCache & secCache,
  68. CRestriction const * pScope = 0,
  69. ACCESS_MASK amAlreadyAccessChecked = 0 );
  70. protected:
  71. virtual ~CGenericPropRetriever( );
  72. virtual void Quiesce();
  73. //
  74. // Stat properties.
  75. //
  76. virtual UNICODE_STRING const * GetName() = 0;
  77. virtual UNICODE_STRING const * GetShortName() = 0;
  78. virtual UNICODE_STRING const * GetPath() = 0;
  79. virtual UNICODE_STRING const * GetVirtualPath() = 0;
  80. virtual LONGLONG CreateTime() = 0;
  81. virtual LONGLONG ModifyTime() = 0;
  82. virtual LONGLONG AccessTime() = 0;
  83. virtual LONGLONG ObjectSize() = 0;
  84. virtual ULONG Attributes() = 0;
  85. virtual ULONG StorageType() { return 0xFFFFFFFF; }
  86. virtual BYTE * GetCachedProperty(PROPID pid, ULONG *pcb) { return 0; }
  87. //
  88. // For metadata
  89. //
  90. virtual BOOL GetVRootType( ULONG & ulType ) { return FALSE; }
  91. virtual BOOL GetPropGuid( GUID & guid ) { return FALSE; }
  92. virtual PROPID GetPropPropid() { return pidInvalid; }
  93. virtual UNICODE_STRING const * GetPropName() { return 0; }
  94. virtual DWORD StorageLevel() { return INVALID_STORE_LEVEL; }
  95. virtual BOOL IsModifiable() { return TRUE; }
  96. BOOL FetchValue( PROPID pid, PROPVARIANT * pbData, unsigned * pcb );
  97. BOOL IsPropRecReleased() const { return _pPropRec == 0; }
  98. BOOL IsClientRemote() const { return _pScope != 0; }
  99. HANDLE GetClientToken()
  100. {
  101. return _secCache.GetToken();
  102. }
  103. ULONG _ulAttribFilter; // restrict based on file attributes
  104. CImpersonateRemoteAccess _remoteAccess;
  105. PCatalog & _cat;
  106. WORKID _widPrimedForPropRetrieval; // Set to the wid for which BeginPropRetreival has been
  107. // called. After EndPropRetrieval has been called, this
  108. // is reset to widInvalid.
  109. void FetchPath( WCHAR * pwcPath, unsigned & cwc );
  110. CCompositePropRecord & GetPropertyRecord()
  111. {
  112. OpenPropertyRecord();
  113. Win4Assert( 0 != _pPropRec );
  114. return *_pPropRec;
  115. }
  116. private:
  117. void OpenPropertyRecord()
  118. {
  119. if ( 0 == _pPropRec )
  120. _pPropRec = _cat.OpenValueRecord( _widPrimedForPropRetrieval,
  121. (BYTE *)&_aulReservedForCPropRecord );
  122. }
  123. void StringToVariant( UNICODE_STRING const * pString,
  124. PROPVARIANT * pbData,
  125. unsigned * pcb );
  126. static unsigned BuildPath( UNICODE_STRING const * pPath,
  127. UNICODE_STRING const * pFilename,
  128. XGrowable<WCHAR> & xwcBuf);
  129. static unsigned BuildPath( UNICODE_STRING const * pPath,
  130. UNICODE_STRING const * pFilename,
  131. CFunnyPath & funnyBuf);
  132. static unsigned BuildPath( UNICODE_STRING const * pPath,
  133. UNICODE_STRING const * pFilename,
  134. WCHAR * pwcBuf,
  135. unsigned cbBuf );
  136. unsigned FixupPath( WCHAR const * pwcsPath,
  137. WCHAR * pwcsFixup,
  138. unsigned cwcFixup );
  139. unsigned FetchFixupInScope( WCHAR const * pwcsPath,
  140. WCHAR * pwcsFixup,
  141. unsigned cwcFixup,
  142. WCHAR const * pwcsRoot,
  143. unsigned cwcRoot,
  144. BOOL fDeep,
  145. BOOL & fUnchanged );
  146. CRestriction const * _pScope; // Used only for scope fixup
  147. ACCESS_MASK _amAlreadyAccessChecked;
  148. //
  149. // For property access.
  150. //
  151. ICiQueryPropertyMapper * _pQueryPropMapper; // Owned by the query session object
  152. COLEPropManager _propMgr;
  153. CCompositePropRecord * _pPropRec;
  154. CSecurityCache & _secCache; // cache of AccessCheck results
  155. ULONG _aulReservedForCPropRecord[ (sizeof_CCompositePropRecord + 2*sizeof(ULONG) - 1) / sizeof(ULONG) ];
  156. ULONG _cRefs;
  157. };