2011-11-13 20:53:23 +00:00
|
|
|
|
/*
|
2011-12-05 11:36:02 +00:00
|
|
|
|
* Rufus: The Reliable USB Formatting Utility
|
2021-02-08 21:02:01 +00:00
|
|
|
|
* Copyright © 2011-2021 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>
|
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)
|
2017-03-10 18:07:48 +00:00
|
|
|
|
// Disable some VS Code Analysis warnings
|
2017-11-13 14:29:48 +00:00
|
|
|
|
#pragma warning(disable: 4996) // Ignore deprecated
|
2015-01-23 02:26:41 +00:00
|
|
|
|
#pragma warning(disable: 6258) // I know what I'm using TerminateThread for
|
2019-04-25 17:58:55 +00:00
|
|
|
|
#pragma warning(disable: 26451) // Stop bugging me with casts already!
|
|
|
|
|
#pragma warning(disable: 28159) // I'll keep using GetVersionEx(), thank you very much...
|
2013-01-09 21:54:28 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-04-25 17:58:55 +00:00
|
|
|
|
/*
|
|
|
|
|
* Features not ready for prime time and that may *DESTROY* your data - USE AT YOUR OWN RISKS!
|
|
|
|
|
*/
|
2017-10-23 16:09:18 +00:00
|
|
|
|
//#define RUFUS_TEST
|
2012-02-01 14:26:36 +00:00
|
|
|
|
|
2012-11-22 01:52:33 +00:00
|
|
|
|
#define APPLICATION_NAME "Rufus"
|
2018-10-27 13:22:09 +00:00
|
|
|
|
#if defined(_M_AMD64)
|
|
|
|
|
#define APPLICATION_ARCH "x64"
|
|
|
|
|
#elif defined(_M_IX86)
|
|
|
|
|
#define APPLICATION_ARCH "x86"
|
|
|
|
|
#elif defined(_M_ARM64)
|
|
|
|
|
#define APPLICATION_ARCH "Arm64"
|
|
|
|
|
#elif defined(_M_ARM)
|
|
|
|
|
#define APPLICATION_ARCH "Arm"
|
|
|
|
|
#else
|
|
|
|
|
#define APPLICATION_ARCH "(Unknown Arch)"
|
|
|
|
|
#endif
|
2012-11-22 01:52:33 +00:00
|
|
|
|
#define COMPANY_NAME "Akeo Consulting"
|
2011-11-24 02:24:50 +00:00
|
|
|
|
#define STR_NO_LABEL "NO_LABEL"
|
2016-05-24 12:21:23 +00:00
|
|
|
|
// Yes, there exist characters between these seemingly empty quotes!
|
2015-10-18 20:31:47 +00:00
|
|
|
|
#define LEFT_TO_RIGHT_MARK ""
|
|
|
|
|
#define RIGHT_TO_LEFT_MARK ""
|
|
|
|
|
#define LEFT_TO_RIGHT_EMBEDDING ""
|
|
|
|
|
#define RIGHT_TO_LEFT_EMBEDDING ""
|
|
|
|
|
#define POP_DIRECTIONAL_FORMATTING ""
|
2018-05-17 19:45:32 +00:00
|
|
|
|
#define LEFT_TO_RIGHT_OVERRIDE ""
|
2015-10-21 23:40:24 +00:00
|
|
|
|
#define RIGHT_TO_LEFT_OVERRIDE ""
|
2013-07-05 21:20:46 +00:00
|
|
|
|
#define DRIVE_ACCESS_TIMEOUT 15000 // How long we should retry drive access (in ms)
|
2017-02-16 14:13:30 +00:00
|
|
|
|
#define DRIVE_ACCESS_RETRIES 150 // How many times we should retry
|
2013-02-10 21:54:47 +00:00
|
|
|
|
#define DRIVE_INDEX_MIN 0x00000080
|
|
|
|
|
#define DRIVE_INDEX_MAX 0x000000C0
|
2016-02-19 12:10:17 +00:00
|
|
|
|
#define MIN_DRIVE_SIZE 8 // Minimum size a drive must have, to be formattable (in MB)
|
2016-06-16 16:29:15 +00:00
|
|
|
|
#define MIN_EXTRA_PART_SIZE (1024*1024) // Minimum size of the extra partition, in bytes
|
2020-10-02 12:58:15 +00:00
|
|
|
|
#define MIN_EXT_SIZE (256*1024*1024) // Minimum size we allow for ext formatting
|
2020-07-29 18:32:32 +00:00
|
|
|
|
#define MAX_ARCHS 9 // Number of arhitectures we recognize
|
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
|
2018-04-19 11:25:11 +00:00
|
|
|
|
#define MAX_PROGRESS 0xFFFF
|
2021-10-09 15:15:21 +00:00
|
|
|
|
#define PATCH_PROGRESS_TOTAL 207
|
2012-05-30 23:32:25 +00:00
|
|
|
|
#define MAX_LOG_SIZE 0x7FFFFFFE
|
2016-03-10 16:13:16 +00:00
|
|
|
|
#define MAX_REFRESH 25 // How long we should wait to refresh UI elements (in ms)
|
2013-01-18 01:39:24 +00:00
|
|
|
|
#define MAX_GUID_STRING_LENGTH 40
|
2019-04-25 17:58:55 +00:00
|
|
|
|
#define MAX_PARTITIONS 16 // Maximum number of partitions we handle
|
2020-06-06 15:34:17 +00:00
|
|
|
|
#define MAX_ESP_TOGGLE 8 // Maximum number of entries we record to toggle GPT ESP back and forth
|
2020-06-06 21:19:20 +00:00
|
|
|
|
#define MAX_ISO_TO_ESP_SIZE 512 // Maximum size we allow for the ISO → ESP option (in MB)
|
2021-09-09 20:20:57 +00:00
|
|
|
|
#define MAX_DEFAULT_LIST_CARD_SIZE 200 // Size above which we don't list a card without enable HDD or Alt-F (in GB)
|
2013-01-18 01:39:24 +00:00
|
|
|
|
#define MAX_SECTORS_TO_CLEAR 128 // nb sectors to zap when clearing the MBR/GPT (must be >34)
|
2019-01-08 18:30:07 +00:00
|
|
|
|
#define MAX_WININST 4 // Max number of install[.wim|.esd] we can handle on an image
|
2013-01-27 20:56:57 +00:00
|
|
|
|
#define MBR_UEFI_MARKER 0x49464555 // 'U', 'E', 'F', 'I', as a 32 bit little endian longword
|
2018-11-20 12:28:20 +00:00
|
|
|
|
#define MORE_INFO_URL 0xFFFF
|
2021-06-10 16:18:40 +00:00
|
|
|
|
#define PROJECTED_SIZE_RATIO 110 // Percentage by which we inflate projected_size to prevent persistence overflow
|
2016-05-09 12:40:54 +00:00
|
|
|
|
#define STATUS_MSG_TIMEOUT 3500 // How long should cheat mode messages appear for on the status bar
|
2018-06-13 18:23:24 +00:00
|
|
|
|
#define WRITE_RETRIES 4
|
2019-01-31 13:50:03 +00:00
|
|
|
|
#define WRITE_TIMEOUT 5000 // How long we should wait between write retries (in ms)
|
2020-09-09 16:00:39 +00:00
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
|
#define SEARCH_PROCESS_TIMEOUT 60000
|
|
|
|
|
#else
|
2019-01-31 13:50:03 +00:00
|
|
|
|
#define SEARCH_PROCESS_TIMEOUT 10000 // How long we should search for conflicting processes before giving up (in ms)
|
2020-09-09 16:00:39 +00:00
|
|
|
|
#endif
|
2019-03-05 16:25:14 +00:00
|
|
|
|
#define NET_SESSION_TIMEOUT 3500 // How long we should wait to connect, send or receive internet data
|
2018-04-19 11:25:11 +00:00
|
|
|
|
#define MARQUEE_TIMER_REFRESH 10 // Time between progress bar marquee refreshes, in ms
|
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
|
2020-11-10 17:24:52 +00:00
|
|
|
|
#define BADLOCKS_PATTERN_TYPES 5
|
2018-06-28 15:25:13 +00:00
|
|
|
|
#define BADBLOCK_PATTERN_COUNT 4
|
2020-11-10 17:24:52 +00:00
|
|
|
|
#define BADBLOCK_PATTERN_ONE_PASS {0x55, 0x00, 0x00, 0x00}
|
|
|
|
|
#define BADBLOCK_PATTERN_TWO_PASSES {0x55, 0xaa, 0x00, 0x00}
|
2018-06-28 15:25:13 +00:00
|
|
|
|
#define BADBLOCK_PATTERN_SLC {0x00, 0xff, 0x55, 0xaa}
|
|
|
|
|
#define BADCLOCK_PATTERN_MLC {0x00, 0xff, 0x33, 0xcc}
|
|
|
|
|
#define BADBLOCK_PATTERN_TLC {0x00, 0xff, 0x1c71c7, 0xe38e38}
|
2021-04-22 00:01:56 +00:00
|
|
|
|
#define BADBLOCK_BLOCK_SIZE (512 * 1024)
|
2021-04-21 21:58:41 +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)
|
2021-11-01 16:00:02 +00:00
|
|
|
|
#define FAT32_CLUSTER_THRESHOLD 1.011f // For FAT32, cluster size changes don't occur at power of 2 boundaries but slightly above
|
2021-04-21 21:58:41 +00:00
|
|
|
|
#define DD_BUFFER_SIZE (32 * 1024 * 1024) // Minimum size of buffer to use for DD operations
|
2019-03-19 12:04:29 +00:00
|
|
|
|
#define UBUFFER_SIZE 4096
|
2018-06-29 17:19:05 +00:00
|
|
|
|
#define RSA_SIGNATURE_SIZE 256
|
2018-05-06 21:31:42 +00:00
|
|
|
|
#define CBN_SELCHANGE_INTERNAL (CBN_SELCHANGE + 256)
|
2018-10-22 16:42:40 +00:00
|
|
|
|
#if defined(RUFUS_TEST)
|
[net] add Windows retail ISO downloads
* This is accomplished through Fido (https://github.com/pbatard/Fido), a *SIGNED*
PowerShell script, that is downloaded from GitHub and that resides in memory for
the duration of a session.
* The reason we use a downloaded PS script, rather than an embedded on, is because:
- Microsoft have regularly been changing the deal with regards to how retail ISOs
can be downloaded, and not for the better, so we can't simply embed a static
means of downloading ISOs and expect that to work forever.
- By using an external script, we can immediately respond to whatever new means of
*ANNOYING* their legitimate users Microsoft will come up with next, as well as
make sure that, the minute a new retail version of Windows becomes available, it
also becomes available for download in Rufus.
* Note that if you are concerned about downloading a remote PS script that is being
run at the same level as an elevated application, you should understand that:
- Only scripts downloaded from GitHub, from an account that is protected with 2FA,
are allowed to run (i.e. someone would first have to steal a *physical* 2FA key
to be in a position to upload a malicious script).
- On top of this, only scripts that are signed with a separate private key (RSA +
AES-256), that is itself also protected with a strong unique password which only
a single person knows (and must manually enter each time they want to make a new
version of the script available for download), are allowed to run.
The above means that there's about as much chance for someone to manage to upload
a malicious script on the GitHub servers, that Rufus would allow to run, as there
is for someone to upload a malicious version of Rufus itself.
Still, if you are paranoid and have concerns that, even as you can validate from
its source that Rufus does not attempt to execute any remote script unless a user
actively selected and clicked the DOWNLOAD button, you can also completely disable
the remote script download feature, if you just set the update check to disabled
(which, by the way, Rufus *EXPLICITLY* asks you to choose whether you want to
enable or not, the very first time you run the application).
* Also remove _unlinkU() which duplicates what DeleteFileU() already does.
2019-03-02 23:28:56 +00:00
|
|
|
|
#define RUFUS_URL "http://nano/~rufus"
|
2018-10-22 16:42:40 +00:00
|
|
|
|
#else
|
2018-03-27 21:03:51 +00:00
|
|
|
|
#define RUFUS_URL "https://rufus.ie"
|
2018-10-22 16:42:40 +00:00
|
|
|
|
#endif
|
2018-03-27 21:03:51 +00:00
|
|
|
|
#define DOWNLOAD_URL RUFUS_URL "/downloads"
|
|
|
|
|
#define FILES_URL RUFUS_URL "/files"
|
2021-05-31 15:54:11 +00:00
|
|
|
|
#define FILES_DIR APPLICATION_NAME
|
2019-03-23 13:59:20 +00:00
|
|
|
|
#define FIDO_VERSION "z1"
|
2018-11-20 12:28:20 +00:00
|
|
|
|
#define SECURE_BOOT_MORE_INFO_URL "https://github.com/pbatard/rufus/wiki/FAQ#Why_do_I_need_to_disable_Secure_Boot_to_use_UEFINTFS"
|
2019-01-30 17:15:25 +00:00
|
|
|
|
#define WPPRECORDER_MORE_INFO_URL "https://github.com/pbatard/rufus/wiki/FAQ#BSODs_with_Windows_To_Go_drives_created_from_Windows_10_1809_ISOs"
|
2018-07-24 13:07:08 +00:00
|
|
|
|
#define SEVENZIP_URL "https://www.7-zip.org"
|
2020-06-06 15:34:17 +00:00
|
|
|
|
#define DEFAULT_ESP_MOUNT_POINT "S:\\"
|
2020-02-11 19:22:22 +00:00
|
|
|
|
#define IS_POWER_OF_2(x) ((x != 0) && (((x) & ((x) - 1)) == 0))
|
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
|
2015-06-26 21:49:32 +00:00
|
|
|
|
#ifndef STRINGIFY
|
|
|
|
|
#define STRINGIFY(x) #x
|
|
|
|
|
#endif
|
2022-01-05 11:57:26 +00:00
|
|
|
|
#define PERCENTAGE(percent, value) ((1ULL * (percent) * (value)) / 100ULL)
|
2011-11-27 23:40:28 +00:00
|
|
|
|
#define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED)
|
2015-10-18 20:31:47 +00:00
|
|
|
|
#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING|MB_RIGHT:0)
|
2019-04-25 17:58:55 +00:00
|
|
|
|
#define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus) && (SCODE_CODE(FormatStatus) == ERROR_CANCELLED)) goto out
|
2018-07-05 23:40:52 +00:00
|
|
|
|
// Bit masks used for the display of additional image options in the UI
|
|
|
|
|
#define IMOP_WINTOGO 0x01
|
|
|
|
|
#define IMOP_PERSISTENCE 0x02
|
2011-11-13 20:53:23 +00:00
|
|
|
|
|
2020-07-17 20:51:15 +00:00
|
|
|
|
#define ComboBox_GetCurItemData(hCtrl) ComboBox_GetItemData(hCtrl, ComboBox_GetCurSel(hCtrl))
|
|
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#define safe_free(p) do {free((void*)p); p = NULL;} while(0)
|
2016-06-10 11:42:43 +00:00
|
|
|
|
#define safe_mm_free(p) do {_mm_free((void*)p); p = NULL;} while(0)
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#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)); \
|
2021-11-16 17:50:20 +00:00
|
|
|
|
((char*)(dst))[safe_min(count, dst_max)-1] = 0;} while(0)
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
|
2017-08-10 18:43:04 +00:00
|
|
|
|
#define static_strcpy(dst, src) safe_strcpy(dst, sizeof(dst), src)
|
2022-01-05 11:57:26 +00:00
|
|
|
|
#define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, (dst_max) - safe_strlen(dst) - 1))
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1)
|
2017-08-10 18:43:04 +00:00
|
|
|
|
#define static_strcat(dst, src) safe_strcat(dst, sizeof(dst), src)
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#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)
|
2015-09-29 22:53:07 +00:00
|
|
|
|
#define safe_release_dc(hDlg, hDC) do {if ((hDC != INVALID_HANDLE_VALUE) && (hDC != NULL)) {ReleaseDC(hDlg, hDC); hDC = NULL;}} 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__)
|
2021-11-16 17:50:20 +00:00
|
|
|
|
#define safe_strlen(str) ((((char*)(str))==NULL)?0:strlen(str))
|
2011-11-13 20:53:23 +00:00
|
|
|
|
#define safe_strdup _strdup
|
2021-10-21 00:59:03 +00:00
|
|
|
|
#define to_windows_path(str) do { size_t __i; for (__i = 0; __i < safe_strlen(str); __i++) if (str[__i] == '/') str[__i] = '\\'; } while(0)
|
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
|
|
|
|
extern void _uprintf(const char *format, ...);
|
2019-04-16 19:44:13 +00:00
|
|
|
|
extern void _uprintfs(const char *str);
|
2011-11-21 17:06:17 +00:00
|
|
|
|
#define uprintf(...) _uprintf(__VA_ARGS__)
|
2019-04-16 19:44:13 +00:00
|
|
|
|
#define uprintfs(s) _uprintfs(s)
|
2017-07-17 15:02:47 +00:00
|
|
|
|
#define vuprintf(...) do { if (verbose) _uprintf(__VA_ARGS__); } while(0)
|
|
|
|
|
#define vvuprintf(...) do { if (verbose > 1) _uprintf(__VA_ARGS__); } while(0)
|
|
|
|
|
#define suprintf(...) do { if (!bSilent) _uprintf(__VA_ARGS__); } while(0)
|
|
|
|
|
#define uuprintf(...) do { if (usb_debug) _uprintf(__VA_ARGS__); } while(0)
|
2022-01-05 11:57:26 +00:00
|
|
|
|
#define ubprintf(...) do { safe_sprintf(&ubuffer[ubuffer_pos], UBUFFER_SIZE - ubuffer_pos - 4, __VA_ARGS__); \
|
2017-04-25 19:25:50 +00:00
|
|
|
|
ubuffer_pos = strlen(ubuffer); ubuffer[ubuffer_pos++] = '\r'; ubuffer[ubuffer_pos++] = '\n'; \
|
|
|
|
|
ubuffer[ubuffer_pos] = 0; } while(0)
|
|
|
|
|
#define ubflush() do { if (ubuffer_pos) uprintf("%s", ubuffer); ubuffer_pos = 0; } while(0)
|
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-18 01:58:08 +00:00
|
|
|
|
|
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,
|
2018-03-22 23:14:20 +00:00
|
|
|
|
UM_UPDATE_CSM_TOOLTIP,
|
|
|
|
|
UM_RESIZE_BUTTONS,
|
[net] add Windows retail ISO downloads
* This is accomplished through Fido (https://github.com/pbatard/Fido), a *SIGNED*
PowerShell script, that is downloaded from GitHub and that resides in memory for
the duration of a session.
* The reason we use a downloaded PS script, rather than an embedded on, is because:
- Microsoft have regularly been changing the deal with regards to how retail ISOs
can be downloaded, and not for the better, so we can't simply embed a static
means of downloading ISOs and expect that to work forever.
- By using an external script, we can immediately respond to whatever new means of
*ANNOYING* their legitimate users Microsoft will come up with next, as well as
make sure that, the minute a new retail version of Windows becomes available, it
also becomes available for download in Rufus.
* Note that if you are concerned about downloading a remote PS script that is being
run at the same level as an elevated application, you should understand that:
- Only scripts downloaded from GitHub, from an account that is protected with 2FA,
are allowed to run (i.e. someone would first have to steal a *physical* 2FA key
to be in a position to upload a malicious script).
- On top of this, only scripts that are signed with a separate private key (RSA +
AES-256), that is itself also protected with a strong unique password which only
a single person knows (and must manually enter each time they want to make a new
version of the script available for download), are allowed to run.
The above means that there's about as much chance for someone to manage to upload
a malicious script on the GitHub servers, that Rufus would allow to run, as there
is for someone to upload a malicious version of Rufus itself.
Still, if you are paranoid and have concerns that, even as you can validate from
its source that Rufus does not attempt to execute any remote script unless a user
actively selected and clicked the DOWNLOAD button, you can also completely disable
the remote script download feature, if you just set the update check to disabled
(which, by the way, Rufus *EXPLICITLY* asks you to choose whether you want to
enable or not, the very first time you run the application).
* Also remove _unlinkU() which duplicates what DeleteFileU() already does.
2019-03-02 23:28:56 +00:00
|
|
|
|
UM_ENABLE_CONTROLS,
|
2019-03-04 11:57:33 +00:00
|
|
|
|
UM_SELECT_ISO,
|
|
|
|
|
UM_TIMER_START,
|
2018-07-03 21:54:06 +00:00
|
|
|
|
UM_FORMAT_START,
|
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,
|
2017-07-16 21:42:19 +00:00
|
|
|
|
MSG_WARNING_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;
|
2018-11-20 12:28:20 +00:00
|
|
|
|
union {
|
|
|
|
|
Callback_t callback;
|
|
|
|
|
char* url;
|
|
|
|
|
};
|
2012-12-02 03:50:08 +00:00
|
|
|
|
} notification_info; // To provide a "More info..." on notifications
|
2011-11-21 17:06:17 +00:00
|
|
|
|
|
2015-06-30 22:22:10 +00:00
|
|
|
|
/* Status Bar sections */
|
2015-07-06 21:04:38 +00:00
|
|
|
|
#define SB_SECTION_LEFT 0
|
2018-03-22 23:14:20 +00:00
|
|
|
|
#define SB_SECTION_RIGHT 1
|
2015-07-06 21:04:38 +00:00
|
|
|
|
#define SB_TIMER_SECTION_SIZE 58.0f
|
2015-06-30 22:22:10 +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,
|
2016-02-23 11:21:36 +00:00
|
|
|
|
TID_OUTPUT_INFO,
|
|
|
|
|
TID_OUTPUT_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,
|
2018-04-19 11:25:11 +00:00
|
|
|
|
TID_REFRESH_TIMER,
|
|
|
|
|
TID_MARQUEE_TIMER
|
2011-12-09 01:39:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Action type, for progress bar breakdown */
|
|
|
|
|
enum action_type {
|
2019-08-20 17:06:07 +00:00
|
|
|
|
OP_NOOP_WITH_TASKBAR = -3,
|
|
|
|
|
OP_NOOP = -2,
|
|
|
|
|
OP_INIT = -1,
|
|
|
|
|
OP_ANALYZE_MBR = 0,
|
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,
|
2019-08-20 17:06:07 +00:00
|
|
|
|
OP_FILE_COPY,
|
2021-10-09 15:15:21 +00:00
|
|
|
|
OP_PATCH,
|
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 */
|
2015-08-22 14:18:25 +00:00
|
|
|
|
enum fs_type {
|
2011-12-01 15:01:10 +00:00
|
|
|
|
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,
|
2019-04-25 17:58:55 +00:00
|
|
|
|
FS_EXT2,
|
|
|
|
|
FS_EXT3,
|
|
|
|
|
FS_EXT4,
|
2011-11-24 23:49:42 +00:00
|
|
|
|
FS_MAX
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-01 20:26:15 +00:00
|
|
|
|
enum boot_type {
|
2018-07-18 11:22:37 +00:00
|
|
|
|
BT_NON_BOOTABLE = 0,
|
|
|
|
|
BT_MSDOS,
|
2015-07-01 20:26:15 +00:00
|
|
|
|
BT_FREEDOS,
|
2018-03-22 23:14:20 +00:00
|
|
|
|
BT_IMAGE,
|
2015-07-01 20:26:15 +00:00
|
|
|
|
BT_SYSLINUX_V4, // Start of indexes that only display in advanced mode
|
|
|
|
|
BT_SYSLINUX_V6,
|
|
|
|
|
BT_REACTOS,
|
|
|
|
|
BT_GRUB4DOS,
|
|
|
|
|
BT_GRUB2,
|
|
|
|
|
BT_UEFI_NTFS,
|
|
|
|
|
BT_MAX
|
2011-12-15 00:46:47 +00:00
|
|
|
|
};
|
|
|
|
|
|
2015-07-01 20:26:15 +00:00
|
|
|
|
enum target_type {
|
|
|
|
|
TT_BIOS = 0,
|
|
|
|
|
TT_UEFI,
|
|
|
|
|
TT_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
|
2017-08-12 14:12:00 +00:00
|
|
|
|
#define PARTITION_STYLE_SFD PARTITION_STYLE_RAW
|
2013-01-18 01:39:24 +00:00
|
|
|
|
|
2021-10-08 18:22:33 +00:00
|
|
|
|
enum image_option_type {
|
|
|
|
|
IMOP_WIN_STANDARD = 0,
|
|
|
|
|
IMOP_WIN_EXTENDED,
|
|
|
|
|
IMOP_WIN_TO_GO,
|
|
|
|
|
IMOP_MAX
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-24 12:21:23 +00:00
|
|
|
|
enum checksum_type {
|
|
|
|
|
CHECKSUM_MD5 = 0,
|
|
|
|
|
CHECKSUM_SHA1,
|
|
|
|
|
CHECKSUM_SHA256,
|
2020-06-24 13:08:24 +00:00
|
|
|
|
CHECKSUM_SHA512,
|
2016-05-24 12:21:23 +00:00
|
|
|
|
CHECKSUM_MAX
|
|
|
|
|
};
|
|
|
|
|
|
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 */
|
2018-06-22 19:59:03 +00:00
|
|
|
|
#define WINPE_I386 0x0007
|
|
|
|
|
#define WINPE_AMD64 0x0023
|
|
|
|
|
#define WINPE_MININT 0x01C0
|
2019-01-08 18:30:07 +00:00
|
|
|
|
#define SPECIAL_WIM_VERSION 0x000E0000
|
2016-12-14 23:27:04 +00:00
|
|
|
|
#define HAS_KOLIBRIOS(r) (r.has_kolibrios)
|
|
|
|
|
#define HAS_REACTOS(r) (r.reactos_path[0] != 0)
|
|
|
|
|
#define HAS_GRUB(r) ((r.has_grub2) || (r.has_grub4dos))
|
2015-02-26 23:47:20 +00:00
|
|
|
|
#define HAS_SYSLINUX(r) (r.sl_version != 0)
|
2018-09-14 13:10:40 +00:00
|
|
|
|
#define HAS_BOOTMGR_BIOS(r) (r.has_bootmgr)
|
|
|
|
|
#define HAS_BOOTMGR_EFI(r) (r.has_bootmgr_efi)
|
|
|
|
|
#define HAS_BOOTMGR(r) (HAS_BOOTMGR_BIOS(r) || HAS_BOOTMGR_EFI(r))
|
2020-07-29 18:32:32 +00:00
|
|
|
|
#define HAS_REGULAR_EFI(r) (r.has_efi & 0x7FFE)
|
2019-01-08 18:30:07 +00:00
|
|
|
|
#define HAS_WININST(r) (r.wininst_index != 0)
|
2018-06-22 19:59:03 +00:00
|
|
|
|
#define HAS_WINPE(r) (((r.winpe & WINPE_I386) == WINPE_I386)||((r.winpe & WINPE_AMD64) == WINPE_AMD64)||((r.winpe & WINPE_MININT) == WINPE_MININT))
|
2016-12-14 23:27:04 +00:00
|
|
|
|
#define HAS_WINDOWS(r) (HAS_BOOTMGR(r) || (r.uses_minint) || HAS_WINPE(r))
|
2019-01-08 18:30:07 +00:00
|
|
|
|
#define HAS_WIN7_EFI(r) ((r.has_efi == 1) && HAS_WININST(r))
|
2017-08-09 15:27:11 +00:00
|
|
|
|
#define HAS_EFI_IMG(r) (r.efi_img_path[0] != 0)
|
2022-01-07 13:25:46 +00:00
|
|
|
|
#define IS_DD_BOOTABLE(r) (r.is_bootable_img > 0)
|
|
|
|
|
#define IS_DD_ONLY(r) ((r.is_bootable_img > 0) && (!r.is_iso || r.disable_iso))
|
2017-08-09 15:27:11 +00:00
|
|
|
|
#define IS_EFI_BOOTABLE(r) (r.has_efi != 0)
|
2016-12-14 23:27:04 +00:00
|
|
|
|
#define IS_BIOS_BOOTABLE(r) (HAS_BOOTMGR(r) || HAS_SYSLINUX(r) || HAS_WINPE(r) || HAS_GRUB(r) || HAS_REACTOS(r) || HAS_KOLIBRIOS(r))
|
2019-01-08 18:30:07 +00:00
|
|
|
|
#define HAS_WINTOGO(r) (HAS_BOOTMGR(r) && IS_EFI_BOOTABLE(r) && HAS_WININST(r))
|
2019-04-16 19:44:13 +00:00
|
|
|
|
#define HAS_PERSISTENCE(r) ((HAS_SYSLINUX(r) || HAS_GRUB(r)) && !(HAS_WINDOWS(r) || HAS_REACTOS(r) || HAS_KOLIBRIOS(r)))
|
2019-04-13 14:29:27 +00:00
|
|
|
|
#define IS_FAT(fs) ((fs_type == FS_FAT16) || (fs_type == FS_FAT32))
|
2020-02-05 13:23:49 +00:00
|
|
|
|
#define SYMLINKS_RR 0x01
|
|
|
|
|
#define SYMLINKS_UDF 0x02
|
2012-12-15 03:27:14 +00:00
|
|
|
|
|
2021-10-08 10:14:29 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
uint16_t major;
|
|
|
|
|
uint16_t minor;
|
|
|
|
|
uint16_t build;
|
|
|
|
|
uint16_t revision;
|
|
|
|
|
} winver_t;
|
|
|
|
|
|
2012-02-01 14:26:36 +00:00
|
|
|
|
typedef struct {
|
2019-01-08 18:30:07 +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 wininst_path[MAX_WININST][64]; // path to the Windows install image(s)
|
|
|
|
|
char efi_img_path[128]; // path to an efi.img file
|
2017-05-01 15:22:34 +00:00
|
|
|
|
uint64_t image_size;
|
2020-06-10 20:25:33 +00:00
|
|
|
|
uint64_t archive_size;
|
2012-02-01 14:26:36 +00:00
|
|
|
|
uint64_t projected_size;
|
2017-06-24 16:23:06 +00:00
|
|
|
|
int64_t mismatch_size;
|
2019-01-08 18:30:07 +00:00
|
|
|
|
uint32_t wininst_version;
|
2015-09-02 22:20:00 +00:00
|
|
|
|
BOOLEAN is_iso;
|
2022-01-07 13:25:46 +00:00
|
|
|
|
int8_t is_bootable_img;
|
2019-08-02 16:57:10 +00:00
|
|
|
|
BOOLEAN is_vhd;
|
2020-07-19 21:35:30 +00:00
|
|
|
|
BOOLEAN is_windows_img;
|
2019-08-02 16:57:10 +00:00
|
|
|
|
BOOLEAN disable_iso;
|
2021-10-11 16:55:46 +00:00
|
|
|
|
BOOLEAN rh8_derivative;
|
2018-06-22 19:59:03 +00:00
|
|
|
|
uint16_t winpe;
|
2020-07-29 18:32:32 +00:00
|
|
|
|
uint16_t has_efi;
|
2020-04-06 15:27:05 +00:00
|
|
|
|
uint8_t has_md5sum;
|
2019-01-08 18:30:07 +00:00
|
|
|
|
uint8_t wininst_index;
|
2020-02-05 13:23:49 +00:00
|
|
|
|
uint8_t has_symlinks;
|
2015-05-24 22:06:36 +00:00
|
|
|
|
BOOLEAN has_4GB_file;
|
|
|
|
|
BOOLEAN has_long_filename;
|
2020-05-29 11:21:56 +00:00
|
|
|
|
BOOLEAN has_deep_directories;
|
2015-05-24 22:06:36 +00:00
|
|
|
|
BOOLEAN has_bootmgr;
|
2018-09-14 13:10:40 +00:00
|
|
|
|
BOOLEAN has_bootmgr_efi;
|
2015-05-24 22:06:36 +00:00
|
|
|
|
BOOLEAN has_autorun;
|
|
|
|
|
BOOLEAN has_old_c32[NB_OLD_C32];
|
|
|
|
|
BOOLEAN has_old_vesamenu;
|
|
|
|
|
BOOLEAN has_efi_syslinux;
|
|
|
|
|
BOOLEAN needs_syslinux_overwrite;
|
|
|
|
|
BOOLEAN has_grub4dos;
|
2022-04-07 00:57:24 +00:00
|
|
|
|
uint8_t has_grub2;
|
2021-10-08 10:14:29 +00:00
|
|
|
|
BOOLEAN has_compatresources_dll;
|
2015-05-24 22:06:36 +00:00
|
|
|
|
BOOLEAN has_kolibrios;
|
2019-08-02 16:57:10 +00:00
|
|
|
|
BOOLEAN uses_casper;
|
2015-05-24 22:06:36 +00:00
|
|
|
|
BOOLEAN uses_minint;
|
2022-01-05 11:57:26 +00:00
|
|
|
|
uint8_t compression_type;
|
2021-10-08 10:14:29 +00:00
|
|
|
|
winver_t win_version; // Windows ISO version
|
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];
|
2015-09-02 22:20:00 +00:00
|
|
|
|
} RUFUS_IMG_REPORT;
|
2012-02-01 14:26:36 +00:00
|
|
|
|
|
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))
|
|
|
|
|
|
2022-05-25 12:21:36 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
char* id;
|
|
|
|
|
char* name;
|
|
|
|
|
char* display_name;
|
|
|
|
|
char* label;
|
|
|
|
|
char* hub;
|
|
|
|
|
DWORD index;
|
|
|
|
|
uint32_t port;
|
|
|
|
|
uint64_t size;
|
|
|
|
|
} RUFUS_DRIVE;
|
|
|
|
|
|
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;
|
|
|
|
|
|
2016-12-06 11:47:19 +00:00
|
|
|
|
#define IMG_SAVE_TYPE_VHD 1
|
|
|
|
|
#define IMG_SAVE_TYPE_ISO 2
|
|
|
|
|
|
2015-06-07 21:51:54 +00:00
|
|
|
|
typedef struct {
|
2016-12-06 11:47:19 +00:00
|
|
|
|
DWORD Type;
|
2015-06-07 21:51:54 +00:00
|
|
|
|
DWORD DeviceNum;
|
2016-12-06 11:47:19 +00:00
|
|
|
|
DWORD BufSize;
|
|
|
|
|
LONGLONG DeviceSize;
|
|
|
|
|
char* DevicePath;
|
|
|
|
|
char* ImagePath;
|
|
|
|
|
char* Label;
|
|
|
|
|
} IMG_SAVE;
|
2015-06-07 21:51:54 +00:00
|
|
|
|
|
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__
|
2015-10-18 20:31:47 +00:00
|
|
|
|
#define __VA_GROUP__(...) __VA_ARGS__
|
2014-05-22 21:46:36 +00:00
|
|
|
|
#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,
|
2017-09-15 11:40:33 +00:00
|
|
|
|
WINDOWS_2003 = 0x52, // Also XP_64
|
2021-09-28 14:39:51 +00:00
|
|
|
|
WINDOWS_VISTA = 0x60, // Also Server 2008
|
|
|
|
|
WINDOWS_7 = 0x61, // Also Server 2008_R2
|
|
|
|
|
WINDOWS_8 = 0x62, // Also Server 2012
|
|
|
|
|
WINDOWS_8_1 = 0x63, // Also Server 2012_R2
|
2015-02-08 00:38:21 +00:00
|
|
|
|
WINDOWS_10_PREVIEW1 = 0x64,
|
2021-09-28 14:39:51 +00:00
|
|
|
|
WINDOWS_10 = 0xA0, // Also Server 2016, also Server 2019
|
|
|
|
|
WINDOWS_11 = 0xB0, // Also Server 2022
|
2013-06-25 21:50:22 +00:00
|
|
|
|
WINDOWS_MAX
|
2012-05-16 22:38:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-10-22 16:42:40 +00:00
|
|
|
|
enum CpuArch {
|
|
|
|
|
CPU_ARCH_X86_32 = 0,
|
|
|
|
|
CPU_ARCH_X86_64,
|
|
|
|
|
CPU_ARCH_ARM_32,
|
|
|
|
|
CPU_ARCH_ARM_64,
|
|
|
|
|
CPU_ARCH_UNDEFINED,
|
|
|
|
|
CPU_ARCH_MAX
|
|
|
|
|
};
|
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
|
|
|
|
|
*/
|
2018-07-05 23:40:52 +00:00
|
|
|
|
extern RUFUS_UPDATE update;
|
|
|
|
|
extern RUFUS_IMG_REPORT img_report;
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern HINSTANCE hMainInstance;
|
2020-07-17 20:51:15 +00:00
|
|
|
|
extern HWND hMainDialog, hLogDialog, hStatus, hDeviceList, hCapacity, hImageOption;
|
2018-03-22 23:14:20 +00:00
|
|
|
|
extern HWND hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog;
|
|
|
|
|
extern HWND hInfo, hProgress, hDiskID;
|
2018-07-05 23:40:52 +00:00
|
|
|
|
extern WORD selected_langid;
|
2019-04-09 20:37:08 +00:00
|
|
|
|
extern DWORD FormatStatus, DownloadStatus, MainThreadId, LastWriteError;
|
2019-08-22 13:04:41 +00:00
|
|
|
|
extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, op_in_progress, right_to_left_mode;
|
2018-07-05 23:40:52 +00:00
|
|
|
|
extern BOOL allow_dual_uefi_bios, large_drive, usb_debug;
|
2012-02-07 16:17:14 +00:00
|
|
|
|
extern int64_t iso_blocking_status;
|
2018-07-05 23:40:52 +00:00
|
|
|
|
extern uint8_t image_options;
|
2015-02-08 22:36:57 +00:00
|
|
|
|
extern uint16_t rufus_version[3], embedded_sl_version[2];
|
2019-08-02 16:57:10 +00:00
|
|
|
|
extern uint64_t persistence_size;
|
2017-04-25 13:32:19 +00:00
|
|
|
|
extern size_t ubuffer_pos;
|
2018-07-05 23:40:52 +00:00
|
|
|
|
extern const int nb_steps[FS_MAX];
|
|
|
|
|
extern float fScale;
|
2021-10-21 01:02:17 +00:00
|
|
|
|
extern int nWindowsVersion, nWindowsBuildNumber, nWindowsEdition, dialog_showing, force_update;
|
2019-04-13 14:29:27 +00:00
|
|
|
|
extern int fs_type, boot_type, partition_type, target_type;
|
2018-07-05 23:40:52 +00:00
|
|
|
|
extern unsigned long syslinux_ldlinux_len[2];
|
|
|
|
|
extern char WindowsVersionStr[128], ubuffer[UBUFFER_SIZE], embedded_sl_version_str[2][12];
|
2019-03-12 14:20:19 +00:00
|
|
|
|
extern char szFolderPath[MAX_PATH], app_dir[MAX_PATH], temp_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH];
|
2021-05-31 15:54:11 +00:00
|
|
|
|
extern char app_data_dir[MAX_PATH], *image_path, *fido_url;
|
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);
|
2018-10-22 16:42:40 +00:00
|
|
|
|
extern BOOL GetCpuArch(void);
|
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);
|
2021-10-09 15:15:21 +00:00
|
|
|
|
extern void _UpdateProgressWithInfo(int op, int msg, uint64_t processed, uint64_t total, BOOL force);
|
|
|
|
|
#define UpdateProgressWithInfo(op, msg, processed, total) _UpdateProgressWithInfo(op, msg, processed, total, FALSE)
|
|
|
|
|
#define UpdateProgressWithInfoForce(op, msg, processed, total) _UpdateProgressWithInfo(op, msg, processed, total, TRUE)
|
2019-08-20 17:06:07 +00:00
|
|
|
|
#define UpdateProgressWithInfoInit(hProgressDialog, bNoAltMode) UpdateProgressWithInfo(OP_INIT, (int)bNoAltMode, (uint64_t)(uintptr_t)hProgressDialog, 0);
|
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);
|
2020-06-06 15:34:17 +00:00
|
|
|
|
extern GUID* StringToGuid(const char* str);
|
2015-01-28 23:22:11 +00:00
|
|
|
|
extern char* SizeToHumanReadable(uint64_t size, BOOL copy_to_log, BOOL fake_units);
|
2017-09-03 12:54:07 +00:00
|
|
|
|
extern char* TimestampToHumanReadable(uint64_t ts);
|
2015-07-03 22:42:45 +00:00
|
|
|
|
extern HWND MyCreateDialog(HINSTANCE hInstance, int Dialog_ID, HWND hWndParent, DLGPROC lpDialogFunc);
|
|
|
|
|
extern INT_PTR MyDialogBox(HINSTANCE hInstance, int Dialog_ID, HWND hWndParent, DLGPROC lpDialogFunc);
|
2019-03-07 16:29:43 +00:00
|
|
|
|
extern void CenterDialog(HWND hDlg, HWND hParent);
|
2015-08-22 14:18:25 +00:00
|
|
|
|
extern void ResizeMoveCtrl(HWND hDlg, HWND hCtrl, int dx, int dy, int dw, int dh, float scale);
|
2018-03-22 23:14:20 +00:00
|
|
|
|
extern void ResizeButtonHeight(HWND hDlg, int id);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
extern void CreateStatusBar(void);
|
2018-03-22 23:14:20 +00:00
|
|
|
|
extern void CreateStaticFont(HDC hDC, HFONT* hFont, BOOL underlined);
|
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);
|
2018-11-20 12:28:20 +00:00
|
|
|
|
extern BOOL Notification(int type, const char* dont_display_setting, const notification_info* more_info, char* title, char* format, ...);
|
2017-07-11 16:43:51 +00:00
|
|
|
|
extern int SelectionDialog(char* title, char* message, char** choices, int size);
|
|
|
|
|
extern void ListDialog(char* title, char* message, char** items, int size);
|
2018-03-22 23:14:20 +00:00
|
|
|
|
extern SIZE GetTextSize(HWND hCtrl, char* txt);
|
[net] add Windows retail ISO downloads
* This is accomplished through Fido (https://github.com/pbatard/Fido), a *SIGNED*
PowerShell script, that is downloaded from GitHub and that resides in memory for
the duration of a session.
* The reason we use a downloaded PS script, rather than an embedded on, is because:
- Microsoft have regularly been changing the deal with regards to how retail ISOs
can be downloaded, and not for the better, so we can't simply embed a static
means of downloading ISOs and expect that to work forever.
- By using an external script, we can immediately respond to whatever new means of
*ANNOYING* their legitimate users Microsoft will come up with next, as well as
make sure that, the minute a new retail version of Windows becomes available, it
also becomes available for download in Rufus.
* Note that if you are concerned about downloading a remote PS script that is being
run at the same level as an elevated application, you should understand that:
- Only scripts downloaded from GitHub, from an account that is protected with 2FA,
are allowed to run (i.e. someone would first have to steal a *physical* 2FA key
to be in a position to upload a malicious script).
- On top of this, only scripts that are signed with a separate private key (RSA +
AES-256), that is itself also protected with a strong unique password which only
a single person knows (and must manually enter each time they want to make a new
version of the script available for download), are allowed to run.
The above means that there's about as much chance for someone to manage to upload
a malicious script on the GitHub servers, that Rufus would allow to run, as there
is for someone to upload a malicious version of Rufus itself.
Still, if you are paranoid and have concerns that, even as you can validate from
its source that Rufus does not attempt to execute any remote script unless a user
actively selected and clicked the DOWNLOAD button, you can also completely disable
the remote script download feature, if you just set the update check to disabled
(which, by the way, Rufus *EXPLICITLY* asks you to choose whether you want to
enable or not, the very first time you run the application).
* Also remove _unlinkU() which duplicates what DeleteFileU() already does.
2019-03-02 23:28:56 +00:00
|
|
|
|
extern BOOL ExtractAppIcon(const char* filename, BOOL bSilent);
|
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);
|
2019-04-04 18:12:48 +00:00
|
|
|
|
extern BOOL HasEfiImgBootLoaders(void);
|
|
|
|
|
extern BOOL DumpFatDir(const char* path, int32_t cluster);
|
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-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);
|
2021-10-08 18:22:33 +00:00
|
|
|
|
extern BOOL MountRegistryHive(const HKEY key, const char* pszHiveName, const char* pszHivePath);
|
|
|
|
|
extern BOOL UnmountRegistryHive(const HKEY key, const char* pszHiveName);
|
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);
|
2019-03-12 14:20:19 +00:00
|
|
|
|
extern uint64_t DownloadToFileOrBuffer(const char* url, const char* file, BYTE** buffer, HWND hProgressDialog, BOOL bTaskBarProgress);
|
2018-06-30 21:45:15 +00:00
|
|
|
|
extern DWORD DownloadSignedFile(const char* url, const char* file, HWND hProgressDialog, BOOL PromptOnError);
|
|
|
|
|
extern HANDLE DownloadSignedFileThreaded(const char* url, const char* file, HWND hProgressDialog, BOOL bPromptOnError);
|
2012-11-29 23:14:36 +00:00
|
|
|
|
extern INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
2021-02-08 21:02:01 +00:00
|
|
|
|
extern void SetFidoCheck(void);
|
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);
|
[net] add Windows retail ISO downloads
* This is accomplished through Fido (https://github.com/pbatard/Fido), a *SIGNED*
PowerShell script, that is downloaded from GitHub and that resides in memory for
the duration of a session.
* The reason we use a downloaded PS script, rather than an embedded on, is because:
- Microsoft have regularly been changing the deal with regards to how retail ISOs
can be downloaded, and not for the better, so we can't simply embed a static
means of downloading ISOs and expect that to work forever.
- By using an external script, we can immediately respond to whatever new means of
*ANNOYING* their legitimate users Microsoft will come up with next, as well as
make sure that, the minute a new retail version of Windows becomes available, it
also becomes available for download in Rufus.
* Note that if you are concerned about downloading a remote PS script that is being
run at the same level as an elevated application, you should understand that:
- Only scripts downloaded from GitHub, from an account that is protected with 2FA,
are allowed to run (i.e. someone would first have to steal a *physical* 2FA key
to be in a position to upload a malicious script).
- On top of this, only scripts that are signed with a separate private key (RSA +
AES-256), that is itself also protected with a strong unique password which only
a single person knows (and must manually enter each time they want to make a new
version of the script available for download), are allowed to run.
The above means that there's about as much chance for someone to manage to upload
a malicious script on the GitHub servers, that Rufus would allow to run, as there
is for someone to upload a malicious version of Rufus itself.
Still, if you are paranoid and have concerns that, even as you can validate from
its source that Rufus does not attempt to execute any remote script unless a user
actively selected and clicked the DOWNLOAD button, you can also completely disable
the remote script download feature, if you just set the update check to disabled
(which, by the way, Rufus *EXPLICITLY* asks you to choose whether you want to
enable or not, the very first time you run the application).
* Also remove _unlinkU() which duplicates what DeleteFileU() already does.
2019-03-02 23:28:56 +00:00
|
|
|
|
extern BOOL DownloadISO(void);
|
2019-03-04 19:14:54 +00:00
|
|
|
|
extern BOOL IsDownloadable(const char* url);
|
2012-05-31 12:05:12 +00:00
|
|
|
|
extern BOOL IsShown(HWND hDlg);
|
2020-04-06 15:27:05 +00:00
|
|
|
|
extern uint32_t read_file(const char* path, uint8_t** buf);
|
|
|
|
|
extern uint32_t write_file(const char* path, const uint8_t* buf, const uint32_t size);
|
2016-12-13 14:21:51 +00:00
|
|
|
|
extern char* get_token_data_file_indexed(const char* token, const char* filename, int index);
|
|
|
|
|
#define get_token_data_file(token, filename) get_token_data_file_indexed(token, filename, 1)
|
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);
|
2017-09-04 13:32:56 +00:00
|
|
|
|
extern void* get_data_from_asn1(const uint8_t* buf, size_t buf_len, const char* oid_str, uint8_t asn1_type, size_t* data_len);
|
2020-07-19 21:35:30 +00:00
|
|
|
|
extern uint8_t WimExtractCheck(BOOL bSilent);
|
|
|
|
|
extern BOOL WimExtractFile(const char* wim_image, int index, const char* src, const char* dst, BOOL bSilent);
|
|
|
|
|
extern BOOL WimExtractFile_API(const char* image, int index, const char* src, const char* dst, BOOL bSilent);
|
|
|
|
|
extern BOOL WimExtractFile_7z(const char* image, int index, const char* src, const char* dst, BOOL bSilent);
|
2015-01-15 01:45:10 +00:00
|
|
|
|
extern BOOL WimApplyImage(const char* image, int index, const char* dst);
|
2021-10-08 18:22:33 +00:00
|
|
|
|
extern char* WimMountImage(const char* image, int index);
|
|
|
|
|
extern BOOL WimUnmountImage(const char* image, int index);
|
2022-01-07 13:25:46 +00:00
|
|
|
|
extern int8_t IsBootableImage(const char* path);
|
2014-05-27 01:02:50 +00:00
|
|
|
|
extern BOOL AppendVHDFooter(const char* vhd_path);
|
2017-05-01 23:21:14 +00:00
|
|
|
|
extern int SetWinToGoIndex(void);
|
2013-11-17 01:39:43 +00:00
|
|
|
|
extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid);
|
2021-05-26 23:18:05 +00:00
|
|
|
|
extern char* GetSignatureName(const char* path, const char* country_code, BOOL bSilent);
|
2017-09-01 17:27:34 +00:00
|
|
|
|
extern uint64_t GetSignatureTimeStamp(const char* path);
|
2015-10-13 22:29:30 +00:00
|
|
|
|
extern LONG ValidateSignature(HWND hDlg, const char* path);
|
2018-06-29 17:19:05 +00:00
|
|
|
|
extern BOOL ValidateOpensslSignature(BYTE* pbBuffer, DWORD dwBufferLen, BYTE* pbSignature, DWORD dwSigLen);
|
2015-12-30 14:27:52 +00:00
|
|
|
|
extern BOOL IsFontAvailable(const char* font_name);
|
2016-01-14 17:43:02 +00:00
|
|
|
|
extern BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
|
|
|
|
LPDWORD lpNumberOfBytesWritten, DWORD nNumRetries);
|
2016-03-03 17:24:54 +00:00
|
|
|
|
extern BOOL SetThreadAffinity(DWORD_PTR* thread_affinity, size_t num_threads);
|
2016-05-25 11:20:20 +00:00
|
|
|
|
extern BOOL HashFile(const unsigned type, const char* path, uint8_t* sum);
|
2021-10-08 18:22:33 +00:00
|
|
|
|
extern BOOL HashBuffer(const unsigned type, const uint8_t* buf, const size_t len, uint8_t* sum);
|
2016-05-25 11:20:20 +00:00
|
|
|
|
extern BOOL IsFileInDB(const char* path);
|
|
|
|
|
extern BOOL IsBufferInDB(const unsigned char* buf, const size_t len);
|
2016-03-01 17:13:37 +00:00
|
|
|
|
#define printbits(x) _printbits(sizeof(x), &x, 0)
|
|
|
|
|
#define printbitslz(x) _printbits(sizeof(x), &x, 1)
|
|
|
|
|
extern char* _printbits(size_t const size, void const * const ptr, int leading_zeroes);
|
2016-07-09 15:20:58 +00:00
|
|
|
|
extern BOOL IsCurrentProcessElevated(void);
|
|
|
|
|
extern char* GetCurrentMUI(void);
|
2019-03-13 17:01:26 +00:00
|
|
|
|
extern void SetAlertPromptMessages(void);
|
2019-03-05 12:41:10 +00:00
|
|
|
|
extern BOOL SetAlertPromptHook(void);
|
|
|
|
|
extern void ClrAlertPromptHook(void);
|
2019-04-09 20:37:08 +00:00
|
|
|
|
extern DWORD CheckDriveAccess(DWORD dwTimeOut, BOOL bPrompt);
|
2017-07-20 16:42:53 +00:00
|
|
|
|
extern BYTE SearchProcess(char* HandleName, DWORD dwTimeout, BOOL bPartialMatch, BOOL bIgnoreSelf, BOOL bQuiet);
|
2017-05-02 13:07:04 +00:00
|
|
|
|
extern BOOL EnablePrivileges(void);
|
2017-07-04 13:51:25 +00:00
|
|
|
|
extern void FlashTaskbar(HANDLE handle);
|
2017-07-24 10:36:06 +00:00
|
|
|
|
extern DWORD WaitForSingleObjectWithMessages(HANDLE hHandle, DWORD dwMilliseconds);
|
2018-05-10 09:51:31 +00:00
|
|
|
|
extern HICON CreateMirroredIcon(HICON hiconOrg);
|
2020-02-03 20:23:06 +00:00
|
|
|
|
extern HANDLE CreatePreallocatedFile(const char* lpFileName, DWORD dwDesiredAccess,
|
|
|
|
|
DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
|
|
|
|
|
DWORD dwFlagsAndAttributes, LONGLONG fileSize);
|
2018-03-22 23:14:20 +00:00
|
|
|
|
#define GetTextWidth(hDlg, id) GetTextSize(GetDlgItem(hDlg, id), NULL).cx
|
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);
|
2015-06-29 22:43:49 +00:00
|
|
|
|
DWORD WINAPI SumThread(void* param);
|
2014-05-23 00:03:01 +00:00
|
|
|
|
|
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);
|
2016-12-13 14:21:51 +00:00
|
|
|
|
extern int32_t StrArrayAdd(StrArray* arr, const char* str, BOOL );
|
2018-03-22 23:14:20 +00:00
|
|
|
|
extern int32_t StrArrayFind(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
|
|
|
|
|
2022-04-07 00:57:24 +00:00
|
|
|
|
/* Patch structs for GRUB */
|
|
|
|
|
typedef struct {
|
|
|
|
|
const uint32_t offset;
|
|
|
|
|
const uint32_t size;
|
|
|
|
|
const uint8_t data[];
|
|
|
|
|
} chunk_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
const chunk_t* src;
|
|
|
|
|
const chunk_t* rep;
|
|
|
|
|
} patch_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
const char* version;
|
|
|
|
|
const patch_t patch[2];
|
|
|
|
|
} grub_patch_t;
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
2021-10-18 12:14:43 +00:00
|
|
|
|
#define MAX_LIBRARY_HANDLES 64
|
2014-05-12 21:44:10 +00:00
|
|
|
|
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;
|
2021-10-18 12:14:43 +00:00
|
|
|
|
wchar_t* wszLibraryName = NULL;
|
|
|
|
|
int size;
|
|
|
|
|
if (szLibraryName == NULL || szLibraryName[0] == 0)
|
|
|
|
|
goto out;
|
|
|
|
|
size = MultiByteToWideChar(CP_UTF8, 0, szLibraryName, -1, NULL, 0);
|
2021-10-23 12:08:13 +00:00
|
|
|
|
if ((size <= 1) || ((wszLibraryName = (wchar_t*)calloc(size, sizeof(wchar_t))) == NULL) ||
|
|
|
|
|
(MultiByteToWideChar(CP_UTF8, 0, szLibraryName, -1, wszLibraryName, size) != size))
|
2021-10-18 12:14:43 +00:00
|
|
|
|
goto out;
|
2021-10-23 12:08:13 +00:00
|
|
|
|
// If the library is already opened, just return a handle (that doesn't need to be freed)
|
|
|
|
|
if ((h = GetModuleHandleW(wszLibraryName)) != NULL)
|
2021-10-18 12:14:43 +00:00
|
|
|
|
goto out;
|
2021-10-23 12:08:13 +00:00
|
|
|
|
// Sanity check
|
|
|
|
|
if (OpenedLibrariesHandleSize >= MAX_LIBRARY_HANDLES) {
|
|
|
|
|
uprintf("Error: MAX_LIBRARY_HANDLES is too small\n");
|
2021-10-18 12:14:43 +00:00
|
|
|
|
goto out;
|
2014-05-09 21:05:25 +00:00
|
|
|
|
}
|
2021-10-23 12:08:13 +00:00
|
|
|
|
h = LoadLibraryExW(wszLibraryName, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
|
|
|
|
// Some Windows 7 platforms (most likely the ones missing KB2533623 per the
|
|
|
|
|
// official LoadLibraryEx doc) can return ERROR_INVALID_PARAMETER when using
|
|
|
|
|
// the Ex() version. If that's the case, fallback to using LoadLibraryW().
|
|
|
|
|
if ((h == NULL) && (SCODE_CODE(GetLastError()) == ERROR_INVALID_PARAMETER))
|
|
|
|
|
h = LoadLibraryW(wszLibraryName);
|
|
|
|
|
if (h != NULL)
|
|
|
|
|
OpenedLibrariesHandle[OpenedLibrariesHandleSize++] = h;
|
|
|
|
|
else
|
|
|
|
|
uprintf("Unable to load '%S.dll': %s", wszLibraryName, WindowsErrorString());
|
2021-10-18 12:14:43 +00:00
|
|
|
|
out:
|
|
|
|
|
free(wszLibraryName);
|
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); \
|
2021-10-23 12:08:13 +00:00
|
|
|
|
if (pf##proc == NULL) {uprintf("Unable to locate %s() in '%s.dll': %s", \
|
2014-05-12 21:44:10 +00:00
|
|
|
|
#proc, #name, WindowsErrorString()); goto out;} } while(0)
|
2020-02-03 20:23:06 +00:00
|
|
|
|
#define PF_INIT_OR_SET_STATUS(proc, name) do {PF_INIT(proc, name); \
|
|
|
|
|
if ((pf##proc == NULL) && (NT_SUCCESS(status))) status = STATUS_NOT_IMPLEMENTED; } while(0)
|
2012-02-01 14:26:36 +00:00
|
|
|
|
|
2011-11-28 12:37:58 +00:00
|
|
|
|
/* Custom application errors */
|
2020-02-23 16:29:16 +00:00
|
|
|
|
#define FAC(f) ((f)<<16)
|
|
|
|
|
#define APPERR(err) (APPLICATION_ERROR_MASK|(err))
|
2011-12-04 19:47:27 +00:00
|
|
|
|
#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
|
2018-06-30 21:45:15 +00:00
|
|
|
|
#define ERROR_BAD_SIGNATURE 0x120D
|
2020-02-03 12:35:49 +00:00
|
|
|
|
#define ERROR_CANT_DOWNLOAD 0x120E
|