[ntfs] fix creation of Windows 7 bootable USB from XP

* When using Win7 installation ISOs, XP would return the error:
  [0x00000456] The media in the drive may have changed
* This seems to be due to unmounting of the drive before writing
  the PBR
* Also, our ms-sys/NTFS code wasn't identifying NTFS properly on XP
This commit is contained in:
Pete Batard 2012-02-24 18:51:33 +00:00
parent 352a796eff
commit b03065b1f5
3 changed files with 12 additions and 14 deletions

View File

@ -66,7 +66,6 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
case FCC_PROGRESS:
percent = (DWORD*)pData;
PrintStatus(0, FALSE, "Formatting: %d%% completed.", *percent);
// uprintf("%d percent completed.\n", *percent);
UpdateProgress(OP_FORMAT, 1.0f * (*percent));
break;
case FCC_STRUCTURE_PROGRESS: // No progress on quick format
@ -611,10 +610,8 @@ DWORD WINAPI FormatThread(LPVOID param)
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED;
goto out;
}
// Make sure the volume is dismounted before writing the PBR
// This is especially critical, as NTFS will only be made bootable
// after the FS is re-mounted by Windows
UnmountDrive(hLogicalVolume);
// NB: if you unmount the logical volume here, XP will report error:
// [0x00000456] The media in the drive may have changed
PrintStatus(0, TRUE, "Writing partition boot record...");
if (!WritePBR(hLogicalVolume)) {
if (!FormatStatus)
@ -668,6 +665,7 @@ DWORD WINAPI FormatThread(LPVOID param)
}
if (IsChecked(IDC_SET_ICON))
SetAutorun(drive_name);
UpdateProgress(OP_DOS, -1.0f);
// Issue another complete remount before we exit, to ensure we're clean
RemountVolume(drive_name[0]);
}

View File

@ -25,9 +25,9 @@
int is_ntfs_fs(FILE *fp)
{
char *szMagic = "NTFS";
unsigned char aucMagic[] = {'N','T','F','S',' ',' ',' ',' '};
return contains_data(fp, 0x6F, szMagic, strlen(szMagic));
return contains_data(fp, 0x03, aucMagic, sizeof(aucMagic));
} /* is_ntfs_fs */
int is_ntfs_br(FILE *fp)
@ -35,7 +35,7 @@ int is_ntfs_br(FILE *fp)
/* A "file" is probably some kind of NTFS boot record if it contains the
magic chars 0x55, 0xAA at positions 0x1FE */
unsigned char aucRef[] = {0x55, 0xAA};
unsigned char aucMagic[] = {'N','T','F','S','0','0','0','0'};
unsigned char aucMagic[] = {'N','T','F','S',' ',' ',' ',' '};
if( ! contains_data(fp, 0x1FE, aucRef, sizeof(aucRef)))
return 0;

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 289
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.1.3.144"
CAPTION "Rufus v1.1.3.145"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,248,50,14
@ -73,7 +73,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.1.3 (Build 144)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.1.3 (Build 145)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -223,8 +223,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,3,144
PRODUCTVERSION 1,1,3,144
FILEVERSION 1,1,3,145
PRODUCTVERSION 1,1,3,145
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -241,13 +241,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.1.3.144"
VALUE "FileVersion", "1.1.3.145"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.1.3.144"
VALUE "ProductVersion", "1.1.3.145"
END
END
BLOCK "VarFileInfo"