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.

144 lines
4.9 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. rstrmap.h
  5. Abstract:
  6. This file contains the declaration of the CRestoreMapManager class, which
  7. manages restore map and performs necessary operations
  8. Revision History:
  9. Seong Kook Khang (SKKhang) 07/06/99
  10. created
  11. Anand Arvind (aarvind) 1999-10-10
  12. Added status for tracking of restore process
  13. Split restore process into three seperate operations
  14. If A: or B: then no restoring takes place
  15. ******************************************************************************/
  16. #ifndef _RSTRMAP_H__INCLUDED_
  17. #define _RSTRMAP_H__INCLUDED_
  18. #pragma once
  19. enum
  20. {
  21. RSTRMAP_STATUS_NONE = 0,
  22. RSTRMAP_STATUS_STARTED,
  23. RSTRMAP_STATUS_INITIALIZING,
  24. RSTRMAP_STATUS_CREATING_MAP,
  25. RSTRMAP_STATUS_RESTORING,
  26. RSTRMAP_STATUS_FINISHED
  27. };
  28. struct SMapEntry
  29. {
  30. DWORD dwID; // Internal ID Number
  31. DWORD dwOperation; // Type of Operation
  32. DWORD dwFlags;
  33. DWORD dwAttribute; // Attribute
  34. CSRStr strDrive; // Hard drive GUID
  35. CSRStr strCab; // CAB file name
  36. CSRStr strTemp; // Temp file name
  37. CSRStr strTempPath; // Full path of Temp file
  38. CSRStr strSrc; // Source path
  39. CSRStr strSrcSFN; // Source path, SFN
  40. CSRStr strDst; // Destination path
  41. CSRStr strDstSFN; // Destination path, SFN
  42. DWORD dwRes; // Result of Operation
  43. DWORD dwErr; // Error code, if applicable
  44. SMapEntry *pNext; // Link
  45. };
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CRestoreMapManager
  48. class CRestoreMapManager
  49. {
  50. public:
  51. CRestoreMapManager();
  52. ~CRestoreMapManager();
  53. // Operations
  54. public:
  55. BOOL Initialize( INT64 llSeqNum, BOOL fUI );
  56. BOOL InitRestoreMap( INT64 llSeqNum, INT nMinProgressVal, INT nMaxProgressVal, BOOL fUI );
  57. BOOL FInit_Initialize( INT64 llSeqNum, LPCWSTR cszCAB, BOOL fUI );
  58. BOOL FInit_RestoreMap( INT64 llSeqNum, LPCWSTR cszCAB, INT nMinProgressVal, INT nMaxProgressVal, BOOL fUI );
  59. BOOL DoOperation( BOOL fUI, INT nMinProgressVal, INT nMaxProgressVal);
  60. INT CurrentProgress(void);
  61. BOOL AreRestoreDrivesActive( BOOL *fAllDrivesActive, WCHAR *szInactiveDrives);
  62. protected:
  63. void CleanUp();
  64. DWORD ExtractFile( LPCWSTR cszCAB, LPCWSTR cszTmp, LPCWSTR cszDrive, LPCWSTR &rcszTmp );
  65. void ExtractFile( SMapEntry *pEnt );
  66. BOOL CreatePlaceHolderFile( LPCWSTR cszFile );
  67. BOOL ProcessRegSnapLog( LPCWSTR cszRegCAB );
  68. BOOL UpdateSystemRegistry( LPCWSTR cszTmpPath, BOOL fUI );
  69. BOOL UpdateUserRegistry( LPCWSTR cszTmpPath );
  70. BOOL ScanDependency( SMapEntry *pEnt );
  71. BOOL UpdateWinInitForDirRename( SMapEntry *pEntRen );
  72. BOOL CanFIFO( int chDrive );
  73. BOOL IsDriveValid( LPCWSTR cszDrive );
  74. void OprFileAdd( SMapEntry *pEnt );
  75. void OprFileDelete( SMapEntry *pEnt );
  76. void OprFileModify( SMapEntry *pEnt );
  77. void OprRename( SMapEntry *pEnt );
  78. void OprSetAttribute( SMapEntry *pEnt );
  79. void OprDirectoryCreate( SMapEntry *pEnt );
  80. void OprDirectoryDelete( SMapEntry *pEnt );
  81. void AbortRestore( BOOL fUndo, BOOL fIsDiskFull, BOOL fUI );
  82. void ChangeSrcToCPFileName( SMapEntry *pEnt );
  83. void SetRegKeyRestoreFail( BOOL fUI );
  84. void SetRegKeyRestoreFailLowDisk( BOOL fUI );
  85. void GetSFN( SMapEntry *pEnt, DWORD dwFlags = 0 );
  86. BOOL InitLogFile( DWORD dwEntry );
  87. BOOL WriteLogEntry( SMapEntry *pEnt );
  88. void CloseLogFile();
  89. BOOL InitWinInitFile();
  90. BOOL WriteWinInitEntry( LPCWSTR cszKey, LPCWSTR cszVal );
  91. BOOL CloseWinInitFile( BOOL fDiscard );
  92. BOOL CreateS2LMapFile();
  93. BOOL WriteS2LMapEntry( DWORD dwType, LPCWSTR cszSFN, LPCWSTR cszLFN, DWORD dwAttr = 0 );
  94. BOOL CloseS2LMapFile();
  95. // Attributes
  96. protected:
  97. SMapEntry m_sMapEnt; // Regular Map Entries
  98. SMapEntry m_sMapReg; // Map Entries for the Registry
  99. INT m_nMaxMapEnt ; // Number of map entries
  100. INT m_nMaxMapReg ; // Number of registry map entries
  101. INT m_nRestoreStatus ; // Status of operation
  102. INT m_nRestoreProgress ; // Progress value
  103. INT m_fInitChgLogCalled ; // Called API so shutdown to be done
  104. INT m_fRMapEntriesExist ; // Set if there are no entires in Restore Map
  105. WCHAR m_szDSArchive[MAX_PATH+1];
  106. WCHAR m_szWinInitPath[MAX_PATH+1];
  107. WCHAR m_szWinInitErr[MAX_PATH+1];
  108. HANDLE m_hfLog;
  109. HANDLE m_hfSeqNumLog;
  110. INT m_pfDrive[26];
  111. BOOL m_fFIFODisabled;
  112. WCHAR m_szWITmp[MAX_PATH];
  113. HANDLE m_hfWinInitTmp;
  114. WCHAR m_szS2LMap[MAX_PATH+1];
  115. HANDLE m_hfS2LMap;
  116. };
  117. #endif //_RSTRMAP_H__INCLUDED_