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.

176 lines
4.0 KiB

  1. //-------------------------------------------------------------------
  2. //
  3. // critical drivers suppot
  4. //
  5. typedef struct _WSTRING_DATA_LINK
  6. {
  7. struct _WSTRING_DATA_LINK *m_psdlNext;
  8. WCHAR rgwc[2040];
  9. } WSTRING_DATA_LINK;
  10. // class string data
  11. class CWStringData
  12. {
  13. public:
  14. // @cmember constructor
  15. CWStringData();
  16. // @cmember destructor
  17. ~CWStringData();
  18. // @cmember allocate a string
  19. LPWSTR AllocateString(unsigned cwc);
  20. // @cmember copy a string
  21. LPWSTR CopyString(LPCWSTR wsz);
  22. private:
  23. // @cmember allocate a new string data link
  24. void AllocateNewLink();
  25. // @cmember current link
  26. WSTRING_DATA_LINK *m_psdlCur;
  27. // @cmember offset in current link for next string
  28. unsigned m_ulNextString;
  29. // @cmember first link
  30. WSTRING_DATA_LINK *m_psdlFirst;
  31. };
  32. // list of critical volumes
  33. class CVolumeList
  34. {
  35. public:
  36. // constructor
  37. CVolumeList();
  38. // destructor
  39. ~CVolumeList();
  40. // add a path to the volume list
  41. void AddPath(LPWSTR wszPath);
  42. // @cmember add a file to the volume list
  43. void AddFile(LPWSTR wszFile);
  44. // @cmember obtain list of volumes
  45. LPWSTR GetVolumeList();
  46. private:
  47. enum
  48. {
  49. // amount to grow paths array by
  50. x_cwszPathsInc = 8,
  51. // amount to grow volumes array by
  52. x_cwszVolumesInc = 4
  53. };
  54. // determine if a path is a volume
  55. BOOL TryAddVolumeToList(LPCWSTR wszPath, BOOL fVolumeRoot);
  56. // determine if path is in the list; if not add it to list
  57. BOOL AddPathToList(LPWSTR wszPath);
  58. // @cmember determine if a volume is in the list; if not add it to the list
  59. BOOL AddVolumeToList(LPCWSTR wszVolume);
  60. // @cmember get volume from the path
  61. void GetVolumeFromPath(LPCWSTR wsz, LPWSTR wszVolumeName);
  62. // @cmember cached strings
  63. CWStringData m_sd;
  64. // volumes encountered so far
  65. LPCWSTR *m_rgwszVolumes;
  66. // # of volumes allocate
  67. unsigned m_cwszVolumes;
  68. // max # of volumes in array
  69. unsigned m_cwszVolumesMax;
  70. // paths encountered so far
  71. LPCWSTR *m_rgwszPaths;
  72. // # of paths encountered so far
  73. unsigned m_cwszPaths;
  74. // @cmember max # of paths in array
  75. unsigned m_cwszPathsMax;
  76. };
  77. // FRS entry points
  78. typedef DWORD ( WINAPI *PF_FRS_ERR_CALLBACK )( CHAR *, DWORD );
  79. typedef DWORD ( WINAPI *PF_FRS_INIT )( PF_FRS_ERR_CALLBACK, DWORD, PVOID * );
  80. typedef DWORD ( WINAPI *PF_FRS_DESTROY )( PVOID *, DWORD, HKEY *, LPDWORD, CHAR *) ;
  81. typedef DWORD ( WINAPI *PF_FRS_GET_SETS )( PVOID );
  82. typedef DWORD ( WINAPI *PF_FRS_ENUM_SETS )( PVOID, DWORD, PVOID * );
  83. typedef DWORD ( WINAPI *PF_FRS_IS_SYSVOL )( PVOID, PVOID, BOOL * );
  84. typedef DWORD ( WINAPI *PF_FRS_GET_PATH )( PVOID, PVOID, DWORD *, WCHAR * ) ;
  85. typedef DWORD ( WINAPI *PF_FRS_GET_OTHER_PATHS)(PVOID, PVOID, DWORD *, WCHAR *, DWORD *, WCHAR *);
  86. // iterate over frs drives
  87. class CFRSIter
  88. {
  89. public:
  90. // constructor
  91. CFRSIter();
  92. // destructor
  93. ~CFRSIter();
  94. // initialization routine
  95. void Init();
  96. // initialize iterator
  97. BOOL BeginIteration();
  98. // end iteration
  99. void EndIteration();
  100. // obtain path to next replication set
  101. LPWSTR GetNextSet(BOOL fSkipToSysVol, LPWSTR *pwszPaths);
  102. private:
  103. // cleanup frs backup restore context
  104. void CleanupIteration();
  105. enum
  106. {
  107. x_IterNotStarted,
  108. x_IterStarted,
  109. x_IterComplete
  110. };
  111. // is this initialized
  112. BOOL m_fInitialized;
  113. HINSTANCE m_hLib;
  114. DWORD ( WINAPI *m_pfnFrsInitBuRest )( PF_FRS_ERR_CALLBACK, DWORD, PVOID * );
  115. DWORD ( WINAPI *m_pfnFrsEndBuRest )( PVOID *, DWORD, HKEY *, LPDWORD, CHAR *) ;
  116. DWORD ( WINAPI *m_pfnFrsGetSets )( PVOID );
  117. DWORD ( WINAPI *m_pfnFrsEnumSets )( PVOID, DWORD, PVOID * );
  118. DWORD ( WINAPI *m_pfnFrsIsSetSysVol )( PVOID, PVOID, BOOL * );
  119. DWORD ( WINAPI *m_pfnFrsGetPath )( PVOID, PVOID, DWORD *, WCHAR * ) ;
  120. DWORD ( WINAPI *m_pfnFrsGetOtherPaths) ( PVOID, PVOID, DWORD *, WCHAR *, DWORD *, WCHAR * );
  121. // has iteration been started
  122. int m_stateIteration;
  123. // current set iterated
  124. unsigned m_iset;
  125. // context for iteration
  126. PVOID m_frs_context;
  127. };
  128. LPWSTR pFindCriticalVolumes();