2011-11-13 20:53:23 +00:00
|
|
|
|
/*
|
2011-12-05 11:36:02 +00:00
|
|
|
|
* Rufus: The Reliable USB Formatting Utility
|
2015-01-01 23:39:28 +00:00
|
|
|
|
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
|
2011-11-13 20:53:23 +00:00
|
|
|
|
*
|
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2011-12-01 17:20:52 +00:00
|
|
|
|
#include <windows.h>
|
2011-12-11 23:38:16 +00:00
|
|
|
|
#include <winioctl.h> // for DISK_GEOMETRY
|
2013-10-15 21:58:27 +00:00
|
|
|
|
#include <malloc.h>
|
2015-01-28 23:22:11 +00:00
|
|
|
|
#include <inttypes.h>
|
2011-11-13 20:53:23 +00:00
|
|
|
|
|
2013-01-09 21:54:28 +00:00
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
// Disable some VS2012 Code Analysis warnings
|
2014-11-13 01:01:27 +00:00
|
|
|
|
#pragma warning(disable: 4996) // Ignore deprecated (eg. GetVersionEx()), as we have to contend with XP
|
2013-01-09 21:54:28 +00:00
|
|
|
|
#pragma warning(disable: 28159) // VS2012 wants us to use GetTickCount64(), but it's not available on XP
|
2015-01-23 02:26:41 +00:00
|
|
|
|
#pragma warning(disable: 6258) // I know what I'm using TerminateThread for
|
2013-01-09 21:54:28 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2011-12-11 23:38:16 +00:00
|
|
|
|
/* Program options */
|
2012-02-07 16:17:14 +00:00
|
|
|
|
#define RUFUS_DEBUG // print debug info to Debug facility
|
2012-02-01 14:26:36 +00:00
|
|
|
|
/* Features not ready for prime time and that may *DESTROY* your data - USE AT YOUR OWN RISKS! */
|
2013-10-15 21:58:27 +00:00
|
|
|
|
// #define RUFUS_TEST
|
2015-02-12 19:00:06 +00:00
|
|
|
|
/* Languages for which translators are M.I.A. and that we could use help with */
|
2015-02-12 19:22:51 +00:00
|
|
|
|
#define LOST_TRANSLATORS { "ar-SA", "da-DK", "id-ID", "pt-PT" } // NB: locales MUST be <= 5 chars
|
2015-02-03 23:42:27 +00:00
|
|
|
|
/* Probability of getting the M.I.A. translator message. For more on this, see LostTranslatorCheck() */
|
|
|
|
|
#define LOST_TRANSLATOR_PROBABILITY 1000
|
2012-02-01 14:26:36 +00:00
|
|
|
|
|
2012-11-22 01:52:33 +00:00
|
|
|
|
#define APPLICATION_NAME "Rufus"
|
|
|
|
|
#define COMPANY_NAME "Akeo Consulting"
|
2011-11-24 02:24:50 +00:00
|
|
|
|
#define STR_NO_LABEL "NO_LABEL"
|
2014-01-24 02:46:06 +00:00
|
|
|
|
#define LEFT_TO_RIGHT_MARK "" // Yes, there is a character between the quotes!
|
2015-01-12 00:34:09 +00:00
|
|
|
|
#define RIGHT_TO_LEFT_MARK "" // Yes, there is a character between the quotes!
|
2013-07-05 21:20:46 +00:00
|
|
|
|
#define DRIVE_ACCESS_TIMEOUT 15000 // How long we should retry drive access (in ms)
|
|
|
|
|
#define DRIVE_ACCESS_RETRIES 60 // How many times we should retry
|
2013-02-10 21:54:47 +00:00
|
|
|
|
#define DRIVE_INDEX_MIN 0x00000080
|
|
|
|
|
#define DRIVE_INDEX_MAX 0x000000C0
|
2015-01-20 21:50:24 +00:00
|
|
|
|
#define MIN_EXTRA_PART_SIZE (1024*1024) // Minimum size of the extra partition, in bytes
|
2013-02-10 21:54:47 +00:00
|
|
|
|
#define MAX_DRIVES (DRIVE_INDEX_MAX - DRIVE_INDEX_MIN)
|
2013-10-15 21:58:27 +00:00
|
|
|
|
#define MAX_TOOLTIPS 128
|
|
|
|
|
#define MAX_SIZE_SUFFIXES 6 // bytes, KB, MB, GB, TB, PB
|
|
|
|
|
#define MAX_CLUSTER_SIZES 18
|
2011-12-09 01:39:13 +00:00
|
|
|
|
#define MAX_PROGRESS (0xFFFF-1) // leave room for 1 more for insta-progress workaround
|
2012-05-30 23:32:25 +00:00
|
|
|
|
#define MAX_LOG_SIZE 0x7FFFFFFE
|
2013-01-18 01:39:24 +00:00
|
|
|
|
#define MAX_GUID_STRING_LENGTH 40
|
|
|
|
|
#define MAX_GPT_PARTITIONS 128
|
|
|
|
|
#define MAX_SECTORS_TO_CLEAR 128 // nb sectors to zap when clearing the MBR/GPT (must be >34)
|
2013-01-27 20:56:57 +00:00
|
|
|
|
#define MBR_UEFI_MARKER 0x49464555 // 'U', 'E', 'F', 'I', as a 32 bit little endian longword
|
2014-02-09 23:38:16 +00:00
|
|
|
|
#define WRITE_RETRIES 3
|
2011-11-24 23:49:42 +00:00
|
|
|
|
#define FS_DEFAULT FS_FAT32
|
2014-10-28 19:16:35 +00:00
|
|
|
|
#define SINGLE_CLUSTERSIZE_DEFAULT 0x00000100
|
2013-10-15 21:58:27 +00:00
|
|
|
|
#define BADBLOCK_PATTERNS {0xaa, 0x55, 0xff, 0x00}
|
2012-11-03 17:40:33 +00:00
|
|
|
|
#define LARGE_FAT32_SIZE (32*1073741824LL) // Size at which we need to use fat32format
|
2013-10-31 22:59:53 +00:00
|
|
|
|
#define UDF_FORMAT_SPEED 3.1f // Speed estimate at which we expect UDF drives to be formatted (GB/s)
|
|
|
|
|
#define UDF_FORMAT_WARN 20 // Duration (in seconds) above which we warn about long UDF formatting times
|
2013-09-22 02:28:56 +00:00
|
|
|
|
#define MAX_FAT32_SIZE 2.0f // Threshold above which we disable FAT32 formatting (in TB)
|
2014-04-13 14:20:20 +00:00
|
|
|
|
#define FAT32_CLUSTER_THRESHOLD 1.011f // For FAT32, cluster size changes don't occur at power of 2 boundaries but sligthly above
|
2014-12-03 21:28:24 +00:00
|
|
|
|
#define DD_BUFFER_SIZE 65536 // Minimum size of the buffer we use for DD operations
|
2011-11-21 17:06:17 +00:00
|
|
|
|
#define WHITE RGB(255,255,255)
|
|
|
|
|
#define SEPARATOR_GREY RGB(223,223,223)
|
2011-12-09 22:47:44 +00:00
|
|
|
|
#define RUFUS_URL "http://rufus.akeo.ie"
|
2014-01-21 17:08:41 +00:00
|
|
|
|
#define DOWNLOAD_URL RUFUS_URL "/downloads"
|
|
|
|
|
#define FILES_URL RUFUS_URL "/files"
|
2013-01-20 22:46:11 +00:00
|
|
|
|
#define SEVENZIP_URL "http://sourceforge.net/projects/sevenzip/files/7-Zip/"
|
2014-01-21 17:08:41 +00:00
|
|
|
|
#define FILES_DIR "rufus_files"
|
2011-11-17 01:43:06 +00:00
|
|
|
|
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
|
2011-11-18 21:46:34 +00:00
|
|
|
|
#ifndef ARRAYSIZE
|
|
|
|
|
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
|
|
|
|
#endif
|
2011-11-27 23:40:28 +00:00
|
|
|
|
#define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED)
|
2014-01-24 02:46:06 +00:00
|
|
|
|
#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING:0)
|
2014-11-12 02:38:13 +00:00
|
|
|
|
#define IDD_OFFSET ((right_to_left_mode?100:0) + ((nWindowsVersion <= WINDOWS_XP)?50:0))
|
2011-11-13 20:53:23 +00:00
|
|
|
|
|
|
|
|
|
#define safe_free(p) do {free((void*)p); p = NULL;} while(0)
|
|
|
|
|
#define safe_min(a, b) min((size_t)(a), (size_t)(b))
|
|
|
|
|
#define safe_strcp(dst, dst_max, src, count) do {memcpy(dst, src, safe_min(count, dst_max)); \
|
|
|
|
|
((char*)dst)[safe_min(count, dst_max)-1] = 0;} while(0)
|
|
|
|
|
#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
|
|
|
|
|
#define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1))
|
|
|
|
|
#define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1)
|
|
|
|
|
#define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
|
2014-03-29 13:55:30 +00:00
|
|
|
|
#define safe_strstr(str1, str2) strstr(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
|
|
|
|
|
#define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
|
2012-03-16 18:30:44 +00:00
|
|
|
|
#define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
|
2013-06-25 17:39:07 +00:00
|
|
|
|
#define safe_closehandle(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
|
|
|
|
#define safe_unlockclose(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
2013-01-09 21:54:28 +00:00
|
|
|
|
#define safe_sprintf(dst, count, ...) do {_snprintf(dst, count, __VA_ARGS__); (dst)[(count)-1] = 0; } while(0)
|
2014-01-21 17:08:41 +00:00
|
|
|
|
#define static_sprintf(dst, ...) safe_sprintf(dst, sizeof(dst), __VA_ARGS__)
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#define safe_strlen(str) ((((char*)str)==NULL)?0:strlen(str))
|
|
|
|
|
#define safe_strdup _strdup
|
2011-11-17 01:43:06 +00:00
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
#define safe_vsnprintf(buf, size, format, arg) _vsnprintf_s(buf, size, _TRUNCATE, format, arg)
|
|
|
|
|
#else
|
|
|
|
|
#define safe_vsnprintf vsnprintf
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-21 17:06:17 +00:00
|
|
|
|
#ifdef RUFUS_DEBUG
|
|
|
|
|
extern void _uprintf(const char *format, ...);
|
|
|
|
|
#define uprintf(...) _uprintf(__VA_ARGS__)
|
2012-11-22 01:52:33 +00:00
|
|
|
|
#define vuprintf(...) if (verbose) _uprintf(__VA_ARGS__)
|
|
|
|
|
#define vvuprintf(...) if (verbose > 1) _uprintf(__VA_ARGS__)
|
2014-08-07 00:45:46 +00:00
|
|
|
|
#define suprintf(...) if (!bSilent) _uprintf(__VA_ARGS__)
|
2014-06-03 21:16:40 +00:00
|
|
|
|
#ifdef _DEBUG
|
2013-01-27 20:56:57 +00:00
|
|
|
|
#define duprintf(...) _uprintf(__VA_ARGS__)
|
|
|
|
|
#else
|
|
|
|
|
#define duprintf(...)
|
|
|
|
|
#endif
|
2011-11-21 17:06:17 +00:00
|
|
|
|
#else
|
|
|
|
|
#define uprintf(...)
|
2013-01-27 20:56:57 +00:00
|
|
|
|
#define vuprintf(...)
|
|
|
|
|
#define vvuprintf(...)
|
|
|
|
|
#define duprintf(...)
|
2014-08-07 00:45:46 +00:00
|
|
|
|
#define suprintf(...)
|
2011-11-18 01:58:08 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-26 00:25:04 +00:00
|
|
|
|
/* Custom Windows messages */
|
|
|
|
|
enum user_message_type {
|
2012-02-01 14:26:36 +00:00
|
|
|
|
UM_FORMAT_COMPLETED = WM_APP,
|
2013-12-20 18:32:10 +00:00
|
|
|
|
UM_MEDIA_CHANGE,
|
2014-05-19 22:25:00 +00:00
|
|
|
|
UM_PROGRESS_INIT,
|
|
|
|
|
UM_PROGRESS_EXIT,
|
2015-03-09 02:49:11 +00:00
|
|
|
|
UM_NO_UPDATE,
|
2013-10-24 21:57:34 +00:00
|
|
|
|
// Start of the WM IDs for the language menu items
|
|
|
|
|
UM_LANGUAGE_MENU = WM_APP + 0x100
|
2011-11-26 00:25:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-11-21 17:06:17 +00:00
|
|
|
|
/* Custom notifications */
|
2011-12-08 00:22:13 +00:00
|
|
|
|
enum notification_type {
|
2011-11-21 17:06:17 +00:00
|
|
|
|
MSG_INFO,
|
|
|
|
|
MSG_WARNING,
|
2012-11-29 23:14:36 +00:00
|
|
|
|
MSG_ERROR,
|
|
|
|
|
MSG_QUESTION,
|
2011-11-21 17:06:17 +00:00
|
|
|
|
};
|
2012-11-29 23:14:36 +00:00
|
|
|
|
typedef INT_PTR (CALLBACK *Callback_t)(HWND, UINT, WPARAM, LPARAM);
|
2012-12-02 03:50:08 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
WORD id;
|
|
|
|
|
Callback_t callback;
|
|
|
|
|
} notification_info; // To provide a "More info..." on notifications
|
2011-11-21 17:06:17 +00:00
|
|
|
|
|
2011-12-08 00:22:13 +00:00
|
|
|
|
/* Timers used throughout the program */
|
2011-12-09 01:39:13 +00:00
|
|
|
|
enum timer_type {
|
2015-01-08 00:22:56 +00:00
|
|
|
|
TID_MESSAGE_INFO = 0x1000,
|
|
|
|
|
TID_MESSAGE_STATUS,
|
2011-12-09 01:39:13 +00:00
|
|
|
|
TID_BADBLOCKS_UPDATE,
|
2012-02-07 16:17:14 +00:00
|
|
|
|
TID_APP_TIMER,
|
2013-02-10 21:54:47 +00:00
|
|
|
|
TID_BLOCKING_TIMER,
|
|
|
|
|
TID_REFRESH_TIMER
|
2011-12-09 01:39:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Action type, for progress bar breakdown */
|
|
|
|
|
enum action_type {
|
2013-04-07 23:10:58 +00:00
|
|
|
|
OP_ANALYZE_MBR,
|
2011-12-09 01:39:13 +00:00
|
|
|
|
OP_BADBLOCKS,
|
|
|
|
|
OP_ZERO_MBR,
|
|
|
|
|
OP_PARTITION,
|
2011-12-09 12:57:32 +00:00
|
|
|
|
OP_FORMAT,
|
|
|
|
|
OP_CREATE_FS,
|
2011-12-09 01:39:13 +00:00
|
|
|
|
OP_FIX_MBR,
|
|
|
|
|
OP_DOS,
|
2012-03-29 19:27:53 +00:00
|
|
|
|
OP_FINALIZE,
|
2011-12-09 01:39:13 +00:00
|
|
|
|
OP_MAX
|
2011-12-08 00:22:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-11-24 23:49:42 +00:00
|
|
|
|
/* File system indexes in our FS combobox */
|
2011-12-01 15:01:10 +00:00
|
|
|
|
enum {
|
|
|
|
|
FS_UNKNOWN = -1,
|
2011-11-24 23:49:42 +00:00
|
|
|
|
FS_FAT16 = 0,
|
|
|
|
|
FS_FAT32,
|
|
|
|
|
FS_NTFS,
|
2013-07-08 23:14:29 +00:00
|
|
|
|
FS_UDF,
|
2011-12-01 02:56:44 +00:00
|
|
|
|
FS_EXFAT,
|
2014-03-29 00:22:54 +00:00
|
|
|
|
FS_REFS,
|
2011-11-24 23:49:42 +00:00
|
|
|
|
FS_MAX
|
|
|
|
|
};
|
|
|
|
|
|
2011-12-15 00:46:47 +00:00
|
|
|
|
enum dos_type {
|
2012-01-12 02:52:40 +00:00
|
|
|
|
DT_WINME = 0,
|
|
|
|
|
DT_FREEDOS,
|
2012-03-03 23:12:48 +00:00
|
|
|
|
DT_ISO,
|
2014-02-09 02:54:07 +00:00
|
|
|
|
DT_IMG,
|
2014-01-05 01:39:41 +00:00
|
|
|
|
DT_SYSLINUX_V4, // Start of indexes that only display in advanced mode
|
2014-11-12 02:38:13 +00:00
|
|
|
|
DT_SYSLINUX_V6,
|
2014-01-05 01:39:41 +00:00
|
|
|
|
DT_REACTOS,
|
2014-11-14 23:40:00 +00:00
|
|
|
|
DT_GRUB4DOS,
|
|
|
|
|
DT_GRUB2,
|
2011-12-15 00:46:47 +00:00
|
|
|
|
DT_MAX
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-20 22:46:11 +00:00
|
|
|
|
enum bios_type {
|
|
|
|
|
BT_BIOS = 0,
|
|
|
|
|
BT_UEFI,
|
|
|
|
|
BT_MAX
|
2013-01-18 01:39:24 +00:00
|
|
|
|
};
|
2013-01-20 22:46:11 +00:00
|
|
|
|
// For the partition types we'll use Microsoft's PARTITION_STYLE_### constants
|
2013-12-22 20:48:57 +00:00
|
|
|
|
#define GETBIOSTYPE(x) (((x)>0)?(((x) >> 16) & 0xFFFF):0)
|
|
|
|
|
#define GETPARTTYPE(x) (((x)>0)?((x) & 0xFFFF):0);
|
2013-01-18 01:39:24 +00:00
|
|
|
|
|
2011-12-01 17:20:52 +00:00
|
|
|
|
/* Current drive info */
|
2011-11-20 22:49:55 +00:00
|
|
|
|
typedef struct {
|
2011-12-01 17:20:52 +00:00
|
|
|
|
DWORD DeviceNumber;
|
|
|
|
|
LONGLONG DiskSize;
|
|
|
|
|
DISK_GEOMETRY Geometry;
|
|
|
|
|
DWORD FirstSector;
|
2012-02-21 19:46:28 +00:00
|
|
|
|
char proposed_label[16];
|
2013-01-18 01:39:24 +00:00
|
|
|
|
int PartitionType;
|
2015-01-20 21:50:24 +00:00
|
|
|
|
int nPartitions; // number of partitions we actually care about
|
2011-12-01 17:20:52 +00:00
|
|
|
|
int FSType;
|
2013-01-20 22:46:11 +00:00
|
|
|
|
BOOL has_protective_mbr;
|
2013-01-27 20:56:57 +00:00
|
|
|
|
BOOL has_mbr_uefi_marker;
|
2011-12-01 17:20:52 +00:00
|
|
|
|
struct {
|
|
|
|
|
ULONG Allowed;
|
|
|
|
|
ULONG Default;
|
|
|
|
|
} ClusterSize[FS_MAX];
|
|
|
|
|
} RUFUS_DRIVE_INFO;
|
2011-11-26 00:25:04 +00:00
|
|
|
|
|
2012-12-15 03:27:14 +00:00
|
|
|
|
/* Special handling for old .c32 files we need to replace */
|
|
|
|
|
#define NB_OLD_C32 2
|
2014-01-21 17:08:41 +00:00
|
|
|
|
#define OLD_C32_NAMES { "menu.c32", "vesamenu.c32" }
|
|
|
|
|
#define OLD_C32_THRESHOLD { 53500, 148000 }
|
2012-12-15 03:27:14 +00:00
|
|
|
|
|
2012-02-01 14:26:36 +00:00
|
|
|
|
/* ISO details that the application may want */
|
2015-02-26 23:47:20 +00:00
|
|
|
|
#define WINPE_MININT 0x2A
|
|
|
|
|
#define WINPE_I386 0x15
|
|
|
|
|
#define HAS_SYSLINUX(r) (r.sl_version != 0)
|
|
|
|
|
#define HAS_INSTALL_WIM(r) (r.install_wim_path[0] != 0)
|
|
|
|
|
#define HAS_TOGO(r) (r.has_bootmgr && r.has_efi && HAS_INSTALL_WIM(r))
|
|
|
|
|
#define IS_WINPE(r) (((r & WINPE_MININT) == WINPE_MININT)||(( r & WINPE_I386) == WINPE_I386))
|
|
|
|
|
#define IS_WIN7_EFI(r) (r.has_efi & 1)
|
|
|
|
|
#define IS_REACTOS(r) (r.reactos_path[0] != 0)
|
|
|
|
|
#define IS_GRUB(r) ((r.has_grub2) || (r.has_grub4dos))
|
|
|
|
|
#define IS_FAT(fs) ((fs == FS_FAT16) || (fs == FS_FAT32))
|
2012-12-15 03:27:14 +00:00
|
|
|
|
|
2012-02-01 14:26:36 +00:00
|
|
|
|
typedef struct {
|
2015-02-26 23:47:20 +00:00
|
|
|
|
char label[192]; /* 3*64 to account for UTF-8 */
|
|
|
|
|
char usb_label[192]; /* converted USB label for workaround */
|
|
|
|
|
char cfg_path[128]; /* path to the ISO's isolinux.cfg */
|
|
|
|
|
char reactos_path[128]; /* path to the ISO's freeldr.sys or setupldr.sys */
|
|
|
|
|
char install_wim_path[64]; /* path to install.wim or install.swm */
|
2012-02-01 14:26:36 +00:00
|
|
|
|
uint64_t projected_size;
|
2014-12-29 20:34:41 +00:00
|
|
|
|
uint64_t src_size;
|
2012-03-16 18:30:44 +00:00
|
|
|
|
uint8_t winpe;
|
2015-01-13 02:11:57 +00:00
|
|
|
|
uint8_t has_efi;
|
2012-02-01 14:26:36 +00:00
|
|
|
|
BOOL has_4GB_file;
|
2013-10-13 23:02:32 +00:00
|
|
|
|
BOOL has_long_filename;
|
2014-02-13 21:25:34 +00:00
|
|
|
|
BOOL has_symlinks;
|
2012-02-07 02:05:58 +00:00
|
|
|
|
BOOL has_bootmgr;
|
2012-02-21 19:46:28 +00:00
|
|
|
|
BOOL has_autorun;
|
2012-12-15 03:27:14 +00:00
|
|
|
|
BOOL has_old_c32[NB_OLD_C32];
|
2012-03-11 01:55:25 +00:00
|
|
|
|
BOOL has_old_vesamenu;
|
2014-10-29 02:00:46 +00:00
|
|
|
|
BOOL has_efi_syslinux;
|
2014-11-14 23:40:00 +00:00
|
|
|
|
BOOL has_grub4dos;
|
2014-11-17 23:41:46 +00:00
|
|
|
|
BOOL has_grub2;
|
2014-05-15 20:17:12 +00:00
|
|
|
|
BOOL has_kolibrios;
|
2012-03-27 19:31:15 +00:00
|
|
|
|
BOOL uses_minint;
|
2014-02-09 02:54:07 +00:00
|
|
|
|
BOOL is_bootable_img;
|
2014-12-29 20:34:41 +00:00
|
|
|
|
BOOL compression_type;
|
2014-05-22 00:52:25 +00:00
|
|
|
|
BOOL is_vhd;
|
2014-01-21 17:08:41 +00:00
|
|
|
|
uint16_t sl_version; // Syslinux/Isolinux version
|
|
|
|
|
char sl_version_str[12];
|
2014-08-05 23:57:32 +00:00
|
|
|
|
char sl_version_ext[32];
|
2014-12-30 19:46:13 +00:00
|
|
|
|
char grub2_version[32];
|
2012-02-01 14:26:36 +00:00
|
|
|
|
} RUFUS_ISO_REPORT;
|
|
|
|
|
|
2014-01-21 17:08:41 +00:00
|
|
|
|
/* Isolate the Syslinux version numbers */
|
|
|
|
|
#define SL_MAJOR(x) ((uint8_t)((x)>>8))
|
|
|
|
|
#define SL_MINOR(x) ((uint8_t)(x))
|
|
|
|
|
|
2012-12-05 01:53:10 +00:00
|
|
|
|
typedef struct {
|
2015-02-08 22:36:57 +00:00
|
|
|
|
uint16_t version[3];
|
2012-12-07 00:54:40 +00:00
|
|
|
|
uint32_t platform_min[2]; // minimum platform version required
|
2012-12-05 01:53:10 +00:00
|
|
|
|
char* download_url;
|
|
|
|
|
char* release_notes;
|
|
|
|
|
} RUFUS_UPDATE;
|
|
|
|
|
|
2014-05-22 21:46:36 +00:00
|
|
|
|
/*
|
|
|
|
|
* Structure and macros used for the extensions specification of FileDialog()
|
|
|
|
|
* You can use:
|
|
|
|
|
* EXT_DECL(my_extensions, "default.std", __VA_GROUP__("*.std", "*.other"), __VA_GROUP__("Standard type", "Other Type"));
|
|
|
|
|
* to define an 'ext_t my_extensions' variable initialized with the relevant attributes.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct ext_t {
|
|
|
|
|
const size_t count;
|
|
|
|
|
const char* filename;
|
|
|
|
|
const char** extension;
|
|
|
|
|
const char** description;
|
|
|
|
|
} ext_t;
|
|
|
|
|
|
|
|
|
|
#ifndef __VA_GROUP__
|
|
|
|
|
#define __VA_GROUP__(...) __VA_ARGS__
|
|
|
|
|
#endif
|
|
|
|
|
#define EXT_X(prefix, ...) const char* _##prefix##_x[] = { __VA_ARGS__ }
|
|
|
|
|
#define EXT_D(prefix, ...) const char* _##prefix##_d[] = { __VA_ARGS__ }
|
|
|
|
|
#define EXT_DECL(var, filename, extensions, descriptions) \
|
|
|
|
|
EXT_X(var, extensions); \
|
|
|
|
|
EXT_D(var, descriptions); \
|
|
|
|
|
ext_t var = { ARRAYSIZE(_##var##_x), filename, _##var##_x, _##var##_d }
|
|
|
|
|
|
2012-03-29 17:16:06 +00:00
|
|
|
|
/* Duplication of the TBPFLAG enum for Windows 7 taskbar progress */
|
|
|
|
|
typedef enum TASKBAR_PROGRESS_FLAGS
|
|
|
|
|
{
|
|
|
|
|
TASKBAR_NOPROGRESS = 0,
|
|
|
|
|
TASKBAR_INDETERMINATE = 0x1,
|
|
|
|
|
TASKBAR_NORMAL = 0x2,
|
|
|
|
|
TASKBAR_ERROR = 0x4,
|
|
|
|
|
TASKBAR_PAUSED = 0x8
|
|
|
|
|
} TASKBAR_PROGRESS_FLAGS;
|
|
|
|
|
|
2012-05-16 22:38:39 +00:00
|
|
|
|
/* Windows versions */
|
|
|
|
|
enum WindowsVersion {
|
2013-11-05 02:16:49 +00:00
|
|
|
|
WINDOWS_UNDEFINED = -1,
|
|
|
|
|
WINDOWS_UNSUPPORTED = 0,
|
|
|
|
|
WINDOWS_XP = 0x51,
|
|
|
|
|
WINDOWS_2003 = 0x52, // Also XP x64
|
|
|
|
|
WINDOWS_VISTA = 0x60,
|
|
|
|
|
WINDOWS_7 = 0x61,
|
|
|
|
|
WINDOWS_8 = 0x62,
|
2014-11-08 00:23:50 +00:00
|
|
|
|
WINDOWS_8_1 = 0x63,
|
2015-02-08 00:38:21 +00:00
|
|
|
|
WINDOWS_10_PREVIEW1 = 0x64,
|
|
|
|
|
WINDOWS_10 = 0xA0,
|
2013-06-25 21:50:22 +00:00
|
|
|
|
WINDOWS_MAX
|
2012-05-16 22:38:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
2014-05-22 00:52:25 +00:00
|
|
|
|
|
2011-11-26 00:25:04 +00:00
|
|
|
|
/*
|
2011-12-01 17:20:52 +00:00
|
|
|
|
* Globals
|
|
|
|
|
*/
|
|
|
|
|
extern HINSTANCE hMainInstance;
|
2012-05-30 23:32:25 +00:00
|
|
|
|
extern HWND hMainDialog, hLogDlg, hStatus, hDeviceList, hCapacity;
|
2013-01-24 21:30:11 +00:00
|
|
|
|
extern HWND hPartitionScheme, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog;
|
2015-01-01 23:39:28 +00:00
|
|
|
|
extern HWND hInfo, hProgress, hDiskID;
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern float fScale;
|
2012-12-04 01:47:45 +00:00
|
|
|
|
extern char szFolderPath[MAX_PATH], app_dir[MAX_PATH];
|
2014-05-22 00:52:25 +00:00
|
|
|
|
extern char* image_path;
|
2014-08-05 23:57:32 +00:00
|
|
|
|
extern DWORD FormatStatus, DownloadStatus;
|
|
|
|
|
extern BOOL PromptOnError;
|
2014-01-21 17:08:41 +00:00
|
|
|
|
extern DWORD syslinux_ldlinux_len[2];
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern RUFUS_DRIVE_INFO SelectedDrive;
|
2011-12-09 01:39:13 +00:00
|
|
|
|
extern const int nb_steps[FS_MAX];
|
2014-01-24 02:46:06 +00:00
|
|
|
|
extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, iso_op_in_progress, format_op_in_progress, right_to_left_mode;
|
2015-01-22 22:31:34 +00:00
|
|
|
|
extern BOOL allow_dual_uefi_bios, togo_mode;
|
2012-02-01 14:26:36 +00:00
|
|
|
|
extern RUFUS_ISO_REPORT iso_report;
|
2012-02-07 16:17:14 +00:00
|
|
|
|
extern int64_t iso_blocking_status;
|
2015-02-08 22:36:57 +00:00
|
|
|
|
extern uint16_t rufus_version[3], embedded_sl_version[2];
|
2013-11-05 02:16:49 +00:00
|
|
|
|
extern int nWindowsVersion;
|
|
|
|
|
extern char WindowsVersionStr[128];
|
2014-01-21 17:08:41 +00:00
|
|
|
|
extern char embedded_sl_version_str[2][12];
|
2012-12-05 01:53:10 +00:00
|
|
|
|
extern RUFUS_UPDATE update;
|
2012-12-07 00:54:40 +00:00
|
|
|
|
extern int dialog_showing;
|
2011-12-01 17:20:52 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Shared prototypes
|
2011-11-26 00:25:04 +00:00
|
|
|
|
*/
|
2013-11-05 02:16:49 +00:00
|
|
|
|
extern void GetWindowsVersion(void);
|
2013-11-23 00:46:06 +00:00
|
|
|
|
extern BOOL is_x64(void);
|
2014-11-08 00:23:50 +00:00
|
|
|
|
//extern const char* PrintWindowsVersion(enum WindowsVersion version);
|
2011-12-04 19:47:27 +00:00
|
|
|
|
extern const char *WindowsErrorString(void);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern void DumpBufferHex(void *buf, size_t size);
|
2015-01-01 23:39:28 +00:00
|
|
|
|
extern void PrintStatusInfo(BOOL info, BOOL debug, unsigned int duration, int msg_id, ...);
|
|
|
|
|
#define PrintStatus(...) PrintStatusInfo(FALSE, FALSE, __VA_ARGS__)
|
|
|
|
|
#define PrintStatusDebug(...) PrintStatusInfo(FALSE, TRUE, __VA_ARGS__)
|
|
|
|
|
#define PrintInfo(...) PrintStatusInfo(TRUE, FALSE, __VA_ARGS__)
|
|
|
|
|
#define PrintInfoDebug(...) PrintStatusInfo(TRUE, TRUE, __VA_ARGS__)
|
2011-12-09 01:39:13 +00:00
|
|
|
|
extern void UpdateProgress(int op, float percent);
|
2013-12-19 23:56:40 +00:00
|
|
|
|
extern const char* StrError(DWORD error_code, BOOL use_default_locale);
|
2013-01-18 01:39:24 +00:00
|
|
|
|
extern char* GuidToString(const GUID* guid);
|
2015-01-28 23:22:11 +00:00
|
|
|
|
extern char* SizeToHumanReadable(uint64_t size, BOOL copy_to_log, BOOL fake_units);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern void CenterDialog(HWND hDlg);
|
2013-10-15 21:58:27 +00:00
|
|
|
|
extern void ResizeMoveCtrl(HWND hDlg, HWND hCtrl, int dx, int dy, int dw, int dh);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern void CreateStatusBar(void);
|
2012-12-05 01:53:10 +00:00
|
|
|
|
extern void SetTitleBarIcon(HWND hDlg);
|
2012-03-29 17:16:06 +00:00
|
|
|
|
extern BOOL CreateTaskbarList(void);
|
|
|
|
|
extern BOOL SetTaskbarProgressState(TASKBAR_PROGRESS_FLAGS tbpFlags);
|
|
|
|
|
extern BOOL SetTaskbarProgressValue(ULONGLONG ullCompleted, ULONGLONG ullTotal);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern INT_PTR CreateAboutBox(void);
|
2012-05-21 10:11:42 +00:00
|
|
|
|
extern BOOL CreateTooltip(HWND hControl, const char* message, int duration);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern void DestroyTooltip(HWND hWnd);
|
|
|
|
|
extern void DestroyAllTooltips(void);
|
2012-12-02 03:50:08 +00:00
|
|
|
|
extern BOOL Notification(int type, const notification_info* more_info, char* title, char* format, ...);
|
2012-11-29 02:59:52 +00:00
|
|
|
|
extern BOOL Question(char* title, char* format, ...);
|
2014-11-28 22:42:22 +00:00
|
|
|
|
extern SIZE GetTextSize(HWND hCtrl);
|
2012-01-12 02:52:40 +00:00
|
|
|
|
extern BOOL ExtractDOS(const char* path);
|
2012-02-01 14:26:36 +00:00
|
|
|
|
extern BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan);
|
2014-05-15 20:17:12 +00:00
|
|
|
|
extern int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_file, DWORD attributes);
|
2015-01-14 00:51:41 +00:00
|
|
|
|
extern char* MountISO(const char* path);
|
|
|
|
|
extern void UnMountISO(void);
|
2014-11-11 19:53:39 +00:00
|
|
|
|
extern BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs);
|
2014-08-05 23:57:32 +00:00
|
|
|
|
extern uint16_t GetSyslinuxVersion(char* buf, size_t buf_size, char** ext);
|
2012-02-01 14:26:36 +00:00
|
|
|
|
extern BOOL CreateProgress(void);
|
2012-02-21 19:46:28 +00:00
|
|
|
|
extern BOOL SetAutorun(const char* path);
|
2014-05-22 00:52:25 +00:00
|
|
|
|
extern char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options);
|
2012-05-30 23:32:25 +00:00
|
|
|
|
extern BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size);
|
2013-01-25 01:38:10 +00:00
|
|
|
|
extern unsigned char* GetResource(HMODULE module, char* name, char* type, const char* desc, DWORD* len, BOOL duplicate);
|
2014-12-20 00:22:00 +00:00
|
|
|
|
extern DWORD GetResourceSize(HMODULE module, char* name, char* type, const char* desc);
|
2015-01-16 01:51:24 +00:00
|
|
|
|
extern DWORD RunCommand(const char* cmdline, const char* dir, BOOL log);
|
2015-01-20 21:50:24 +00:00
|
|
|
|
extern BOOL CompareGUID(const GUID *guid1, const GUID *guid2);
|
2014-05-17 23:37:01 +00:00
|
|
|
|
extern BOOL GetUSBDevices(DWORD devnum);
|
2013-01-24 21:30:11 +00:00
|
|
|
|
extern BOOL SetLGP(BOOL bRestore, BOOL* bExistingKey, const char* szPath, const char* szPolicy, DWORD dwValue);
|
2012-03-11 01:55:25 +00:00
|
|
|
|
extern LONG GetEntryWidth(HWND hDropDown, const char* entry);
|
2014-01-21 17:08:41 +00:00
|
|
|
|
extern DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog);
|
2012-12-06 01:40:44 +00:00
|
|
|
|
extern HANDLE DownloadFileThreaded(const char* url, const char* file, HWND hProgressDialog);
|
2012-11-29 23:14:36 +00:00
|
|
|
|
extern INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
2012-12-02 03:50:08 +00:00
|
|
|
|
extern BOOL SetUpdateCheck(void);
|
2012-12-06 01:40:44 +00:00
|
|
|
|
extern BOOL CheckForUpdates(BOOL force);
|
2012-12-05 01:53:10 +00:00
|
|
|
|
extern void DownloadNewVersion(void);
|
2012-05-31 12:05:12 +00:00
|
|
|
|
extern BOOL IsShown(HWND hDlg);
|
2012-11-12 01:53:34 +00:00
|
|
|
|
extern char* get_token_data_file(const char* token, const char* filename);
|
2015-01-25 00:56:38 +00:00
|
|
|
|
extern char* set_token_data_file(const char* token, const char* data, const char* filename);
|
2012-11-12 01:53:34 +00:00
|
|
|
|
extern char* get_token_data_buffer(const char* token, unsigned int n, const char* buffer, size_t buffer_size);
|
2012-03-27 19:31:15 +00:00
|
|
|
|
extern char* insert_section_data(const char* filename, const char* section, const char* data, BOOL dos2unix);
|
|
|
|
|
extern char* replace_in_token_data(const char* filename, const char* token, const char* src, const char* rep, BOOL dos2unix);
|
2014-11-07 23:57:17 +00:00
|
|
|
|
extern char* replace_char(const char* src, const char c, const char* rep);
|
2012-11-22 01:52:33 +00:00
|
|
|
|
extern void parse_update(char* buf, size_t len);
|
2015-01-15 01:45:10 +00:00
|
|
|
|
extern uint8_t WimExtractCheck(void);
|
2013-01-20 22:46:11 +00:00
|
|
|
|
extern BOOL WimExtractFile(const char* wim_image, int index, const char* src, const char* dst);
|
2015-01-15 01:45:10 +00:00
|
|
|
|
extern BOOL WimApplyImage(const char* image, int index, const char* dst);
|
2014-05-22 00:52:25 +00:00
|
|
|
|
extern BOOL IsHDImage(const char* path);
|
2014-05-27 01:02:50 +00:00
|
|
|
|
extern BOOL AppendVHDFooter(const char* vhd_path);
|
2013-11-17 01:39:43 +00:00
|
|
|
|
extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid);
|
2015-02-03 23:42:27 +00:00
|
|
|
|
extern void LostTranslatorCheck(void);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
|
2014-05-23 00:03:01 +00:00
|
|
|
|
DWORD WINAPI FormatThread(void* param);
|
|
|
|
|
DWORD WINAPI SaveImageThread(void* param);
|
|
|
|
|
|
2014-05-22 21:46:36 +00:00
|
|
|
|
static __inline BOOL UnlockDrive(HANDLE hDrive) {
|
2011-12-01 17:20:52 +00:00
|
|
|
|
DWORD size;
|
|
|
|
|
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL);
|
2011-11-26 00:25:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-22 21:46:36 +00:00
|
|
|
|
static __inline void *_reallocf(void *ptr, size_t size) {
|
2013-10-15 21:58:27 +00:00
|
|
|
|
void *ret = realloc(ptr, size);
|
|
|
|
|
if (!ret)
|
|
|
|
|
free(ptr);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-17 23:37:01 +00:00
|
|
|
|
/* Hash tables */
|
|
|
|
|
typedef struct htab_entry {
|
|
|
|
|
uint32_t used;
|
|
|
|
|
char* str;
|
|
|
|
|
void* data;
|
|
|
|
|
} htab_entry;
|
|
|
|
|
typedef struct htab_table {
|
|
|
|
|
htab_entry *table;
|
|
|
|
|
uint32_t size;
|
|
|
|
|
uint32_t filled;
|
|
|
|
|
} htab_table;
|
|
|
|
|
#define HTAB_EMPTY {NULL, 0, 0}
|
|
|
|
|
extern BOOL htab_create(uint32_t nel, htab_table* htab);
|
|
|
|
|
extern void htab_destroy(htab_table* htab);
|
|
|
|
|
extern uint32_t htab_hash(char* str, htab_table* htab);
|
|
|
|
|
|
2011-12-01 17:20:52 +00:00
|
|
|
|
/* Basic String Array */
|
|
|
|
|
typedef struct {
|
2014-05-17 23:37:01 +00:00
|
|
|
|
char** String;
|
|
|
|
|
uint32_t Index; // Current array size
|
|
|
|
|
uint32_t Max; // Maximum array size
|
2011-12-01 17:20:52 +00:00
|
|
|
|
} StrArray;
|
2014-05-17 23:37:01 +00:00
|
|
|
|
extern void StrArrayCreate(StrArray* arr, uint32_t initial_size);
|
|
|
|
|
extern int32_t StrArrayAdd(StrArray* arr, const char* str);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern void StrArrayClear(StrArray* arr);
|
|
|
|
|
extern void StrArrayDestroy(StrArray* arr);
|
2014-01-21 17:08:41 +00:00
|
|
|
|
#define IsStrArrayEmpty(arr) (arr.Index == 0)
|
2011-12-01 17:20:52 +00:00
|
|
|
|
|
2012-03-11 01:55:25 +00:00
|
|
|
|
/*
|
|
|
|
|
* typedefs for the function prototypes. Use the something like:
|
|
|
|
|
* PF_DECL(FormatEx);
|
|
|
|
|
* which translates to:
|
|
|
|
|
* FormatEx_t pfFormatEx = NULL;
|
|
|
|
|
* in your code, to declare the entrypoint and then use:
|
2014-05-12 21:44:10 +00:00
|
|
|
|
* PF_INIT(FormatEx, Fmifs);
|
2012-03-11 01:55:25 +00:00
|
|
|
|
* which translates to:
|
|
|
|
|
* pfFormatEx = (FormatEx_t) GetProcAddress(GetDLLHandle("fmifs"), "FormatEx");
|
|
|
|
|
* to make it accessible.
|
|
|
|
|
*/
|
2014-05-12 21:44:10 +00:00
|
|
|
|
#define MAX_LIBRARY_HANDLES 32
|
|
|
|
|
extern HMODULE OpenedLibrariesHandle[MAX_LIBRARY_HANDLES];
|
|
|
|
|
extern uint16_t OpenedLibrariesHandleSize;
|
|
|
|
|
#define OPENED_LIBRARIES_VARS HMODULE OpenedLibrariesHandle[MAX_LIBRARY_HANDLES]; uint16_t OpenedLibrariesHandleSize = 0
|
|
|
|
|
#define CLOSE_OPENED_LIBRARIES while(OpenedLibrariesHandleSize > 0) FreeLibrary(OpenedLibrariesHandle[--OpenedLibrariesHandleSize])
|
|
|
|
|
static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
|
2012-03-11 01:55:25 +00:00
|
|
|
|
HMODULE h = NULL;
|
2014-05-12 21:44:10 +00:00
|
|
|
|
if ((h = GetModuleHandleA(szLibraryName)) == NULL) {
|
|
|
|
|
if (OpenedLibrariesHandleSize >= MAX_LIBRARY_HANDLES) {
|
2014-05-09 21:05:25 +00:00
|
|
|
|
uprintf("Error: MAX_LIBRARY_HANDLES is too small\n");
|
|
|
|
|
} else {
|
2014-05-12 21:44:10 +00:00
|
|
|
|
h = LoadLibraryA(szLibraryName);
|
2014-05-09 21:05:25 +00:00
|
|
|
|
if (h != NULL)
|
2014-05-12 21:44:10 +00:00
|
|
|
|
OpenedLibrariesHandle[OpenedLibrariesHandleSize++] = h;
|
2014-05-09 21:05:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-11 01:55:25 +00:00
|
|
|
|
return h;
|
|
|
|
|
}
|
2014-05-12 21:44:10 +00:00
|
|
|
|
#define PF_TYPE(api, ret, proc, args) typedef ret (api *proc##_t)args
|
|
|
|
|
#define PF_DECL(proc) static proc##_t pf##proc = NULL
|
|
|
|
|
#define PF_TYPE_DECL(api, ret, proc, args) PF_TYPE(api, ret, proc, args); PF_DECL(proc)
|
|
|
|
|
#define PF_INIT(proc, name) if (pf##proc == NULL) pf##proc = \
|
|
|
|
|
(proc##_t) GetProcAddress(GetLibraryHandle(#name), #proc)
|
|
|
|
|
#define PF_INIT_OR_OUT(proc, name) do {PF_INIT(proc, name); \
|
|
|
|
|
if (pf##proc == NULL) {uprintf("Unable to locate %s() in %s.dll: %s\n", \
|
|
|
|
|
#proc, #name, WindowsErrorString()); goto out;} } while(0)
|
2012-02-01 14:26:36 +00:00
|
|
|
|
|
2011-12-01 17:54:35 +00:00
|
|
|
|
/* Clang/MinGW32 has an issue with intptr_t */
|
|
|
|
|
#ifndef _UINTPTR_T_DEFINED
|
|
|
|
|
#define _UINTPTR_T_DEFINED
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
|
typedef unsigned __int64 uintptr_t;
|
|
|
|
|
#else
|
|
|
|
|
typedef unsigned int uintptr_t;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-28 12:37:58 +00:00
|
|
|
|
/* Custom application errors */
|
|
|
|
|
#define FAC(f) (f<<16)
|
2011-12-04 19:47:27 +00:00
|
|
|
|
#define APPERR(err) (APPLICATION_ERROR_MASK|err)
|
|
|
|
|
#define ERROR_INCOMPATIBLE_FS 0x1201
|
|
|
|
|
#define ERROR_CANT_QUICK_FORMAT 0x1202
|
|
|
|
|
#define ERROR_INVALID_CLUSTER_SIZE 0x1203
|
|
|
|
|
#define ERROR_INVALID_VOLUME_SIZE 0x1204
|
|
|
|
|
#define ERROR_CANT_START_THREAD 0x1205
|
2011-12-06 23:35:55 +00:00
|
|
|
|
#define ERROR_BADBLOCKS_FAILURE 0x1206
|
2012-02-01 14:26:36 +00:00
|
|
|
|
#define ERROR_ISO_SCAN 0x1207
|
|
|
|
|
#define ERROR_ISO_EXTRACT 0x1208
|
2012-02-05 19:54:48 +00:00
|
|
|
|
#define ERROR_CANT_REMOUNT_VOLUME 0x1209
|
2013-04-07 23:10:58 +00:00
|
|
|
|
#define ERROR_CANT_PATCH 0x120A
|
|
|
|
|
#define ERROR_CANT_ASSIGN_LETTER 0x120B
|
|
|
|
|
#define ERROR_CANT_MOUNT_VOLUME 0x120C
|
2012-03-11 01:55:25 +00:00
|
|
|
|
|
|
|
|
|
/* 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)
|
2012-03-29 17:16:06 +00:00
|
|
|
|
#endif
|
2013-01-25 01:38:10 +00:00
|
|
|
|
|
2013-01-27 01:40:09 +00:00
|
|
|
|
/* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */
|
2013-01-25 01:38:10 +00:00
|
|
|
|
#define _RT_ICON MAKEINTRESOURCEA(3)
|
|
|
|
|
#define _RT_RCDATA MAKEINTRESOURCEA(10)
|
|
|
|
|
#define _RT_GROUP_ICON MAKEINTRESOURCEA((ULONG_PTR)(MAKEINTRESOURCEA(3) + 11))
|