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.

119 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. writer.h
  5. Abstract:
  6. Header file for FRS writer
  7. Author:
  8. Reuven Lax 17-Sep-2002
  9. --*/
  10. #ifndef _WRITER_H_
  11. #define _WRITER_H_
  12. extern "C" {
  13. #include <ntreppch.h>
  14. #include <frs.h>
  15. #include <ntfrsapi.h>
  16. }
  17. #include <vss.h>
  18. #include <vswriter.h>
  19. #include <vsbackup.h>
  20. // {D76F5A28-3092-4589-BA48-2958FB88CE29}
  21. static const VSS_ID WriterId =
  22. { 0xd76f5a28, 0x3092, 0x4589, { 0xba, 0x48, 0x29, 0x58, 0xfb, 0x88, 0xce, 0x29 } };
  23. static const WCHAR* WriterName = L"FRS Writer";
  24. // auto pointer that uses the FRS deallocation method
  25. template <class T>
  26. class CAutoFrsPointer {
  27. private:
  28. T* m_pointer;
  29. CAutoFrsPointer(const CAutoFrsPointer&); // disable copy constructor
  30. CAutoFrsPointer& operator=(const CAutoFrsPointer&); // disable operator=
  31. public:
  32. CAutoFrsPointer(T* pointer = NULL) : m_pointer(pointer)
  33. {}
  34. CAutoFrsPointer& operator=(T* pointer) {
  35. FrsFree(m_pointer);
  36. m_pointer = pointer;
  37. return *this;
  38. }
  39. operator T*() {
  40. return m_pointer;
  41. }
  42. T** GetAddress() {
  43. return &m_pointer;
  44. }
  45. T* Detach() {
  46. T* old = m_pointer;
  47. m_pointer = NULL;
  48. return old;
  49. }
  50. ~CAutoFrsPointer() {
  51. FrsFree(m_pointer);
  52. }
  53. };
  54. // FRS Writer class
  55. class CFrsWriter : public CVssWriter {
  56. private:
  57. // auto object that ensures that the backup/restore context is always destroyed
  58. struct CAutoFrsBackupRestore {
  59. CAutoFrsBackupRestore(void* context) : m_context(context)
  60. {}
  61. ~CAutoFrsBackupRestore() {
  62. #undef DEBSUB
  63. #define DEBSUB "CFrsWriter::CAutoFrsBackupRestore::~CAutoFrsBackupRestore:"
  64. if (m_context && !WIN_SUCCESS(::NtFrsApiDestroyBackupRestore(&m_context, NTFRSAPI_BUR_FLAGS_NONE, NULL, NULL, NULL)))
  65. DPRINT(3, "failed to successfully call NtFrsApiDestroyBackupRestore\n");
  66. }
  67. void* m_context;
  68. };
  69. static CFrsWriter* m_pWriterInstance; // global instance of the writer
  70. CFrsWriter()
  71. {}
  72. virtual ~CFrsWriter() {
  73. Uninitialize();
  74. }
  75. HRESULT STDMETHODCALLTYPE Initialize();
  76. void Uninitialize();
  77. bool AddExcludes(IVssCreateWriterMetadata* pMetadata, WCHAR* filters);
  78. bool ParseExclude(WCHAR* exclude, WCHAR** path, WCHAR** filespec, bool* recursive);
  79. bool ProcessReplicaSet(void* context, void* replicaSet, IVssCreateWriterMetadata* pMetadata, WCHAR** retFilters);
  80. public:
  81. virtual bool STDMETHODCALLTYPE OnIdentify(IN IVssCreateWriterMetadata *pMetadata);
  82. virtual bool STDMETHODCALLTYPE OnPrepareSnapshot();
  83. virtual bool STDMETHODCALLTYPE OnFreeze();
  84. virtual bool STDMETHODCALLTYPE OnThaw();
  85. virtual bool STDMETHODCALLTYPE OnAbort();
  86. static HRESULT CreateWriter();
  87. static void DestroyWriter();
  88. };
  89. #endif