mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
parent
51fb4e339f
commit
98ff7a931a
3 changed files with 35 additions and 26 deletions
47
src/dos.c
47
src/dos.c
|
@ -166,40 +166,51 @@ static void FatDateTimeToSystemTime(PLARGE_INTEGER SystemTime, PFAT_DATETIME Fat
|
||||||
* IO.SYS 000003AA 75 -> EB
|
* IO.SYS 000003AA 75 -> EB
|
||||||
* COMMAND.COM 00006510 75 -> EB
|
* COMMAND.COM 00006510 75 -> EB
|
||||||
*/
|
*/
|
||||||
static BOOL Patch_COMMAND_COM(size_t filestart, size_t filesize)
|
static BOOL Patch_COMMAND_COM(HANDLE hFile)
|
||||||
{
|
{
|
||||||
const BYTE expected[8] = { 0x15, 0x80, 0xFA, 0x03, 0x75, 0x10, 0xB8, 0x0E };
|
const BYTE expected[8] = { 0x15, 0x80, 0xFA, 0x03, 0x75, 0x10, 0xB8, 0x0E };
|
||||||
|
BYTE data[sizeof(expected)] = { 0x00 };
|
||||||
|
DWORD size = sizeof(data);
|
||||||
|
|
||||||
uprintf("Patching COMMAND.COM...\n");
|
uprintf("Patching COMMAND.COM...\n");
|
||||||
if (filesize != 93040) {
|
if (GetFileSize(hFile, NULL) != 93040) {
|
||||||
uprintf(" unexpected file size\n");
|
uprintf(" unexpected file size\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
// See #24: https://github.com/pbatard/rufus/issues/24
|
SetFilePointer(hFile, 0x650c, NULL, FILE_BEGIN);
|
||||||
// uprintf("&DiskImage[filestart(=%x)+0x650c] = %p\n", filestart, &DiskImage[filestart+0x650c]);
|
ReadFile(hFile, data, size, &size, NULL);
|
||||||
// uprintf("&DiskImage[0] = %p\n", &DiskImage[0]);
|
if (memcmp(data, expected, sizeof(expected)) != 0) {
|
||||||
if (memcmp(&DiskImage[filestart+0x650c], expected, sizeof(expected)) != 0) {
|
|
||||||
uprintf(" unexpected binary data\n");
|
uprintf(" unexpected binary data\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
DiskImage[filestart+0x6510] = 0xeb;
|
data[4] = 0xeb;
|
||||||
|
SetFilePointer(hFile, 0x650c, NULL, FILE_BEGIN);
|
||||||
|
size = sizeof(data);
|
||||||
|
WriteFile(hFile, data, size, &size, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL Patch_IO_SYS(size_t filestart, size_t filesize)
|
static BOOL Patch_IO_SYS(HANDLE hFile)
|
||||||
{
|
{
|
||||||
const BYTE expected[8] = { 0xFA, 0x80, 0x75, 0x09, 0x8D, 0xB6, 0x99, 0x00 };
|
const BYTE expected[8] = { 0xFA, 0x80, 0x75, 0x09, 0x8D, 0xB6, 0x99, 0x00 };
|
||||||
|
BYTE data[sizeof(expected)] = { 0x00 };
|
||||||
|
DWORD size = sizeof(data);
|
||||||
|
|
||||||
uprintf("Patching IO.SYS...\n");
|
uprintf("Patching IO.SYS...\n");
|
||||||
if (filesize != 116736) {
|
if (GetFileSize(hFile, NULL) != 116736) {
|
||||||
uprintf(" unexpected file size\n");
|
uprintf(" unexpected file size\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (memcmp(&DiskImage[filestart+0x3a8], expected, sizeof(expected)) != 0) {
|
SetFilePointer(hFile, 0x3a8, NULL, FILE_BEGIN);
|
||||||
|
ReadFile(hFile, data, size, &size, NULL);
|
||||||
|
if (memcmp(data, expected, sizeof(expected)) != 0) {
|
||||||
uprintf(" unexpected binary data\n");
|
uprintf(" unexpected binary data\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
DiskImage[filestart+0x3aa] = 0xeb;
|
data[2] = 0xeb;
|
||||||
|
SetFilePointer(hFile, 0x3a8, NULL, FILE_BEGIN);
|
||||||
|
size = sizeof(data);
|
||||||
|
WriteFile(hFile, data, size, &size, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,13 +256,6 @@ static BOOL ExtractFAT(int entry, const char* path)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WinME DOS files need to be patched */
|
|
||||||
if (strcmp(&filename[fnamepos], "COMMAND.COM") == 0) {
|
|
||||||
Patch_COMMAND_COM(filestart, filesize);
|
|
||||||
} else if (strcmp(&filename[fnamepos], "IO.SYS") == 0) {
|
|
||||||
Patch_IO_SYS(filestart, filesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a file, using the same attributes as found in the FAT */
|
/* Create a file, using the same attributes as found in the FAT */
|
||||||
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||||
NULL, CREATE_ALWAYS, dir_entry->Attributes, 0);
|
NULL, CREATE_ALWAYS, dir_entry->Attributes, 0);
|
||||||
|
@ -266,6 +270,13 @@ static BOOL ExtractFAT(int entry, const char* path)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* WinME DOS files need to be patched */
|
||||||
|
if (strcmp(&filename[fnamepos], "COMMAND.COM") == 0) {
|
||||||
|
Patch_COMMAND_COM(hFile);
|
||||||
|
} else if (strcmp(&filename[fnamepos], "IO.SYS") == 0) {
|
||||||
|
Patch_IO_SYS(hFile);
|
||||||
|
}
|
||||||
|
|
||||||
/* Restore timestamps from FAT */
|
/* Restore timestamps from FAT */
|
||||||
FatDateTimeToSystemTime(&liCreationTime, &dir_entry->CreationDateTime, dir_entry->CreationTimeTenMs);
|
FatDateTimeToSystemTime(&liCreationTime, &dir_entry->CreationDateTime, dir_entry->CreationTimeTenMs);
|
||||||
ftCreationTime.dwHighDateTime = liCreationTime.HighPart;
|
ftCreationTime.dwHighDateTime = liCreationTime.HighPart;
|
||||||
|
|
|
@ -126,8 +126,6 @@ static BOOL SaveIcon(const char* filename)
|
||||||
// Write icon data
|
// Write icon data
|
||||||
offset = 3*sizeof(WORD) + icondir->idCount*sizeof(ICONDIRENTRY);
|
offset = 3*sizeof(WORD) + icondir->idCount*sizeof(ICONDIRENTRY);
|
||||||
for (i=0; i<icondir->idCount; i++) {
|
for (i=0; i<icondir->idCount; i++) {
|
||||||
// wPlanes is set to 0 in the original .ico => fix it
|
|
||||||
icondir->idEntries[i].wPlanes = 0; // NB: this produces an exception which we don't care about
|
|
||||||
// Write the common part of ICONDIRENTRY
|
// Write the common part of ICONDIRENTRY
|
||||||
if ( (!WriteFile(hFile, &icondir->idEntries[i], sizeof(GRPICONDIRENTRY)-sizeof(WORD), &Size, NULL))
|
if ( (!WriteFile(hFile, &icondir->idEntries[i], sizeof(GRPICONDIRENTRY)-sizeof(WORD), &Size, NULL))
|
||||||
|| (Size != sizeof(GRPICONDIRENTRY)-sizeof(WORD)) ) {
|
|| (Size != sizeof(GRPICONDIRENTRY)-sizeof(WORD)) ) {
|
||||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 206, 289
|
IDD_DIALOG DIALOGEX 12, 12, 206, 289
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_APPWINDOW
|
EXSTYLE WS_EX_APPWINDOW
|
||||||
CAPTION "Rufus v1.2.0.162"
|
CAPTION "Rufus v1.2.0.163"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,248,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,248,50,14
|
||||||
|
@ -71,7 +71,7 @@ BEGIN
|
||||||
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
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,
|
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
||||||
"SysLink",WS_TABSTOP,46,47,114,9
|
"SysLink",WS_TABSTOP,46,47,114,9
|
||||||
LTEXT "Version 1.2.0 (Build 162)",IDC_STATIC,46,19,78,8
|
LTEXT "Version 1.2.0 (Build 163)",IDC_STATIC,46,19,78,8
|
||||||
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
|
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
|
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
|
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
||||||
|
@ -216,8 +216,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,2,0,162
|
FILEVERSION 1,2,0,163
|
||||||
PRODUCTVERSION 1,2,0,162
|
PRODUCTVERSION 1,2,0,163
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -234,13 +234,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "akeo.ie"
|
VALUE "CompanyName", "akeo.ie"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "1.2.0.162"
|
VALUE "FileVersion", "1.2.0.163"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011 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", "1.2.0.162"
|
VALUE "ProductVersion", "1.2.0.163"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue