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.

172 lines
5.1 KiB

  1. #ifndef _FSAFLTR_
  2. #define _FSAFLTR_
  3. /*++
  4. 1998 Seagate Software, Inc. All rights reserved.
  5. Module Name:
  6. fsafltr.h
  7. Abstract:
  8. This class represents a file system filter for NTFS 5.0.
  9. Author:
  10. Chuck Bardeen [cbardeen] 12-Feb-1997
  11. Revision History:
  12. --*/
  13. #include "resource.h" // main symbols
  14. #include "wsb.h"
  15. #include "fsa.h"
  16. #include "rpdata.h"
  17. #include "rpguid.h"
  18. #include "rpio.h"
  19. typedef struct _FSA_IOCTL_CONTROL {
  20. HANDLE dHand;
  21. OVERLAPPED overlap;
  22. RP_MSG in;
  23. RP_MSG out;
  24. DWORD outSize;
  25. struct _FSA_IOCTL_CONTROL *next;
  26. } FSA_IOCTL_CONTROL, *PFSA_IOCTL_CONTROL;
  27. //
  28. // This defines the length of time a client structure will be kept around after
  29. // the last recall was done (in seconds).
  30. //
  31. #define FSA_CLIENT_EXPIRATION_TIME 600 // 10 minutes
  32. #define THREAD_HANDLE_COUNT 2 //for WaitForMultipleObjects array
  33. /*++
  34. Class Name:
  35. CFsaFilter
  36. Class Description:
  37. This class represents a file system filter for NTFS 5.0.
  38. --*/
  39. class CFsaFilter :
  40. public CWsbCollectable,
  41. public IFsaFilter,
  42. public IFsaFilterPriv,
  43. public CComCoClass<CFsaFilter,&CLSID_CFsaFilterNTFS>
  44. {
  45. public:
  46. CFsaFilter() {}
  47. BEGIN_COM_MAP(CFsaFilter)
  48. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  49. COM_INTERFACE_ENTRY(IPersistStream)
  50. COM_INTERFACE_ENTRY(IFsaFilter)
  51. COM_INTERFACE_ENTRY(IFsaFilterPriv)
  52. COM_INTERFACE_ENTRY(IWsbCollectable)
  53. COM_INTERFACE_ENTRY(IWsbTestable)
  54. END_COM_MAP()
  55. DECLARE_REGISTRY_RESOURCEID(IDR_FsaFilter)
  56. // CComObjectRoot
  57. public:
  58. STDMETHOD(FinalConstruct)(void);
  59. STDMETHOD(FinalRelease)(void);
  60. // IWsbCollectable
  61. public:
  62. STDMETHOD(CompareTo)(IUnknown* pUnknown, SHORT* pResult);
  63. // IPersist
  64. public:
  65. STDMETHOD(GetClassID)(LPCLSID pClsid);
  66. // IPersistStream
  67. public:
  68. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pSize);
  69. STDMETHOD(Load)(IStream* pStream);
  70. STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
  71. // IWsbTestable
  72. STDMETHOD(Test)(USHORT *passed, USHORT* failed);
  73. // IFsaFilterPriv
  74. public:
  75. STDMETHOD(Init)(IFsaServer* pServer);
  76. STDMETHOD(SetIdentifier)(GUID id);
  77. STDMETHOD(IoctlThread)(void);
  78. STDMETHOD(PipeThread)(void);
  79. STDMETHOD(SendCancel)(IFsaFilterRecallPriv *pRecallPriv);
  80. STDMETHOD(SendComplete)(IFsaFilterRecallPriv *pRecall, HRESULT result);
  81. // IFsaFilter
  82. public:
  83. STDMETHOD(Cancel)(void);
  84. STDMETHOD(CancelRecall)(IFsaFilterRecall* pRecall);
  85. STDMETHOD(CompareToIdentifier)(GUID id, SHORT* pResult);
  86. STDMETHOD(CompareToIFilter)(IFsaFilter* pFilter, SHORT* pResult);
  87. STDMETHOD(DeleteRecall)(IFsaFilterRecall* pRecall);
  88. STDMETHOD(EnumRecalls)(IWsbEnum** ppEnum);
  89. STDMETHOD(GetAdminExemption)(BOOL *isExempt);
  90. STDMETHOD(GetIdentifier)(GUID* pId);
  91. STDMETHOD(GetLogicalName)(OLECHAR** pName, ULONG bufferSize);
  92. STDMETHOD(GetMaxRecallBuffers)(ULONG* pMaxBuffers);
  93. STDMETHOD(GetMaxRecalls)(ULONG* pMaxRecalls);
  94. STDMETHOD(GetMinRecallInterval)(ULONG* pMinIterval);
  95. STDMETHOD(GetState)(HSM_JOB_STATE* pState);
  96. STDMETHOD(IsEnabled)();
  97. STDMETHOD(Pause)(void);
  98. STDMETHOD(Resume)(void);
  99. STDMETHOD(SetIsEnabled)(BOOL isEnabled);
  100. STDMETHOD(SetMaxRecalls)(ULONG maxRecalls);
  101. STDMETHOD(SetMinRecallInterval)(ULONG minIterval);
  102. STDMETHOD(SetMaxRecallBuffers)(ULONG maxBuffers);
  103. STDMETHOD(Start)(void);
  104. STDMETHOD(StopIoctlThread)(void);
  105. STDMETHOD(FindRecall)(GUID recallId, IFsaFilterRecall** pRecall);
  106. STDMETHOD(SetAdminExemption)(BOOL isExempt);
  107. private:
  108. HRESULT DoOpenAction(PFSA_IOCTL_CONTROL pIoCmd);
  109. HRESULT DoRecallWaitingAction(PFSA_IOCTL_CONTROL pIoCmd);
  110. HRESULT DoRecallAction(PFSA_IOCTL_CONTROL pIoCmd);
  111. HRESULT DoNoRecallAction(PFSA_IOCTL_CONTROL pIoCmd);
  112. HRESULT DoCloseAction(PFSA_IOCTL_CONTROL pIoCmd);
  113. HRESULT DoPreDeleteAction(PFSA_IOCTL_CONTROL pIoCmd);
  114. HRESULT DoPostDeleteAction(PFSA_IOCTL_CONTROL pIoCmd);
  115. HRESULT DoCancelRecall(ULONGLONG filterId);
  116. HRESULT CleanupClients(void);
  117. NTSTATUS CFsaFilter::TranslateHresultToNtStatus(HRESULT hr);
  118. protected:
  119. GUID m_id;
  120. HSM_JOB_STATE m_state;
  121. ULONG m_maxRecalls;
  122. ULONG m_minRecallInterval;
  123. ULONG m_maxRecallBuffers;
  124. HANDLE m_pipeHandle;
  125. HANDLE m_pipeThread;
  126. HANDLE m_ioctlThread;
  127. HANDLE m_ioctlHandle;
  128. HANDLE m_terminateEvent;
  129. IFsaServer* m_pFsaServer; // Parent Pointer, Weak Reference
  130. CComPtr<IWsbCollection> m_pClients;
  131. CComPtr<IWsbCollection> m_pRecalls;
  132. CRITICAL_SECTION m_clientLock; // Protect client collection from multiple thread access
  133. CRITICAL_SECTION m_recallLock; // Protect recall collection from multiple thread access
  134. CRITICAL_SECTION m_stateLock; // Protect state change while sending new Ioctls
  135. BOOL m_isEnabled;
  136. BOOL m_exemptAdmin; // TRUE = exempt admin from runaway recall check
  137. };
  138. #endif // _FSAFLTR_