[misc] Misc. fixes

* Addresses issue #66 (insert media notification with empty card readers)
* Addresses issue #67 (devices without FriendlyName aren't listed)
* Addresses issue #68 (WinPE/AIK images don't boot)
* Also updates version to rufus-next
This commit is contained in:
Pete Batard 2012-03-09 01:38:52 +00:00
parent 7ee5b35551
commit e0f209a128
8 changed files with 157 additions and 35 deletions

20
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for rufus 1.1.4.
# Generated by GNU Autoconf 2.68 for rufus 1.1.5.
#
# Report bugs to <https://github.com/pbatard/rufus/issues>.
#
@ -559,8 +559,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='1.1.4'
PACKAGE_STRING='rufus 1.1.4'
PACKAGE_VERSION='1.1.5'
PACKAGE_STRING='rufus 1.1.5'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='http://rufus.akeo.ie'
@ -1204,7 +1204,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures rufus 1.1.4 to adapt to many kinds of systems.
\`configure' configures rufus 1.1.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1270,7 +1270,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of rufus 1.1.4:";;
short | recursive ) echo "Configuration of rufus 1.1.5:";;
esac
cat <<\_ACEOF
@ -1363,7 +1363,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
rufus configure 1.1.4
rufus configure 1.1.5
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@ -1418,7 +1418,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 1.1.4, which was
It was created by rufus $as_me 1.1.5, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@ -2233,7 +2233,7 @@ fi
# Define the identity of the package.
PACKAGE='rufus'
VERSION='1.1.4'
VERSION='1.1.5'
cat >>confdefs.h <<_ACEOF
@ -4091,7 +4091,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by rufus $as_me 1.1.4, which was
This file was extended by rufus $as_me 1.1.5, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -4145,7 +4145,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
rufus config.status 1.1.4
rufus config.status 1.1.5
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"

View File

@ -1,4 +1,4 @@
AC_INIT([rufus], [1.1.4], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie])
AC_INIT([rufus], [1.1.5], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4])

View File

@ -150,8 +150,9 @@ out:
*/
BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label)
{
HANDLE hDrive;
char AutorunPath[] = "#:\\autorun.inf", *AutorunLabel;
HANDLE hDrive, hPhysical;
DWORD size;
char AutorunPath[] = "#:\\autorun.inf", *AutorunLabel = NULL;
wchar_t wDrivePath[] = L"#:\\";
wchar_t wVolumeLabel[MAX_PATH+1];
static char VolumeLabel[MAX_PATH+1];
@ -166,9 +167,17 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label)
wDrivePath[0] = *letter;
// Try to read an extended label from autorun first. Fallback to regular label if not found.
AutorunLabel = get_token_data(AutorunPath, "label");
// In the case of card readers with no card, users can get an annoying popup asking them
// to insert media. Use IOCTL_STORAGE_CHECK_VERIFY to prevent this
hPhysical = GetDriveHandle(DriveIndex, NULL, FALSE, FALSE);
if (DeviceIoControl(hPhysical, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, NULL, 0, &size, NULL))
AutorunLabel = get_token_data(AutorunPath, "label");
else if (GetLastError() == ERROR_NOT_READY)
uprintf("Ignoring autorun.inf label for drive %c: %s\n", *letter,
(HRESULT_CODE(GetLastError()) == ERROR_NOT_READY)?"No media":WindowsErrorString());
safe_closehandle(hPhysical);
if (AutorunLabel != NULL) {
uprintf("Using autorun.inf label for device %c:\n", *letter);
uprintf("Using autorun.inf label for drive %c: '%s'\n", *letter, AutorunLabel);
strncpy(VolumeLabel, AutorunLabel, sizeof(VolumeLabel));
safe_free(AutorunLabel);
*label = VolumeLabel;

View File

@ -136,6 +136,62 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
return (!IS_ERROR(FormatStatus));
}
/*
* Chkdsk callback. Return FALSE to halt operations
*/
static BOOLEAN __stdcall ChkdskCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, DWORD Action, PVOID pData)
{
DWORD* percent;
if (IS_ERROR(FormatStatus))
return FALSE;
switch(Command) {
case FCC_PROGRESS:
case FCC_CHECKDISK_PROGRESS:
percent = (DWORD*)pData;
PrintStatus(0, FALSE, "NTFS Fixup: %d%% completed.", *percent);
break;
case FCC_DONE:
if(*(BOOLEAN*)pData == FALSE) {
uprintf("Error while checking disk.\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_GEN_FAILURE;
}
break;
case FCC_UNKNOWN1A:
case FCC_DONE_WITH_STRUCTURE:
// Silence these specific calls
break;
case FCC_INCOMPATIBLE_FILE_SYSTEM:
uprintf("Incompatible File System\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_INCOMPATIBLE_FS);
break;
case FCC_ACCESS_DENIED:
uprintf("Access denied\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_ACCESS_DENIED;
break;
case FCC_MEDIA_WRITE_PROTECTED:
uprintf("Media is write protected\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_PROTECT;
break;
case FCC_VOLUME_IN_USE:
uprintf("Volume is in use\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_DEVICE_IN_USE;
break;
case FCC_OUTPUT:
uprintf("%s\n", ((PTEXTOUTPUT)pData)->Output);
break;
case FCC_NO_MEDIA_IN_DRIVE:
uprintf("No media in drive\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NO_MEDIA_IN_DRIVE;
break;
default:
uprintf("ChkdskExCallback: received unhandled command %X\n", Command);
// Assume the command isn't an error
break;
}
return (!IS_ERROR(FormatStatus));
}
/*
* Converts an UTF-16 label to a valid FAT/NTFS one
*/
@ -237,6 +293,41 @@ out:
return r;
}
/*
* Call on fmifs.dll's Chkdsk() to fixup the filesystem
*/
static BOOL CheckDisk(char DriveLetter)
{
BOOL r = FALSE;
PF_DECL(Chkdsk);
WCHAR wDriveRoot[] = L"?:\\";
WCHAR wFSType[32];
size_t i;
wDriveRoot[0] = (WCHAR)DriveLetter;
PrintStatus(0, TRUE, "NTFS Fixup (Checkdisk)...");
PF_INIT_OR_OUT(Chkdsk, fmifs);
GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType));
// We may have a " (Default)" trail
for (i=0; i<wcslen(wFSType); i++) {
if (wFSType[i] == ' ') {
wFSType[i] = 0;
break;
}
}
pfChkdsk(wDriveRoot, wFSType, FALSE, FALSE, FALSE, FALSE, NULL, NULL, ChkdskCallback);
if (!IS_ERROR(FormatStatus)) {
uprintf("NTFS Fixup completed.\n");
r = TRUE;
}
out:
return r;
}
static BOOL AnalyzeMBR(HANDLE hPhysicalDrive)
{
FILE fake_fd = { 0 };
@ -668,6 +759,9 @@ DWORD WINAPI FormatThread(LPVOID param)
UpdateProgress(OP_DOS, -1.0f);
// Issue another complete remount before we exit, to ensure we're clean
RemountVolume(drive_name[0]);
// NTFS fixup (WinPE/AIK images don't seem to boot without an extra checkdisk)
if ((dt == DT_ISO) && (fs = FS_NTFS))
CheckDisk(drive_name[0]);
}
out:

View File

@ -70,6 +70,18 @@ typedef enum {
FCC_VOLUME_TOO_SMALL,
FCC_VOLUME_TOO_BIG,
FCC_NO_MEDIA_IN_DRIVE,
FCC_UNKNOWN15,
FCC_UNKNOWN16,
FCC_UNKNOWN17,
FCC_UNKNOWN18,
FCC_CHECKDISK_PROGRESS,
FCC_UNKNOWN1A,
FCC_UNKNOWN1B,
FCC_UNKNOWN1C,
FCC_UNKNOWN1D,
FCC_UNKNOWN1E,
FCC_UNKNOWN1F,
FCC_UNKNOWN20,
} FILE_SYSTEM_CALLBACK_COMMAND;
typedef struct {
@ -95,6 +107,18 @@ typedef VOID (WINAPI *FormatEx_t)(
FILE_SYSTEM_CALLBACK Callback
);
/* Mostly from http://doxygen.reactos.org/df/d85/fmifs_8h_source.html */
typedef LONG (WINAPI *Chkdsk_t)(
WCHAR* DriveRoot,
WCHAR* FileSystemTypeName,
BOOL CorrectErrors,
BOOL Verbose,
BOOL CheckOnlyIfDirty,
BOOL ScanDrive,
VOID* Unused2,
VOID* Unused3,
FILE_SYSTEM_CALLBACK Callback);
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa383357.aspx */
typedef enum {
FPF_COMPRESSED = 0x01

View File

@ -294,9 +294,9 @@ static BOOL GetDriveInfo(void)
return FALSE;
r = DeviceIoControl(hDrive, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL );
NULL, 0, geometry, sizeof(geometry), &size, NULL);
if (!r || size <= 0) {
uprintf("IOCTL_DISK_GET_DRIVE_GEOMETRY_EX failed: %s\n", WindowsErrorString());
uprintf("IOCTL_DISK_GET_DRIVE_GEOMETRY_EX failed for drive %c: %s\n", DrivePath[0], WindowsErrorString());
safe_closehandle(hDrive);
return FALSE;
}
@ -309,7 +309,7 @@ static BOOL GetDriveInfo(void)
r = DeviceIoControl(hDrive, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
NULL, 0, layout, sizeof(layout), &size, NULL );
if (!r || size <= 0) {
uprintf("IOCTL_DISK_GET_DRIVE_LAYOUT_EX failed: %s\n", WindowsErrorString());
uprintf("IOCTL_DISK_GET_DRIVE_LAYOUT_EX failed for drive %c: %s\n", DrivePath[0], WindowsErrorString());
} else {
DestroyTooltip(hFSTooltip);
hFSTooltip = NULL;
@ -561,6 +561,7 @@ static BOOL GetUSBDevices(DWORD devnum)
char drive_letter;
char *label, entry[MAX_PATH], buffer[MAX_PATH];
const char* usbstor_name = "USBSTOR";
const char* generic_friendly_name = "USB Storage Device (Generic)";
GUID _GUID_DEVINTERFACE_DISK = // only known to some...
{ 0x53f56307L, 0xb6bf, 0x11d0, {0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} };
@ -571,7 +572,7 @@ static BOOL GetUSBDevices(DWORD devnum)
dev_info = SetupDiGetClassDevsA(&_GUID_DEVINTERFACE_DISK, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE);
if (dev_info == INVALID_HANDLE_VALUE) {
uprintf("SetupDiGetClassDevs (Interface) failed: %d\n", WindowsErrorString());
uprintf("SetupDiGetClassDevs (Interface) failed: %s\n", WindowsErrorString());
return FALSE;
}
@ -580,7 +581,7 @@ static BOOL GetUSBDevices(DWORD devnum)
memset(buffer, 0, sizeof(buffer));
if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_ENUMERATOR_NAME,
&datatype, (LPBYTE)buffer, sizeof(buffer), &size)) {
uprintf("SetupDiGetDeviceRegistryProperty (Enumerator Name) failed: %d\n", WindowsErrorString());
uprintf("SetupDiGetDeviceRegistryProperty (Enumerator Name) failed: %s\n", WindowsErrorString());
continue;
}
@ -589,8 +590,9 @@ static BOOL GetUSBDevices(DWORD devnum)
memset(buffer, 0, sizeof(buffer));
if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
&datatype, (LPBYTE)buffer, sizeof(buffer), &size)) {
uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %d\n", WindowsErrorString());
continue;
uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %s\n", WindowsErrorString());
// We can afford a failure on this call - just replace the name
safe_strcpy(buffer, sizeof(buffer), generic_friendly_name);
}
uprintf("Found drive '%s'\n", buffer);
@ -1508,11 +1510,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Initialize COM for folder selection
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
#ifdef DISABLE_AUTORUN
// We use local group policies rather than direct registry manipulation
// 0x9e disables removable and fixed drive notifications
SetLGP(FALSE, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e);
#endif
// Find out if the FreeDOS resources are embedded in the app
bWithFreeDOS = (FindResource(hMainInstance, MAKEINTRESOURCE(IDR_FD_COMMAND_COM), RT_RCDATA) != NULL) &&
@ -1544,14 +1544,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
GetUSBDevices(0);
continue;
}
#ifdef DISABLE_AUTORUN
// Alt-D => Delete the NoDriveTypeAutorun key on exit (useful if the app crashed)
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'D')) {
PrintStatus(0, FALSE, "NoDriveTypeAutorun will be deleted on exit.");
existing_key = FALSE;
continue;
}
#endif
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@ -1560,9 +1558,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
out:
DestroyAllTooltips();
safe_free(iso_path);
#ifdef DISABLE_AUTORUN
SetLGP(TRUE, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0);
#endif
CloseHandle(mutex);
uprintf("*** RUFUS EXIT ***\n");

View File

@ -23,7 +23,6 @@
/* Program options */
#define RUFUS_DEBUG // print debug info to Debug facility
#define DISABLE_AUTORUN // disable new USB drive notification from explorer when application is running
/* Features not ready for prime time and that may *DESTROY* your data - USE AT YOUR OWN RISKS! */
//#define RUFUS_TEST

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.4.150"
CAPTION "Rufus v1.1.5.151"
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.4 (Build 150)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.1.5 (Build 151)",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,4,150
PRODUCTVERSION 1,1,4,150
FILEVERSION 1,1,5,151
PRODUCTVERSION 1,1,5,151
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -241,13 +241,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.1.4.150"
VALUE "FileVersion", "1.1.5.151"
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.4.150"
VALUE "ProductVersion", "1.1.5.151"
END
END
BLOCK "VarFileInfo"