mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
parent
7ff5b3ca6e
commit
d1eccbd107
6 changed files with 48 additions and 27 deletions
29
src/format.c
29
src/format.c
|
@ -1280,9 +1280,7 @@ BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
|
||||||
#endif
|
#endif
|
||||||
static char unattend_path[] = "?:\\Windows\\System32\\sysprep\\unattend.xml";
|
static char unattend_path[] = "?:\\Windows\\System32\\sysprep\\unattend.xml";
|
||||||
char *mounted_iso, *ms_efi = NULL, image[128], cmd[MAX_PATH];
|
char *mounted_iso, *ms_efi = NULL, image[128], cmd[MAX_PATH];
|
||||||
char usb_system_dir[] = "?:\\Windows\\System32";
|
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
int i;
|
|
||||||
wchar_t wVolumeName[] = L"?:";
|
wchar_t wVolumeName[] = L"?:";
|
||||||
DWORD bufsize;
|
DWORD bufsize;
|
||||||
ULONG cluster_size;
|
ULONG cluster_size;
|
||||||
|
@ -1291,7 +1289,6 @@ BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
|
||||||
PF_INIT(FormatEx, Fmifs);
|
PF_INIT(FormatEx, Fmifs);
|
||||||
|
|
||||||
uprintf("Windows To Go mode selected");
|
uprintf("Windows To Go mode selected");
|
||||||
usb_system_dir[0] = drive_name[0];
|
|
||||||
// Additional sanity checks
|
// Additional sanity checks
|
||||||
if ( ((use_ms_efi) && (SelectedDrive.Geometry.MediaType != FixedMedia)) ||
|
if ( ((use_ms_efi) && (SelectedDrive.Geometry.MediaType != FixedMedia)) ||
|
||||||
((nWindowsVersion < WINDOWS_8) || ((WimExtractCheck() & 4) == 0)) ) {
|
((nWindowsVersion < WINDOWS_8) || ((WimExtractCheck() & 4) == 0)) ) {
|
||||||
|
@ -1353,25 +1350,21 @@ BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
|
||||||
AltUnmountVolume(ms_efi);
|
AltUnmountVolume(ms_efi);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Sleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try the 'bcdboot' command, first using the one from the target drive and, if that doesn't work, the system's
|
// We invoke the 'bcdboot' command from the host, as the one from the drive produces problems (#558)
|
||||||
|
// Also, since Rufus should (usually) be running as a 32 bit app, on 64 bit systems, we need to use
|
||||||
|
// 'C:\Windows\Sysnative' and not 'C:\Windows\System32' to invoke bcdboot, as 'C:\Windows\System32'
|
||||||
|
// will get converted to 'C:\Windows\SysWOW64' behind the scenes, and ther is no bcdboot.exe there.
|
||||||
uprintf("Enabling boot...");
|
uprintf("Enabling boot...");
|
||||||
for (i = 0; i < 2; i++) {
|
static_sprintf(cmd, "%s\\bcdboot.exe %s\\Windows /v /f ALL /s %s", sysnative_dir,
|
||||||
static_sprintf(cmd, "%s\\bcdboot.exe %s\\Windows /f ALL /s %s",
|
drive_name, (use_ms_efi)?ms_efi:drive_name);
|
||||||
(i==0)?usb_system_dir:system_dir, drive_name, (use_ms_efi)?ms_efi:drive_name);
|
if (RunCommand(cmd, sysnative_dir, TRUE) != 0) {
|
||||||
if (RunCommand(cmd, NULL, TRUE) == 0)
|
// Try to continue... but report a failure
|
||||||
break;
|
uprintf("Failed to enable boot using command '%s'", cmd);
|
||||||
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_ISO_EXTRACT);
|
||||||
}
|
}
|
||||||
if (i >= 2) {
|
|
||||||
// Fatal, as the UFD is unlikely to boot then
|
|
||||||
uprintf("Failed to enable boot - aborting", cmd);
|
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_ISO_EXTRACT);
|
|
||||||
if (use_ms_efi)
|
|
||||||
AltUnmountVolume(ms_efi);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
uprintf("Boot was successfully enabled using command '%s'", cmd);
|
|
||||||
|
|
||||||
if (use_ms_efi) {
|
if (use_ms_efi) {
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
|
|
|
@ -433,6 +433,20 @@ static __inline UINT GetSystemDirectoryU(char* lpBuffer, UINT uSize)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline UINT GetSystemWindowsDirectoryU(char* lpBuffer, UINT uSize)
|
||||||
|
{
|
||||||
|
UINT ret = 0, err = ERROR_INVALID_DATA;
|
||||||
|
walloc(lpBuffer, uSize);
|
||||||
|
ret = GetSystemWindowsDirectoryW(wlpBuffer, uSize);
|
||||||
|
err = GetLastError();
|
||||||
|
if ((ret != 0) && ((ret = wchar_to_utf8_no_alloc(wlpBuffer, lpBuffer, uSize)) == 0)) {
|
||||||
|
err = GetLastError();
|
||||||
|
}
|
||||||
|
wfree(lpBuffer);
|
||||||
|
SetLastError(err);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static __inline DWORD GetTempPathU(DWORD nBufferLength, char* lpBuffer)
|
static __inline DWORD GetTempPathU(DWORD nBufferLength, char* lpBuffer)
|
||||||
{
|
{
|
||||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||||
|
|
18
src/rufus.c
18
src/rufus.c
|
@ -129,7 +129,7 @@ char lost_translators[][6] = LOST_TRANSLATORS;
|
||||||
OPENED_LIBRARIES_VARS;
|
OPENED_LIBRARIES_VARS;
|
||||||
HINSTANCE hMainInstance;
|
HINSTANCE hMainInstance;
|
||||||
HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL;
|
HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL;
|
||||||
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH];
|
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH];
|
||||||
char* image_path = NULL;
|
char* image_path = NULL;
|
||||||
float fScale = 1.0f;
|
float fScale = 1.0f;
|
||||||
int default_fs;
|
int default_fs;
|
||||||
|
@ -2823,7 +2823,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
uprintf("Could not access UTF-16 args");
|
uprintf("Could not access UTF-16 args");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the current application directory as well as the system dir
|
// Retrieve the current application directory as well as the system & sysnative dirs
|
||||||
if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) {
|
if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) {
|
||||||
uprintf("Could not get current directory: %s", WindowsErrorString());
|
uprintf("Could not get current directory: %s", WindowsErrorString());
|
||||||
app_dir[0] = 0;
|
app_dir[0] = 0;
|
||||||
|
@ -2832,6 +2832,20 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
uprintf("Could not get system directory: %s", WindowsErrorString());
|
uprintf("Could not get system directory: %s", WindowsErrorString());
|
||||||
safe_strcpy(system_dir, sizeof(system_dir), "C:\\Windows\\System32");
|
safe_strcpy(system_dir, sizeof(system_dir), "C:\\Windows\\System32");
|
||||||
}
|
}
|
||||||
|
// Construct Sysnative ourselves as there is no GetSysnativeDirectory() call
|
||||||
|
// By default (64bit app running on 64 bit OS or 32 bit app running on 32 bit OS)
|
||||||
|
// Sysnative and System32 are the same
|
||||||
|
safe_strcpy(sysnative_dir, sizeof(sysnative_dir), system_dir);
|
||||||
|
// But if the app is 32 bit and the OS is 64 bit, Sysnative must differ from System32
|
||||||
|
#if (!defined(_WIN64) && !defined(BUILD64))
|
||||||
|
if (is_x64()) {
|
||||||
|
if (GetSystemWindowsDirectoryU(sysnative_dir, sizeof(sysnative_dir)) == 0) {
|
||||||
|
uprintf("Could not get Windows directory: %s", WindowsErrorString());
|
||||||
|
safe_strcpy(sysnative_dir, sizeof(sysnative_dir), "C:\\Windows");
|
||||||
|
}
|
||||||
|
safe_strcat(sysnative_dir, sizeof(sysnative_dir), "\\Sysnative");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Look for a .ini file in the current app directory
|
// Look for a .ini file in the current app directory
|
||||||
static_sprintf(ini_path, "%s\\rufus.ini", app_dir);
|
static_sprintf(ini_path, "%s\\rufus.ini", app_dir);
|
||||||
|
|
|
@ -355,7 +355,7 @@ extern HWND hMainDialog, hLogDlg, hStatus, hDeviceList, hCapacity;
|
||||||
extern HWND hPartitionScheme, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog;
|
extern HWND hPartitionScheme, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog;
|
||||||
extern HWND hInfo, hProgress, hDiskID, hStatusToolbar;
|
extern HWND hInfo, hProgress, hDiskID, hStatusToolbar;
|
||||||
extern float fScale;
|
extern float fScale;
|
||||||
extern char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH];
|
extern char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH];
|
||||||
extern char* image_path;
|
extern char* image_path;
|
||||||
extern DWORD FormatStatus, DownloadStatus;
|
extern DWORD FormatStatus, DownloadStatus;
|
||||||
extern BOOL PromptOnError;
|
extern BOOL PromptOnError;
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
|
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Rufus 2.3.702"
|
CAPTION "Rufus 2.3.703"
|
||||||
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
||||||
|
@ -317,8 +317,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 2,3,702,0
|
FILEVERSION 2,3,703,0
|
||||||
PRODUCTVERSION 2,3,702,0
|
PRODUCTVERSION 2,3,703,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -335,13 +335,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "2.3.702"
|
VALUE "FileVersion", "2.3.703"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus.exe"
|
VALUE "OriginalFilename", "rufus.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "2.3.702"
|
VALUE "ProductVersion", "2.3.703"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -544,7 +544,7 @@ DWORD RunCommand(const char* cmd, const char* dir, BOOL log)
|
||||||
|
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
if (log) {
|
if (log) {
|
||||||
// NB: The size of a pipe is a suggestion, NOT an absolute gaurantee
|
// NB: The size of a pipe is a suggestion, NOT an absolute guarantee
|
||||||
// This means that you may get a pipe of 4K even if you requested 1K
|
// This means that you may get a pipe of 4K even if you requested 1K
|
||||||
if (!CreatePipe(&hOutputRead, &hOutputWrite, NULL, dwPipeSize)) {
|
if (!CreatePipe(&hOutputRead, &hOutputWrite, NULL, dwPipeSize)) {
|
||||||
ret = GetLastError();
|
ret = GetLastError();
|
||||||
|
|
Loading…
Reference in a new issue