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.

151 lines
3.9 KiB

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