2011-11-13 20:53:23 +00:00
|
|
|
/*
|
2011-12-05 11:36:02 +00:00
|
|
|
* Rufus: The Reliable USB Formatting Utility
|
2012-01-02 23:55:47 +00:00
|
|
|
* Copyright (c) 2011-2012 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
|
2012-02-01 14:26:36 +00:00
|
|
|
#include <stdint.h>
|
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! */
|
2012-11-08 01:20:48 +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"
|
|
|
|
#define COMPANY_NAME "Akeo Consulting"
|
2011-11-24 02:24:50 +00:00
|
|
|
#define STR_NO_LABEL "NO_LABEL"
|
2011-11-28 12:37:58 +00:00
|
|
|
#define RUFUS_CANCELBOX_TITLE "Rufus - Cancellation"
|
2012-02-07 16:17:14 +00:00
|
|
|
#define RUFUS_BLOCKING_IO_TITLE "Rufus - Flushing buffers"
|
2011-11-23 12:27:51 +00:00
|
|
|
#define DRIVE_INDEX_MIN 0x80
|
|
|
|
#define DRIVE_INDEX_MAX 0xC0
|
2011-11-24 02:24:50 +00:00
|
|
|
#define MAX_DRIVES 16
|
2012-05-22 11:30:22 +00:00
|
|
|
#define MAX_TOOLTIPS 32
|
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
|
2011-11-24 20:02:14 +00:00
|
|
|
#define PROPOSEDLABEL_TOLERANCE 0.10
|
2011-11-24 23:49:42 +00:00
|
|
|
#define FS_DEFAULT FS_FAT32
|
2012-11-03 17:40:33 +00:00
|
|
|
#define LARGE_FAT32_SIZE (32*1073741824LL) // Size at which we need to use fat32format
|
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"
|
2012-03-11 01:55:25 +00:00
|
|
|
#define VESAMENU_URL "http://cloud.github.com/downloads/pbatard/rufus/vesamenu.c32"
|
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)
|
2011-11-13 20:53:23 +00:00
|
|
|
|
|
|
|
#define safe_free(p) do {free((void*)p); p = NULL;} while(0)
|
2011-11-18 01:58:08 +00:00
|
|
|
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} 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)); \
|
|
|
|
((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))
|
|
|
|
#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)
|
2011-11-13 20:53:23 +00:00
|
|
|
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
2011-11-29 20:18:23 +00:00
|
|
|
#define safe_unlockclose(h) do {if (h != INVALID_HANDLE_VALUE) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
2011-11-13 20:53:23 +00:00
|
|
|
#define safe_sprintf _snprintf
|
|
|
|
#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__)
|
2011-11-21 17:06:17 +00:00
|
|
|
#else
|
|
|
|
#define uprintf(...)
|
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,
|
|
|
|
UM_ISO_EXIT
|
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,
|
|
|
|
MSG_ERROR
|
|
|
|
};
|
|
|
|
|
2011-12-08 00:22:13 +00:00
|
|
|
/* Timers used throughout the program */
|
2011-12-09 01:39:13 +00:00
|
|
|
enum timer_type {
|
|
|
|
TID_MESSAGE = 0x1000,
|
|
|
|
TID_BADBLOCKS_UPDATE,
|
2012-02-07 16:17:14 +00:00
|
|
|
TID_APP_TIMER,
|
|
|
|
TID_BLOCKING_TIMER
|
2011-12-09 01:39:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Action type, for progress bar breakdown */
|
|
|
|
enum action_type {
|
|
|
|
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,
|
2011-12-01 02:56:44 +00:00
|
|
|
FS_EXFAT,
|
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,
|
2012-05-16 22:38:39 +00:00
|
|
|
DT_SYSLINUX,
|
2011-12-15 00:46:47 +00:00
|
|
|
DT_MAX
|
|
|
|
};
|
|
|
|
|
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];
|
2011-12-01 17:20:52 +00:00
|
|
|
int FSType;
|
|
|
|
struct {
|
|
|
|
ULONG Allowed;
|
|
|
|
ULONG Default;
|
|
|
|
} ClusterSize[FS_MAX];
|
|
|
|
} RUFUS_DRIVE_INFO;
|
2011-11-26 00:25:04 +00:00
|
|
|
|
2012-02-01 14:26:36 +00:00
|
|
|
/* ISO details that the application may want */
|
2012-03-16 18:30:44 +00:00
|
|
|
#define WINPE_MININT 0x2A
|
|
|
|
#define WINPE_I386 0x15
|
2012-03-25 21:09:24 +00:00
|
|
|
#define IS_WINPE(r) (((r&WINPE_MININT) == WINPE_MININT)||((r&WINPE_I386) == WINPE_I386))
|
2012-02-01 14:26:36 +00:00
|
|
|
typedef struct {
|
2012-02-21 00:08:31 +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 */
|
2012-02-01 14:26:36 +00:00
|
|
|
uint64_t projected_size;
|
2012-03-16 18:30:44 +00:00
|
|
|
uint8_t winpe;
|
2012-02-01 14:26:36 +00:00
|
|
|
BOOL has_4GB_file;
|
2012-02-07 02:05:58 +00:00
|
|
|
BOOL has_bootmgr;
|
|
|
|
BOOL has_isolinux;
|
2012-02-21 19:46:28 +00:00
|
|
|
BOOL has_autorun;
|
2012-03-11 01:55:25 +00:00
|
|
|
BOOL has_old_vesamenu;
|
2012-03-27 19:31:15 +00:00
|
|
|
BOOL uses_minint;
|
2012-02-01 14:26:36 +00:00
|
|
|
} RUFUS_ISO_REPORT;
|
|
|
|
|
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 {
|
|
|
|
WINDOWS_UNDEFINED,
|
|
|
|
WINDOWS_UNSUPPORTED,
|
|
|
|
WINDOWS_2K,
|
|
|
|
WINDOWS_XP,
|
|
|
|
WINDOWS_2003_XP64,
|
|
|
|
WINDOWS_VISTA,
|
|
|
|
WINDOWS_7,
|
|
|
|
WINDOWS_8
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
extern HWND hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses, hLog;
|
2012-05-16 22:38:39 +00:00
|
|
|
extern HWND hISOProgressDlg, hISOProgressBar, hISOFileName, hDiskID;
|
2011-12-01 17:20:52 +00:00
|
|
|
extern float fScale;
|
|
|
|
extern char szFolderPath[MAX_PATH];
|
2012-02-07 02:05:58 +00:00
|
|
|
extern char* iso_path;
|
2011-12-01 17:20:52 +00:00
|
|
|
extern DWORD FormatStatus;
|
|
|
|
extern RUFUS_DRIVE_INFO SelectedDrive;
|
2011-12-09 01:39:13 +00:00
|
|
|
extern const int nb_steps[FS_MAX];
|
2012-05-16 22:38:39 +00:00
|
|
|
extern BOOL use_own_vesamenu, detect_fakes;
|
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;
|
2012-03-11 01:55:25 +00:00
|
|
|
extern int rufus_version[4];
|
2012-05-16 22:38:39 +00:00
|
|
|
extern enum WindowsVersion nWindowsVersion;
|
2011-12-01 17:20:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Shared prototypes
|
2011-11-26 00:25:04 +00:00
|
|
|
*/
|
2012-05-16 22:38:39 +00:00
|
|
|
extern void DetectWindowsVersion(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);
|
2012-02-03 18:19:50 +00:00
|
|
|
extern void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...);
|
2011-12-09 01:39:13 +00:00
|
|
|
extern void UpdateProgress(int op, float percent);
|
2011-12-04 19:47:27 +00:00
|
|
|
extern const char* StrError(DWORD error_code);
|
2011-12-01 17:20:52 +00:00
|
|
|
extern void CenterDialog(HWND hDlg);
|
|
|
|
extern void CreateStatusBar(void);
|
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);
|
2011-12-04 19:47:27 +00:00
|
|
|
extern BOOL Notification(int type, char* title, char* format, ...);
|
2012-11-29 02:59:52 +00:00
|
|
|
extern BOOL Question(char* title, char* format, ...);
|
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);
|
2012-03-27 19:31:15 +00:00
|
|
|
extern BOOL ExtractISOFile(const char* iso, const char* iso_file, const char* dest_file);
|
2012-01-12 11:04:03 +00:00
|
|
|
extern BOOL InstallSyslinux(DWORD num, const char* drive_name);
|
2012-02-07 02:05:58 +00:00
|
|
|
DWORD WINAPI FormatThread(void* param);
|
2011-12-01 17:20:52 +00:00
|
|
|
extern BOOL CreatePartition(HANDLE hDrive);
|
|
|
|
extern HANDLE GetDriveHandle(DWORD DriveIndex, char* DriveLetter, BOOL bWriteAccess, BOOL bLockDrive);
|
2011-12-01 17:54:35 +00:00
|
|
|
extern BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label);
|
2011-12-11 02:19:38 +00:00
|
|
|
extern BOOL UnmountDrive(HANDLE hDrive);
|
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);
|
2012-02-02 13:16:49 +00:00
|
|
|
extern char* FileDialog(BOOL save, char* path, char* filename, char* ext, char* ext_desc);
|
2012-05-30 23:32:25 +00:00
|
|
|
extern BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size);
|
2012-03-11 01:55:25 +00:00
|
|
|
extern LONG GetEntryWidth(HWND hDropDown, const char* entry);
|
|
|
|
extern BOOL DownloadFile(const char* url, const char* file);
|
2012-11-22 01:52:33 +00:00
|
|
|
extern BOOL CheckForUpdates(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);
|
|
|
|
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);
|
2012-11-22 01:52:33 +00:00
|
|
|
extern void parse_update(char* buf, size_t len);
|
2011-12-01 17:20:52 +00:00
|
|
|
|
|
|
|
__inline static BOOL UnlockDrive(HANDLE hDrive)
|
2011-11-26 00:25:04 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2011-12-01 17:20:52 +00:00
|
|
|
/* Basic String Array */
|
|
|
|
typedef struct {
|
|
|
|
char** Table;
|
2012-02-21 00:08:31 +00:00
|
|
|
size_t Index; // Current array size
|
|
|
|
size_t Max; // Maximum array size
|
2011-12-01 17:20:52 +00:00
|
|
|
} StrArray;
|
|
|
|
extern void StrArrayCreate(StrArray* arr, size_t initial_size);
|
|
|
|
extern void StrArrayAdd(StrArray* arr, const char* str);
|
|
|
|
extern void StrArrayClear(StrArray* arr);
|
|
|
|
extern void StrArrayDestroy(StrArray* arr);
|
|
|
|
|
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:
|
|
|
|
* PF_INIT(FormatEx, fmifs);
|
|
|
|
* which translates to:
|
|
|
|
* pfFormatEx = (FormatEx_t) GetProcAddress(GetDLLHandle("fmifs"), "FormatEx");
|
|
|
|
* to make it accessible.
|
|
|
|
*/
|
|
|
|
static __inline HMODULE GetDLLHandle(char* szDLLName)
|
|
|
|
{
|
|
|
|
HMODULE h = NULL;
|
|
|
|
if ((h = GetModuleHandleA(szDLLName)) == NULL)
|
|
|
|
h = LoadLibraryA(szDLLName);
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
#define PF_DECL(proc) proc##_t pf##proc = NULL
|
|
|
|
#define PF_INIT(proc, dllname) pf##proc = (proc##_t) GetProcAddress(GetDLLHandle(#dllname), #proc)
|
|
|
|
#define PF_INIT_OR_OUT(proc, dllname) \
|
|
|
|
PF_INIT(proc, dllname); if (pf##proc == NULL) { \
|
2012-05-30 23:32:25 +00:00
|
|
|
uprintf("Unable to access %s DLL: %s\n", #dllname, \
|
2012-03-11 01:55:25 +00:00
|
|
|
WindowsErrorString()); goto out; }
|
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-12-01 17:20:52 +00:00
|
|
|
/* We need a redef of this MS structure */
|
2011-11-26 00:25:04 +00:00
|
|
|
typedef struct {
|
2011-12-01 17:20:52 +00:00
|
|
|
DWORD DeviceType;
|
|
|
|
ULONG DeviceNumber;
|
|
|
|
ULONG PartitionNumber;
|
|
|
|
} STORAGE_DEVICE_NUMBER_REDEF;
|
|
|
|
|
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
|
2012-03-27 19:31:15 +00:00
|
|
|
#define ERROR_CANT_PATCH 0x1210
|
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
|