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.

155 lines
4.2 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. VOID CleanUpHardDriveTags (VOID);
  4. //
  5. // BUGBUG -- Should we check any return codes in this function?
  6. //
  7. DWORD
  8. StartCleanup(
  9. IN PVOID ThreadParameter
  10. )
  11. //
  12. // BUGBUG - this routine NEVER gets executed in a /checkupgradeonly case
  13. //
  14. {
  15. TCHAR Buffer[MAX_PATH];
  16. TCHAR baseDir[MAX_PATH];
  17. HKEY setupKey;
  18. DWORD error;
  19. //
  20. // Make sure the copy threads are really gone so we're not
  21. // trying to clean up files at the same time as files are
  22. // getting copied.
  23. //
  24. CancelledMakeSureCopyThreadsAreDead();
  25. error = RegOpenKeyEx (
  26. HKEY_LOCAL_MACHINE,
  27. TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup"),
  28. 0,
  29. KEY_ALL_ACCESS,
  30. &setupKey
  31. );
  32. if (error == ERROR_SUCCESS) {
  33. #if defined(_X86_)
  34. //
  35. // If canceled, remove last report time, so that the report
  36. // will be displayed on the next run of setup.
  37. //
  38. if (!ISNT()) {
  39. if (!CheckUpgradeOnly) {
  40. RegDeleteValue (setupKey, TEXT("LastReportTime"));
  41. }
  42. }
  43. #if defined(UNICODE)
  44. MyGetWindowsDirectory (baseDir, MAX_PATH);
  45. ConcatenatePaths (baseDir, TEXT("Setup"), MAX_PATH);
  46. MyDelnode(baseDir);
  47. #endif
  48. #endif
  49. RegCloseKey (setupKey);
  50. }
  51. //
  52. // Let upgrade code do its cleanup.
  53. //
  54. if(UpgradeSupport.CleanupRoutine) {
  55. UpgradeSupport.CleanupRoutine();
  56. }
  57. if (g_DynUpdtStatus->ForceRemoveWorkingDir || !g_DynUpdtStatus->PreserveWorkingDir) {
  58. if (g_DynUpdtStatus->WorkingDir[0] && !g_DynUpdtStatus->RestartWinnt32) {
  59. MyDelnode (g_DynUpdtStatus->WorkingDir);
  60. }
  61. //Note - the following two statements will always work, since they deal only
  62. //with static strings.
  63. GetCurrentWinnt32RegKey (Buffer, MAX_PATH);
  64. ConcatenatePaths (Buffer, WINNT_U_DYNAMICUPDATESHARE, MAX_PATH);
  65. //This function may fail, however.
  66. RegDeleteKey (HKEY_LOCAL_MACHINE, Buffer);
  67. }
  68. #if 0
  69. //
  70. // Remove registry entries
  71. //
  72. if (GetCurrentWinnt32RegKey (Buffer, MAX_PATH)) {
  73. RegDeleteKey (HKEY_LOCAL_MACHINE, Buffer);
  74. }
  75. #endif
  76. //
  77. // Always do this, since the system might not boot otherwise.
  78. //
  79. ForceBootFilesUncompressed(ThreadParameter,FALSE);
  80. //
  81. // The first thing to do is to wipe out the local source drive.
  82. //
  83. if(LocalSourceDirectory[0]) {
  84. MyDelnode(LocalSourceDirectory);
  85. }
  86. if (!IsArc()) {
  87. #if defined(_AMD64_) || defined(_X86_)
  88. //
  89. // Blow away the local boot dir.
  90. //
  91. if(LocalBootDirectory[0]) {
  92. MyDelnode(LocalBootDirectory);
  93. }
  94. //This is safe, since it is again dealing with static strings
  95. BuildSystemPartitionPathToFile (AUX_BS_NAME, Buffer, MAX_PATH);
  96. SetFileAttributes(Buffer,FILE_ATTRIBUTE_NORMAL);
  97. DeleteFile(Buffer);
  98. BuildSystemPartitionPathToFile(TEXTMODE_INF, Buffer, MAX_PATH);
  99. SetFileAttributes(Buffer,FILE_ATTRIBUTE_NORMAL);
  100. DeleteFile(Buffer);
  101. RestoreBootSector();
  102. RestoreBootIni();
  103. //
  104. // restore backed up files and clean up backup directory
  105. //
  106. if(IsNEC98() && LocalBackupDirectory[0]) {
  107. SaveRestoreBootFiles_NEC98(NEC98RESTOREBOOTFILES);
  108. MyDelnode(LocalBackupDirectory);
  109. }
  110. //
  111. // Clean up any ~_~ files from drvlettr migration.
  112. //
  113. if (!ISNT()) {
  114. CleanUpHardDriveTags ();
  115. }
  116. #endif // defined(_AMD64_) || defined(_X86_)
  117. } else { // We're on an ARC machine.
  118. #ifdef UNICODE // Always true for ARC, never true for Win9x upgrade
  119. //
  120. // Blow away setupldr off the root of the system partition.
  121. //
  122. BuildSystemPartitionPathToFile (SETUPLDR_FILENAME, Buffer, MAX_PATH);
  123. SetFileAttributes(Buffer,FILE_ATTRIBUTE_NORMAL);
  124. DeleteFile(Buffer);
  125. RestoreNvRam();
  126. #endif // UNICODE
  127. } // if (!IsArc())
  128. PostMessage(ThreadParameter,WMX_I_AM_DONE,0,0);
  129. return(0);
  130. }