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.

132 lines
2.6 KiB

  1. //***************************************************************************
  2. //
  3. // (c) 2001 by Microsoft Corp. All Rights Reserved.
  4. //
  5. // PageManager.H
  6. //
  7. // Declarations for CPageFile, CPageSource for WMI repository for
  8. // Windows XP.
  9. //
  10. //
  11. // 21-Feb-01 raymcc
  12. //
  13. //***************************************************************************
  14. #ifndef _PAGEMGR_H_
  15. #define _PAGEMGR_H_
  16. #include <map>
  17. #define WMIREP_PAGE_SIZE (8192)
  18. class CPageSource;
  19. typedef struct _Page
  20. {
  21. DWORD dwPageId;
  22. bool bActive;
  23. BYTE aPage[WMIREP_PAGE_SIZE];
  24. } Page;
  25. typedef map<DWORD, Page*, less<DWORD> > PAGETABLE;
  26. typedef map<DWORD, DWORD, less<DWORD> > PAGEFREELIST;
  27. class CPageFile
  28. {
  29. friend CPageSource;
  30. PAGETABLE m_aMasterPageTable;
  31. PAGETABLE m_aTransactionPageTable;
  32. PAGEFREELIST m_aFreeList;
  33. bool m_bInTransaction;
  34. const char *m_pszFile;
  35. DWORD dwCommitTrans();
  36. DWORD RollbackTrans();
  37. // Private methods
  38. CPageFile(const char *pszFile);
  39. ~CPageFile();
  40. DWORD Init(LPWSTR pszPrimaryFile, LPWSTR pszMapFile, DWORD dwPageSize, DWORD dwCacheSize);
  41. DWORD Shutdown();
  42. DWORD RetrievePage(DWORD dwId, Page **ppPage);
  43. DWORD StorePage(Page *pPage);
  44. public:
  45. enum { InvalidPage = 0xFFFFFFFF };
  46. ULONG AddRef( );
  47. ULONG Release( );
  48. DWORD GetPage(
  49. DWORD dwId, // page zero is admin page; doesn't require NewPage() call
  50. DWORD dwFlags,
  51. LPVOID pPage
  52. );
  53. DWORD PutPage(
  54. DWORD dwId,
  55. DWORD dwFlags,
  56. LPVOID pPage
  57. );
  58. DWORD NewPage(
  59. DWORD dwFlags,
  60. DWORD dwCount,
  61. DWORD *pdwFirstId
  62. );
  63. DWORD FreePage(
  64. DWORD dwFlags,
  65. DWORD dwId
  66. );
  67. DWORD GetPageSize() { return WMIREP_PAGE_SIZE; }
  68. DWORD CommitTran();
  69. DWORD AbortTran();
  70. DWORD BeginTran();
  71. void Dump(FILE *f);
  72. };
  73. class CPageSource
  74. {
  75. CPageFile *m_pHeap;
  76. CPageFile *m_pIndex;
  77. public:
  78. CPageSource();
  79. ~CPageSource();
  80. DWORD Init(
  81. DWORD dwCachePages = 128,
  82. DWORD dwCheckpointTime = 15000, // milliseconds
  83. DWORD dwPageSize = 8192
  84. );
  85. DWORD Shutdown(DWORD dwShutdownType );
  86. DWORD GetBTreePageFile(OUT CPageFile **pPF); // Use Release() when done
  87. DWORD GetObjectHeapPageFile(OUT CPageFile **pPF); // Use Release() when done
  88. // Transactions
  89. DWORD BeginTrans();
  90. DWORD CommitTrans(); // Flag allows full commit vs subcommit within checkpoint
  91. DWORD RollbackTrans();
  92. DWORD Flush();
  93. DWORD LastCommitVersion(DWORD *pdwCommitted);
  94. DWORD CurrentVersion(DWORD *pdwCurrent);
  95. // Checkpoint
  96. DWORD Checkpoint();
  97. DWORD Dump(FILE *f);
  98. };
  99. #endif