diff --git a/_sign.cmd b/_sign.cmd index 7b74a33c..7d0132ee 100644 --- a/_sign.cmd +++ b/_sign.cmd @@ -1,6 +1,3 @@ @echo off -"C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool" sign /v /sha1 655f6413a8f721e3286ace95025c9e0ea132a984 /fd SHA1 /tr http://timestamp.comodoca.com/rfc3161 /td SHA1 %1 -if ERRORLEVEL 1 goto out -"C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool" sign /as /v /sha1 5759b23dc8f45e9120a7317f306e5b6890b612f0 /fd SHA256 /tr http://timestamp.comodoca.com/rfc3161 /td SHA256 %1 -:out +"C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool" sign /v /sha1 5759b23dc8f45e9120a7317f306e5b6890b612f0 /fd SHA256 /tr http://timestamp.comodoca.com/rfc3161 /td SHA256 %1 exit diff --git a/configure b/configure index 5ad1c2a2..6267b5bc 100755 --- a/configure +++ b/configure @@ -3813,9 +3813,7 @@ esac $as_echo "#define _GNU_SOURCE /**/" >>confdefs.h -# Clang needs an explicit WIN32_WINNT defined else it produces warnings -# in msapi_utf8.h - including winver.h only doesn't work -AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_IE=0x501 -D_WIN32_WINNT=0x501" +AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x601 -D_WIN32_WINNT=0x601 -D_WIN32_IE=0x800" # "-Wl,--nxcompat" to enable DEP (Data Execution Prevention) AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined -Wl,--nxcompat" diff --git a/configure.ac b/configure.ac index 72d493ba..8c41e9ff 100644 --- a/configure.ac +++ b/configure.ac @@ -17,9 +17,7 @@ AC_CHECK_TOOL(WINDRES, windres, windres) AC_C_INLINE AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions]) -# Clang needs an explicit WIN32_WINNT defined else it produces warnings -# in msapi_utf8.h - including winver.h only doesn't work -AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_IE=0x501 -D_WIN32_WINNT=0x501" +AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x601 -D_WIN32_WINNT=0x601 -D_WIN32_IE=0x800" # "-Wl,--nxcompat" to enable DEP (Data Execution Prevention) AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined -Wl,--nxcompat" diff --git a/res/down.ico b/res/down.ico deleted file mode 100644 index ccce932a..00000000 Binary files a/res/down.ico and /dev/null differ diff --git a/res/up.ico b/res/up.ico deleted file mode 100644 index 908ee490..00000000 Binary files a/res/up.ico and /dev/null differ diff --git a/src/Makefile.am b/src/Makefile.am index e60a4061..b9a3a92a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,4 +15,4 @@ rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDADD = rufus_rc.o bled/libbled.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a syslinux/win/libwin.a \ - libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -luuid -lpsapi + libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -lcomctl32 -luuid -lpsapi diff --git a/src/Makefile.in b/src/Makefile.in index f40c4c10..fa2984d7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -276,7 +276,7 @@ rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDADD = rufus_rc.o bled/libbled.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a syslinux/win/libwin.a \ - libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -luuid -lpsapi + libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -lcomctl32 -luuid -lpsapi all: all-recursive diff --git a/src/badblocks.c b/src/badblocks.c index 02318a05..4f7bc9b0 100644 --- a/src/badblocks.c +++ b/src/badblocks.c @@ -350,7 +350,7 @@ static void pattern_fill(unsigned char *buffer, unsigned int pattern, unsigned char bpattern[sizeof(pattern)], *ptr; if (pattern == (unsigned int) ~0) { - srand((unsigned int)_GetTickCount64()); + srand((unsigned int)GetTickCount64()); for (ptr = buffer; ptr < buffer + n; ptr++) { // coverity[dont_call] (*ptr) = rand() % (1 << (8 * sizeof(char))); @@ -452,7 +452,7 @@ static unsigned int test_rw(HANDLE hDrive, blk_t last_block, size_t block_size, cur_pattern = 0; for (pat_idx = 0; pat_idx < nb_passes; pat_idx++) { - srand((unsigned int)_GetTickCount64()); + srand((unsigned int)GetTickCount64()); if (cancel_ops) goto out; // coverity[dont_call] id_offset = rand() * (block_size-sizeof(blk_t)) / RAND_MAX; diff --git a/src/checksum.c b/src/checksum.c index 27d4443a..40352a61 100644 --- a/src/checksum.c +++ b/src/checksum.c @@ -929,8 +929,8 @@ DWORD WINAPI SumThread(void* param) read_size[0] = 1; // Don't trigger the first loop break for (rb = 0; ;rb += read_size[_bufnum]) { // Update the progress and check for cancel - if (_GetTickCount64() > LastRefresh + MAX_REFRESH) { - LastRefresh = _GetTickCount64(); + if (GetTickCount64() > LastRefresh + MAX_REFRESH) { + LastRefresh = GetTickCount64(); format_percent = (100.0f*rb) / (1.0f*img_report.image_size); PrintInfo(0, MSG_271, format_percent); SendMessage(hProgress, PBM_SETPOS, (WPARAM)((format_percent / 100.0f)*MAX_PROGRESS), 0); diff --git a/src/dev.c b/src/dev.c index 7ecd327e..b2e61281 100644 --- a/src/dev.c +++ b/src/dev.c @@ -136,7 +136,7 @@ BOOL ResetDevice(int index) USB_CYCLE_PORT_PARAMS cycle_port; // Wait at least 10 secs between resets - if (_GetTickCount64() < LastReset + 10000ULL) { + if (GetTickCount64() < LastReset + 10000ULL) { uprintf("You must wait at least 10 seconds before trying to reset a device"); return FALSE; } @@ -144,7 +144,7 @@ BOOL ResetDevice(int index) if (DriveHub.String[index] == NULL) return FALSE; - LastReset = _GetTickCount64(); + LastReset = GetTickCount64(); handle = CreateFileA(DriveHub.String[index], GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (handle == INVALID_HANDLE_VALUE) { @@ -432,9 +432,7 @@ BOOL GetDevices(DWORD devnum) // Build a single list of Device IDs from all the storage enumerators we know of full_list_size = 0; - ulFlags = CM_GETIDLIST_FILTER_SERVICE; - if (nWindowsVersion >= WINDOWS_7) - ulFlags |= CM_GETIDLIST_FILTER_PRESENT; + ulFlags = CM_GETIDLIST_FILTER_SERVICE | CM_GETIDLIST_FILTER_PRESENT; for (s=0; sPartitionEntry[i].Gpt.PartitionType, &PARTITION_MSFT_RESERVED_GUID)) || (CompareGUID(&DriveLayout->PartitionEntry[i].Gpt.PartitionType, &PARTITION_SYSTEM_GUID)) ) --SelectedDrive.nPartitions; - if ( (memcmp(&PARTITION_BASIC_DATA_GUID, &DriveLayout->PartitionEntry[i].Gpt.PartitionType, sizeof(GUID)) == 0) && - (nWindowsVersion >= WINDOWS_VISTA) ) + if (memcmp(&PARTITION_BASIC_DATA_GUID, &DriveLayout->PartitionEntry[i].Gpt.PartitionType, sizeof(GUID)) == 0) ret = TRUE; } break; @@ -1242,7 +1242,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m // This helps us reselect the partition scheme option that was used when creating the // drive in Rufus. As far as I can tell, Windows doesn't care much if this signature // isn't unique for USB drives. - CreateDisk.Mbr.Signature = mbr_uefi_marker?MBR_UEFI_MARKER:(DWORD)_GetTickCount64(); + CreateDisk.Mbr.Signature = mbr_uefi_marker?MBR_UEFI_MARKER:(DWORD)GetTickCount64(); DriveLayoutEx.PartitionStyle = PARTITION_STYLE_MBR; DriveLayoutEx.PartitionCount = 4; // Must be multiple of 4 for MBR diff --git a/src/format.c b/src/format.c index 460e5995..adf1a276 100644 --- a/src/format.c +++ b/src/format.c @@ -607,8 +607,8 @@ static BOOL FormatFAT32(DWORD DriveIndex) format_percent = 0.0f; for (i=0; i<(SystemAreaSize+BurstSize-1); i+=BurstSize) { - if (_GetTickCount64() > LastRefresh + MAX_REFRESH) { - LastRefresh = _GetTickCount64(); + if (GetTickCount64() > LastRefresh + MAX_REFRESH) { + LastRefresh = GetTickCount64(); format_percent = (100.0f*i)/(1.0f*(SystemAreaSize+BurstSize)); PrintInfo(0, MSG_217, format_percent); UpdateProgress(OP_FORMAT, format_percent); @@ -1516,8 +1516,8 @@ static BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi) static void update_progress(const uint64_t processed_bytes) { - if (_GetTickCount64() > LastRefresh + MAX_REFRESH) { - LastRefresh = _GetTickCount64(); + if (GetTickCount64() > LastRefresh + MAX_REFRESH) { + LastRefresh = GetTickCount64(); format_percent = (100.0f*processed_bytes)/(1.0f*img_report.image_size); PrintInfo(0, MSG_261, format_percent); UpdateProgress(OP_FORMAT, format_percent); @@ -1574,8 +1574,8 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) // will be as fast, if not faster, than whatever async scheme you can come up with. rSize = BufSize; for (wb = 0, wSize = 0; wb < (uint64_t)SelectedDrive.DiskSize; wb += wSize) { - if (_GetTickCount64() > LastRefresh + MAX_REFRESH) { - LastRefresh = _GetTickCount64(); + if (GetTickCount64() > LastRefresh + MAX_REFRESH) { + LastRefresh = GetTickCount64(); format_percent = (100.0f*wb) / (1.0f*target_size); PrintInfo(0, hSourceImage?MSG_261:MSG_286, format_percent); UpdateProgress(OP_FORMAT, format_percent); @@ -1661,11 +1661,6 @@ DWORD WINAPI FormatThread(void* param) char kolibri_dst[] = "?:\\MTLD_F32"; char grub4dos_dst[] = "?:\\grldr"; - PF_TYPE_DECL(WINAPI, LANGID, GetThreadUILanguage, (void)); - PF_TYPE_DECL(WINAPI, LANGID, SetThreadUILanguage, (LANGID)); - PF_INIT(GetThreadUILanguage, Kernel32); - PF_INIT(SetThreadUILanguage, Kernel32); - fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); @@ -1751,10 +1746,6 @@ DWORD WINAPI FormatThread(void* param) UpdateProgress(OP_ANALYZE_MBR, -1.0f); } - // Yet another half-workaround needed for XP... - if (nWindowsVersion <= WINDOWS_XP) - InitializeDisk(hPhysicalDrive); - if (zero_drive) { WriteDrive(hPhysicalDrive, NULL); goto out; @@ -1764,7 +1755,7 @@ DWORD WINAPI FormatThread(void* param) // Note, Microsoft's way of cleaning partitions (IOCTL_DISK_CREATE_DISK, which is what we apply // in InitializeDisk) is *NOT ENOUGH* to reset a disk and can render it inoperable for partitioning // or formatting under Windows. See https://github.com/pbatard/rufus/issues/759 for details. - if ((nWindowsVersion > WINDOWS_XP) && ((!IsChecked(IDC_BOOT)) || (bt != BT_IMG))) { + if ((!IsChecked(IDC_BOOT)) || (bt != BT_IMG)) { if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) || (!InitializeDisk(hPhysicalDrive))) { uprintf("Could not reset partitions\n"); @@ -2068,9 +2059,9 @@ DWORD WINAPI FormatThread(void* param) // NTFS fixup (WinPE/AIK images don't seem to boot without an extra checkdisk) if ((bt == BT_ISO) && (fs == FS_NTFS)) { // Try to ensure that all messages from Checkdisk will be in English - if ((pfGetThreadUILanguage != NULL) && (PRIMARYLANGID(pfGetThreadUILanguage()) != LANG_ENGLISH)) { - pfSetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); - if (PRIMARYLANGID(pfGetThreadUILanguage()) != LANG_ENGLISH) + if (PRIMARYLANGID(GetThreadUILanguage()) != LANG_ENGLISH) { + SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); + if (PRIMARYLANGID(GetThreadUILanguage()) != LANG_ENGLISH) uprintf("Note: CheckDisk messages may be localized"); } CheckDisk(drive_name[0]); @@ -2169,8 +2160,8 @@ DWORD WINAPI SaveImageThread(void* param) } if (rSize == 0) break; - if (_GetTickCount64() > LastRefresh + MAX_REFRESH) { - LastRefresh = _GetTickCount64(); + if (GetTickCount64() > LastRefresh + MAX_REFRESH) { + LastRefresh = GetTickCount64(); format_percent = (100.0f*wb)/(1.0f*img_save->DeviceSize); PrintInfo(0, MSG_261, format_percent); UpdateProgress(OP_FORMAT, format_percent); diff --git a/src/iso.c b/src/iso.c index ea9a05a7..76f28ad2 100644 --- a/src/iso.c +++ b/src/iso.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/src/localization.c b/src/localization.c index 350443cf..fe0b89c5 100644 --- a/src/localization.c +++ b/src/localization.c @@ -447,7 +447,7 @@ static void CALLBACK OutputMessageTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent KillTimer(hMainDialog, idEvent); bOutputTimerArmed[i] = FALSE; PrintMessage[i](output_msg[i]); - last_msg_time[i] = _GetTickCount64(); + last_msg_time[i] = GetTickCount64(); } static void OutputMessage(BOOL info, char* msg) @@ -460,7 +460,7 @@ static void OutputMessage(BOOL info, char* msg) output_msg[i] = msg; } else { // Find if we need to arm a timer - delta = _GetTickCount64() - last_msg_time[i]; + delta = GetTickCount64() - last_msg_time[i]; if (delta < (2 * MAX_REFRESH)) { // Not enough time has elapsed since our last output => arm a timer output_msg[i] = msg; @@ -468,7 +468,7 @@ static void OutputMessage(BOOL info, char* msg) bOutputTimerArmed[i] = TRUE; } else { PrintMessage[i](msg); - last_msg_time[i] = _GetTickCount64(); + last_msg_time[i] = GetTickCount64(); } } } diff --git a/src/missing.h b/src/missing.h index 0822fc4a..8e0b4bfa 100644 --- a/src/missing.h +++ b/src/missing.h @@ -18,10 +18,6 @@ */ #include -#include -#include -#include -#include #pragma once @@ -106,461 +102,14 @@ static __inline void *_reallocf(void *ptr, size_t size) { #define _RT_RCDATA MAKEINTRESOURCEA(10) #define _RT_GROUP_ICON MAKEINTRESOURCEA((ULONG_PTR)(MAKEINTRESOURCEA(3) + 11)) -/* UI redefinitions for MinGW */ -#ifndef PBM_SETSTATE -#define PBM_SETSTATE (WM_USER+16) -#endif -#ifndef PBST_NORMAL -#define PBST_NORMAL 1 -#endif -#ifndef PBST_ERROR -#define PBST_ERROR 2 -#endif -#ifndef PBST_PAUSED -#define PBST_PAUSED 3 -#endif -#ifndef BUTTON_IMAGELIST_ALIGN_CENTER -#define BUTTON_IMAGELIST_ALIGN_CENTER 4 -#endif -#ifndef BCM_SETIMAGELIST -#define BCM_SETIMAGELIST 0x1602 -#endif -#ifndef DBT_CUSTOMEVENT -#define DBT_CUSTOMEVENT 0x8006 -#endif -#ifndef ERROR_FILE_TOO_LARGE -#define ERROR_FILE_TOO_LARGE 223 -#endif -#ifndef MSGFLT_ADD -#define MSGFLT_ADD 1 -#endif +/* MinGW doesn't know these */ #ifndef WM_CLIENTSHUTDOWN #define WM_CLIENTSHUTDOWN 0x3B #endif #ifndef WM_COPYGLOBALDATA #define WM_COPYGLOBALDATA 0x49 #endif -#ifndef PBS_MARQUEE -#define PBS_MARQUEE 0x08 -#endif -#ifndef PBM_SETMARQUEE -#define PBM_SETMARQUEE (WM_USER+10) -#endif - -typedef struct { - HIMAGELIST himl; - RECT margin; - UINT uAlign; -} MY_BUTTON_IMAGELIST; - -typedef struct -{ - LPCITEMIDLIST pidl; - BOOL fRecursive; -} MY_SHChangeNotifyEntry; /* The following is used for native ISO mounting in Windows 8 or later */ #define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \ { 0xEC984AECL, 0xA0F9, 0x47e9, { 0x90, 0x1F, 0x71, 0x41, 0x5A, 0x66, 0x34, 0x5B } } - -typedef enum _VIRTUAL_DISK_ACCESS_MASK { - VIRTUAL_DISK_ACCESS_NONE = 0x00000000, - VIRTUAL_DISK_ACCESS_ATTACH_RO = 0x00010000, - VIRTUAL_DISK_ACCESS_ATTACH_RW = 0x00020000, - VIRTUAL_DISK_ACCESS_DETACH = 0x00040000, - VIRTUAL_DISK_ACCESS_GET_INFO = 0x00080000, - VIRTUAL_DISK_ACCESS_CREATE = 0x00100000, - VIRTUAL_DISK_ACCESS_METAOPS = 0x00200000, - VIRTUAL_DISK_ACCESS_READ = 0x000d0000, - VIRTUAL_DISK_ACCESS_ALL = 0x003f0000, - VIRTUAL_DISK_ACCESS_WRITABLE = 0x00320000 -} VIRTUAL_DISK_ACCESS_MASK; - -typedef enum _OPEN_VIRTUAL_DISK_FLAG { - OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00000000, - OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = 0x00000001, - OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = 0x00000002, - OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = 0x00000004, - OPEN_VIRTUAL_DISK_FLAG_CACHED_IO = 0x00000008, - OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN = 0x00000010 -} OPEN_VIRTUAL_DISK_FLAG; - -typedef enum _OPEN_VIRTUAL_DISK_VERSION { - OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0, - OPEN_VIRTUAL_DISK_VERSION_1 = 1, - OPEN_VIRTUAL_DISK_VERSION_2 = 2 -} OPEN_VIRTUAL_DISK_VERSION; - -typedef enum _ATTACH_VIRTUAL_DISK_FLAG { - ATTACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000, - ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = 0x00000001, - ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER = 0x00000002, - ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = 0x00000004, - ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST = 0x00000008 -} ATTACH_VIRTUAL_DISK_FLAG; - -typedef enum _ATTACH_VIRTUAL_DISK_VERSION { - ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0, - ATTACH_VIRTUAL_DISK_VERSION_1 = 1 -} ATTACH_VIRTUAL_DISK_VERSION; - -typedef enum _DETACH_VIRTUAL_DISK_FLAG { - DETACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000 -} DETACH_VIRTUAL_DISK_FLAG; - -#ifndef _VIRTUAL_STORAGE_TYPE_DEFINED -#define _VIRTUAL_STORAGE_TYPE_DEFINED -typedef struct _VIRTUAL_STORAGE_TYPE { - ULONG DeviceId; - GUID VendorId; -} VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE; -#endif - -typedef struct _OPEN_VIRTUAL_DISK_PARAMETERS { - OPEN_VIRTUAL_DISK_VERSION Version; - union { - struct { - ULONG RWDepth; - } Version1; - struct { - BOOL GetInfoOnly; - BOOL ReadOnly; - GUID ResiliencyGuid; - } Version2; - }; -} OPEN_VIRTUAL_DISK_PARAMETERS, *POPEN_VIRTUAL_DISK_PARAMETERS; - -typedef struct _ATTACH_VIRTUAL_DISK_PARAMETERS { - ATTACH_VIRTUAL_DISK_VERSION Version; - union { - struct { - ULONG Reserved; - } Version1; - }; -} ATTACH_VIRTUAL_DISK_PARAMETERS, *PATTACH_VIRTUAL_DISK_PARAMETERS; - -/* Networking constants missing from MinGW */ -#if !defined(ERROR_INTERNET_DISCONNECTED) -#define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163) -#endif -#if !defined(ERROR_INTERNET_SERVER_UNREACHABLE) -#define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164) -#endif -#if !defined(ERROR_INTERNET_PROXY_SERVER_UNREACHABLE) -#define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165) -#endif -#if !defined(ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT) -#define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166) -#endif -#if !defined(ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT) -#define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167) -#endif -#if !defined(ERROR_INTERNET_FAILED_DUETOSECURITYCHECK) -#define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171) -#endif -#if !defined(ERROR_INTERNET_NOT_INITIALIZED) -#define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172) -#endif -#if !defined(ERROR_INTERNET_NEED_MSN_SSPI_PKG) -#define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173) -#endif -#if !defined(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY) -#define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174) -#endif - -/* - * IFile[Open]Dialog interface for Vista and later (from MinGW headers) - */ -#ifndef __IFileDialog_INTERFACE_DEFINED__ -#define __IFileDialog_INTERFACE_DEFINED__ - -enum _FILEOPENDIALOGOPTIONS { - FOS_OVERWRITEPROMPT = 0x2, - FOS_STRICTFILETYPES = 0x4, - FOS_NOCHANGEDIR = 0x8, - FOS_PICKFOLDERS = 0x20, - FOS_FORCEFILESYSTEM = 0x40, - FOS_ALLNONSTORAGEITEMS = 0x80, - FOS_NOVALIDATE = 0x100, - FOS_ALLOWMULTISELECT = 0x200, - FOS_PATHMUSTEXIST = 0x800, - FOS_FILEMUSTEXIST = 0x1000, - FOS_CREATEPROMPT = 0x2000, - FOS_SHAREAWARE = 0x4000, - FOS_NOREADONLYRETURN = 0x8000, - FOS_NOTESTFILECREATE = 0x10000, - FOS_HIDEMRUPLACES = 0x20000, - FOS_HIDEPINNEDPLACES = 0x40000, - FOS_NODEREFERENCELINKS = 0x100000, - FOS_DONTADDTORECENT = 0x2000000, - FOS_FORCESHOWHIDDEN = 0x10000000, - FOS_DEFAULTNOMINIMODE = 0x20000000, - FOS_FORCEPREVIEWPANEON = 0x40000000 -}; - -typedef enum FDAP { - FDAP_BOTTOM = 0, - FDAP_TOP = 1 -} FDAP; - -typedef DWORD FILEOPENDIALOGOPTIONS; - -DEFINE_GUID(IID_IFileDialog, 0x42f85136, 0xdb7e, 0x439c, 0x85, 0xf1, 0xe4, 0x07, 0x5d, 0x13, 0x5f, 0xc8); - -typedef struct IFileDialogVtbl { - BEGIN_INTERFACE - - /*** IUnknown methods ***/ - HRESULT(STDMETHODCALLTYPE *QueryInterface)( - IFileDialog* This, - REFIID riid, - void **ppvObject); - - ULONG(STDMETHODCALLTYPE *AddRef)( - IFileDialog* This); - - ULONG(STDMETHODCALLTYPE *Release)( - IFileDialog* This); - - /*** IModalWindow methods ***/ - HRESULT(STDMETHODCALLTYPE *Show)( - IFileDialog* This, - HWND hwndOwner); - - /*** IFileDialog methods ***/ - HRESULT(STDMETHODCALLTYPE *SetFileTypes)( - IFileDialog* This, - UINT cFileTypes, - const COMDLG_FILTERSPEC *rgFilterSpec); - - HRESULT(STDMETHODCALLTYPE *SetFileTypeIndex)( - IFileDialog* This, - UINT iFileType); - - HRESULT(STDMETHODCALLTYPE *GetFileTypeIndex)( - IFileDialog* This, - UINT *piFileType); - - HRESULT(STDMETHODCALLTYPE *Advise)( - IFileDialog* This, - IFileDialogEvents *pfde, - DWORD *pdwCookie); - - HRESULT(STDMETHODCALLTYPE *Unadvise)( - IFileDialog* This, - DWORD dwCookie); - - HRESULT(STDMETHODCALLTYPE *SetOptions)( - IFileDialog* This, - FILEOPENDIALOGOPTIONS fos); - - HRESULT(STDMETHODCALLTYPE *GetOptions)( - IFileDialog* This, - FILEOPENDIALOGOPTIONS *pfos); - - HRESULT(STDMETHODCALLTYPE *SetDefaultFolder)( - IFileDialog* This, - IShellItem *psi); - - HRESULT(STDMETHODCALLTYPE *SetFolder)( - IFileDialog* This, - IShellItem *psi); - - HRESULT(STDMETHODCALLTYPE *GetFolder)( - IFileDialog* This, - IShellItem **ppsi); - - HRESULT(STDMETHODCALLTYPE *GetCurrentSelection)( - IFileDialog* This, - IShellItem **ppsi); - - HRESULT(STDMETHODCALLTYPE *SetFileName)( - IFileDialog* This, - LPCWSTR pszName); - - HRESULT(STDMETHODCALLTYPE *GetFileName)( - IFileDialog* This, - LPWSTR *pszName); - - HRESULT(STDMETHODCALLTYPE *SetTitle)( - IFileDialog* This, - LPCWSTR pszTitle); - - HRESULT(STDMETHODCALLTYPE *SetOkButtonLabel)( - IFileDialog* This, - LPCWSTR pszText); - - HRESULT(STDMETHODCALLTYPE *SetFileNameLabel)( - IFileDialog* This, - LPCWSTR pszLabel); - - HRESULT(STDMETHODCALLTYPE *GetResult)( - IFileDialog* This, - IShellItem **ppsi); - - HRESULT(STDMETHODCALLTYPE *AddPlace)( - IFileDialog* This, - IShellItem *psi, - FDAP fdap); - - HRESULT(STDMETHODCALLTYPE *SetDefaultExtension)( - IFileDialog* This, - LPCWSTR pszDefaultExtension); - - HRESULT(STDMETHODCALLTYPE *Close)( - IFileDialog* This, - HRESULT hr); - - HRESULT(STDMETHODCALLTYPE *SetClientGuid)( - IFileDialog* This, - REFGUID guid); - - HRESULT(STDMETHODCALLTYPE *ClearClientData)( - IFileDialog* This); - - HRESULT(STDMETHODCALLTYPE *SetFilter)( - IFileDialog* This, - IShellItemFilter *pFilter); - - END_INTERFACE -} IFileDialogVtbl; -interface IFileDialog { - CONST_VTBL IFileDialogVtbl* lpVtbl; -}; -#endif - -#ifndef __IFileOpenDialog_INTERFACE_DEFINED__ -#define __IFileOpenDialog_INTERFACE_DEFINED__ - -DEFINE_GUID(IID_IFileOpenDialog, 0xd57c7288, 0xd4ad, 0x4768, 0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60); - -typedef struct IFileOpenDialogVtbl { - BEGIN_INTERFACE - - /*** IUnknown methods ***/ - HRESULT(STDMETHODCALLTYPE *QueryInterface)( - IFileOpenDialog* This, - REFIID riid, - void **ppvObject); - - ULONG(STDMETHODCALLTYPE *AddRef)( - IFileOpenDialog* This); - - ULONG(STDMETHODCALLTYPE *Release)( - IFileOpenDialog* This); - - /*** IModalWindow methods ***/ - HRESULT(STDMETHODCALLTYPE *Show)( - IFileOpenDialog* This, - HWND hwndOwner); - - /*** IFileDialog methods ***/ - HRESULT(STDMETHODCALLTYPE *SetFileTypes)( - IFileOpenDialog* This, - UINT cFileTypes, - const COMDLG_FILTERSPEC *rgFilterSpec); - - HRESULT(STDMETHODCALLTYPE *SetFileTypeIndex)( - IFileOpenDialog* This, - UINT iFileType); - - HRESULT(STDMETHODCALLTYPE *GetFileTypeIndex)( - IFileOpenDialog* This, - UINT *piFileType); - - HRESULT(STDMETHODCALLTYPE *Advise)( - IFileOpenDialog* This, - IFileDialogEvents *pfde, - DWORD *pdwCookie); - - HRESULT(STDMETHODCALLTYPE *Unadvise)( - IFileOpenDialog* This, - DWORD dwCookie); - - HRESULT(STDMETHODCALLTYPE *SetOptions)( - IFileOpenDialog* This, - FILEOPENDIALOGOPTIONS fos); - - HRESULT(STDMETHODCALLTYPE *GetOptions)( - IFileOpenDialog* This, - FILEOPENDIALOGOPTIONS *pfos); - - HRESULT(STDMETHODCALLTYPE *SetDefaultFolder)( - IFileOpenDialog* This, - IShellItem *psi); - - HRESULT(STDMETHODCALLTYPE *SetFolder)( - IFileOpenDialog* This, - IShellItem *psi); - - HRESULT(STDMETHODCALLTYPE *GetFolder)( - IFileOpenDialog* This, - IShellItem **ppsi); - - HRESULT(STDMETHODCALLTYPE *GetCurrentSelection)( - IFileOpenDialog* This, - IShellItem **ppsi); - - HRESULT(STDMETHODCALLTYPE *SetFileName)( - IFileOpenDialog* This, - LPCWSTR pszName); - - HRESULT(STDMETHODCALLTYPE *GetFileName)( - IFileOpenDialog* This, - LPWSTR *pszName); - - HRESULT(STDMETHODCALLTYPE *SetTitle)( - IFileOpenDialog* This, - LPCWSTR pszTitle); - - HRESULT(STDMETHODCALLTYPE *SetOkButtonLabel)( - IFileOpenDialog* This, - LPCWSTR pszText); - - HRESULT(STDMETHODCALLTYPE *SetFileNameLabel)( - IFileOpenDialog* This, - LPCWSTR pszLabel); - - HRESULT(STDMETHODCALLTYPE *GetResult)( - IFileOpenDialog* This, - IShellItem **ppsi); - - HRESULT(STDMETHODCALLTYPE *AddPlace)( - IFileOpenDialog* This, - IShellItem *psi, - FDAP fdap); - - HRESULT(STDMETHODCALLTYPE *SetDefaultExtension)( - IFileOpenDialog* This, - LPCWSTR pszDefaultExtension); - - HRESULT(STDMETHODCALLTYPE *Close)( - IFileOpenDialog* This, - HRESULT hr); - - HRESULT(STDMETHODCALLTYPE *SetClientGuid)( - IFileOpenDialog* This, - REFGUID guid); - - HRESULT(STDMETHODCALLTYPE *ClearClientData)( - IFileOpenDialog* This); - - HRESULT(STDMETHODCALLTYPE *SetFilter)( - IFileOpenDialog* This, - IShellItemFilter *pFilter); - - /*** IFileOpenDialog methods ***/ - HRESULT(STDMETHODCALLTYPE *GetResults)( - IFileOpenDialog* This, - IShellItemArray **ppenum); - - HRESULT(STDMETHODCALLTYPE *GetSelectedItems)( - IFileOpenDialog* This, - IShellItemArray **ppsai); - - END_INTERFACE -} IFileOpenDialogVtbl; -interface IFileOpenDialog { - CONST_VTBL IFileOpenDialogVtbl* lpVtbl; -}; -#endif diff --git a/src/resource.h b/src/resource.h index e059eb71..8f8f0398 100644 --- a/src/resource.h +++ b/src/resource.h @@ -13,8 +13,6 @@ #define IDD_CHECKSUM 109 #define IDD_LIST 110 #define IDI_ICON 120 -#define IDI_UP 121 -#define IDI_DOWN 122 #define IDD_DIALOG_XP 151 #define IDD_ABOUTBOX_XP 152 #define IDD_NOTIFICATION_XP 153 diff --git a/src/rufus.c b/src/rufus.c index 85471ff2..c496721f 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -47,14 +47,6 @@ #include "../res/grub/grub_version.h" #include "../res/grub2/grub2_version.h" -// ImageList calls are unavailable on XP -PF_TYPE_DECL(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int)); -PF_TYPE_DECL(WINAPI, int, ImageList_AddIcon, (HIMAGELIST, HICON)); -PF_TYPE_DECL(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON)); - -PF_TYPE_DECL(WINAPI, BOOL, SHChangeNotifyDeregister, (ULONG)); -PF_TYPE_DECL(WINAPI, ULONG, SHChangeNotifyRegister, (HWND, int, LONG, UINT, int, const MY_SHChangeNotifyEntry*)); - const char* cmdline_hogger = "rufus.com"; const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "UDF", "exFAT", "ReFS" }; const char* ep_reg = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; @@ -92,8 +84,7 @@ char msgbox[1024], msgbox_title[32], *ini_file = NULL; OPENED_LIBRARIES_VARS; HINSTANCE hMainInstance; HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL; -MY_BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }; -GetTickCount64_t pfGetTickCount64 = NULL; +BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }; char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH]; char* image_path = NULL; float fScale = 1.0f; @@ -265,22 +256,18 @@ static BOOL DefineClusterSizes(void) } } - // exFAT (requires KB955704 installed on XP => don't bother) - if (nWindowsVersion > WINDOWS_XP) { - SelectedDrive.ClusterSize[FS_EXFAT].Allowed = 0x03FFFE00; - if (SelectedDrive.DiskSize < 256*MB) // < 256 MB - SelectedDrive.ClusterSize[FS_EXFAT].Default = 4*KB; - else if (SelectedDrive.DiskSize < 32*GB) // < 32 GB - SelectedDrive.ClusterSize[FS_EXFAT].Default = 32*KB; - else - SelectedDrive.ClusterSize[FS_EXFAT].Default = 128*KB; - } + // exFAT + SelectedDrive.ClusterSize[FS_EXFAT].Allowed = 0x03FFFE00; + if (SelectedDrive.DiskSize < 256*MB) // < 256 MB + SelectedDrive.ClusterSize[FS_EXFAT].Default = 4*KB; + else if (SelectedDrive.DiskSize < 32*GB) // < 32 GB + SelectedDrive.ClusterSize[FS_EXFAT].Default = 32*KB; + else + SelectedDrive.ClusterSize[FS_EXFAT].Default = 128*KB; - // UDF (only supported for Vista and later) - if (nWindowsVersion >= WINDOWS_VISTA) { - SelectedDrive.ClusterSize[FS_UDF].Allowed = SINGLE_CLUSTERSIZE_DEFAULT; - SelectedDrive.ClusterSize[FS_UDF].Default = 1; - } + // UDF + SelectedDrive.ClusterSize[FS_UDF].Allowed = SINGLE_CLUSTERSIZE_DEFAULT; + SelectedDrive.ClusterSize[FS_UDF].Default = 1; // ReFS (only supported for Windows 8.1 and later and for fixed disks) if (SelectedDrive.DiskSize >= 512*MB) { @@ -445,10 +432,7 @@ static BOOL SetDriveInfo(int ComboIndex) } for (i=0; i<3; i++) { - // Populate MBR/BIOS, MBR/UEFI and GPT/UEFI targets, with an exception - // for XP, as it doesn't support GPT at all - if ((i == 2) && (nWindowsVersion <= WINDOWS_XP)) - continue; + // Populate MBR/BIOS, MBR/UEFI and GPT/UEFI targets pt = (i==2)?PARTITION_STYLE_GPT:PARTITION_STYLE_MBR; if (i==0) { SetMBRForUEFI(FALSE); @@ -820,8 +804,8 @@ void UpdateProgress(int op, float percent) } // Reduce the refresh rate, to avoid weird effects on the sliding part of progress bar - if (_GetTickCount64() > LastRefresh + (2 * MAX_REFRESH)) { - LastRefresh = _GetTickCount64(); + if (GetTickCount64() > LastRefresh + (2 * MAX_REFRESH)) { + LastRefresh = GetTickCount64(); SendMessage(hProgress, PBM_SETPOS, (WPARAM)pos, 0); SetTaskbarProgressValue(pos, MAX_PROGRESS); } @@ -1708,10 +1692,6 @@ static void InitDialog(HWND hDlg) ShowWindow(GetDlgItem(hDlg, IDC_TEST), SW_SHOW); #endif - PF_INIT(ImageList_Create, Comctl32); - PF_INIT(ImageList_AddIcon, Comctl32); - PF_INIT(ImageList_ReplaceIcon, Comctl32); - // Quite a burden to carry around as parameters hMainDialog = hDlg; MainThreadId = GetCurrentThreadId(); @@ -1748,7 +1728,7 @@ static void InitDialog(HWND hDlg) // Create the font and brush for the Info edit box hInfoFont = CreateFontA(lfHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, - 0, 0, PROOF_QUALITY, 0, (nWindowsVersion >= WINDOWS_VISTA)?"Segoe UI":"Arial Unicode MS"); + 0, 0, PROOF_QUALITY, 0, "Segoe UI"); SendDlgItemMessageA(hDlg, IDC_INFO, WM_SETFONT, (WPARAM)hInfoFont, TRUE); hInfoBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); HideCaret(hInfo); @@ -1853,22 +1833,15 @@ static void InitDialog(HWND hDlg) hIconLang = (HICON)LoadImage(hINetCplDllInst, MAKEINTRESOURCE(1313), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); } - if (nWindowsVersion >= WINDOWS_VISTA) { - hIconDown = (HICON)LoadImage(hShell32DllInst, MAKEINTRESOURCE(16750), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); - hIconUp = (HICON)LoadImage(hShell32DllInst, MAKEINTRESOURCE(16749), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); - } else { - hIconDown = (HICON)LoadImage(hMainInstance, MAKEINTRESOURCE(IDI_DOWN), IMAGE_ICON, 16, 16, 0); - hIconUp = (HICON)LoadImage(hMainInstance, MAKEINTRESOURCE(IDI_UP), IMAGE_ICON, 16, 16, 0); - } + hIconDown = (HICON)LoadImage(hShell32DllInst, MAKEINTRESOURCE(16750), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); + hIconUp = (HICON)LoadImage(hShell32DllInst, MAKEINTRESOURCE(16749), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); // Create the language toolbar hLangToolbar = CreateWindowExW(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_TABSTOP | TBSTYLE_TRANSPARENT | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER, 0, 0, 0, 0, hMainDialog, NULL, hMainInstance, NULL); - if ((pfImageList_Create != NULL) && (pfImageList_AddIcon != NULL)) { - hLangToolbarImageList = pfImageList_Create(i16, i16, ILC_COLOR32, 1, 0); - pfImageList_AddIcon(hLangToolbarImageList, hIconLang); - SendMessage(hLangToolbar, TB_SETIMAGELIST, (WPARAM)0, (LPARAM)hLangToolbarImageList); - } + hLangToolbarImageList = ImageList_Create(i16, i16, ILC_COLOR32, 1, 0); + ImageList_AddIcon(hLangToolbarImageList, hIconLang); + SendMessage(hLangToolbar, TB_SETIMAGELIST, (WPARAM)0, (LPARAM)hLangToolbarImageList); SendMessage(hLangToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); memset(tbLangToolbarButtons, 0, sizeof(TBBUTTON)); tbLangToolbarButtons[0].idCommand = lang_button_id; @@ -1917,25 +1890,22 @@ static void InitDialog(HWND hDlg) info_original_proc = (WNDPROC)SetWindowLongPtr(hInfo, GWLP_WNDPROC, (LONG_PTR)InfoCallback); // Set the icons on the the buttons - if ((pfImageList_Create != NULL) && (pfImageList_ReplaceIcon != NULL)) { + bi_iso.himl = ImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + ImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc); + SetRect(&bi_iso.margin, 0, 1, 0, 0); + bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_down.himl = ImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + ImageList_ReplaceIcon(bi_down.himl, -1, hIconDown); + SetRect(&bi_down.margin, 0, 0, 0, 0); + bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_up.himl = ImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + ImageList_ReplaceIcon(bi_up.himl, -1, hIconUp); + SetRect(&bi_up.margin, 0, 0, 0, 0); + bi_up.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - bi_iso.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); - pfImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc); - SetRect(&bi_iso.margin, 0, 1, 0, 0); - bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - bi_down.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); - pfImageList_ReplaceIcon(bi_down.himl, -1, hIconDown); - SetRect(&bi_down.margin, 0, 0, 0, 0); - bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - bi_up.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); - pfImageList_ReplaceIcon(bi_up.himl, -1, hIconUp); - SetRect(&bi_up.margin, 0, 0, 0, 0); - bi_up.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - - SendMessage(hSelectISO, BCM_SETIMAGELIST, 0, (LPARAM)&bi_iso); - SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, - (LPARAM)(advanced_mode?&bi_up:&bi_down)); - } + SendMessage(hSelectISO, BCM_SETIMAGELIST, 0, (LPARAM)&bi_iso); + SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, + (LPARAM)(advanced_mode?&bi_up:&bi_down)); // Set the various tooltips CreateTooltip(hFileSystem, lmprintf(MSG_157), -1); @@ -1960,10 +1930,8 @@ static void InitDialog(HWND hDlg) CreateTooltip(hLangToolbar, lmprintf(MSG_273), -1); // Set a label for the Advanced Mode and Select Image button for screen readers - if (nWindowsVersion > WINDOWS_XP) { - SetWindowTextU(GetDlgItem(hDlg, IDC_ADVANCED), lmprintf(MSG_160)); - SetWindowTextU(hSelectISO, lmprintf(MSG_165)); - } + SetWindowTextU(GetDlgItem(hDlg, IDC_ADVANCED), lmprintf(MSG_160)); + SetWindowTextU(hSelectISO, lmprintf(MSG_165)); if (!advanced_mode) // Hide as needed, since we display the advanced controls by default ToggleAdvanced(FALSE); @@ -2195,7 +2163,7 @@ static BOOL CheckDriveAccess(DWORD dwTimeOut) char *PhysicalPath = NULL, DevPath[MAX_PATH]; char drive_letter[27], drive_name[] = "?:"; char *message, title[128]; - DWORD cur_time, end_time = GetTickCount() + dwTimeOut; + uint64_t cur_time, end_time = GetTickCount64() + dwTimeOut; // Get the current selected device DWORD DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList)); @@ -2225,10 +2193,10 @@ static BOOL CheckDriveAccess(DWORD dwTimeOut) drive_name[0] = drive_letter[i]; if (QueryDosDeviceA(drive_name, DevPath, sizeof(DevPath)) != 0) { StrArrayClear(&BlockingProcess); - cur_time = GetTickCount(); + cur_time = GetTickCount64(); if (cur_time >= end_time) break; - access_mask = SearchProcess(DevPath, end_time - cur_time, TRUE, TRUE, TRUE); + access_mask = SearchProcess(DevPath, (DWORD)(end_time - cur_time), TRUE, TRUE, TRUE); CHECK_FOR_USER_CANCEL; // Ignore if all we have is read-only if ((access_mask & 0x06) || (access_mask == 0x80)) { @@ -2272,7 +2240,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA static BOOL first_log_display = TRUE, isMarquee = FALSE, queued_hotplug_event = FALSE; static ULONG ulRegister = 0; static LPITEMIDLIST pidlDesktop = NULL; - static MY_SHChangeNotifyEntry NotifyEntry; + static SHChangeNotifyEntry NotifyEntry; static DWORD_PTR thread_affinity[4]; DRAWITEMSTRUCT* pDI; HDROP droppedFileInfo; @@ -2316,7 +2284,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA switch(LOWORD(wParam)) { case IDOK: // close application case IDCANCEL: - PF_INIT(SHChangeNotifyDeregister, Shell32); EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE); if (format_thid != NULL) { if ((no_confirmation_on_cancel) || (MessageBoxExU(hMainDialog, lmprintf(MSG_105), lmprintf(MSG_049), @@ -2343,8 +2310,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA PrintInfo(0, MSG_201); return (INT_PTR)TRUE; } - if ((pfSHChangeNotifyDeregister != NULL) && (ulRegister != 0)) - pfSHChangeNotifyDeregister(ulRegister); + if (ulRegister != 0) + SHChangeNotifyDeregister(ulRegister); PostQuitMessage(0); StrArrayDestroy(&DriveID); StrArrayDestroy(&DriveLabel); @@ -2711,7 +2678,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA case DBT_DEVICEARRIVAL: case DBT_DEVICEREMOVECOMPLETE: case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change - LastRefresh = _GetTickCount64(); + LastRefresh = GetTickCount64(); KillTimer(hMainDialog, TID_REFRESH_TIMER); if (!format_op_in_progress) { queued_hotplug_event = FALSE; @@ -2724,8 +2691,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA return (INT_PTR)TRUE; case DBT_DEVNODES_CHANGED: // If it's been more than a second since last device refresh, arm a refresh timer - if (_GetTickCount64() > LastRefresh + 1000) { - LastRefresh = _GetTickCount64(); + if (GetTickCount64() > LastRefresh + 1000) { + LastRefresh = GetTickCount64(); SetTimer(hMainDialog, TID_REFRESH_TIMER, 1000, RefreshTimer); } break; @@ -2736,7 +2703,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA break; case WM_INITDIALOG: - PF_INIT(SHChangeNotifyRegister, shell32); // Make sure fScale is set before the first call to apply localization, so that move/resize scale appropriately hDC = GetDC(hDlg); fScale = GetDeviceCaps(hDC, LOGPIXELSX) / 96.0f; @@ -2753,12 +2719,12 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA GetDevices(0); CheckForUpdates(FALSE); // Register MEDIA_INSERTED/MEDIA_REMOVED notifications for card readers - if ((pfSHChangeNotifyRegister != NULL) && (SUCCEEDED(SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidlDesktop)))) { + if (SUCCEEDED(SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidlDesktop))) { NotifyEntry.pidl = pidlDesktop; NotifyEntry.fRecursive = TRUE; // NB: The following only works if the media is already formatted. // If you insert a blank card, notifications will not be sent... :( - ulRegister = pfSHChangeNotifyRegister(hDlg, 0x0001 | 0x0002 | 0x8000, + ulRegister = SHChangeNotifyRegister(hDlg, 0x0001 | 0x0002 | 0x8000, SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED, UM_MEDIA_CHANGE, 1, &NotifyEntry); } // Bring our Window on top. We have to go through all *THREE* of these, or Far Manager hides our window :( @@ -3039,7 +3005,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine char *tmp, *locale_name = NULL, **argv = NULL; wchar_t **wenv, **wargv; PF_TYPE_DECL(CDECL, int, __wgetmainargs, (int*, wchar_t***, wchar_t***, int, int*)); - PF_TYPE_DECL(WINAPI, BOOL, ChangeWindowMessageFilter, (UINT message, DWORD dwFlag)); HANDLE mutex = NULL, hogmutex = NULL, hFile = NULL; HWND hDlg = NULL; HDC hDC; @@ -3058,7 +3023,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine SetDllDirectoryA(""); uprintf("*** " APPLICATION_NAME " init ***\n"); - PF_INIT(GetTickCount64, kernel32); // Reattach the console, if we were started from commandline if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) { @@ -3239,6 +3203,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine } selected_langid = get_language_id(selected_locale); + // Set the Windows version + GetWindowsVersion(); + + // ...and nothing of value was lost + if (nWindowsVersion < WINDOWS_7) { + // Load the translation before we print the error + get_loc_data_file(loc_file, selected_locale); + right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT); + // Set MB_SYSTEMMODAL to prevent Far Manager from stealing focus... + MessageBoxExU(NULL, lmprintf(MSG_294), lmprintf(MSG_293), MB_ICONSTOP | MB_IS_RTL | MB_SYSTEMMODAL, selected_langid); + goto out; + } + // This is needed as there appears to be a *FLAW* in Windows allowing the app to run unelevated with some // weirdly configured user accounts, even as we explicitly set 'requireAdministrator' in the manifest... if (!IsCurrentProcessElevated()) { @@ -3280,9 +3257,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine uprintf("Could not load RichEdit library - some dialogs may not display: %s\n", WindowsErrorString()); } - // Set the Windows version - GetWindowsVersion(); - // Increase the application privileges (SE_DEBUG_PRIVILEGE), so that we can report // the Windows Services preventing access to the disk or volume we want to format. EnablePrivileges(); @@ -3291,16 +3265,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // 0x9e disables removable and fixed drive notifications lgp_set = SetLGP(FALSE, &existing_key, ep_reg, "NoDriveTypeAutorun", 0x9e); - if (nWindowsVersion > WINDOWS_XP) { - // Re-enable AutoMount if needed - if (!GetAutoMount(&automount)) { - uprintf("Could not get AutoMount status"); - automount = TRUE; // So that we don't try to change its status on exit - } else if (!automount) { - uprintf("AutoMount was detected as disabled - temporarily re-enabling it"); - if (!SetAutoMount(TRUE)) - uprintf("Failed to enable AutoMount"); - } + // Re-enable AutoMount if needed + if (!GetAutoMount(&automount)) { + uprintf("Could not get AutoMount status"); + automount = TRUE; // So that we don't try to change its status on exit + } else if (!automount) { + uprintf("AutoMount was detected as disabled - temporarily re-enabling it"); + if (!SetAutoMount(TRUE)) + uprintf("Failed to enable AutoMount"); } relaunch: @@ -3329,18 +3301,11 @@ relaunch: if ((relaunch_rc.left > -65536) && (relaunch_rc.top > -65536)) SetWindowPos(hDlg, HWND_TOP, relaunch_rc.left, relaunch_rc.top, 0, 0, SWP_NOSIZE); - // Enable drag-n-drop through the message filter (for Vista or later) - if (nWindowsVersion >= WINDOWS_VISTA) { - PF_INIT(ChangeWindowMessageFilter, user32); - if (pfChangeWindowMessageFilter != NULL) { - // NB: We use ChangeWindowMessageFilter() here because - // ChangeWindowMessageFilterEx() is not available on Vista - pfChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD); - pfChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD); - // CopyGlobalData is needed sine we are running elevated - pfChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD); - } - } + // Enable drag-n-drop through the message filter + ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD); + ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD); + // CopyGlobalData is needed sine we are running elevated + ChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD); // Set the hook to automatically close Windows' "You need to format the disk in drive..." prompt if (!SetFormatPromptHook()) @@ -3596,7 +3561,7 @@ out: } if (lgp_set) SetLGP(TRUE, &existing_key, ep_reg, "NoDriveTypeAutorun", 0); - if ((nWindowsVersion > WINDOWS_XP) && (!automount) && (!SetAutoMount(FALSE))) + if ((!automount) && (!SetAutoMount(FALSE))) uprintf("Failed to restore AutoMount to disabled"); ubflush(); // Unconditional delete with retry, just in case... diff --git a/src/rufus.h b/src/rufus.h index 27e48262..473a3e31 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -21,8 +21,8 @@ #if defined(_MSC_VER) // Disable some VS Code Analysis warnings -#pragma warning(disable: 4996) // Ignore deprecated (eg. GetVersionEx()), as we have to contend with XP -#pragma warning(disable: 28159) // We use GetTickCount64() where possible, but it's not available on XP +#pragma warning(disable: 4996) // Ignore deprecated +#pragma warning(disable: 28159) // I'll keep using GetVersionEx(), thank you very much! #pragma warning(disable: 6258) // I know what I'm using TerminateThread for #endif @@ -599,7 +599,3 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) { #define ERROR_CANT_ASSIGN_LETTER 0x120B #define ERROR_CANT_MOUNT_VOLUME 0x120C -/* GetTickCount64 not being available on XP is a massive bother */ -PF_TYPE(WINAPI, ULONGLONG, GetTickCount64, (void)); -extern GetTickCount64_t pfGetTickCount64; -#define _GetTickCount64() ((pfGetTickCount64 != NULL)?(uint64_t)pfGetTickCount64():(uint64_t)GetTickCount()) diff --git a/src/rufus.rc b/src/rufus.rc index 89f6287c..2f9220dc 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.18.1214" +CAPTION "Rufus 2.18.1215" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -366,8 +366,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,18,1214,0 - PRODUCTVERSION 2,18,1214,0 + FILEVERSION 2,18,1215,0 + PRODUCTVERSION 2,18,1215,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -384,13 +384,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.18.1214" + VALUE "FileVersion", "2.18.1215" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.18.1214" + VALUE "ProductVersion", "2.18.1215" END END BLOCK "VarFileInfo" @@ -409,10 +409,6 @@ END // remains consistent on all systems. IDI_ICON ICON "../res/rufus.ico" -IDI_UP ICON "../res/up.ico" - -IDI_DOWN ICON "../res/down.ico" - #endif // Neutral resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/stdfn.c b/src/stdfn.c index 8dc64898..779184dd 100644 --- a/src/stdfn.c +++ b/src/stdfn.c @@ -36,8 +36,6 @@ int nWindowsVersion = WINDOWS_UNDEFINED; int nWindowsBuildNumber = -1; char WindowsVersionStr[128] = "Windows "; -PF_TYPE_DECL(WINAPI, int, LCIDToLocaleName, (LCID, LPWSTR, int, DWORD)); - /* * Hash table functions - modified From glibc 2.3.2: * [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986 @@ -900,11 +898,7 @@ char* GetCurrentMUI(void) static char mui_str[LOCALE_NAME_MAX_LENGTH]; wchar_t wmui_str[LOCALE_NAME_MAX_LENGTH]; - // Of course LCIDToLocaleName() is not available on XP... grrrr! - PF_INIT(LCIDToLocaleName, kernel32); - - if ( (pfLCIDToLocaleName != NULL) && - (pfLCIDToLocaleName(GetUserDefaultUILanguage(), wmui_str, LOCALE_NAME_MAX_LENGTH, 0) > 0) ) { + if (LCIDToLocaleName(GetUserDefaultUILanguage(), wmui_str, LOCALE_NAME_MAX_LENGTH, 0) > 0) { wchar_to_utf8_no_alloc(wmui_str, mui_str, LOCALE_NAME_MAX_LENGTH); } else { static_strcpy(mui_str, "en-US"); diff --git a/src/stdio.c b/src/stdio.c index a9ce4654..6298d239 100644 --- a/src/stdio.c +++ b/src/stdio.c @@ -381,7 +381,8 @@ BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWr // This is needed, for instance, if you are waiting for a thread that may issue uprintf's DWORD WaitForSingleObjectWithMessages(HANDLE hHandle, DWORD dwMilliseconds) { - DWORD res, dwCurTime, dwEndTime = GetTickCount() + dwMilliseconds; + uint64_t CurTime, EndTime = GetTickCount64() + dwMilliseconds; + DWORD res; MSG msg; do { @@ -399,11 +400,11 @@ DWORD WaitForSingleObjectWithMessages(HANDLE hHandle, DWORD dwMilliseconds) res = MsgWaitForMultipleObjects(1, &hHandle, FALSE, dwMilliseconds, QS_ALLINPUT); if (dwMilliseconds != INFINITE) { - dwCurTime = GetTickCount(); + CurTime = GetTickCount64(); // Account for the case where we may reach the timeout condition while // processing timestamps - if (dwCurTime < dwEndTime) - dwMilliseconds = dwEndTime - dwCurTime; + if (CurTime < EndTime) + dwMilliseconds = (DWORD) (EndTime - CurTime); else res = WAIT_TIMEOUT; } diff --git a/src/stdlg.c b/src/stdlg.c index bdec209f..3e549b61 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -42,12 +42,6 @@ #include "settings.h" #include "license.h" -PF_TYPE_DECL(WINAPI, HRESULT, SHCreateItemFromParsingName, (PCWSTR, IBindCtx*, REFIID, void **)); -PF_TYPE_DECL(WINAPI, LPITEMIDLIST, SHSimpleIDListFromPath, (PCWSTR pszPath)); -#define INIT_VISTA_SHELL32 PF_INIT(SHCreateItemFromParsingName, Shell32) -#define INIT_XP_SHELL32 PF_INIT(SHSimpleIDListFromPath, Shell32) -#define IS_VISTA_SHELL32_AVAILABLE (pfSHCreateItemFromParsingName != NULL) - /* Globals */ static HICON hMessageIcon = (HICON)INVALID_HANDLE_VALUE; static char* szMessageText = NULL; @@ -107,21 +101,15 @@ INT CALLBACK BrowseInfoCallback(HWND hDlg, UINT message, LPARAM lParam, LPARAM p hBrowseEdit = FindWindowExA(hDlg, NULL, "Edit", NULL); SetWindowTextU(hBrowseEdit, szFolderPath); SetDialogFocus(hDlg, hBrowseEdit); - // On XP, BFFM_SETSELECTION can't be used with a Unicode Path in SendMessageW - // or a pidl (at least with MinGW) => must use SendMessageA - if (nWindowsVersion <= WINDOWS_XP) { - SendMessageLU(hDlg, BFFM_SETSELECTION, (WPARAM)TRUE, szFolderPath); - } else { - // On Windows 7, MinGW only properly selects the specified folder when using a pidl - wpath = utf8_to_wchar(szFolderPath); - pidl = (*pfSHSimpleIDListFromPath)(wpath); - safe_free(wpath); - // NB: see http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7 - // for details as to why we send BFFM_SETSELECTION twice. - SendMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); - Sleep(100); - PostMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); - } + // On Windows 7, MinGW only properly selects the specified folder when using a pidl + wpath = utf8_to_wchar(szFolderPath); + pidl = SHSimpleIDListFromPath(wpath); + safe_free(wpath); + // NB: see http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7 + // for details as to why we send BFFM_SETSELECTION twice. + SendMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); + Sleep(100); + PostMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); break; case BFFM_SELCHANGED: // Update the status @@ -136,7 +124,6 @@ INT CALLBACK BrowseInfoCallback(HWND hDlg, UINT message, LPARAM lParam, LPARAM p /* * Browse for a folder and update the folder edit box - * Will use the newer IFileOpenDialog if *compiled* for Vista or later */ void BrowseForFolder(void) { @@ -152,78 +139,72 @@ void BrowseForFolder(void) { char* tmp_path = NULL; dialog_showing++; - if (nWindowsVersion >= WINDOWS_VISTA) { - INIT_VISTA_SHELL32; - if (IS_VISTA_SHELL32_AVAILABLE) { - hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC, - &IID_IFileOpenDialog, (LPVOID)&pfod); - if (FAILED(hr)) { - uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr); - pfod = NULL; // Just in case - goto fallback; + hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC, + &IID_IFileOpenDialog, (LPVOID)&pfod); + if (FAILED(hr)) { + uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr); + pfod = NULL; // Just in case + goto fallback; + } + hr = pfod->lpVtbl->SetOptions(pfod, FOS_PICKFOLDERS); + if (FAILED(hr)) { + uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr); + goto fallback; + } + // Set the initial folder (if the path is invalid, will simply use last) + wpath = utf8_to_wchar(szFolderPath); + // The new IFileOpenDialog makes us split the path + fname = NULL; + if ((wpath != NULL) && (wcslen(wpath) >= 1)) { + for (i = wcslen(wpath) - 1; i != 0; i--) { + if (wpath[i] == L'\\') { + wpath[i] = 0; + fname = &wpath[i + 1]; + break; } - hr = pfod->lpVtbl->SetOptions(pfod, FOS_PICKFOLDERS); - if (FAILED(hr)) { - uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr); - goto fallback; - } - // Set the initial folder (if the path is invalid, will simply use last) - wpath = utf8_to_wchar(szFolderPath); - // The new IFileOpenDialog makes us split the path - fname = NULL; - if ((wpath != NULL) && (wcslen(wpath) >= 1)) { - for (i = wcslen(wpath) - 1; i != 0; i--) { - if (wpath[i] == L'\\') { - wpath[i] = 0; - fname = &wpath[i + 1]; - break; - } - } - } - - hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path); - if (SUCCEEDED(hr)) { - if (wpath != NULL) { - pfod->lpVtbl->SetFolder(pfod, si_path); - } - if (fname != NULL) { - pfod->lpVtbl->SetFileName(pfod, fname); - } - } - safe_free(wpath); - - hr = pfod->lpVtbl->Show(pfod, hMainDialog); - if (SUCCEEDED(hr)) { - hr = pfod->lpVtbl->GetResult(pfod, &psi); - if (SUCCEEDED(hr)) { - psi->lpVtbl->GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath); - tmp_path = wchar_to_utf8(wpath); - CoTaskMemFree(wpath); - if (tmp_path == NULL) { - uprintf("Could not convert path\n"); - } else { - static_strcpy(szFolderPath, tmp_path); - safe_free(tmp_path); - } - } else { - uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr); - } - } else if ((hr & 0xFFFF) != ERROR_CANCELLED) { - // If it's not a user cancel, assume the dialog didn't show and fallback - uprintf("Could not show FileOpenDialog: error %X\n", hr); - goto fallback; - } - pfod->lpVtbl->Release(pfod); - dialog_showing--; - return; - } -fallback: - if (pfod != NULL) { - pfod->lpVtbl->Release(pfod); } } - INIT_XP_SHELL32; + hr = SHCreateItemFromParsingName(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path); + if (SUCCEEDED(hr)) { + if (wpath != NULL) { + pfod->lpVtbl->SetFolder(pfod, si_path); + } + if (fname != NULL) { + pfod->lpVtbl->SetFileName(pfod, fname); + } + } + safe_free(wpath); + + hr = pfod->lpVtbl->Show(pfod, hMainDialog); + if (SUCCEEDED(hr)) { + hr = pfod->lpVtbl->GetResult(pfod, &psi); + if (SUCCEEDED(hr)) { + psi->lpVtbl->GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath); + tmp_path = wchar_to_utf8(wpath); + CoTaskMemFree(wpath); + if (tmp_path == NULL) { + uprintf("Could not convert path\n"); + } else { + static_strcpy(szFolderPath, tmp_path); + safe_free(tmp_path); + } + } else { + uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr); + } + } else if ((hr & 0xFFFF) != ERROR_CANCELLED) { + // If it's not a user cancel, assume the dialog didn't show and fallback + uprintf("Could not show FileOpenDialog: error %X\n", hr); + goto fallback; + } + pfod->lpVtbl->Release(pfod); + dialog_showing--; + return; +fallback: + if (pfod != NULL) { + pfod->lpVtbl->Release(pfod); + } + memset(&bi, 0, sizeof(BROWSEINFOW)); bi.hwndOwner = hMainDialog; bi.lpszTitle = utf8_to_wchar(lmprintf(MSG_106)); @@ -241,11 +222,10 @@ fallback: /* * Return the UTF8 path of a file selected through a load or save dialog - * Will use the newer IFileOpenDialog if *compiled* for Vista or later * All string parameters are UTF-8 - * IMPORTANT NOTE: On Vista and later, remember that you need to call - * CoInitializeEx() for *EACH* thread you invoke FileDialog from, as - * GetDisplayName() will return error 0x8001010E otherwise. + * IMPORTANT NOTE: Remember that you need to call CoInitializeEx() for + * *EACH* thread you invoke FileDialog from, as GetDisplayName() will + * return error 0x8001010E otherwise. */ char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options) { @@ -267,86 +247,84 @@ char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options) return NULL; dialog_showing++; - if (nWindowsVersion >= WINDOWS_VISTA) { - INIT_VISTA_SHELL32; - filter_spec = (COMDLG_FILTERSPEC*)calloc(ext->count + 1, sizeof(COMDLG_FILTERSPEC)); - if ((IS_VISTA_SHELL32_AVAILABLE) && (filter_spec != NULL)) { - // Setup the file extension filter table - for (i = 0; i < ext->count; i++) { - filter_spec[i].pszSpec = utf8_to_wchar(ext->extension[i]); - filter_spec[i].pszName = utf8_to_wchar(ext->description[i]); - } - filter_spec[i].pszSpec = L"*.*"; - filter_spec[i].pszName = utf8_to_wchar(lmprintf(MSG_107)); + filter_spec = (COMDLG_FILTERSPEC*)calloc(ext->count + 1, sizeof(COMDLG_FILTERSPEC)); + if (filter_spec != NULL) { + // Setup the file extension filter table + for (i = 0; i < ext->count; i++) { + filter_spec[i].pszSpec = utf8_to_wchar(ext->extension[i]); + filter_spec[i].pszName = utf8_to_wchar(ext->description[i]); + } + filter_spec[i].pszSpec = L"*.*"; + filter_spec[i].pszName = utf8_to_wchar(lmprintf(MSG_107)); - hr = CoCreateInstance(save ? &CLSID_FileSaveDialog : &CLSID_FileOpenDialog, NULL, CLSCTX_INPROC, - &IID_IFileDialog, (LPVOID)&pfd); + hr = CoCreateInstance(save ? &CLSID_FileSaveDialog : &CLSID_FileOpenDialog, NULL, CLSCTX_INPROC, + &IID_IFileDialog, (LPVOID)&pfd); - if (FAILED(hr)) { - SetLastError(hr); - uprintf("CoCreateInstance for FileOpenDialog failed: %s\n", WindowsErrorString()); - pfd = NULL; // Just in case - goto fallback; - } + if (FAILED(hr)) { + SetLastError(hr); + uprintf("CoCreateInstance for FileOpenDialog failed: %s\n", WindowsErrorString()); + pfd = NULL; // Just in case + goto fallback; + } - // Set the file extension filters - pfd->lpVtbl->SetFileTypes(pfd, (UINT)ext->count + 1, filter_spec); + // Set the file extension filters + pfd->lpVtbl->SetFileTypes(pfd, (UINT)ext->count + 1, filter_spec); - // Set the default directory - wpath = utf8_to_wchar(path); - hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path); - if (SUCCEEDED(hr)) { - pfd->lpVtbl->SetFolder(pfd, si_path); - } - safe_free(wpath); + // Set the default directory + wpath = utf8_to_wchar(path); + hr = SHCreateItemFromParsingName(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path); + if (SUCCEEDED(hr)) { + pfd->lpVtbl->SetFolder(pfd, si_path); + } + safe_free(wpath); - // Set the default filename - wfilename = utf8_to_wchar((ext->filename == NULL) ? "" : ext->filename); - if (wfilename != NULL) { - pfd->lpVtbl->SetFileName(pfd, wfilename); - } + // Set the default filename + wfilename = utf8_to_wchar((ext->filename == NULL) ? "" : ext->filename); + if (wfilename != NULL) { + pfd->lpVtbl->SetFileName(pfd, wfilename); + } - // Display the dialog - hr = pfd->lpVtbl->Show(pfd, hMainDialog); + // Display the dialog + hr = pfd->lpVtbl->Show(pfd, hMainDialog); - // Cleanup - safe_free(wfilename); - for (i = 0; i < ext->count; i++) { - safe_free(filter_spec[i].pszSpec); - safe_free(filter_spec[i].pszName); - } + // Cleanup + safe_free(wfilename); + for (i = 0; i < ext->count; i++) { + safe_free(filter_spec[i].pszSpec); safe_free(filter_spec[i].pszName); - safe_free(filter_spec); - - if (SUCCEEDED(hr)) { - // Obtain the result of the user's interaction with the dialog. - hr = pfd->lpVtbl->GetResult(pfd, &psiResult); - if (SUCCEEDED(hr)) { - hr = psiResult->lpVtbl->GetDisplayName(psiResult, SIGDN_FILESYSPATH, &wpath); - if (SUCCEEDED(hr)) { - filepath = wchar_to_utf8(wpath); - CoTaskMemFree(wpath); - } else { - SetLastError(hr); - uprintf("Unable to access file path: %s\n", WindowsErrorString()); - } - psiResult->lpVtbl->Release(psiResult); - } - } else if ((hr & 0xFFFF) != ERROR_CANCELLED) { - // If it's not a user cancel, assume the dialog didn't show and fallback - SetLastError(hr); - uprintf("Could not show FileOpenDialog: %s\n", WindowsErrorString()); - goto fallback; - } - pfd->lpVtbl->Release(pfd); - dialog_showing--; - return filepath; } - fallback: + safe_free(filter_spec[i].pszName); safe_free(filter_spec); - if (pfd != NULL) { - pfd->lpVtbl->Release(pfd); + + if (SUCCEEDED(hr)) { + // Obtain the result of the user's interaction with the dialog. + hr = pfd->lpVtbl->GetResult(pfd, &psiResult); + if (SUCCEEDED(hr)) { + hr = psiResult->lpVtbl->GetDisplayName(psiResult, SIGDN_FILESYSPATH, &wpath); + if (SUCCEEDED(hr)) { + filepath = wchar_to_utf8(wpath); + CoTaskMemFree(wpath); + } else { + SetLastError(hr); + uprintf("Unable to access file path: %s\n", WindowsErrorString()); + } + psiResult->lpVtbl->Release(psiResult); + } + } else if ((hr & 0xFFFF) != ERROR_CANCELLED) { + // If it's not a user cancel, assume the dialog didn't show and fallback + SetLastError(hr); + uprintf("Could not show FileOpenDialog: %s\n", WindowsErrorString()); + goto fallback; } + pfd->lpVtbl->Release(pfd); + dialog_showing--; + return filepath; + } + +fallback: + safe_free(filter_spec); + if (pfd != NULL) { + pfd->lpVtbl->Release(pfd); } memset(&ofn, 0, sizeof(ofn)); @@ -433,7 +411,7 @@ void CreateStatusBar(void) // Set the font we'll use to display the '#' sign in the toolbar button hFont = CreateFontA(-MulDiv(10, GetDeviceCaps(GetDC(hMainDialog), LOGPIXELSY), 72), 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, DEFAULT_CHARSET, - 0, 0, PROOF_QUALITY, 0, (nWindowsVersion >= WINDOWS_VISTA)?"Segoe UI":"Arial Unicode MS"); + 0, 0, PROOF_QUALITY, 0, "Segoe UI"); // Find the width of our hash sign hDC = GetDC(hMainDialog); @@ -458,10 +436,6 @@ void CreateStatusBar(void) // Compute the dimensions for the hash button x = edge[0]; - if (nWindowsVersion <= WINDOWS_XP) { - x -= 1; - height -= 2; - } y = rect.bottom - height + 1; width = edge[1] - edge[0] - 1; // How I wish there was a way to figure out how to make Windows controls look good @@ -721,23 +695,21 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP switch (message) { case WM_INITDIALOG: - if (nWindowsVersion >= WINDOWS_VISTA) { // of course, this stuff doesn't work on XP! - // Get the system message box font. See http://stackoverflow.com/a/6057761 - ncm.cbSize = sizeof(ncm); - // If we're compiling with the Vista SDK or later, the NONCLIENTMETRICS struct - // will be the wrong size for previous versions, so we need to adjust it. - #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) - ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth); - #endif - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); - hDlgFont = CreateFontIndirect(&(ncm.lfMessageFont)); - // Set the dialog to use the system message box font - SendMessage(hDlg, WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); - SendMessage(GetDlgItem(hDlg, IDC_NOTIFICATION_TEXT), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); - SendMessage(GetDlgItem(hDlg, IDC_MORE_INFO), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); - SendMessage(GetDlgItem(hDlg, IDYES), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); - SendMessage(GetDlgItem(hDlg, IDNO), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); - } + // Get the system message box font. See http://stackoverflow.com/a/6057761 + ncm.cbSize = sizeof(ncm); + // If we're compiling with the Vista SDK or later, the NONCLIENTMETRICS struct + // will be the wrong size for previous versions, so we need to adjust it. + #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth); + #endif + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); + hDlgFont = CreateFontIndirect(&(ncm.lfMessageFont)); + // Set the dialog to use the system message box font + SendMessage(hDlg, WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); + SendMessage(GetDlgItem(hDlg, IDC_NOTIFICATION_TEXT), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); + SendMessage(GetDlgItem(hDlg, IDC_MORE_INFO), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); + SendMessage(GetDlgItem(hDlg, IDYES), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); + SendMessage(GetDlgItem(hDlg, IDNO), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); apply_localization(IDD_NOTIFICATION, hDlg); background_brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); @@ -878,11 +850,9 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA // If we're compiling with the Vista SDK or later, the NONCLIENTMETRICS struct // will be the wrong size for previous versions, so we need to adjust it. #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) - if (nWindowsVersion >= WINDOWS_VISTA) { - // In versions of Windows prior to Vista, the iPaddedBorderWidth member - // is not present, so we need to subtract its size from cbSize. - ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth); - } + // In versions of Windows prior to Vista, the iPaddedBorderWidth member + // is not present, so we need to subtract its size from cbSize. + ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth); #endif SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); hDlgFont = CreateFontIndirect(&(ncm.lfMessageFont)); @@ -1020,11 +990,9 @@ INT_PTR CALLBACK ListCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa // If we're compiling with the Vista SDK or later, the NONCLIENTMETRICS struct // will be the wrong size for previous versions, so we need to adjust it. #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) - if (nWindowsVersion >= WINDOWS_VISTA) { - // In versions of Windows prior to Vista, the iPaddedBorderWidth member - // is not present, so we need to subtract its size from cbSize. - ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth); - } + // In versions of Windows prior to Vista, the iPaddedBorderWidth member + // is not present, so we need to subtract its size from cbSize. + ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth); #endif SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); hDlgFont = CreateFontIndirect(&(ncm.lfMessageFont)); @@ -1290,97 +1258,15 @@ LONG GetEntryWidth(HWND hDropDown, const char *entry) /* * Windows 7 taskbar icon handling (progress bar overlay, etc) - * Some platforms don't have these, so we redefine */ -typedef enum MY_STPFLAG -{ - MY_STPF_NONE = 0, - MY_STPF_USEAPPTHUMBNAILALWAYS = 0x1, - MY_STPF_USEAPPTHUMBNAILWHENACTIVE = 0x2, - MY_STPF_USEAPPPEEKALWAYS = 0x4, - MY_STPF_USEAPPPEEKWHENACTIVE = 0x8 -} MY_STPFLAG; - -typedef enum MY_THUMBBUTTONMASK -{ - MY_THB_BITMAP = 0x1, - MY_THB_ICON = 0x2, - MY_THB_TOOLTIP = 0x4, - MY_THB_FLAGS = 0x8 -} MY_THUMBBUTTONMASK; - -typedef enum MY_THUMBBUTTONFLAGS -{ - MY_THBF_ENABLED = 0, - MY_THBF_DISABLED = 0x1, - MY_THBF_DISMISSONCLICK = 0x2, - MY_THBF_NOBACKGROUND = 0x4, - MY_THBF_HIDDEN = 0x8, - MY_THBF_NONINTERACTIVE = 0x10 -} MY_THUMBBUTTONFLAGS; - -typedef struct MY_THUMBBUTTON -{ - MY_THUMBBUTTONMASK dwMask; - UINT iId; - UINT iBitmap; - HICON hIcon; - WCHAR szTip[260]; - MY_THUMBBUTTONFLAGS dwFlags; -} MY_THUMBBUTTON; - -/* -typedef enum MY_TBPFLAG -{ - TASKBAR_NOPROGRESS = 0, - TASKBAR_INDETERMINATE = 0x1, - TASKBAR_NORMAL = 0x2, - TASKBAR_ERROR = 0x4, - TASKBAR_PAUSED = 0x8 -} MY_TBPFLAG; -*/ - -#pragma push_macro("INTERFACE") -#undef INTERFACE -#define INTERFACE my_ITaskbarList3 -DECLARE_INTERFACE_(my_ITaskbarList3, IUnknown) { - STDMETHOD (QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD (HrInit) (THIS) PURE; - STDMETHOD (AddTab) (THIS_ HWND hwnd) PURE; - STDMETHOD (DeleteTab) (THIS_ HWND hwnd) PURE; - STDMETHOD (ActivateTab) (THIS_ HWND hwnd) PURE; - STDMETHOD (SetActiveAlt) (THIS_ HWND hwnd) PURE; - STDMETHOD (MarkFullscreenWindow) (THIS_ HWND hwnd, int fFullscreen) PURE; - STDMETHOD (SetProgressValue) (THIS_ HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) PURE; - STDMETHOD (SetProgressState) (THIS_ HWND hwnd, TASKBAR_PROGRESS_FLAGS tbpFlags) PURE; - STDMETHOD (RegisterTab) (THIS_ HWND hwndTab,HWND hwndMDI) PURE; - STDMETHOD (UnregisterTab) (THIS_ HWND hwndTab) PURE; - STDMETHOD (SetTabOrder) (THIS_ HWND hwndTab, HWND hwndInsertBefore) PURE; - STDMETHOD (SetTabActive) (THIS_ HWND hwndTab, HWND hwndMDI, DWORD dwReserved) PURE; - STDMETHOD (ThumbBarAddButtons) (THIS_ HWND hwnd, UINT cButtons, MY_THUMBBUTTON* pButton) PURE; - STDMETHOD (ThumbBarUpdateButtons) (THIS_ HWND hwnd, UINT cButtons, MY_THUMBBUTTON* pButton) PURE; - STDMETHOD (ThumbBarSetImageList) (THIS_ HWND hwnd, HIMAGELIST himl) PURE; - STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE; - STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE; - STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE; -}; -const IID my_IID_ITaskbarList3 = - { 0xea1afb91, 0x9e28, 0x4b86, { 0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf } }; -const IID my_CLSID_TaskbarList = - { 0x56fdf344, 0xfd6d, 0x11d0, { 0x95, 0x8a ,0x0, 0x60, 0x97, 0xc9, 0xa0 ,0x90 } }; - -static my_ITaskbarList3* ptbl = NULL; +static ITaskbarList3* ptbl = NULL; // Create a taskbar icon progressbar BOOL CreateTaskbarList(void) { HRESULT hr; - if (nWindowsVersion < WINDOWS_7) - // Only valid for Windows 7 or later - return FALSE; - hr = CoCreateInstance(&my_CLSID_TaskbarList, NULL, CLSCTX_ALL, &my_IID_ITaskbarList3, (LPVOID)&ptbl); + + hr = CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_ALL, &IID_ITaskbarList3, (LPVOID)&ptbl); if (FAILED(hr)) { uprintf("CoCreateInstance for TaskbarList failed: error %X\n", hr); ptbl = NULL; @@ -1402,8 +1288,6 @@ BOOL SetTaskbarProgressValue(ULONGLONG ullCompleted, ULONGLONG ullTotal) return FALSE; return !FAILED(ptbl->lpVtbl->SetProgressValue(ptbl, hMainDialog, ullCompleted, ullTotal)); } -#pragma pop_macro("INTERFACE") - /* * Update policy and settings dialog callback @@ -1523,7 +1407,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l BOOL SetUpdateCheck(void) { BOOL enable_updates; - uint64_t commcheck = _GetTickCount64(); + uint64_t commcheck = GetTickCount64(); notification_info more_info = { IDD_UPDATE_POLICY, UpdateCallback }; char filename[MAX_PATH] = "", exename[] = APPLICATION_NAME ".exe"; size_t fn_len, exe_len; @@ -1837,7 +1721,7 @@ LPCDLGTEMPLATE GetDialogTemplate(int Dialog_ID) } // All our dialogs are set to use 'Segoe UI Symbol' by default: - // 1. So that we can replace the font name with 'MS Shell Dlg' (XP) or 'Segoe UI' + // 1. So that we can replace the font name with 'Segoe UI' // 2. So that Thai displays properly on RTF controls as it won't work with regular // 'Segoe UI'... but Cyrillic won't work with 'Segoe UI Symbol' @@ -1865,12 +1749,8 @@ LPCDLGTEMPLATE GetDialogTemplate(int Dialog_ID) // We can't simply zero the characters we don't want, as the size of the font // string determines the next item lookup. So we must memmove the remaining of // our buffer. Oh, and those items are DWORD aligned. - if ((nWindowsVersion > WINDOWS_XP) && IsFontAvailable("Segoe UI")) { - // 'Segoe UI Symbol' -> 'Segoe UI' - wBuf[8] = 0; - } else { - wcscpy(wBuf, L"MS Shell Dlg"); - } + // 'Segoe UI Symbol' -> 'Segoe UI' + wBuf[8] = 0; len = wcslen(wBuf); wBuf[len + 1] = 0; dst = (uintptr_t)&wBuf[len + 2]; diff --git a/src/vhd.c b/src/vhd.c index 31042602..8a81a9f3 100644 --- a/src/vhd.c +++ b/src/vhd.c @@ -590,12 +590,12 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV wim_nb_files++; } else { wim_proc_files++; - if (_GetTickCount64() > LastRefresh + 100) { + if (GetTickCount64() > LastRefresh + 100) { // At the end of an actual apply, the WIM API re-lists a bunch of directories it // already processed, so we end up with more entries than counted - ignore those. if (wim_proc_files > wim_nb_files) wim_proc_files = wim_nb_files; - LastRefresh = _GetTickCount64(); + LastRefresh = GetTickCount64(); // x^3 progress, so as not to give a better idea right from the onset // as to the dismal speed with which the WIM API can actually apply files... apply_percent = 4.636942595f * ((float)wim_proc_files) / ((float)wim_nb_files);