Permalink
Browse files

See: pbatard#870

MS-DOS system files are now loaded from a copy of diskcopy.dll located in the same folder as the Rufus EXE file.
Source a copy of diskcopy.dll from a Win7 or Win8 system.
  • Loading branch information...
ptr727 committed Dec 24, 2016
1 parent d783573 commit 0ac0b5cfe2c03df15d56ae94b7e7e518c8f37213
Showing with 41 additions and 11 deletions.
  1. +2 −0 .gitignore
  2. +33 −7 src/dos.c
  3. +6 −4 src/rufus.c
View
@@ -37,3 +37,5 @@ config.status
config.sub
depcomp
stamp-h1
/rufus.VC.db
/rufus.VC.VC.opendb
View
@@ -30,6 +30,8 @@
#include <stdlib.h>
#include <string.h>
#include "Shlwapi.h"
#include "rufus.h"
#include "missing.h"
#include "resource.h"
@@ -289,7 +291,6 @@ static BOOL ExtractMSDOS(const char* path)
{
char dllname[MAX_PATH] = "C:\\Windows\\System32";
int i, j;
UINT len;
BOOL r = FALSE;
HMODULE hDLL = NULL;
char locale_path[MAX_PATH];
@@ -305,13 +306,38 @@ static BOOL ExtractMSDOS(const char* path)
safe_strcat(locale_path, sizeof(locale_path), "LOCALE\\");
CreateDirectoryA(locale_path, NULL);
len = GetSystemDirectoryA(dllname, sizeof(dllname));
if ((len == 0) || (len >= sizeof(dllname))) {
uprintf("Unable to get system directory: %s\n", WindowsErrorString());
goto out;
// Do not load from system32, load from the current directory
// Source your own copy of the DLL from a Win7 or Win8 system
{
// Get EXE path
char szExePath[_MAX_PATH];
GetModuleFileNameA(NULL, szExePath, _countof(szExePath));
if (GetLastError() != ERROR_SUCCESS)
{
goto out;
}
// Split path
char szDrive[_MAX_DRIVE];
char szDir[_MAX_DIR];
char szFileName[_MAX_FNAME];
char szExt[_MAX_EXT];
errno_t err;
err = _splitpath_s(szExePath, szDrive, _countof(szDrive), szDir, _countof(szDir), szFileName, _countof(szFileName), szExt, _countof(szExt));
if (err != 0)
{
goto out;
}
// Make path
err = _makepath_s(dllname, _countof(dllname), szDrive, szDir, "diskcopy", ".dll");
if (err != 0)
{
goto out;
}
}
safe_strcat(dllname, sizeof(dllname), "\\diskcopy.dll");
hDLL = LoadLibraryA(dllname);
// The DLL comes from a different OS, load it as a resource, not as code
hDLL = LoadLibraryExA(dllname, NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (hDLL == NULL) {
uprintf("Unable to open %s: %s\n", dllname, WindowsErrorString());
goto out;
View
@@ -1752,8 +1752,9 @@ void InitDialog(HWND hDlg)
IGNORE_RETVAL(ComboBox_SetCurSel(hNBPasses, 0));
SetPassesTooltip();
// Fill up the boot type dropdown
if (nWindowsVersion < WINDOWS_10) // The diskcopy.dll with the MS-DOS floppy image was removed in Windows 10
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), BT_MSDOS));
// if (nWindowsVersion < WINDOWS_10) // The diskcopy.dll with the MS-DOS floppy image was removed in Windows 10
// We are going to load DiskCopy.dll from the app folder
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), BT_MSDOS));
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "FreeDOS"), BT_FREEDOS));
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_036)), BT_ISO));
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_095)), BT_IMG));
@@ -1959,8 +1960,9 @@ void SetBoot(int fs, int tt)
IGNORE_RETVAL(ComboBox_ResetContent(hBootType));
if ((tt == TT_BIOS) && (IS_FAT(fs))) {
if (nWindowsVersion < WINDOWS_10) // The diskcopy.dll with the MS-DOS floppy image was removed in Windows 10
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), BT_MSDOS));
// if (nWindowsVersion < WINDOWS_10) // The diskcopy.dll with the MS-DOS floppy image was removed in Windows 10
// We are going to load DiskCopy.dll from the app folder
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), BT_MSDOS));
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "FreeDOS"), BT_FREEDOS));
}
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_036)), BT_ISO));

0 comments on commit 0ac0b5c

Please sign in to comment.