diff --git a/res/appstore/Package.appxmanifest b/res/appstore/Package.appxmanifest
index 5b1083da..e6766e26 100644
--- a/res/appstore/Package.appxmanifest
+++ b/res/appstore/Package.appxmanifest
@@ -9,7 +9,7 @@
+ Version="3.14.1741.0" />
Rufus
diff --git a/res/appstore/appstore.wapproj b/res/appstore/appstore.wapproj
index 7d8c0d15..f534d1a4 100644
--- a/res/appstore/appstore.wapproj
+++ b/res/appstore/appstore.wapproj
@@ -98,7 +98,7 @@
-
+
@@ -144,6 +144,7 @@
+
diff --git a/res/appstore/rufus/rufus.app b/res/appstore/rufus/rufus.app
new file mode 100644
index 00000000..e69de29b
diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h
index 3e830025..ce2db9c0 100644
--- a/src/msapi_utf8.h
+++ b/src/msapi_utf8.h
@@ -571,13 +571,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/pki.c b/src/pki.c
index 11264be3..a94a15fb 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -212,7 +212,6 @@ char* GetSignatureName(const char* path, const char* country_code)
char *p = NULL, *mpath = NULL;
int i;
BOOL r;
- HMODULE hm;
HCERTSTORE hStore = NULL;
HCRYPTMSG hMsg = NULL;
PCCERT_CONTEXT pCertContext = NULL;
@@ -228,12 +227,7 @@ char* GetSignatureName(const char* path, const char* country_code)
szFileName = calloc(MAX_PATH, sizeof(wchar_t));
if (szFileName == NULL)
return NULL;
- hm = GetModuleHandle(NULL);
- if (hm == NULL) {
- uprintf("PKI: Could not get current executable handle: %s", WinPKIErrorString());
- goto out;
- }
- dwSize = GetModuleFileNameW(hm, szFileName, MAX_PATH);
+ dwSize = GetModuleFileNameW(NULL, szFileName, MAX_PATH);
if ((dwSize == 0) || ((dwSize == MAX_PATH) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER))) {
uprintf("PKI: Could not get module filename: %s", WinPKIErrorString());
goto out;
diff --git a/src/rufus.c b/src/rufus.c
index 7d860638..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,33 +3295,8 @@ 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);
diff --git a/src/rufus.rc b/src/rufus.rc
index 052d00f5..e8f51d51 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.1740"
+CAPTION "Rufus 3.14.1741"
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,1740,0
- PRODUCTVERSION 3,14,1740,0
+ FILEVERSION 3,14,1741,0
+ PRODUCTVERSION 3,14,1741,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.1740"
+ VALUE "FileVersion", "3.14.1741"
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.14.exe"
VALUE "ProductName", "Rufus"
- VALUE "ProductVersion", "3.14.1740"
+ VALUE "ProductVersion", "3.14.1741"
END
END
BLOCK "VarFileInfo"