diff --git a/src/.msvc/rufus.vcxproj b/src/.msvc/rufus.vcxproj
index 5992d19d..be5ef45f 100644
--- a/src/.msvc/rufus.vcxproj
+++ b/src/.msvc/rufus.vcxproj
@@ -209,6 +209,7 @@
+
diff --git a/src/.msvc/rufus.vcxproj.filters b/src/.msvc/rufus.vcxproj.filters
index bd16ab97..41f2ae8a 100644
--- a/src/.msvc/rufus.vcxproj.filters
+++ b/src/.msvc/rufus.vcxproj.filters
@@ -137,6 +137,9 @@
Header Files
+
+ Header Files
+
diff --git a/src/badblocks.c b/src/badblocks.c
index c5ac77f3..571625d9 100644
--- a/src/badblocks.c
+++ b/src/badblocks.c
@@ -7,7 +7,7 @@
*
* Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o
* Copyright 1999 by David Beattie
- * Copyright 2011-2015 by Pete Batard
+ * Copyright 2011-2016 by Pete Batard
*
* This file is based on the minix file system programs fsck and mkfs
* written and copyrighted by Linus Torvalds
@@ -42,11 +42,12 @@
#include
#include "rufus.h"
+#include "resource.h"
+#include "msapi_utf8.h"
+#include "localization.h"
+
#include "badblocks.h"
#include "file.h"
-#include "msapi_utf8.h"
-#include "resource.h"
-#include "localization.h"
FILE* log_fd = NULL;
static const char* abort_msg = "Too many bad blocks, aborting test\n";
@@ -257,7 +258,7 @@ static bb_badblocks_iterate bb_iter = NULL;
static __inline void *allocate_buffer(size_t size) {
#ifdef __MINGW32__
return __mingw_aligned_malloc(size, BB_SYS_PAGE_SIZE);
-#else
+#else
return _aligned_malloc(size, BB_SYS_PAGE_SIZE);
#endif
}
diff --git a/src/checksum.c b/src/checksum.c
index 7637b54b..4e429d2f 100644
--- a/src/checksum.c
+++ b/src/checksum.c
@@ -51,9 +51,10 @@
#include
#include
#include
-#include "msapi_utf8.h"
+
#include "rufus.h"
#include "resource.h"
+#include "msapi_utf8.h"
#include "localization.h"
#undef BIG_ENDIAN_HOST
diff --git a/src/dos.c b/src/dos.c
index 69cc467d..0f506dc9 100644
--- a/src/dos.c
+++ b/src/dos.c
@@ -31,9 +31,10 @@
#include
#include "rufus.h"
-#include "dos.h"
#include "resource.h"
+#include "dos.h"
+
static BYTE* DiskImage = NULL;
static DWORD DiskImageSize;
diff --git a/src/drive.c b/src/drive.c
index 65980555..894b2873 100644
--- a/src/drive.c
+++ b/src/drive.c
@@ -26,17 +26,19 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
+#include "missing.h"
+#include "resource.h"
+#include "msapi_utf8.h"
+#include "localization.h"
+
#include "file.h"
#include "drive.h"
-#include "resource.h"
#include "sys_types.h"
#include "br.h"
#include "fat16.h"
#include "fat32.h"
#include "ntfs.h"
-#include "localization.h"
#if !defined(PARTITION_BASIC_DATA_GUID)
const GUID PARTITION_BASIC_DATA_GUID =
@@ -1045,7 +1047,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// Compute the start offset of our first partition
if ((partition_style == PARTITION_STYLE_GPT) || (!IsChecked(IDC_EXTRA_PARTITION))) {
// Go with the MS 1 MB wastage at the beginning...
- DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = 1024*1024;
+ DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = MB;
} else {
// Align on Cylinder
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = bytes_per_track;
@@ -1054,7 +1056,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// If required, set the MSR partition (GPT only - must be created before the data part)
if ((partition_style == PARTITION_STYLE_GPT) && (extra_partitions & XP_MSR)) {
uprintf("Adding MSR partition");
- DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = 128*1024*1024;
+ DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = 128*MB;
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_MSFT_RESERVED_GUID;
IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId));
// coverity[strcpy_overrun]
@@ -1090,11 +1092,11 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// The size of the EFI partition depends on the minimum size we're able to format in FAT32,
// which in turn depends on the cluster size used, which in turn depends on the disk sector size.
if (SelectedDrive.Geometry.BytesPerSector <= 1024)
- ms_efi_size = 100*1024*1024;
+ ms_efi_size = 100*MB;
else if (SelectedDrive.Geometry.BytesPerSector <= 4096)
- ms_efi_size = 300*1024*1024;
+ ms_efi_size = 300*MB;
else
- ms_efi_size = 1200*1024*1024; // That'll teach you to have a nonstandard disk!
+ ms_efi_size = 1200*MB; // That'll teach you to have a nonstandard disk!
extra_part_size_in_tracks = (ms_efi_size + bytes_per_track - 1) / bytes_per_track;
} else if (extra_partitions & XP_UEFI_NTFS)
extra_part_size_in_tracks = (MIN_EXTRA_PART_SIZE + bytes_per_track - 1) / bytes_per_track;
diff --git a/src/format.c b/src/format.c
index 0c2c8487..5a488544 100644
--- a/src/format.c
+++ b/src/format.c
@@ -32,9 +32,12 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
+#include "missing.h"
#include "resource.h"
+#include "msapi_utf8.h"
+#include "localization.h"
+
#include "br.h"
#include "fat16.h"
#include "fat32.h"
@@ -44,7 +47,6 @@
#include "drive.h"
#include "format.h"
#include "badblocks.h"
-#include "localization.h"
#include "bled/bled.h"
#include "../res/grub/grub_version.h"
@@ -999,7 +1001,7 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector);
// Ensure that we have sufficient space for the SBR
max_size = IsChecked(IDC_EXTRA_PARTITION) ?
- (DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1024 * 1024;
+ (DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1*MB;
max_size -= mbr_size;
// Syslinux has precedence over Grub
if ((bt == BT_ISO) && (!HAS_SYSLINUX(img_report))) {
diff --git a/src/icon.c b/src/icon.c
index ddd66eb9..5e1985b3 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -27,9 +27,9 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
#include "resource.h"
+#include "msapi_utf8.h"
#pragma pack(push)
#pragma pack(2)
diff --git a/src/iso.c b/src/iso.c
index 41769cbb..c7e0177e 100644
--- a/src/iso.c
+++ b/src/iso.c
@@ -39,8 +39,9 @@
#include
#include "rufus.h"
-#include "msapi_utf8.h"
+#include "missing.h"
#include "resource.h"
+#include "msapi_utf8.h"
#include "localization.h"
// How often should we update the progress bar (in 2K blocks) as updating
@@ -1068,91 +1069,9 @@ out:
if (p_udf != NULL)
udf_close(p_udf);
safe_free(wim_path);
- return bswap_32(r);
+ return bswap_uint32(r);
}
-/*
- * 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;
-
// VirtDisk API Prototypes - Only available for Windows 8 or later
PF_TYPE_DECL(WINAPI, DWORD, OpenVirtualDisk, (PVIRTUAL_STORAGE_TYPE, PCWSTR,
VIRTUAL_DISK_ACCESS_MASK, OPEN_VIRTUAL_DISK_FLAG, POPEN_VIRTUAL_DISK_PARAMETERS, PHANDLE));
diff --git a/src/missing.h b/src/missing.h
new file mode 100644
index 00000000..2ecacd06
--- /dev/null
+++ b/src/missing.h
@@ -0,0 +1,214 @@
+/*
+* Rufus: The Reliable USB Formatting Utility
+* Constants and defines missing from various toolchains
+* Copyright © 2016 Pete Batard
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*/
+
+#include
+#include
+#include
+#include
+
+#pragma once
+
+/* Convenient to have around */
+#define KB 1024LL
+#define MB 1048576LL
+#define GB 1073741824LL
+#define TB 1099511627776LL
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#if defined(_MSC_VER)
+#define bswap_uint64 _byteswap_uint64
+#define bswap_uint32 _byteswap_ulong
+#define bswap_uint16 _byteswap_ushort
+#else
+#define bswap_uint64 __builtin_bswap64
+#define bswap_uint32 __builtin_bswap32
+#define bswap_uint16 __builtin_bswap16
+#endif
+
+static __inline void *_reallocf(void *ptr, size_t size) {
+ void *ret = realloc(ptr, size);
+ if (!ret)
+ free(ptr);
+ return ret;
+}
+
+/* UI redefinitions for WDK and 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
+#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
diff --git a/src/net.c b/src/net.c
index 8ef0d9c3..f6af0e61 100644
--- a/src/net.c
+++ b/src/net.c
@@ -30,12 +30,13 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
-#include "settings.h"
#include "resource.h"
+#include "msapi_utf8.h"
#include "localization.h"
+#include "settings.h"
+
/* Maximum download chunk size, in bytes */
#define DOWNLOAD_BUFFER_SIZE 10240
/* Default delay between update checks (1 day) */
@@ -49,35 +50,6 @@ static DWORD error_code;
static BOOL update_check_in_progress = FALSE;
static BOOL force_update_check = FALSE;
-/* MinGW is missing some of those */
-#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
-
/*
* FormatMessage does not handle internet errors
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa385465.aspx
diff --git a/src/parser.c b/src/parser.c
index 6568102e..8c94dc6b 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -32,6 +32,7 @@
#include
#include "rufus.h"
+#include "missing.h"
#include "msapi_utf8.h"
#include "localization.h"
diff --git a/src/pki.c b/src/pki.c
index 76e4d9dd..13ee38f7 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* PKI functions (code signing, etc.)
- * Copyright © 2015 Pete Batard
+ * Copyright © 2015-2016 Pete Batard
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,8 +29,8 @@
#include
#include "rufus.h"
-#include "msapi_utf8.h"
#include "resource.h"
+#include "msapi_utf8.h"
#include "localization.h"
#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
diff --git a/src/rufus.c b/src/rufus.c
index b58cab78..87fba22d 100644
--- a/src/rufus.c
+++ b/src/rufus.c
@@ -35,69 +35,23 @@
#include
#include
-#include "msapi_utf8.h"
-#include "resource.h"
#include "rufus.h"
+#include "missing.h"
+#include "resource.h"
+#include "msapi_utf8.h"
+#include "localization.h"
+
#include "drive.h"
#include "settings.h"
-#include "localization.h"
#include "bled/bled.h"
#include "../res/grub/grub_version.h"
#include "../res/grub2/grub2_version.h"
-/* Redefinitions for WDK and MinGW */
-// TODO: these would be better in a 'missing.h' file
-#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
-#ifndef WM_CLIENTSHUTDOWN
-#define WM_CLIENTSHUTDOWN 0x3B
-#endif
-#ifndef WM_COPYGLOBALDATA
-#define WM_COPYGLOBALDATA 0x49
-#endif
-
-struct {
- HIMAGELIST himl;
- RECT margin;
- UINT uAlign;
-} bi_iso = {0}, bi_up = {0}, bi_down = {0}; // BUTTON_IMAGELIST
-
-typedef struct
-{
- LPCITEMIDLIST pidl;
- BOOL fRecursive;
-} MY_SHChangeNotifyEntry;
-
// MinGW doesn't know these
PF_TYPE(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int));
PF_TYPE(WINAPI, int, ImageList_AddIcon, (HIMAGELIST, HICON));
PF_TYPE(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON));
+
// WDK blows up when trying to using PF_TYPE_DECL() for the ImageList calls... so we don't.
PF_DECL(ImageList_Create);
PF_DECL(ImageList_AddIcon);
@@ -139,6 +93,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 };
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH];
char* image_path = NULL;
float fScale = 1.0f;
@@ -193,11 +148,6 @@ static __inline void SetComboEntry(HWND hDlg, int data) {
}
}
-#define KB 1024LL
-#define MB 1048576LL
-#define GB 1073741824LL
-#define TB 1099511627776LL
-
/*
* Fill in the cluster size names
*/
@@ -370,10 +320,6 @@ static BOOL DefineClusterSizes(void)
return r;
}
-#undef KB
-#undef MB
-#undef GB
-#undef TB
/*
* Populate the Allocation unit size field
diff --git a/src/rufus.h b/src/rufus.h
index 6348423e..c42fbf64 100644
--- a/src/rufus.h
+++ b/src/rufus.h
@@ -469,25 +469,6 @@ static __inline BOOL UnlockDrive(HANDLE hDrive) {
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL);
}
-static __inline void *_reallocf(void *ptr, size_t size) {
- void *ret = realloc(ptr, size);
- if (!ret)
- free(ptr);
- return ret;
-}
-
-static __inline uint16_t bswap_16(uint16_t x) {
- return (x >> 8) | (x << 8);
-}
-
-static __inline uint32_t bswap_32(uint32_t x) {
- return (bswap_16(x & 0xffff) << 16) | (bswap_16(x >> 16));
-}
-
-static __inline uint64_t bswap_64(uint64_t x) {
- return (((uint64_t) bswap_32(x & 0xffffffffull)) << 32) | (bswap_32(x >> 32));
-}
-
/* Hash tables */
typedef struct htab_entry {
uint32_t used;
@@ -580,17 +561,6 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
#define ERROR_CANT_ASSIGN_LETTER 0x120B
#define ERROR_CANT_MOUNT_VOLUME 0x120C
-/* More niceties */
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-#ifndef PBS_MARQUEE
-#define PBS_MARQUEE 0x08
-#endif
-#ifndef PBM_SETMARQUEE
-#define PBM_SETMARQUEE (WM_USER+10)
-#endif
-
/* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */
#define _RT_ICON MAKEINTRESOURCEA(3)
#define _RT_DIALOG MAKEINTRESOURCEA(5)
diff --git a/src/rufus.rc b/src/rufus.rc
index 72471d9f..8530a789 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.8.860"
+CAPTION "Rufus 2.8.861"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@@ -320,8 +320,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,8,860,0
- PRODUCTVERSION 2,8,860,0
+ FILEVERSION 2,8,861,0
+ PRODUCTVERSION 2,8,861,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -338,13 +338,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
- VALUE "FileVersion", "2.8.860"
+ VALUE "FileVersion", "2.8.861"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
- VALUE "ProductVersion", "2.8.860"
+ VALUE "ProductVersion", "2.8.861"
END
END
BLOCK "VarFileInfo"
diff --git a/src/smart.c b/src/smart.c
index a6526893..a07de632 100644
--- a/src/smart.c
+++ b/src/smart.c
@@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* SMART HDD vs Flash detection (using ATA over USB, S.M.A.R.T., etc.)
- * Copyright © 2013-2014 Pete Batard
+ * Copyright © 2013-2016 Pete Batard
*
* Based in part on scsiata.cpp from Smartmontools: http://smartmontools.sourceforge.net
* Copyright © 2006-12 Douglas Gilbert
@@ -31,8 +31,10 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
+#include "missing.h"
+#include "msapi_utf8.h"
+
#include "drive.h"
#include "smart.h"
#include "hdd_vs_ufd.h"
@@ -43,7 +45,7 @@ static uint8_t GetAtaDirection(uint8_t AtaCmd, uint8_t Features) {
// Far from complete -- only the commands we *may* use.
// Most SMART commands require DATA_IN but there are a couple exceptions
- BOOL smart_out = (AtaCmd == ATA_SMART_CMD) &&
+ BOOL smart_out = (AtaCmd == ATA_SMART_CMD) &&
((Features == ATA_SMART_STATUS) || (Features == ATA_SMART_WRITE_LOG_SECTOR));
switch (AtaCmd) {
@@ -413,7 +415,7 @@ BOOL SmartGetVersion(HANDLE hdevice)
* THUS, IF DATA LOSS IS INCURRED DUE TO THIS, OR ANY OTHER PART OF THIS APPLICATION,
* NOT BEHAVING IN THE MANNER YOU EXPECTED, THE RESPONSIBILITY IS ENTIRELY ON YOU!
*
- * What you have below, then, is our *current best guess* at differentiating UFDs
+ * What you have below, then, is our *current best guess* at differentiating UFDs
* from HDDs. But short of a crystal ball, this remains just a guess, which may be
* way off mark. Still, you are also reminded that Rufus does produce PROMINENT
* warnings before you format a drive, and also provides extensive info about the
@@ -426,7 +428,7 @@ BOOL SmartGetVersion(HANDLE hdevice)
* - some UFDs (SanDisk Extreme) have added S.M.A.R.T. support, which also used to be
* reserved for HDDs => can't use that either
* - even if S.M.A.R.T. was enough, not all USB->IDE or USB->SATA bridges support ATA
- * passthrough, which is required S.M.A.R.T. data, and each manufacturer of an
+ * passthrough, which is required S.M.A.R.T. data, and each manufacturer of an
* USB<->(S)ATA bridge seem to have their own method of implementing passthrough.
* - SSDs have also changed the deal completely, as you can get something that looks
* like Flash but that is really an HDD.
@@ -436,7 +438,6 @@ BOOL SmartGetVersion(HANDLE hdevice)
* from the above) => there is no magic API we can query that will tell us what we're
* really looking at.
*/
-#define GB 1073741824LL
int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid)
{
int score = 0;
diff --git a/src/stdfn.c b/src/stdfn.c
index 99235128..b5391751 100644
--- a/src/stdfn.c
+++ b/src/stdfn.c
@@ -24,12 +24,13 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
#include "resource.h"
-#include "settings.h"
+#include "msapi_utf8.h"
#include "localization.h"
+#include "settings.h"
+
int nWindowsVersion = WINDOWS_UNDEFINED;
char WindowsVersionStr[128] = "Windows ";
diff --git a/src/stdio.c b/src/stdio.c
index af0f9e41..581861fd 100644
--- a/src/stdio.c
+++ b/src/stdio.c
@@ -29,9 +29,9 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
#include "resource.h"
+#include "msapi_utf8.h"
#include "localization.h"
/*
diff --git a/src/stdlg.c b/src/stdlg.c
index 066932db..bf606ae7 100644
--- a/src/stdlg.c
+++ b/src/stdlg.c
@@ -35,12 +35,13 @@
#include
#include "rufus.h"
+#include "resource.h"
#include "msapi_utf8.h"
+#include "localization.h"
+
#include "registry.h"
#include "settings.h"
-#include "resource.h"
#include "license.h"
-#include "localization.h"
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
PF_TYPE_DECL(WINAPI, HRESULT, SHCreateItemFromParsingName, (PCWSTR, IBindCtx*, REFIID, void **));
diff --git a/src/syslinux.c b/src/syslinux.c
index 2ee20bb6..ed979c38 100644
--- a/src/syslinux.c
+++ b/src/syslinux.c
@@ -27,10 +27,11 @@
#include
#include "rufus.h"
-#include "drive.h"
#include "resource.h"
-#include "localization.h"
#include "msapi_utf8.h"
+#include "localization.h"
+
+#include "drive.h"
#include "syslinux.h"
#include "syslxfs.h"
diff --git a/src/usb.c b/src/usb.c
index 762429d3..8abff8b3 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -33,11 +33,13 @@
#include
#include
-#include "msapi_utf8.h"
#include "rufus.h"
-#include "drive.h"
+#include "missing.h"
#include "resource.h"
+#include "msapi_utf8.h"
#include "localization.h"
+
+#include "drive.h"
#include "usb.h"
extern StrArray DriveID, DriveLabel;
@@ -537,7 +539,7 @@ BOOL GetUSBDevices(DWORD devnum)
safe_free(devint_detail_data);
break;
}
- if (GetDriveSize(drive_index) < (MIN_DRIVE_SIZE*1024*1024)) {
+ if (GetDriveSize(drive_index) < (MIN_DRIVE_SIZE*MB)) {
uprintf("Device eliminated because it is smaller than %d MB\n", MIN_DRIVE_SIZE);
safe_closehandle(hDrive);
safe_free(devint_detail_data);
diff --git a/src/vhd.c b/src/vhd.c
index 5a39aa49..ddc361c6 100644
--- a/src/vhd.c
+++ b/src/vhd.c
@@ -24,22 +24,14 @@
#include
#include "rufus.h"
+#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
+
#include "drive.h"
#include "registry.h"
#include "bled/bled.h"
-#if defined(_MSC_VER)
-#define bswap_uint64 _byteswap_uint64
-#define bswap_uint32 _byteswap_ulong
-#define bswap_uint16 _byteswap_ushort
-#else
-#define bswap_uint64 __builtin_bswap64
-#define bswap_uint32 __builtin_bswap32
-#define bswap_uint16 __builtin_bswap16
-#endif
-
#define VHD_FOOTER_COOKIE { 'c', 'o', 'n', 'e', 'c', 't', 'i', 'x' }
#define VHD_FOOTER_FEATURES_NONE 0x00000000