diff --git a/configure b/configure index 76e2f77c..9ca50685 100644 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # 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 . # @@ -560,8 +560,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rufus' PACKAGE_TARNAME='rufus' -PACKAGE_VERSION='1.4.7' -PACKAGE_STRING='rufus 1.4.7' +PACKAGE_VERSION='1.4.8' +PACKAGE_STRING='rufus 1.4.8' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' 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. # This message is too long to be a string in the A/UX 3.1 sh. 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]... @@ -1269,7 +1269,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of rufus 1.4.7:";; + short | recursive ) echo "Configuration of rufus 1.4.8:";; esac cat <<\_ACEOF @@ -1357,7 +1357,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -rufus configure 1.4.7 +rufus configure 1.4.8 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1412,7 +1412,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while 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 $ $0 $@ @@ -2227,7 +2227,7 @@ fi # Define the identity of the package. PACKAGE='rufus' - VERSION='1.4.7' + VERSION='1.4.8' 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 # values after options handling. 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 CONFIG_FILES = $CONFIG_FILES @@ -4194,7 +4194,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -rufus config.status 1.4.7 +rufus config.status 1.4.8 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 99f55361..aa750e2d 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/src/format.c b/src/format.c index 90be956a..27e76bb4 100644 --- a/src/format.c +++ b/src/format.c @@ -717,8 +717,8 @@ static BOOL FormatDrive(DWORD DriveIndex) // problems with tolower(). Make sure we restore the locale. For more details, // see http://comments.gmane.org/gmane.comp.gnu.mingw.user/39300 locale = setlocale(LC_ALL, NULL); - PF_INIT_OR_OUT(FormatEx, fmifs); - PF_INIT(EnableVolumeCompression, fmifs); + PF_INIT_OR_OUT(FormatEx, Fmifs); + PF_INIT(EnableVolumeCompression, Fmifs); setlocale(LC_ALL, locale); GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType)); @@ -782,7 +782,7 @@ static BOOL CheckDisk(char DriveLetter) wDriveRoot[0] = (WCHAR)DriveLetter; PrintStatus(0, TRUE, MSG_223); - PF_INIT_OR_OUT(Chkdsk, fmifs); + PF_INIT_OR_OUT(Chkdsk, Fmifs); GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType)); // We may have a " (Default)" trail @@ -1218,10 +1218,11 @@ DWORD WINAPI FormatThread(void* param) char logfile[MAX_PATH], *userdir; char wim_image[] = "?:\\sources\\install.wim"; char efi_dst[] = "?:\\efi\\boot\\bootx64.efi"; - PF_DECL(GetThreadUILanguage); - PF_DECL(SetThreadUILanguage); - PF_INIT(GetThreadUILanguage, kernel32); - PF_INIT(SetThreadUILanguage, kernel32); + + PF_TYPE_DECL(WINAPI, LANGID, GetThreadUILanguage, (void)); + PF_TYPE_DECL(WINAPI, LANGID, SetThreadUILanguage, (LANGID)); + PF_INIT(GetThreadUILanguage, Kernel32); + PF_INIT(SetThreadUILanguage, Kernel32); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); diff --git a/src/format.h b/src/format.h index bfedab96..c66fb09b 100644 --- a/src/format.h +++ b/src/format.h @@ -154,7 +154,3 @@ typedef struct { #define die(msg, err) do { uprintf(msg); \ FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|err; \ goto out; } while(0) - -/* Locale */ -typedef LANGID (WINAPI *SetThreadUILanguage_t)(LANGID LangId); -typedef LANGID (WINAPI *GetThreadUILanguage_t)(void); diff --git a/src/rufus.c b/src/rufus.c index c29571b3..b41ecf41 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -67,45 +67,26 @@ #define DBT_CUSTOMEVENT 0x8006 #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 { HIMAGELIST himl; RECT margin; UINT uAlign; } bi_iso = {0}, bi_up = {0}, bi_down = {0}, bi_lang = {0}; // BUTTON_IMAGELIST -// ...and MinGW doesn't know these. typedef struct { LPCITEMIDLIST pidl; - BOOL fRecursive; + BOOL fRecursive; } MY_SHChangeNotifyEntry; -typedef BOOL (WINAPI *SHChangeNotifyDeregister_t)( - ULONG ulID -); -typedef ULONG (WINAPI *SHChangeNotifyRegister_t)( - HWND hwnd, - int fSources, - LONG fEvents, - UINT wMsg, - int cEntries, - const MY_SHChangeNotifyEntry *pshcne -); +// MinGW doesn't know these +PF_TYPE(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int)); +PF_TYPE(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON)); +// WDK blows up when trying to using PF_TYPE_DECL() for the ImageList calls... so we don't. +PF_DECL(ImageList_Create); +PF_DECL(ImageList_ReplaceIcon); +PF_TYPE_DECL(WINAPI, BOOL, SHChangeNotifyDeregister, (ULONG)); +PF_TYPE_DECL(WINAPI, ULONG, SHChangeNotifyRegister, (HWND, int, LONG, UINT, int, const MY_SHChangeNotifyEntry*)); const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "UDF", "exFAT", "ReFS" }; // Number of steps for each FS for FCC_STRUCTURE_PROGRESS @@ -130,7 +111,7 @@ char msgbox[1024], msgbox_title[32]; /* * Globals */ -OPEN_LIBRARIES_TRACKING_VARS; +OPENED_LIBRARIES_VARS; HINSTANCE hMainInstance; HWND hMainDialog; char szFolderPath[MAX_PATH], app_dir[MAX_PATH]; @@ -1650,7 +1631,7 @@ void InitDialog(HWND hDlg) 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) - hDllInst = GetDLLHandle("shell32.dll"); + hDllInst = GetLibraryHandle("Shell32"); 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); if (nWindowsVersion >= WINDOWS_VISTA) { @@ -1662,29 +1643,31 @@ void InitDialog(HWND hDlg) } // Set the icons on the the buttons - pImageList_Create = (ImageList_Create_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_Create"); - pImageList_ReplaceIcon = (ImageList_ReplaceIcon_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_ReplaceIcon"); + PF_INIT(ImageList_Create, Comctl32); + 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); - pImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc); - SetRect(&bi_iso.margin, 0, 1, 0, 0); - bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - bi_lang.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); - pImageList_ReplaceIcon(bi_lang.himl, -1, hIconLang); - SetRect(&bi_lang.margin, 0, 1, 0, 0); - bi_lang.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - bi_down.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); - pImageList_ReplaceIcon(bi_down.himl, -1, hIconDown); - SetRect(&bi_down.margin, 0, 0, 0, 0); - bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - bi_up.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); - pImageList_ReplaceIcon(bi_up.himl, -1, hIconUp); - SetRect(&bi_up.margin, 0, 0, 0, 0); - bi_up.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_iso.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + pfImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc); + SetRect(&bi_iso.margin, 0, 1, 0, 0); + bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_lang.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + pfImageList_ReplaceIcon(bi_lang.himl, -1, hIconLang); + SetRect(&bi_lang.margin, 0, 1, 0, 0); + bi_lang.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_down.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + pfImageList_ReplaceIcon(bi_down.himl, -1, hIconDown); + SetRect(&bi_down.margin, 0, 0, 0, 0); + bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_up.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + pfImageList_ReplaceIcon(bi_up.himl, -1, hIconUp); + SetRect(&bi_up.margin, 0, 0, 0, 0); + bi_up.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - SendMessage(hSelectISO, BCM_SETIMAGELIST, 0, (LPARAM)&bi_iso); - SendMessage(GetDlgItem(hDlg, IDC_LANG), BCM_SETIMAGELIST, 0, (LPARAM)&bi_lang); - SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)&bi_down); + SendMessage(hSelectISO, BCM_SETIMAGELIST, 0, (LPARAM)&bi_iso); + SendMessage(GetDlgItem(hDlg, IDC_LANG), BCM_SETIMAGELIST, 0, (LPARAM)&bi_lang); + SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)&bi_down); + } // Set the various tooltips 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 MY_SHChangeNotifyEntry NotifyEntry; loc_cmd* lcmd = NULL; - PF_DECL(SHChangeNotifyRegister); - PF_DECL(SHChangeNotifyDeregister); switch (message) { @@ -1908,7 +1889,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA switch(LOWORD(wParam)) { case IDOK: // close application case IDCANCEL: - PF_INIT(SHChangeNotifyDeregister, shell32); + PF_INIT(SHChangeNotifyDeregister, Shell32); EnableWindow(GetDlgItem(hISOProgressDlg, IDC_ISO_ABORT), FALSE); EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE); if (format_thid != NULL) { @@ -2306,7 +2287,6 @@ static void DetachConsole(void) /* * Application Entrypoint */ -typedef int (CDECL *__wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*); #if defined(_MSC_VER) && (_MSC_VER >= 1600) int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) #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** argv = NULL; 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; HWND hDlg = NULL; 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 - PF_INIT(__wgetmainargs, msvcrt); + PF_INIT(__wgetmainargs, Msvcrt); if (pf__wgetmainargs != NULL) { pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si); 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)); // 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()); } @@ -2644,7 +2624,7 @@ out: if (attached_console) DetachConsole(); CloseHandle(mutex); - OPEN_LIBRARIES_CLOSE_ALL; + CLOSE_OPENED_LIBRARIES; uprintf("*** " APPLICATION_NAME " exit ***\n"); #ifdef _CRTDBG_MAP_ALLOC _CrtDumpMemoryLeaks(); diff --git a/src/rufus.h b/src/rufus.h index cd88036f..a0c9910e 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -395,36 +395,37 @@ extern void StrArrayDestroy(StrArray* arr); * which translates to: * FormatEx_t pfFormatEx = NULL; * in your code, to declare the entrypoint and then use: - * PF_INIT(FormatEx, fmifs); + * PF_INIT(FormatEx, Fmifs); * which translates to: * pfFormatEx = (FormatEx_t) GetProcAddress(GetDLLHandle("fmifs"), "FormatEx"); * to make it accessible. */ -#define MAX_LIBRARY_HANDLES 32 -extern HMODULE OpenLibraryHandle[MAX_LIBRARY_HANDLES]; -extern uint16_t OpenLibraryHandleSize; -#define OPEN_LIBRARIES_TRACKING_VARS HMODULE OpenLibraryHandle[MAX_LIBRARY_HANDLES]; uint16_t OpenLibraryHandleSize = 0 -#define OPEN_LIBRARIES_CLOSE_ALL while(OpenLibraryHandleSize > 0) FreeLibrary(OpenLibraryHandle[--OpenLibraryHandleSize]) -static __inline HMODULE GetDLLHandle(char* szDLLName) -{ +#define MAX_LIBRARY_HANDLES 32 +extern HMODULE OpenedLibrariesHandle[MAX_LIBRARY_HANDLES]; +extern uint16_t OpenedLibrariesHandleSize; +#define OPENED_LIBRARIES_VARS HMODULE OpenedLibrariesHandle[MAX_LIBRARY_HANDLES]; uint16_t OpenedLibrariesHandleSize = 0 +#define CLOSE_OPENED_LIBRARIES while(OpenedLibrariesHandleSize > 0) FreeLibrary(OpenedLibrariesHandle[--OpenedLibrariesHandleSize]) +static __inline HMODULE GetLibraryHandle(char* szLibraryName) { HMODULE h = NULL; - if ((h = GetModuleHandleA(szDLLName)) == NULL) { - if (OpenLibraryHandleSize >= MAX_LIBRARY_HANDLES) { + if ((h = GetModuleHandleA(szLibraryName)) == NULL) { + if (OpenedLibrariesHandleSize >= MAX_LIBRARY_HANDLES) { uprintf("Error: MAX_LIBRARY_HANDLES is too small\n"); } else { - h = LoadLibraryA(szDLLName); + h = LoadLibraryA(szLibraryName); if (h != NULL) - OpenLibraryHandle[OpenLibraryHandleSize++] = h; + OpenedLibrariesHandle[OpenedLibrariesHandleSize++] = h; } } return h; } -#define PF_DECL(proc) proc##_t pf##proc = NULL -#define PF_INIT(proc, dllname) pf##proc = (proc##_t) GetProcAddress(GetDLLHandle(#dllname), #proc) -#define PF_INIT_OR_OUT(proc, dllname) \ - PF_INIT(proc, dllname); if (pf##proc == NULL) { \ - uprintf("Unable to locate %s() in %s.dll: %s\n", #proc, #dllname, \ - WindowsErrorString()); goto out; } +#define PF_TYPE(api, ret, proc, args) typedef ret (api *proc##_t)args +#define PF_DECL(proc) static proc##_t pf##proc = NULL +#define PF_TYPE_DECL(api, ret, proc, args) PF_TYPE(api, ret, proc, args); PF_DECL(proc) +#define PF_INIT(proc, name) if (pf##proc == NULL) pf##proc = \ + (proc##_t) GetProcAddress(GetLibraryHandle(#name), #proc) +#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 */ #ifndef _UINTPTR_T_DEFINED diff --git a/src/rufus.rc b/src/rufus.rc index 9038deff..20062393 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 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 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -165,7 +165,7 @@ END RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329 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 -CAPTION "Rufus 1.4.7.461" +CAPTION "Rufus 1.4.8.462" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -427,8 +427,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,7,461 - PRODUCTVERSION 1,4,7,461 + FILEVERSION 1,4,8,462 + PRODUCTVERSION 1,4,8,462 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -445,13 +445,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.4.7.461" + VALUE "FileVersion", "1.4.8.462" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.4.7.461" + VALUE "ProductVersion", "1.4.8.462" END END BLOCK "VarFileInfo" diff --git a/src/stdfn.c b/src/stdfn.c index ae3442af..4c59be11 100644 --- a/src/stdfn.c +++ b/src/stdfn.c @@ -35,13 +35,12 @@ char WindowsVersionStr[128] = "Windows "; BOOL is_x64(void) { 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 if (sizeof(uintptr_t) < 8) { - pIsWow64Process = (BOOL (__stdcall *)(HANDLE, PBOOL)) - GetProcAddress(GetDLLHandle("KERNEL32"), "IsWow64Process"); - if (pIsWow64Process != NULL) { - (*pIsWow64Process)(GetCurrentProcess(), &ret); + PF_INIT(IsWow64Process, Kernel32); + if (pfIsWow64Process != NULL) { + (*pfIsWow64Process)(GetCurrentProcess(), &ret); } } else { ret = TRUE; diff --git a/src/stdlg.c b/src/stdlg.c index 38fbe2c4..87040642 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -41,21 +41,13 @@ #include "license.h" #include "localization.h" -/* The following is only available on Vista and later */ #if (_WIN32_WINNT >= 0x0600) -static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR, IBindCtx*, REFIID, void **) = NULL; +PF_TYPE_DECL(WINAPI, HRESULT, SHCreateItemFromParsingName, (PCWSTR, IBindCtx*, REFIID, void **)); #endif -#define INIT_VISTA_SHELL32 if (pSHCreateItemFromParsingName == NULL) { \ - pSHCreateItemFromParsingName = (HRESULT (WINAPI *)(PCWSTR, IBindCtx*, REFIID, void **)) \ - GetProcAddress(GetDLLHandle("SHELL32"), "SHCreateItemFromParsingName"); \ - } -#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"); \ - } +PF_TYPE_DECL(WINAPI, LPITEMIDLIST, SHSimpleIDListFromPath, (PCWSTR pszPath)); +#define INIT_VISTA_SHELL32 PF_INIT(SHCreateItemFromParsingName, Shell32) +#define INIT_XP_SHELL32 PF_INIT(SHSimpleIDListFromPath, Shell32) +#define IS_VISTA_SHELL32_AVAILABLE (pfSHCreateItemFromParsingName != NULL) /* Globals */ static HICON hMessageIcon = (HICON)INVALID_HANDLE_VALUE; @@ -108,7 +100,7 @@ INT CALLBACK BrowseInfoCallback(HWND hDlg, UINT message, LPARAM lParam, LPARAM p } else { // On Windows 7, MinGW only properly selects the specified folder when using a pidl wpath = utf8_to_wchar(szFolderPath); - pidl = (*pSHSimpleIDListFromPath)(wpath); + pidl = (*pfSHSimpleIDListFromPath)(wpath); safe_free(wpath); // 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. @@ -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 (wpath != NULL) { 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 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)) { pfd->lpVtbl->SetFolder(pfd, si_path); } diff --git a/src/vhd.c b/src/vhd.c index 01b12aa1..dc177574 100644 --- a/src/vhd.c +++ b/src/vhd.c @@ -27,45 +27,14 @@ static BOOL has_wimgapi = FALSE, has_7z = FALSE; static char sevenzip_path[MAX_PATH]; +// WIM API Prototypes #define WIM_GENERIC_READ GENERIC_READ #define WIM_OPEN_EXISTING OPEN_EXISTING - -typedef HANDLE (WINAPI *WIMCreateFile_t)( - PWSTR pszWimPath, - DWORD dwDesiredAccess, - DWORD dwCreationDisposition, - 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); +PF_TYPE_DECL(WINAPI, HANDLE, WIMCreateFile, (PWSTR, DWORD, DWORD, DWORD, DWORD, PDWORD)); +PF_TYPE_DECL(WINAPI, BOOL, WIMSetTemporaryPath, (HANDLE, PWSTR)); +PF_TYPE_DECL(WINAPI, HANDLE, WIMLoadImage, (HANDLE, DWORD)); +PF_TYPE_DECL(WINAPI, BOOL, WIMExtractImagePath, (HANDLE, PWSTR, PWSTR, DWORD)); +PF_TYPE_DECL(WINAPI, BOOL, WIMCloseHandle, (HANDLE)); 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 BOOL WimExtractCheck(void) { - PF_INIT(WIMCreateFile, wimgapi); - PF_INIT(WIMSetTemporaryPath, wimgapi); - PF_INIT(WIMLoadImage, wimgapi); - PF_INIT(WIMExtractImagePath, wimgapi); - PF_INIT(WIMCloseHandle, wimgapi); + PF_INIT(WIMCreateFile, Wimgapi); + PF_INIT(WIMSetTemporaryPath, Wimgapi); + PF_INIT(WIMLoadImage, Wimgapi); + PF_INIT(WIMExtractImagePath, Wimgapi); + PF_INIT(WIMCloseHandle, Wimgapi); has_wimgapi = (pfWIMCreateFile && pfWIMSetTemporaryPath && pfWIMLoadImage && pfWIMExtractImagePath && pfWIMCloseHandle); 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* wdst = utf8_to_wchar(dst); - PF_INIT_OR_OUT(WIMCreateFile, wimgapi); - PF_INIT_OR_OUT(WIMSetTemporaryPath, wimgapi); - PF_INIT_OR_OUT(WIMLoadImage, wimgapi); - PF_INIT_OR_OUT(WIMExtractImagePath, wimgapi); - PF_INIT_OR_OUT(WIMCloseHandle, wimgapi); + PF_INIT_OR_OUT(WIMCreateFile, Wimgapi); + PF_INIT_OR_OUT(WIMSetTemporaryPath, Wimgapi); + PF_INIT_OR_OUT(WIMLoadImage, Wimgapi); + PF_INIT_OR_OUT(WIMExtractImagePath, Wimgapi); + PF_INIT_OR_OUT(WIMCloseHandle, Wimgapi); uprintf("Opening: %s:[%d] (API)\n", image, index); if (GetTempPathW(ARRAYSIZE(wtemp), wtemp) == 0) {