mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[mbr] added USB selection MBR support in Rufus
* added mbr_rufus.h to ms-sys, and MBR selection to UI * also simplified int 13 override, fixing potential breakage on concurrent ints
This commit is contained in:
parent
1b7f88eb99
commit
7874f5ea5d
11 changed files with 107 additions and 20 deletions
|
@ -309,18 +309,15 @@ dsk_interrupt:
|
|||
pushf
|
||||
cli
|
||||
call disk_swap
|
||||
mov cs:[int13_cmd], ah # Keep a copy of the command for later referal
|
||||
|
||||
dsk_interrupt_org = .+1
|
||||
call 0:INT_DSK*4 # These CS:IP values will be changed at runtime
|
||||
push ax
|
||||
mov ah, cs:[int13_cmd] # Check the original command for swap exceptions
|
||||
cmp ah, 0x08 # LILO's mapper has these 2 exceptions
|
||||
je 0f
|
||||
cmp ah, 0x15
|
||||
je 0f
|
||||
# NB: subcommands 0x08 and 0x15 (disk props) modify DL, but they only
|
||||
# do so to return the number of drives => unless your computer has 128
|
||||
# or 129 drives, disk_swap will not touch those values.
|
||||
pushf # Don't modify the returned flags
|
||||
call disk_swap
|
||||
0: pop ax
|
||||
popf
|
||||
iret
|
||||
|
||||
|
||||
|
@ -328,11 +325,10 @@ dsk_interrupt_org = .+1
|
|||
/* Data section */
|
||||
/********************************************************************************/
|
||||
|
||||
int13_cmd: .byte 0x00
|
||||
prompt_string: .string "\r\nPress any key to boot from USB."
|
||||
dot_string = .-2 # Reuse the end of previous string
|
||||
counter_timeout:.byte DOT_NUMBER*DOT_TIMEOUT + 1
|
||||
counter_dot: .byte DOT_TIMEOUT
|
||||
prompt_string: .string "\r\nPress any key to boot from USB."
|
||||
dot_string = .-2 # Reuse the end of previous string
|
||||
|
||||
|
||||
/********************************************************************************/
|
||||
|
|
BIN
res/mbr/mbr.bin
BIN
res/mbr/mbr.bin
Binary file not shown.
|
@ -464,7 +464,13 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
|
|||
if ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) {
|
||||
r = write_syslinux_mbr(&fake_fd);
|
||||
} else {
|
||||
r = write_win7_mbr(&fake_fd);
|
||||
if (IsChecked(IDC_RUFUS_MBR)) {
|
||||
uprintf("Using Rufus bootable USB selection MBR\n");
|
||||
r = write_rufus_mbr(&fake_fd);
|
||||
} else {
|
||||
uprintf("Using Windows 7 MBR\n");
|
||||
r = write_win7_mbr(&fake_fd);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<ClInclude Include="..\inc\mbr_95b.h" />
|
||||
<ClInclude Include="..\inc\mbr_dos.h" />
|
||||
<ClInclude Include="..\inc\mbr_dos_f2.h" />
|
||||
<ClInclude Include="..\inc\mbr_rufus.h" />
|
||||
<ClInclude Include="..\inc\mbr_syslinux.h" />
|
||||
<ClInclude Include="..\inc\mbr_vista.h" />
|
||||
<ClInclude Include="..\inc\mbr_win7.h" />
|
||||
|
|
|
@ -107,6 +107,9 @@
|
|||
<ClInclude Include="..\inc\br_ntfs_0x54.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\inc\mbr_rufus.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\br.c">
|
||||
|
|
|
@ -100,6 +100,16 @@ int is_win7_mbr(FILE *fp)
|
|||
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
|
||||
} /* is_win7_mbr */
|
||||
|
||||
int is_rufus_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_rufus.h"
|
||||
unsigned char aucRef[] = {0x55, 0xAA};
|
||||
|
||||
return
|
||||
contains_data(fp, 0x0, mbr_rufus_0x0, sizeof(mbr_rufus_0x0)) &&
|
||||
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
|
||||
} /* is_rufus_mbr */
|
||||
|
||||
int is_syslinux_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_syslinux.h"
|
||||
|
@ -170,6 +180,16 @@ int write_win7_mbr(FILE *fp)
|
|||
write_data(fp, 0x1FE, aucRef, sizeof(aucRef));
|
||||
} /* write_win7_mbr */
|
||||
|
||||
int write_rufus_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_rufus.h"
|
||||
unsigned char aucRef[] = {0x55, 0xAA};
|
||||
|
||||
return
|
||||
write_data(fp, 0x0, mbr_rufus_0x0, sizeof(mbr_rufus_0x0)) &&
|
||||
write_data(fp, 0x1FE, aucRef, sizeof(aucRef));
|
||||
} /* write_rufus_mbr */
|
||||
|
||||
int write_syslinux_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_syslinux.h"
|
||||
|
|
|
@ -36,6 +36,10 @@ int is_vista_mbr(FILE *fp);
|
|||
FALSE.The file position will change when this function is called! */
|
||||
int is_win7_mbr(FILE *fp);
|
||||
|
||||
/* returns TRUE if the file has a Rufus master boot record, otherwise
|
||||
FALSE.The file position will change when this function is called! */
|
||||
int is_rufus_mbr(FILE *fp);
|
||||
|
||||
/* returns TRUE if the file has a syslinux master boot record, otherwise
|
||||
FALSE.The file position will change when this function is called! */
|
||||
int is_syslinux_mbr(FILE *fp);
|
||||
|
@ -64,6 +68,10 @@ int write_vista_mbr(FILE *fp);
|
|||
FALSE */
|
||||
int write_win7_mbr(FILE *fp);
|
||||
|
||||
/* Writes a Rufus master boot record to a file, returns TRUE on success, otherwise
|
||||
FALSE */
|
||||
int write_rufus_mbr(FILE *fp);
|
||||
|
||||
/* Writes a syslinux master boot record to a file, returns TRUE on success, otherwise
|
||||
FALSE */
|
||||
int write_syslinux_mbr(FILE *fp);
|
||||
|
|
40
src/ms-sys/inc/mbr_rufus.h
Normal file
40
src/ms-sys/inc/mbr_rufus.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* First 446 bytes of boot selection MBR from Rufus */
|
||||
unsigned char mbr_rufus_0x0[440] = {
|
||||
0x41, 0x4b, 0x45, 0x4f, 0xfc, 0x31, 0xc0, 0xfa, 0x8e, 0xd0, 0xbc, 0x00,
|
||||
0x7c, 0xfb, 0x89, 0xe6, 0x89, 0xe7, 0x1e, 0x06, 0x8e, 0xd8, 0xbb, 0x13,
|
||||
0x04, 0x8b, 0x07, 0x48, 0x89, 0x07, 0xc1, 0xe0, 0x06, 0x2d, 0xc0, 0x07,
|
||||
0x8e, 0xc0, 0xb9, 0x00, 0x02, 0xf3, 0xa4, 0x50, 0x68, 0x30, 0x7c, 0xcb,
|
||||
0x8e, 0xd8, 0x6a, 0x00, 0x07, 0x66, 0x31, 0xdb, 0xb9, 0x01, 0x00, 0xba,
|
||||
0x81, 0x00, 0xe8, 0x80, 0x00, 0x72, 0x67, 0xbb, 0xbe, 0x7d, 0xb9, 0x04,
|
||||
0x00, 0x26, 0x80, 0x3f, 0x00, 0x7c, 0x09, 0x75, 0x05, 0x83, 0xc3, 0x10,
|
||||
0xe2, 0xf3, 0xeb, 0x52, 0xbe, 0x78, 0x7d, 0xe8, 0xd1, 0x00, 0xe8, 0xc1,
|
||||
0x00, 0xba, 0x4c, 0x7d, 0xbe, 0x61, 0x7d, 0xe8, 0x97, 0x00, 0xb4, 0x01,
|
||||
0xcd, 0x16, 0x75, 0x37, 0xb4, 0x02, 0xcd, 0x16, 0x24, 0x04, 0x75, 0x32,
|
||||
0x80, 0x3e, 0x77, 0x7d, 0x00, 0x7f, 0x0b, 0xbe, 0x98, 0x7d, 0xe8, 0xaa,
|
||||
0x00, 0xc6, 0x06, 0x77, 0x7d, 0x12, 0x80, 0x3e, 0x76, 0x7d, 0x00, 0x75,
|
||||
0xd9, 0xe8, 0x80, 0x00, 0xba, 0x66, 0x7d, 0xbe, 0x6c, 0x7d, 0xe8, 0x64,
|
||||
0x00, 0x07, 0x1f, 0xba, 0x80, 0x00, 0xea, 0x00, 0x7c, 0x00, 0x00, 0xe8,
|
||||
0x6a, 0x00, 0xe8, 0x75, 0x00, 0xbb, 0xbe, 0x7d, 0x8b, 0x17, 0x8b, 0x4f,
|
||||
0x02, 0x66, 0x8b, 0x5f, 0x08, 0xe8, 0x05, 0x00, 0x73, 0xdf, 0x07, 0x1f,
|
||||
0xcb, 0x60, 0xb4, 0x41, 0xbb, 0xaa, 0x55, 0xcd, 0x13, 0x72, 0x2c, 0x81,
|
||||
0xfb, 0x55, 0xaa, 0x75, 0x26, 0xf7, 0xc1, 0x01, 0x00, 0x74, 0x20, 0x61,
|
||||
0x1e, 0x66, 0x31, 0xc0, 0x8e, 0xd8, 0x66, 0x50, 0x66, 0x53, 0x50, 0x68,
|
||||
0x00, 0x7c, 0x40, 0x50, 0x6a, 0x10, 0x89, 0xe6, 0xb4, 0x42, 0xcd, 0x13,
|
||||
0x9f, 0x83, 0xc4, 0x10, 0x9e, 0x1f, 0xc3, 0x61, 0xbb, 0x00, 0x7c, 0xb8,
|
||||
0x01, 0x02, 0xcd, 0x13, 0xc3, 0xfa, 0x8b, 0x1c, 0x26, 0x66, 0x8b, 0x07,
|
||||
0x66, 0x89, 0x04, 0x26, 0x89, 0x17, 0x26, 0x8c, 0x4f, 0x02, 0xfb, 0xc3,
|
||||
0xfa, 0xbb, 0x20, 0x00, 0x66, 0xa1, 0x61, 0x7d, 0x26, 0x66, 0x89, 0x07,
|
||||
0xfb, 0xc3, 0xb4, 0x01, 0xcd, 0x16, 0x74, 0x06, 0xb4, 0x00, 0xcd, 0x16,
|
||||
0xe2, 0xf4, 0xc3, 0xac, 0x3c, 0x00, 0x74, 0x09, 0xb4, 0x0e, 0xbb, 0x07,
|
||||
0x00, 0xcd, 0x10, 0xeb, 0xf2, 0xc3, 0x52, 0x80, 0xe2, 0xfe, 0x80, 0xfa,
|
||||
0x80, 0x5a, 0x75, 0x03, 0x80, 0xf2, 0x01, 0xc3, 0x9c, 0xfa, 0x2e, 0x80,
|
||||
0x3e, 0x76, 0x7d, 0x00, 0x74, 0x0a, 0x2e, 0xfe, 0x0e, 0x77, 0x7d, 0x2e,
|
||||
0xfe, 0x0e, 0x76, 0x7d, 0x9a, 0x20, 0x00, 0x00, 0x00, 0xcf, 0x9c, 0xfa,
|
||||
0xe8, 0xd3, 0xff, 0x9a, 0x4c, 0x00, 0x00, 0x00, 0x9c, 0xe8, 0xca, 0xff,
|
||||
0x9d, 0xcf, 0x49, 0x12, 0x0d, 0x0a, 0x50, 0x72, 0x65, 0x73, 0x73, 0x20,
|
||||
0x61, 0x6e, 0x79, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x74, 0x6f, 0x20, 0x62,
|
||||
0x6f, 0x6f, 0x74, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x55, 0x53, 0x42,
|
||||
0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
|
@ -56,6 +56,7 @@
|
|||
#define IDC_TEST 1015
|
||||
#define IDC_SELECT_ISO 1016
|
||||
#define IDC_SET_ICON 1017
|
||||
#define IDC_RUFUS_MBR 1018
|
||||
#define IDC_ISO_PROGRESS 1020
|
||||
#define IDC_ISO_FILENAME 1021
|
||||
#define IDC_ISO_ABORT 1022
|
||||
|
|
15
src/rufus.c
15
src/rufus.c
|
@ -944,6 +944,7 @@ static void EnableControls(BOOL bEnable)
|
|||
EnableWindow(GetDlgItem(hMainDialog, IDC_SELECT_ISO), bEnable);
|
||||
EnableWindow(GetDlgItem(hMainDialog, IDC_NBPASSES), bEnable);
|
||||
EnableWindow(GetDlgItem(hMainDialog, IDC_SET_ICON), bEnable);
|
||||
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), bEnable);
|
||||
SetDlgItemTextA(hMainDialog, IDCANCEL, bEnable?"Close":"Cancel");
|
||||
}
|
||||
|
||||
|
@ -1050,6 +1051,9 @@ DWORD WINAPI ISOScanThread(LPVOID param)
|
|||
"This ISO image doesn't appear to use either...", "Unsupported ISO", MB_OK|MB_ICONINFORMATION);
|
||||
safe_free(iso_path);
|
||||
} else {
|
||||
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), (iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe)));
|
||||
CheckDlgButton(hMainDialog, IDC_RUFUS_MBR,
|
||||
((iso_report.winpe&WINPE_I386)==WINPE_I386)?BST_CHECKED:BST_UNCHECKED);
|
||||
if (iso_report.has_old_vesamenu) {
|
||||
fd = fopen(vesamenu_filename, "rb");
|
||||
if (fd != NULL) {
|
||||
|
@ -1347,8 +1351,13 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "FreeDOS"), DT_FREEDOS));
|
||||
}
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO));
|
||||
if ((selection_default == DT_ISO) && (iso_path == NULL))
|
||||
selection_default = (bWithFreeDOS)?DT_FREEDOS:DT_WINME;
|
||||
if (selection_default == DT_ISO) {
|
||||
if (iso_path == NULL)
|
||||
selection_default = (bWithFreeDOS)?DT_FREEDOS:DT_WINME;
|
||||
else
|
||||
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR),
|
||||
(iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe)));
|
||||
}
|
||||
for (i=0; i<ComboBox_GetCount(hDOSType); i++) {
|
||||
if (ComboBox_GetItemData(hDOSType, i) == selection_default) {
|
||||
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, i));
|
||||
|
@ -1368,6 +1377,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
if (HIWORD(wParam) != CBN_SELCHANGE)
|
||||
break;
|
||||
if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_ISO) {
|
||||
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), (iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe)));
|
||||
if ((iso_path == NULL) || (iso_report.label[0] == 0)) {
|
||||
// Set focus to the Select ISO button
|
||||
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
|
||||
|
@ -1376,6 +1386,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
SetWindowTextU(hLabel, iso_report.label);
|
||||
}
|
||||
} else {
|
||||
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), TRUE);
|
||||
// Set focus on the start button
|
||||
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
|
||||
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMainDialog, IDC_START), TRUE);
|
||||
|
|
13
src/rufus.rc
13
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 206, 289
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Rufus v1.1.6.156"
|
||||
CAPTION "Rufus v1.1.6.157"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,248,50,14
|
||||
|
@ -60,6 +60,7 @@ BEGIN
|
|||
COMBOBOX IDC_DOSTYPE,119,183,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON
|
||||
PUSHBUTTON "Test",IDC_TEST,62,248,20,14,NOT WS_VISIBLE
|
||||
CONTROL "Rufus MBR",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,173,44,10
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195
|
||||
|
@ -73,7 +74,7 @@ BEGIN
|
|||
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
||||
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
||||
"SysLink",WS_TABSTOP,46,47,114,9
|
||||
LTEXT "Version 1.1.6 (Build 156)",IDC_STATIC,46,19,78,8
|
||||
LTEXT "Version 1.1.6 (Build 157)",IDC_STATIC,46,19,78,8
|
||||
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
|
||||
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
|
||||
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
||||
|
@ -223,8 +224,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,1,6,156
|
||||
PRODUCTVERSION 1,1,6,156
|
||||
FILEVERSION 1,1,6,157
|
||||
PRODUCTVERSION 1,1,6,157
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -241,13 +242,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "akeo.ie"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.1.6.156"
|
||||
VALUE "FileVersion", "1.1.6.157"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.1.6.156"
|
||||
VALUE "ProductVersion", "1.1.6.157"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue