diff --git a/res/appstore/Images/SplashScreen.scale-100.png b/res/appstore/Images/SplashScreen.scale-100.png deleted file mode 100644 index 777642e8..00000000 Binary files a/res/appstore/Images/SplashScreen.scale-100.png and /dev/null differ diff --git a/res/appstore/Images/SplashScreen.scale-125.png b/res/appstore/Images/SplashScreen.scale-125.png deleted file mode 100644 index 99633016..00000000 Binary files a/res/appstore/Images/SplashScreen.scale-125.png and /dev/null differ diff --git a/res/appstore/Images/SplashScreen.scale-150.png b/res/appstore/Images/SplashScreen.scale-150.png deleted file mode 100644 index d67d4d5f..00000000 Binary files a/res/appstore/Images/SplashScreen.scale-150.png and /dev/null differ diff --git a/res/appstore/Images/SplashScreen.scale-200.png b/res/appstore/Images/SplashScreen.scale-200.png deleted file mode 100644 index b2f2786d..00000000 Binary files a/res/appstore/Images/SplashScreen.scale-200.png and /dev/null differ diff --git a/res/appstore/Images/SplashScreen.scale-400.png b/res/appstore/Images/SplashScreen.scale-400.png deleted file mode 100644 index 26f3fbc6..00000000 Binary files a/res/appstore/Images/SplashScreen.scale-400.png and /dev/null differ diff --git a/res/appstore/Package.appxmanifest b/res/appstore/Package.appxmanifest index 596d122e..a9f0024c 100644 --- a/res/appstore/Package.appxmanifest +++ b/res/appstore/Package.appxmanifest @@ -4,13 +4,12 @@ xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" - xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" - IgnorableNamespaces="uap rescap iot"> + IgnorableNamespaces="uap rescap"> + Version="3.13.1734.0" /> Rufus @@ -36,7 +35,13 @@ BackgroundColor="transparent" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png"> - + + + + + + + diff --git a/res/appstore/appstore.listing.csv b/res/appstore/appstore.listing.csv new file mode 100644 index 00000000..e6f3d08b --- /dev/null +++ b/res/appstore/appstore.listing.csv @@ -0,0 +1,205 @@ +Field,ID,Type (Type),default,en-us +Description,2,Text,,"Rufus is a utility that helps format and create bootable USB flash drives. + +IMPORTANT: This is an EXPERIMENTAL App Store version. If you have issues, please download Rufus from the official web site. + +Official Web site: https://rufus.ie +Source Code: https://github.com/pbatard/rufus/" +ReleaseNotes,3,Text,,Release notes: https://github.com/pbatard/rufus/releases +Title,4,Text,,Rufus +ShortTitle,5,Text,, +SortTitle,6,Text,, +VoiceTitle,7,Text,, +ShortDescription,8,Text,, +DevStudio,9,Text,, +CopyrightTrademarkInformation,12,Text,,© 2011-2021 Pete Batard/Akeo Consulting +AdditionalLicenseTerms,13,Text,, +DesktopScreenshot1,100,Relative path (or URL to file in Partner Center),,https://developer.microsoft.com/en-us/dashboard/apps/9PC3H3V7Q9CH/submissions/1152921505693093840/listings/1152922700005959199/listingassets/2000000000082289093 +DesktopScreenshot2,101,Relative path (or URL to file in Partner Center),, +DesktopScreenshot3,102,Relative path (or URL to file in Partner Center),, +DesktopScreenshot4,103,Relative path (or URL to file in Partner Center),, +DesktopScreenshot5,104,Relative path (or URL to file in Partner Center),, +DesktopScreenshot6,105,Relative path (or URL to file in Partner Center),, +DesktopScreenshot7,106,Relative path (or URL to file in Partner Center),, +DesktopScreenshot8,107,Relative path (or URL to file in Partner Center),, +DesktopScreenshot9,108,Relative path (or URL to file in Partner Center),, +DesktopScreenshot10,109,Relative path (or URL to file in Partner Center),, +DesktopScreenshotCaption1,150,Text,, +DesktopScreenshotCaption2,151,Text,, +DesktopScreenshotCaption3,152,Text,, +DesktopScreenshotCaption4,153,Text,, +DesktopScreenshotCaption5,154,Text,, +DesktopScreenshotCaption6,155,Text,, +DesktopScreenshotCaption7,156,Text,, +DesktopScreenshotCaption8,157,Text,, +DesktopScreenshotCaption9,158,Text,, +DesktopScreenshotCaption10,159,Text,, +MobileScreenshot1,200,Relative path (or URL to file in Partner Center),, +MobileScreenshot2,201,Relative path (or URL to file in Partner Center),, +MobileScreenshot3,202,Relative path (or URL to file in Partner Center),, +MobileScreenshot4,203,Relative path (or URL to file in Partner Center),, +MobileScreenshot5,204,Relative path (or URL to file in Partner Center),, +MobileScreenshot6,205,Relative path (or URL to file in Partner Center),, +MobileScreenshot7,206,Relative path (or URL to file in Partner Center),, +MobileScreenshot8,207,Relative path (or URL to file in Partner Center),, +MobileScreenshot9,208,Relative path (or URL to file in Partner Center),, +MobileScreenshot10,209,Relative path (or URL to file in Partner Center),, +MobileScreenshotCaption1,250,Text,, +MobileScreenshotCaption2,251,Text,, +MobileScreenshotCaption3,252,Text,, +MobileScreenshotCaption4,253,Text,, +MobileScreenshotCaption5,254,Text,, +MobileScreenshotCaption6,255,Text,, +MobileScreenshotCaption7,256,Text,, +MobileScreenshotCaption8,257,Text,, +MobileScreenshotCaption9,258,Text,, +MobileScreenshotCaption10,259,Text,, +XboxScreenshot1,300,Relative path (or URL to file in Partner Center),, +XboxScreenshot2,301,Relative path (or URL to file in Partner Center),, +XboxScreenshot3,302,Relative path (or URL to file in Partner Center),, +XboxScreenshot4,303,Relative path (or URL to file in Partner Center),, +XboxScreenshot5,304,Relative path (or URL to file in Partner Center),, +XboxScreenshot6,305,Relative path (or URL to file in Partner Center),, +XboxScreenshot7,306,Relative path (or URL to file in Partner Center),, +XboxScreenshot8,307,Relative path (or URL to file in Partner Center),, +XboxScreenshot9,308,Relative path (or URL to file in Partner Center),, +XboxScreenshot10,309,Relative path (or URL to file in Partner Center),, +XboxScreenshotCaption1,350,Text,, +XboxScreenshotCaption2,351,Text,, +XboxScreenshotCaption3,352,Text,, +XboxScreenshotCaption4,353,Text,, +XboxScreenshotCaption5,354,Text,, +XboxScreenshotCaption6,355,Text,, +XboxScreenshotCaption7,356,Text,, +XboxScreenshotCaption8,357,Text,, +XboxScreenshotCaption9,358,Text,, +XboxScreenshotCaption10,359,Text,, +HolographicScreenshot1,400,Relative path (or URL to file in Partner Center),, +HolographicScreenshot2,401,Relative path (or URL to file in Partner Center),, +HolographicScreenshot3,402,Relative path (or URL to file in Partner Center),, +HolographicScreenshot4,403,Relative path (or URL to file in Partner Center),, +HolographicScreenshot5,404,Relative path (or URL to file in Partner Center),, +HolographicScreenshot6,405,Relative path (or URL to file in Partner Center),, +HolographicScreenshot7,406,Relative path (or URL to file in Partner Center),, +HolographicScreenshot8,407,Relative path (or URL to file in Partner Center),, +HolographicScreenshot9,408,Relative path (or URL to file in Partner Center),, +HolographicScreenshot10,409,Relative path (or URL to file in Partner Center),, +HolographicScreenshotCaption1,450,Text,, +HolographicScreenshotCaption2,451,Text,, +HolographicScreenshotCaption3,452,Text,, +HolographicScreenshotCaption4,453,Text,, +HolographicScreenshotCaption5,454,Text,, +HolographicScreenshotCaption6,455,Text,, +HolographicScreenshotCaption7,456,Text,, +HolographicScreenshotCaption8,457,Text,, +HolographicScreenshotCaption9,458,Text,, +HolographicScreenshotCaption10,459,Text,, +StoreLogo720x1080,600,Relative path (or URL to file in Partner Center),, +StoreLogo1080x1080,601,Relative path (or URL to file in Partner Center),, +StoreLogo300x300,602,Relative path (or URL to file in Partner Center),,https://developer.microsoft.com/en-us/dashboard/apps/9PC3H3V7Q9CH/submissions/1152921505693093840/listings/1152922700005959199/listingassets/2000000000082758754 +OverrideLogosForWin10,603,True/False,,False +StoreLogoOverride150x150,604,Relative path (or URL to file in Partner Center),, +StoreLogoOverride71x71,605,Relative path (or URL to file in Partner Center),, +PromoImage1920x1080,606,Relative path (or URL to file in Partner Center),, +PromoImage2400x1200,607,Relative path (or URL to file in Partner Center),, +XboxBrandedKeyArt584x800,608,Relative path (or URL to file in Partner Center),, +XboxTitledHero1920x1080,609,Relative path (or URL to file in Partner Center),, +XboxFeaturedPromo1080x1080,610,Relative path (or URL to file in Partner Center),, +OptionalPromo358x358,611,Relative path (or URL to file in Partner Center),, +OptionalPromo1000x800,612,Relative path (or URL to file in Partner Center),, +OptionalPromo414x180,613,Relative path (or URL to file in Partner Center),, +Feature1,700,Text,,"Format USB, flash card and virtual drives to FAT/FAT32/NTFS/UDF/exFAT/ReFS/ext2/ext3" +Feature2,701,Text,,"Create DOS bootable USB drives, using FreeDOS or MS-DOS (Windows 8.1 or earlier)" +Feature3,702,Text,,"Create BIOS or UEFI bootable drives, including UEFI bootable NTFS" +Feature4,703,Text,,"Create bootable drives from bootable ISOs (Windows, Linux, etc.)" +Feature5,704,Text,,"Create bootable drives from bootable disk images, including compressed ones" +Feature6,705,Text,,Create Windows To Go drives +Feature7,706,Text,,Create persistent Linux partitions +Feature8,707,Text,,Download official Microsoft Windows 8 or Windows 10 retail ISOs +Feature9,708,Text,,"Compute MD5, SHA-1 and SHA-256 checksums of the selected image" +Feature10,709,Text,,"Twice as fast as Microsoft's USB/DVD tool or UNetbootin, on ISO → USB creation" +Feature11,710,Text,,"Perform bad blocks checks, including detection of ""fake"" flash drives" +Feature12,711,Text,, +Feature13,712,Text,, +Feature14,713,Text,, +Feature15,714,Text,, +Feature16,715,Text,, +Feature17,716,Text,, +Feature18,717,Text,, +Feature19,718,Text,, +Feature20,719,Text,, +MinimumHardwareReq1,800,Text,, +MinimumHardwareReq2,801,Text,, +MinimumHardwareReq3,802,Text,, +MinimumHardwareReq4,803,Text,, +MinimumHardwareReq5,804,Text,, +MinimumHardwareReq6,805,Text,, +MinimumHardwareReq7,806,Text,, +MinimumHardwareReq8,807,Text,, +MinimumHardwareReq9,808,Text,, +MinimumHardwareReq10,809,Text,, +MinimumHardwareReq11,810,Text,, +RecommendedHardwareReq1,850,Text,, +RecommendedHardwareReq2,851,Text,, +RecommendedHardwareReq3,852,Text,, +RecommendedHardwareReq4,853,Text,, +RecommendedHardwareReq5,854,Text,, +RecommendedHardwareReq6,855,Text,, +RecommendedHardwareReq7,856,Text,, +RecommendedHardwareReq8,857,Text,, +RecommendedHardwareReq9,858,Text,, +RecommendedHardwareReq10,859,Text,, +RecommendedHardwareReq11,860,Text,, +SearchTerm1,900,Text,,rufus +SearchTerm2,901,Text,,iso +SearchTerm3,902,Text,,bootable +SearchTerm4,903,Text,,usb +SearchTerm5,904,Text,,format +SearchTerm6,905,Text,,flash drive +SearchTerm7,906,Text,, +TrailerToPlayAtTopOfListing,999,Relative path (or URL to file in Partner Center),, +Trailer1,1000,Relative path (or URL to file in Partner Center),, +Trailer2,1001,Relative path (or URL to file in Partner Center),, +Trailer3,1002,Relative path (or URL to file in Partner Center),, +Trailer4,1003,Relative path (or URL to file in Partner Center),, +Trailer5,1004,Relative path (or URL to file in Partner Center),, +Trailer6,1005,Relative path (or URL to file in Partner Center),, +Trailer7,1006,Relative path (or URL to file in Partner Center),, +Trailer8,1007,Relative path (or URL to file in Partner Center),, +Trailer9,1008,Relative path (or URL to file in Partner Center),, +Trailer10,1009,Relative path (or URL to file in Partner Center),, +Trailer11,1010,Relative path (or URL to file in Partner Center),, +Trailer12,1011,Relative path (or URL to file in Partner Center),, +Trailer13,1012,Relative path (or URL to file in Partner Center),, +Trailer14,1013,Relative path (or URL to file in Partner Center),, +Trailer15,1014,Relative path (or URL to file in Partner Center),, +TrailerTitle1,1020,Text,, +TrailerTitle2,1021,Text,, +TrailerTitle3,1022,Text,, +TrailerTitle4,1023,Text,, +TrailerTitle5,1024,Text,, +TrailerTitle6,1025,Text,, +TrailerTitle7,1026,Text,, +TrailerTitle8,1027,Text,, +TrailerTitle9,1028,Text,, +TrailerTitle10,1029,Text,, +TrailerTitle11,1030,Text,, +TrailerTitle12,1031,Text,, +TrailerTitle13,1032,Text,, +TrailerTitle14,1033,Text,, +TrailerTitle15,1034,Text,, +TrailerThumbnail1,1040,Relative path (or URL to file in Partner Center),, +TrailerThumbnail2,1041,Relative path (or URL to file in Partner Center),, +TrailerThumbnail3,1042,Relative path (or URL to file in Partner Center),, +TrailerThumbnail4,1043,Relative path (or URL to file in Partner Center),, +TrailerThumbnail5,1044,Relative path (or URL to file in Partner Center),, +TrailerThumbnail6,1045,Relative path (or URL to file in Partner Center),, +TrailerThumbnail7,1046,Relative path (or URL to file in Partner Center),, +TrailerThumbnail8,1047,Relative path (or URL to file in Partner Center),, +TrailerThumbnail9,1048,Relative path (or URL to file in Partner Center),, +TrailerThumbnail10,1049,Relative path (or URL to file in Partner Center),, +TrailerThumbnail11,1050,Relative path (or URL to file in Partner Center),, +TrailerThumbnail12,1051,Relative path (or URL to file in Partner Center),, +TrailerThumbnail13,1052,Relative path (or URL to file in Partner Center),, +TrailerThumbnail14,1053,Relative path (or URL to file in Partner Center),, +TrailerThumbnail15,1054,Relative path (or URL to file in Partner Center),, \ No newline at end of file diff --git a/res/appstore/appstore.wapproj b/res/appstore/appstore.wapproj index 3cb51f69..f534d1a4 100644 --- a/res/appstore/appstore.wapproj +++ b/res/appstore/appstore.wapproj @@ -38,7 +38,7 @@ - "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool" sign /v /sha1 9ce9a71ccab3b38a74781b975f1c228222cf7d3b /fd SHA256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp rufus.exe + "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool" sign /v /sha1 9ce9a71ccab3b38a74781b975f1c228222cf7d3b /fd SHA256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp $(OutDir)rufus.exe $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ @@ -98,6 +98,7 @@ + @@ -108,11 +109,6 @@ - - - - - @@ -148,6 +144,7 @@ + diff --git a/res/appstore/appstore.wapproj.user b/res/appstore/appstore.wapproj.user index 2ed16317..2b376f06 100644 --- a/res/appstore/appstore.wapproj.user +++ b/res/appstore/appstore.wapproj.user @@ -14,12 +14,6 @@ False StoreOnly - - AppHostLocalDebugger - False - NativeOnly - NativeOnly - AppHostLocalDebugger False @@ -29,17 +23,19 @@ AppHostLocalDebugger False + NativeOnly + NativeOnly - + AppHostLocalDebugger False - NativeOnly NativeOnly + NativeOnly - + AppHostLocalDebugger False - NativeOnly NativeOnly + NativeOnly \ No newline at end of file diff --git a/res/appstore/rufus/rufus.app b/res/appstore/rufus/rufus.app new file mode 100644 index 00000000..e69de29b diff --git a/rufus.sln b/rufus.sln index 490f65b8..b190e6f5 100644 --- a/rufus.sln +++ b/rufus.sln @@ -219,9 +219,17 @@ Global {9440518F-38FE-43D9-9151-A26618E8C978}.Debug|x64.ActiveCfg = Debug|x64 {9440518F-38FE-43D9-9151-A26618E8C978}.Debug|x86.ActiveCfg = Debug|x86 {9440518F-38FE-43D9-9151-A26618E8C978}.Release|arm.ActiveCfg = Release|ARM + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|arm.Build.0 = Release|ARM + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|arm.Deploy.0 = Release|ARM {9440518F-38FE-43D9-9151-A26618E8C978}.Release|arm64.ActiveCfg = Release|ARM64 + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|arm64.Build.0 = Release|ARM64 + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|arm64.Deploy.0 = Release|ARM64 {9440518F-38FE-43D9-9151-A26618E8C978}.Release|x64.ActiveCfg = Release|x64 + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|x64.Build.0 = Release|x64 + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|x64.Deploy.0 = Release|x64 {9440518F-38FE-43D9-9151-A26618E8C978}.Release|x86.ActiveCfg = Release|x86 + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|x86.Build.0 = Release|x86 + {9440518F-38FE-43D9-9151-A26618E8C978}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h index 7eae40cf..1d720991 100644 --- a/src/msapi_utf8.h +++ b/src/msapi_utf8.h @@ -568,13 +568,23 @@ static __inline BOOL GetTextExtentPointU(HDC hdc, const char* lpString, LPSIZE l return ret; } +// A UTF-8 alternative to MS GetCurrentDirectory() since the latter is useless for +// apps installed from the App Store... static __inline DWORD GetCurrentDirectoryU(DWORD nBufferLength, char* lpBuffer) { - DWORD ret = 0, err = ERROR_INVALID_DATA; + DWORD i, ret = 0, err = ERROR_INVALID_DATA; // coverity[returned_null] walloc(lpBuffer, nBufferLength); - ret = GetCurrentDirectoryW(nBufferLength, wlpBuffer); + ret = GetModuleFileNameW(NULL, wlpBuffer, nBufferLength); err = GetLastError(); + if (ret > 0) { + for (i = ret - 1; i > 0; i--) { + if (wlpBuffer[i] == L'\\') { + wlpBuffer[i] = 0; + break; + } + } + } if ((ret != 0) && ((ret = wchar_to_utf8_no_alloc(wlpBuffer, lpBuffer, nBufferLength)) == 0)) { err = GetLastError(); } diff --git a/src/net.c b/src/net.c index 375f9536..099be9e6 100644 --- a/src/net.c +++ b/src/net.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -265,27 +266,32 @@ static HINTERNET GetInternetSession(BOOL bRetry) { int i; char agent[64]; - BOOL r, decodingSupport = TRUE; - DWORD dwFlags, dwTimeout = NET_SESSION_TIMEOUT, dwProtocolSupport = HTTP_PROTOCOL_FLAG_HTTP2; + BOOL decodingSupport = TRUE; + DWORD dwTimeout = NET_SESSION_TIMEOUT, dwProtocolSupport = HTTP_PROTOCOL_FLAG_HTTP2; HINTERNET hSession = NULL; + HRESULT hr = S_FALSE; + INetworkListManager* pNetworkListManager; + NLM_CONNECTIVITY Connectivity = NLM_CONNECTIVITY_DISCONNECTED; - PF_TYPE_DECL(WINAPI, BOOL, InternetGetConnectedState, (LPDWORD, DWORD)); PF_TYPE_DECL(WINAPI, HINTERNET, InternetOpenA, (LPCSTR, DWORD, LPCSTR, LPCSTR, DWORD)); PF_TYPE_DECL(WINAPI, BOOL, InternetSetOptionA, (HINTERNET, DWORD, LPVOID, DWORD)); - PF_INIT_OR_OUT(InternetGetConnectedState, WinInet); PF_INIT_OR_OUT(InternetOpenA, WinInet); PF_INIT_OR_OUT(InternetSetOptionA, WinInet); - for (i = 0; i <= WRITE_RETRIES; i++) { - r = pfInternetGetConnectedState(&dwFlags, 0); - if (r || !bRetry) - break; - Sleep(1000); + // Create a NetworkListManager Instance to check the network connection + IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)); + hr = CoCreateInstance(&CLSID_NetworkListManager, NULL, CLSCTX_ALL, + &IID_INetworkListManager, (LPVOID*)&pNetworkListManager); + if (hr == S_OK) { + for (i = 0; i <= WRITE_RETRIES; i++) { + hr = INetworkListManager_GetConnectivity(pNetworkListManager, &Connectivity); + if (hr == S_OK || !bRetry) + break; + Sleep(1000); + } } - if (!r) { - // http://msdn.microsoft.com/en-us/library/windows/desktop/aa384702.aspx is wrong... - SetLastError(ERROR_INTERNET_NOT_INITIALIZED); - uprintf("Network is unavailable: %s", WinInetErrorString()); + if (Connectivity == NLM_CONNECTIVITY_DISCONNECTED) { + SetLastError(ERROR_INTERNET_DISCONNECTED); goto out; } static_sprintf(agent, APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)", diff --git a/src/rufus.c b/src/rufus.c index 93e150b9..95b4a25a 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -3101,7 +3101,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine HDC hDC; MSG msg; struct option long_options[] = { - {"appstore", no_argument, NULL, 'a'}, {"extra-devs", no_argument, NULL, 'x'}, {"gui", no_argument, NULL, 'g'}, {"help", no_argument, NULL, 'h'}, @@ -3143,10 +3142,49 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // coverity[pointless_string_compare] is_x86_32 = (strcmp(APPLICATION_ARCH, "x86") == 0); + // Retrieve various app & system directories. + if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) { + uprintf("Could not get current directory: %s", WindowsErrorString()); + app_dir[0] = 0; + } + if (GetSystemDirectoryU(system_dir, sizeof(system_dir)) == 0) { + uprintf("Could not get system directory: %s", WindowsErrorString()); + static_strcpy(system_dir, "C:\\Windows\\System32"); + } + if (GetTempPathU(sizeof(temp_dir), temp_dir) == 0) { + uprintf("Could not get temp directory: %s", WindowsErrorString()); + static_strcpy(temp_dir, ".\\"); + } + // Construct Sysnative ourselves as there is no GetSysnativeDirectory() call + // By default (64bit app running on 64 bit OS or 32 bit app running on 32 bit OS) + // Sysnative and System32 are the same + static_strcpy(sysnative_dir, system_dir); + // But if the app is 32 bit and the OS is 64 bit, Sysnative must differ from System32 +#if (!defined(_WIN64) && !defined(BUILD64)) + if (is_x64()) { + if (GetSystemWindowsDirectoryU(sysnative_dir, sizeof(sysnative_dir)) == 0) { + uprintf("Could not get Windows directory: %s", WindowsErrorString()); + static_strcpy(sysnative_dir, "C:\\Windows"); + } + static_strcat(sysnative_dir, "\\Sysnative"); + } +#endif + + // Look for a rufus.app file in the current app directory + // Since Microsoft makes it downright impossible to pass an arg in the app manifest + // and the automated VS2019 package building process doesn't like renaming the .exe + // right under its nose (else we would use the same trick as for portable vs regular) + // we use yet another workaround to detect if we are running the AppStore version... + static_sprintf(ini_path, "%s\\rufus.app", app_dir); + if (PathFileExistsU(ini_path)) { + appstore_version = TRUE; + goto skip_args_processing; + } + // We have to process the arguments before we acquire the lock and process the locale PF_INIT(__wgetmainargs, Msvcrt); if (pf__wgetmainargs != NULL) { - BOOL list_params = TRUE; // TODO: Remove this once we've seen more from AppStore + BOOL list_params = FALSE; pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si); argv = (char**)calloc(argc, sizeof(char*)); if (argv != NULL) { @@ -3161,11 +3199,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // on the commandline then, which the hogger makes more intuitive. if ((strcmp(argv[i], "-g") == 0) || (strcmp(argv[i], "--gui") == 0)) disable_hogger = TRUE; - // Check for "/InvokerPRAID", which is *STUPIDLY* added by Microsoft + // Check for "/InvokerPRAID", which may *STUPIDLY* be added by Microsoft // when starting an app that was installed from the Windows store... - if ((stricmp(argv[i], "/InvokerPRAID") == 0) || (strcmp(argv[i], "-a") == 0) || - (strcmp(argv[i], "--appstore") == 0)) { - uprintf("AppStore version detected"); + if (stricmp(argv[i], "/InvokerPRAID") == 0) { appstore_version = TRUE; goto skip_args_processing; } @@ -3259,38 +3295,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine } skip_args_processing: - // Retrieve various app & system directories - if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) { - uprintf("Could not get current directory: %s", WindowsErrorString()); - app_dir[0] = 0; - } - if (GetSystemDirectoryU(system_dir, sizeof(system_dir)) == 0) { - uprintf("Could not get system directory: %s", WindowsErrorString()); - static_strcpy(system_dir, "C:\\Windows\\System32"); - } - if (GetTempPathU(sizeof(temp_dir), temp_dir) == 0) { - uprintf("Could not get temp directory: %s", WindowsErrorString()); - static_strcpy(temp_dir, ".\\"); - } - // Construct Sysnative ourselves as there is no GetSysnativeDirectory() call - // By default (64bit app running on 64 bit OS or 32 bit app running on 32 bit OS) - // Sysnative and System32 are the same - static_strcpy(sysnative_dir, system_dir); - // But if the app is 32 bit and the OS is 64 bit, Sysnative must differ from System32 -#if (!defined(_WIN64) && !defined(BUILD64)) - if (is_x64()) { - if (GetSystemWindowsDirectoryU(sysnative_dir, sizeof(sysnative_dir)) == 0) { - uprintf("Could not get Windows directory: %s", WindowsErrorString()); - static_strcpy(sysnative_dir, "C:\\Windows"); - } - static_strcat(sysnative_dir, "\\Sysnative"); - } -#endif + if (appstore_version) + uprintf("AppStore version detected"); // Look for a .ini file in the current app directory static_sprintf(ini_path, "%s\\rufus.ini", app_dir); fd = fopenU(ini_path, ini_flags); // Will create the file if portable mode is requested - vc |= (safe_strcmp(GetSignatureName(NULL, NULL), cert_name[0]) == 0); + // Using the string directly in safe_strcmp() would call GetSignatureName() twice + tmp = GetSignatureName(NULL, NULL); + vc |= (safe_strcmp(tmp, cert_name[0]) == 0); if (fd != NULL) { ini_file = ini_path; fclose(fd); diff --git a/src/rufus.rc b/src/rufus.rc index 0e7a5f2f..fdacf81c 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.14.1733" +CAPTION "Rufus 3.14.1734" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,14,1733,0 - PRODUCTVERSION 3,14,1733,0 + FILEVERSION 3,14,1734,0 + PRODUCTVERSION 3,14,1734,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.14.1733" + VALUE "FileVersion", "3.14.1734" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.13.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.14.1733" + VALUE "ProductVersion", "3.14.1734" END END BLOCK "VarFileInfo"