mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[appstore] add AppStore version detection
* Also make sure we don't include appstore.listing.csv in the app and remove unneeded call to GetModuleHandle() in pki.c.
This commit is contained in:
parent
b3daef6a67
commit
1062dde076
7 changed files with 65 additions and 49 deletions
|
@ -9,7 +9,7 @@
|
|||
<Identity
|
||||
Name="19453.net.Rufus"
|
||||
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
|
||||
Version="3.14.1740.0" />
|
||||
Version="3.14.1741.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Rufus</DisplayName>
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="appstore.listing.csv" />
|
||||
<None Include="appstore.listing.csv" />
|
||||
<Content Include="Images\LargeTile.scale-100.png" />
|
||||
<Content Include="Images\LargeTile.scale-125.png" />
|
||||
<Content Include="Images\LargeTile.scale-150.png" />
|
||||
|
@ -144,6 +144,7 @@
|
|||
<Content Include="Images\Wide310x150Logo.scale-150.png" />
|
||||
<Content Include="Images\Wide310x150Logo.scale-200.png" />
|
||||
<Content Include="Images\Wide310x150Logo.scale-400.png" />
|
||||
<Content Include="rufus\rufus.app" />
|
||||
<None Include="Package.StoreAssociation.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
0
res/appstore/rufus/rufus.app
Normal file
0
res/appstore/rufus/rufus.app
Normal file
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
77
src/rufus.c
77
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);
|
||||
|
|
10
src/rufus.rc
10
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"
|
||||
|
|
Loading…
Reference in a new issue