1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] more DLL handling improvements

* also set rufus-next to 1.4.8
This commit is contained in:
Pete Batard 2014-05-12 22:44:10 +01:00
parent 266599e6fd
commit 7a3fb515ea
10 changed files with 111 additions and 173 deletions

20
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for rufus 1.4.7. # Generated by GNU Autoconf 2.68 for rufus 1.4.8.
# #
# Report bugs to <https://github.com/pbatard/rufus/issues>. # Report bugs to <https://github.com/pbatard/rufus/issues>.
# #
@ -560,8 +560,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='rufus' PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus' PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='1.4.7' PACKAGE_VERSION='1.4.8'
PACKAGE_STRING='rufus 1.4.7' PACKAGE_STRING='rufus 1.4.8'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='http://rufus.akeo.ie' PACKAGE_URL='http://rufus.akeo.ie'
@ -1203,7 +1203,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures rufus 1.4.7 to adapt to many kinds of systems. \`configure' configures rufus 1.4.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1269,7 +1269,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of rufus 1.4.7:";; short | recursive ) echo "Configuration of rufus 1.4.8:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1357,7 +1357,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
rufus configure 1.4.7 rufus configure 1.4.8
generated by GNU Autoconf 2.68 generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc. Copyright (C) 2010 Free Software Foundation, Inc.
@ -1412,7 +1412,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 1.4.7, which was It was created by rufus $as_me 1.4.8, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@ $ $0 $@
@ -2227,7 +2227,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='rufus' PACKAGE='rufus'
VERSION='1.4.7' VERSION='1.4.8'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -4140,7 +4140,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by rufus $as_me 1.4.7, which was This file was extended by rufus $as_me 1.4.8, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -4194,7 +4194,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
rufus config.status 1.4.7 rufus config.status 1.4.8
configured by $0, generated by GNU Autoconf 2.68, configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View file

@ -1,4 +1,4 @@
AC_INIT([rufus], [1.4.7], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie]) AC_INIT([rufus], [1.4.8], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies]) AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])

View file

@ -717,8 +717,8 @@ static BOOL FormatDrive(DWORD DriveIndex)
// problems with tolower(). Make sure we restore the locale. For more details, // problems with tolower(). Make sure we restore the locale. For more details,
// see http://comments.gmane.org/gmane.comp.gnu.mingw.user/39300 // see http://comments.gmane.org/gmane.comp.gnu.mingw.user/39300
locale = setlocale(LC_ALL, NULL); locale = setlocale(LC_ALL, NULL);
PF_INIT_OR_OUT(FormatEx, fmifs); PF_INIT_OR_OUT(FormatEx, Fmifs);
PF_INIT(EnableVolumeCompression, fmifs); PF_INIT(EnableVolumeCompression, Fmifs);
setlocale(LC_ALL, locale); setlocale(LC_ALL, locale);
GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType)); GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType));
@ -782,7 +782,7 @@ static BOOL CheckDisk(char DriveLetter)
wDriveRoot[0] = (WCHAR)DriveLetter; wDriveRoot[0] = (WCHAR)DriveLetter;
PrintStatus(0, TRUE, MSG_223); PrintStatus(0, TRUE, MSG_223);
PF_INIT_OR_OUT(Chkdsk, fmifs); PF_INIT_OR_OUT(Chkdsk, Fmifs);
GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType)); GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType));
// We may have a " (Default)" trail // We may have a " (Default)" trail
@ -1218,10 +1218,11 @@ DWORD WINAPI FormatThread(void* param)
char logfile[MAX_PATH], *userdir; char logfile[MAX_PATH], *userdir;
char wim_image[] = "?:\\sources\\install.wim"; char wim_image[] = "?:\\sources\\install.wim";
char efi_dst[] = "?:\\efi\\boot\\bootx64.efi"; char efi_dst[] = "?:\\efi\\boot\\bootx64.efi";
PF_DECL(GetThreadUILanguage);
PF_DECL(SetThreadUILanguage); PF_TYPE_DECL(WINAPI, LANGID, GetThreadUILanguage, (void));
PF_INIT(GetThreadUILanguage, kernel32); PF_TYPE_DECL(WINAPI, LANGID, SetThreadUILanguage, (LANGID));
PF_INIT(SetThreadUILanguage, kernel32); PF_INIT(GetThreadUILanguage, Kernel32);
PF_INIT(SetThreadUILanguage, Kernel32);
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));

View file

@ -154,7 +154,3 @@ typedef struct {
#define die(msg, err) do { uprintf(msg); \ #define die(msg, err) do { uprintf(msg); \
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|err; \ FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|err; \
goto out; } while(0) goto out; } while(0)
/* Locale */
typedef LANGID (WINAPI *SetThreadUILanguage_t)(LANGID LangId);
typedef LANGID (WINAPI *GetThreadUILanguage_t)(void);

View file

@ -67,45 +67,26 @@
#define DBT_CUSTOMEVENT 0x8006 #define DBT_CUSTOMEVENT 0x8006
#endif #endif
// MinGW fails to link those...
typedef HIMAGELIST (WINAPI *ImageList_Create_t)(
int cx,
int cy,
UINT flags,
int cInitial,
int cGrow
);
ImageList_Create_t pImageList_Create = NULL;
typedef int (WINAPI *ImageList_ReplaceIcon_t)(
HIMAGELIST himl,
int i,
HICON hicon
);
ImageList_ReplaceIcon_t pImageList_ReplaceIcon = NULL;
struct { struct {
HIMAGELIST himl; HIMAGELIST himl;
RECT margin; RECT margin;
UINT uAlign; UINT uAlign;
} bi_iso = {0}, bi_up = {0}, bi_down = {0}, bi_lang = {0}; // BUTTON_IMAGELIST } bi_iso = {0}, bi_up = {0}, bi_down = {0}, bi_lang = {0}; // BUTTON_IMAGELIST
// ...and MinGW doesn't know these.
typedef struct typedef struct
{ {
LPCITEMIDLIST pidl; LPCITEMIDLIST pidl;
BOOL fRecursive; BOOL fRecursive;
} MY_SHChangeNotifyEntry; } MY_SHChangeNotifyEntry;
typedef BOOL (WINAPI *SHChangeNotifyDeregister_t)( // MinGW doesn't know these
ULONG ulID PF_TYPE(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int));
); PF_TYPE(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON));
typedef ULONG (WINAPI *SHChangeNotifyRegister_t)( // WDK blows up when trying to using PF_TYPE_DECL() for the ImageList calls... so we don't.
HWND hwnd, PF_DECL(ImageList_Create);
int fSources, PF_DECL(ImageList_ReplaceIcon);
LONG fEvents, PF_TYPE_DECL(WINAPI, BOOL, SHChangeNotifyDeregister, (ULONG));
UINT wMsg, PF_TYPE_DECL(WINAPI, ULONG, SHChangeNotifyRegister, (HWND, int, LONG, UINT, int, const MY_SHChangeNotifyEntry*));
int cEntries,
const MY_SHChangeNotifyEntry *pshcne
);
const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "UDF", "exFAT", "ReFS" }; const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "UDF", "exFAT", "ReFS" };
// Number of steps for each FS for FCC_STRUCTURE_PROGRESS // Number of steps for each FS for FCC_STRUCTURE_PROGRESS
@ -130,7 +111,7 @@ char msgbox[1024], msgbox_title[32];
/* /*
* Globals * Globals
*/ */
OPEN_LIBRARIES_TRACKING_VARS; OPENED_LIBRARIES_VARS;
HINSTANCE hMainInstance; HINSTANCE hMainInstance;
HWND hMainDialog; HWND hMainDialog;
char szFolderPath[MAX_PATH], app_dir[MAX_PATH]; char szFolderPath[MAX_PATH], app_dir[MAX_PATH];
@ -1650,7 +1631,7 @@ void InitDialog(HWND hDlg)
CheckDlgButton(hDlg, IDC_SET_ICON, BST_CHECKED); CheckDlgButton(hDlg, IDC_SET_ICON, BST_CHECKED);
// Load system icons (NB: Use the excellent http://www.nirsoft.net/utils/iconsext.html to find icon IDs) // Load system icons (NB: Use the excellent http://www.nirsoft.net/utils/iconsext.html to find icon IDs)
hDllInst = GetDLLHandle("shell32.dll"); hDllInst = GetLibraryHandle("Shell32");
hIconDisc = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(12), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR|LR_SHARED); hIconDisc = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(12), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR|LR_SHARED);
hIconLang = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(244), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR|LR_SHARED); hIconLang = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(244), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR|LR_SHARED);
if (nWindowsVersion >= WINDOWS_VISTA) { if (nWindowsVersion >= WINDOWS_VISTA) {
@ -1662,29 +1643,31 @@ void InitDialog(HWND hDlg)
} }
// Set the icons on the the buttons // Set the icons on the the buttons
pImageList_Create = (ImageList_Create_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_Create"); PF_INIT(ImageList_Create, Comctl32);
pImageList_ReplaceIcon = (ImageList_ReplaceIcon_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_ReplaceIcon"); PF_INIT(ImageList_ReplaceIcon, Comctl32);
if ((pfImageList_Create != NULL) && (pfImageList_ReplaceIcon != NULL)) {
bi_iso.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); bi_iso.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
pImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc); pfImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc);
SetRect(&bi_iso.margin, 0, 1, 0, 0); SetRect(&bi_iso.margin, 0, 1, 0, 0);
bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
bi_lang.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); bi_lang.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
pImageList_ReplaceIcon(bi_lang.himl, -1, hIconLang); pfImageList_ReplaceIcon(bi_lang.himl, -1, hIconLang);
SetRect(&bi_lang.margin, 0, 1, 0, 0); SetRect(&bi_lang.margin, 0, 1, 0, 0);
bi_lang.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; bi_lang.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
bi_down.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); bi_down.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
pImageList_ReplaceIcon(bi_down.himl, -1, hIconDown); pfImageList_ReplaceIcon(bi_down.himl, -1, hIconDown);
SetRect(&bi_down.margin, 0, 0, 0, 0); SetRect(&bi_down.margin, 0, 0, 0, 0);
bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
bi_up.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); bi_up.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
pImageList_ReplaceIcon(bi_up.himl, -1, hIconUp); pfImageList_ReplaceIcon(bi_up.himl, -1, hIconUp);
SetRect(&bi_up.margin, 0, 0, 0, 0); SetRect(&bi_up.margin, 0, 0, 0, 0);
bi_up.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; bi_up.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
SendMessage(hSelectISO, BCM_SETIMAGELIST, 0, (LPARAM)&bi_iso); SendMessage(hSelectISO, BCM_SETIMAGELIST, 0, (LPARAM)&bi_iso);
SendMessage(GetDlgItem(hDlg, IDC_LANG), BCM_SETIMAGELIST, 0, (LPARAM)&bi_lang); SendMessage(GetDlgItem(hDlg, IDC_LANG), BCM_SETIMAGELIST, 0, (LPARAM)&bi_lang);
SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)&bi_down); SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)&bi_down);
}
// Set the various tooltips // Set the various tooltips
CreateTooltip(hFileSystem, lmprintf(MSG_157), -1); CreateTooltip(hFileSystem, lmprintf(MSG_157), -1);
@ -1804,8 +1787,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
static LPITEMIDLIST pidlDesktop = NULL; static LPITEMIDLIST pidlDesktop = NULL;
static MY_SHChangeNotifyEntry NotifyEntry; static MY_SHChangeNotifyEntry NotifyEntry;
loc_cmd* lcmd = NULL; loc_cmd* lcmd = NULL;
PF_DECL(SHChangeNotifyRegister);
PF_DECL(SHChangeNotifyDeregister);
switch (message) { switch (message) {
@ -1908,7 +1889,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
switch(LOWORD(wParam)) { switch(LOWORD(wParam)) {
case IDOK: // close application case IDOK: // close application
case IDCANCEL: case IDCANCEL:
PF_INIT(SHChangeNotifyDeregister, shell32); PF_INIT(SHChangeNotifyDeregister, Shell32);
EnableWindow(GetDlgItem(hISOProgressDlg, IDC_ISO_ABORT), FALSE); EnableWindow(GetDlgItem(hISOProgressDlg, IDC_ISO_ABORT), FALSE);
EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE); EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE);
if (format_thid != NULL) { if (format_thid != NULL) {
@ -2306,7 +2287,6 @@ static void DetachConsole(void)
/* /*
* Application Entrypoint * Application Entrypoint
*/ */
typedef int (CDECL *__wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*);
#if defined(_MSC_VER) && (_MSC_VER >= 1600) #if defined(_MSC_VER) && (_MSC_VER >= 1600)
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
#else #else
@ -2322,7 +2302,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
char tmp_path[MAX_PATH] = "", loc_file[MAX_PATH] = "", *tmp, *locale_name = NULL; char tmp_path[MAX_PATH] = "", loc_file[MAX_PATH] = "", *tmp, *locale_name = NULL;
char** argv = NULL; char** argv = NULL;
wchar_t **wenv, **wargv; wchar_t **wenv, **wargv;
PF_DECL(__wgetmainargs); PF_TYPE_DECL(CDECL, int, __wgetmainargs, (int*, wchar_t***, wchar_t***, int, int*));
HANDLE mutex = NULL, hFile = NULL; HANDLE mutex = NULL, hFile = NULL;
HWND hDlg = NULL; HWND hDlg = NULL;
MSG msg; MSG msg;
@ -2354,7 +2334,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
} }
// We have to process the arguments before we acquire the lock and process the locale // We have to process the arguments before we acquire the lock and process the locale
PF_INIT(__wgetmainargs, msvcrt); PF_INIT(__wgetmainargs, Msvcrt);
if (pf__wgetmainargs != NULL) { if (pf__wgetmainargs != NULL) {
pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si); pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si);
argv = (char**)calloc(argc, sizeof(char*)); argv = (char**)calloc(argc, sizeof(char*));
@ -2462,7 +2442,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)); IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
// Some dialogs have Rich Edit controls and won't display without this // Some dialogs have Rich Edit controls and won't display without this
if (GetDLLHandle("Riched20.dll") == NULL) { if (GetLibraryHandle("Riched20") == NULL) {
uprintf("Could not load RichEdit library - some dialogs may not display: %s\n", WindowsErrorString()); uprintf("Could not load RichEdit library - some dialogs may not display: %s\n", WindowsErrorString());
} }
@ -2644,7 +2624,7 @@ out:
if (attached_console) if (attached_console)
DetachConsole(); DetachConsole();
CloseHandle(mutex); CloseHandle(mutex);
OPEN_LIBRARIES_CLOSE_ALL; CLOSE_OPENED_LIBRARIES;
uprintf("*** " APPLICATION_NAME " exit ***\n"); uprintf("*** " APPLICATION_NAME " exit ***\n");
#ifdef _CRTDBG_MAP_ALLOC #ifdef _CRTDBG_MAP_ALLOC
_CrtDumpMemoryLeaks(); _CrtDumpMemoryLeaks();

View file

@ -395,36 +395,37 @@ extern void StrArrayDestroy(StrArray* arr);
* which translates to: * which translates to:
* FormatEx_t pfFormatEx = NULL; * FormatEx_t pfFormatEx = NULL;
* in your code, to declare the entrypoint and then use: * in your code, to declare the entrypoint and then use:
* PF_INIT(FormatEx, fmifs); * PF_INIT(FormatEx, Fmifs);
* which translates to: * which translates to:
* pfFormatEx = (FormatEx_t) GetProcAddress(GetDLLHandle("fmifs"), "FormatEx"); * pfFormatEx = (FormatEx_t) GetProcAddress(GetDLLHandle("fmifs"), "FormatEx");
* to make it accessible. * to make it accessible.
*/ */
#define MAX_LIBRARY_HANDLES 32 #define MAX_LIBRARY_HANDLES 32
extern HMODULE OpenLibraryHandle[MAX_LIBRARY_HANDLES]; extern HMODULE OpenedLibrariesHandle[MAX_LIBRARY_HANDLES];
extern uint16_t OpenLibraryHandleSize; extern uint16_t OpenedLibrariesHandleSize;
#define OPEN_LIBRARIES_TRACKING_VARS HMODULE OpenLibraryHandle[MAX_LIBRARY_HANDLES]; uint16_t OpenLibraryHandleSize = 0 #define OPENED_LIBRARIES_VARS HMODULE OpenedLibrariesHandle[MAX_LIBRARY_HANDLES]; uint16_t OpenedLibrariesHandleSize = 0
#define OPEN_LIBRARIES_CLOSE_ALL while(OpenLibraryHandleSize > 0) FreeLibrary(OpenLibraryHandle[--OpenLibraryHandleSize]) #define CLOSE_OPENED_LIBRARIES while(OpenedLibrariesHandleSize > 0) FreeLibrary(OpenedLibrariesHandle[--OpenedLibrariesHandleSize])
static __inline HMODULE GetDLLHandle(char* szDLLName) static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
{
HMODULE h = NULL; HMODULE h = NULL;
if ((h = GetModuleHandleA(szDLLName)) == NULL) { if ((h = GetModuleHandleA(szLibraryName)) == NULL) {
if (OpenLibraryHandleSize >= MAX_LIBRARY_HANDLES) { if (OpenedLibrariesHandleSize >= MAX_LIBRARY_HANDLES) {
uprintf("Error: MAX_LIBRARY_HANDLES is too small\n"); uprintf("Error: MAX_LIBRARY_HANDLES is too small\n");
} else { } else {
h = LoadLibraryA(szDLLName); h = LoadLibraryA(szLibraryName);
if (h != NULL) if (h != NULL)
OpenLibraryHandle[OpenLibraryHandleSize++] = h; OpenedLibrariesHandle[OpenedLibrariesHandleSize++] = h;
} }
} }
return h; return h;
} }
#define PF_DECL(proc) proc##_t pf##proc = NULL #define PF_TYPE(api, ret, proc, args) typedef ret (api *proc##_t)args
#define PF_INIT(proc, dllname) pf##proc = (proc##_t) GetProcAddress(GetDLLHandle(#dllname), #proc) #define PF_DECL(proc) static proc##_t pf##proc = NULL
#define PF_INIT_OR_OUT(proc, dllname) \ #define PF_TYPE_DECL(api, ret, proc, args) PF_TYPE(api, ret, proc, args); PF_DECL(proc)
PF_INIT(proc, dllname); if (pf##proc == NULL) { \ #define PF_INIT(proc, name) if (pf##proc == NULL) pf##proc = \
uprintf("Unable to locate %s() in %s.dll: %s\n", #proc, #dllname, \ (proc##_t) GetProcAddress(GetLibraryHandle(#name), #proc)
WindowsErrorString()); goto out; } #define PF_INIT_OR_OUT(proc, name) do {PF_INIT(proc, name); \
if (pf##proc == NULL) {uprintf("Unable to locate %s() in %s.dll: %s\n", \
#proc, #name, WindowsErrorString()); goto out;} } while(0)
/* Clang/MinGW32 has an issue with intptr_t */ /* Clang/MinGW32 has an issue with intptr_t */
#ifndef _UINTPTR_T_DEFINED #ifndef _UINTPTR_T_DEFINED

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329 IDD_DIALOG DIALOGEX 12, 12, 206, 329
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
CAPTION "Rufus 1.4.7.461" CAPTION "Rufus 1.4.8.462"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -165,7 +165,7 @@ END
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329 RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
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_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
CAPTION "Rufus 1.4.7.461" CAPTION "Rufus 1.4.8.462"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -427,8 +427,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,7,461 FILEVERSION 1,4,8,462
PRODUCTVERSION 1,4,7,461 PRODUCTVERSION 1,4,8,462
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -445,13 +445,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", "1.4.7.461" VALUE "FileVersion", "1.4.8.462"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2014 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.4.7.461" VALUE "ProductVersion", "1.4.8.462"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -35,13 +35,12 @@ char WindowsVersionStr[128] = "Windows ";
BOOL is_x64(void) BOOL is_x64(void)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
BOOL (__stdcall *pIsWow64Process)(HANDLE, PBOOL) = NULL; PF_TYPE_DECL(__stdcall, BOOL, IsWow64Process, (HANDLE, PBOOL));
// Detect if we're running a 32 or 64 bit system // Detect if we're running a 32 or 64 bit system
if (sizeof(uintptr_t) < 8) { if (sizeof(uintptr_t) < 8) {
pIsWow64Process = (BOOL (__stdcall *)(HANDLE, PBOOL)) PF_INIT(IsWow64Process, Kernel32);
GetProcAddress(GetDLLHandle("KERNEL32"), "IsWow64Process"); if (pfIsWow64Process != NULL) {
if (pIsWow64Process != NULL) { (*pfIsWow64Process)(GetCurrentProcess(), &ret);
(*pIsWow64Process)(GetCurrentProcess(), &ret);
} }
} else { } else {
ret = TRUE; ret = TRUE;

View file

@ -41,21 +41,13 @@
#include "license.h" #include "license.h"
#include "localization.h" #include "localization.h"
/* The following is only available on Vista and later */
#if (_WIN32_WINNT >= 0x0600) #if (_WIN32_WINNT >= 0x0600)
static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR, IBindCtx*, REFIID, void **) = NULL; PF_TYPE_DECL(WINAPI, HRESULT, SHCreateItemFromParsingName, (PCWSTR, IBindCtx*, REFIID, void **));
#endif #endif
#define INIT_VISTA_SHELL32 if (pSHCreateItemFromParsingName == NULL) { \ PF_TYPE_DECL(WINAPI, LPITEMIDLIST, SHSimpleIDListFromPath, (PCWSTR pszPath));
pSHCreateItemFromParsingName = (HRESULT (WINAPI *)(PCWSTR, IBindCtx*, REFIID, void **)) \ #define INIT_VISTA_SHELL32 PF_INIT(SHCreateItemFromParsingName, Shell32)
GetProcAddress(GetDLLHandle("SHELL32"), "SHCreateItemFromParsingName"); \ #define INIT_XP_SHELL32 PF_INIT(SHSimpleIDListFromPath, Shell32)
} #define IS_VISTA_SHELL32_AVAILABLE (pfSHCreateItemFromParsingName != NULL)
#define IS_VISTA_SHELL32_AVAILABLE (pSHCreateItemFromParsingName != NULL)
// And this one is simply not available in MinGW32
static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPath)(PCWSTR pszPath) = NULL;
#define INIT_XP_SHELL32 if (pSHSimpleIDListFromPath == NULL) { \
pSHSimpleIDListFromPath = (LPITEMIDLIST (WINAPI *)(PCWSTR)) \
GetProcAddress(GetDLLHandle("SHELL32"), "SHSimpleIDListFromPath"); \
}
/* Globals */ /* Globals */
static HICON hMessageIcon = (HICON)INVALID_HANDLE_VALUE; static HICON hMessageIcon = (HICON)INVALID_HANDLE_VALUE;
@ -108,7 +100,7 @@ INT CALLBACK BrowseInfoCallback(HWND hDlg, UINT message, LPARAM lParam, LPARAM p
} else { } else {
// On Windows 7, MinGW only properly selects the specified folder when using a pidl // On Windows 7, MinGW only properly selects the specified folder when using a pidl
wpath = utf8_to_wchar(szFolderPath); wpath = utf8_to_wchar(szFolderPath);
pidl = (*pSHSimpleIDListFromPath)(wpath); pidl = (*pfSHSimpleIDListFromPath)(wpath);
safe_free(wpath); safe_free(wpath);
// NB: see http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7 // NB: see http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7
// for details as to why we send BFFM_SETSELECTION twice. // for details as to why we send BFFM_SETSELECTION twice.
@ -178,7 +170,7 @@ void BrowseForFolder(void) {
} }
} }
hr = (*pSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path); hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
if (wpath != NULL) { if (wpath != NULL) {
hr = pfod->lpVtbl->SetFolder(pfod, si_path); hr = pfod->lpVtbl->SetFolder(pfod, si_path);
@ -294,7 +286,7 @@ char* FileDialog(BOOL save, char* path, char* filename, char* ext, char* ext_des
// Set the default directory // Set the default directory
wpath = utf8_to_wchar(path); wpath = utf8_to_wchar(path);
hr = (*pSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID) &si_path); hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID) &si_path);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
pfd->lpVtbl->SetFolder(pfd, si_path); pfd->lpVtbl->SetFolder(pfd, si_path);
} }

View file

@ -27,45 +27,14 @@
static BOOL has_wimgapi = FALSE, has_7z = FALSE; static BOOL has_wimgapi = FALSE, has_7z = FALSE;
static char sevenzip_path[MAX_PATH]; static char sevenzip_path[MAX_PATH];
// WIM API Prototypes
#define WIM_GENERIC_READ GENERIC_READ #define WIM_GENERIC_READ GENERIC_READ
#define WIM_OPEN_EXISTING OPEN_EXISTING #define WIM_OPEN_EXISTING OPEN_EXISTING
PF_TYPE_DECL(WINAPI, HANDLE, WIMCreateFile, (PWSTR, DWORD, DWORD, DWORD, DWORD, PDWORD));
typedef HANDLE (WINAPI *WIMCreateFile_t)( PF_TYPE_DECL(WINAPI, BOOL, WIMSetTemporaryPath, (HANDLE, PWSTR));
PWSTR pszWimPath, PF_TYPE_DECL(WINAPI, HANDLE, WIMLoadImage, (HANDLE, DWORD));
DWORD dwDesiredAccess, PF_TYPE_DECL(WINAPI, BOOL, WIMExtractImagePath, (HANDLE, PWSTR, PWSTR, DWORD));
DWORD dwCreationDisposition, PF_TYPE_DECL(WINAPI, BOOL, WIMCloseHandle, (HANDLE));
DWORD dwFlagsAndAttributes,
DWORD dwCompressionType,
PDWORD pdwCreationResult
);
typedef BOOL (WINAPI *WIMSetTemporaryPath_t)(
HANDLE hWim,
PWSTR pszPath
);
typedef HANDLE (WINAPI *WIMLoadImage_t)(
HANDLE hWim,
DWORD dwImageIndex
);
typedef BOOL (WINAPI *WIMExtractImagePath_t)(
HANDLE hImage,
PWSTR pszImagePath,
PWSTR pszDestinationPath,
DWORD dwExtractFlags
);
typedef BOOL (WINAPI *WIMCloseHandle_t)(
HANDLE hObj
);
// WIM API Prototypes
static PF_DECL(WIMCreateFile);
static PF_DECL(WIMSetTemporaryPath);
static PF_DECL(WIMLoadImage);
static PF_DECL(WIMExtractImagePath);
static PF_DECL(WIMCloseHandle);
static BOOL Get7ZipPath(void) static BOOL Get7ZipPath(void)
{ {
@ -80,11 +49,11 @@ static BOOL Get7ZipPath(void)
// Find out if we have any way to extraxt WIM files on this platform // Find out if we have any way to extraxt WIM files on this platform
BOOL WimExtractCheck(void) BOOL WimExtractCheck(void)
{ {
PF_INIT(WIMCreateFile, wimgapi); PF_INIT(WIMCreateFile, Wimgapi);
PF_INIT(WIMSetTemporaryPath, wimgapi); PF_INIT(WIMSetTemporaryPath, Wimgapi);
PF_INIT(WIMLoadImage, wimgapi); PF_INIT(WIMLoadImage, Wimgapi);
PF_INIT(WIMExtractImagePath, wimgapi); PF_INIT(WIMExtractImagePath, Wimgapi);
PF_INIT(WIMCloseHandle, wimgapi); PF_INIT(WIMCloseHandle, Wimgapi);
has_wimgapi = (pfWIMCreateFile && pfWIMSetTemporaryPath && pfWIMLoadImage && pfWIMExtractImagePath && pfWIMCloseHandle); has_wimgapi = (pfWIMCreateFile && pfWIMSetTemporaryPath && pfWIMLoadImage && pfWIMExtractImagePath && pfWIMCloseHandle);
has_7z = Get7ZipPath(); has_7z = Get7ZipPath();
@ -109,11 +78,11 @@ static BOOL WimExtractFile_API(const char* image, int index, const char* src, co
wchar_t* wsrc = utf8_to_wchar(src); wchar_t* wsrc = utf8_to_wchar(src);
wchar_t* wdst = utf8_to_wchar(dst); wchar_t* wdst = utf8_to_wchar(dst);
PF_INIT_OR_OUT(WIMCreateFile, wimgapi); PF_INIT_OR_OUT(WIMCreateFile, Wimgapi);
PF_INIT_OR_OUT(WIMSetTemporaryPath, wimgapi); PF_INIT_OR_OUT(WIMSetTemporaryPath, Wimgapi);
PF_INIT_OR_OUT(WIMLoadImage, wimgapi); PF_INIT_OR_OUT(WIMLoadImage, Wimgapi);
PF_INIT_OR_OUT(WIMExtractImagePath, wimgapi); PF_INIT_OR_OUT(WIMExtractImagePath, Wimgapi);
PF_INIT_OR_OUT(WIMCloseHandle, wimgapi); PF_INIT_OR_OUT(WIMCloseHandle, Wimgapi);
uprintf("Opening: %s:[%d] (API)\n", image, index); uprintf("Opening: %s:[%d] (API)\n", image, index);
if (GetTempPathW(ARRAYSIZE(wtemp), wtemp) == 0) { if (GetTempPathW(ARRAYSIZE(wtemp), wtemp) == 0) {