[appstore] don't exit on unhandled parameters

* Looks like executables installed from the Windows Store launch with a "/InvokerPRAID"
  added parameter, which of course BREAKS apps that have a defined set of parameters
  and don't except that Microsoft would gingerly add random unwanted stuff there...
* The provision of this extra parameter also appears to be tied to using one of:
  - <TargetDeviceFamily Name="Windows.Universal" ...>
  - <uap:SplashScreen ...>
  - <Application EntryPoint="$targetentrypoint$" ...>
  in the appxmanifest.
* This resulted in our argument processing loop to cause early exit on account that an
  unexpected option was provided.
* Fix this by adding an explicit check for /InvokerPRAID and not exiting on unhandled
  params and removing or altering the 3 appxmanifest options listed above.
* Also set an explicit Windows.FullTrustApplication and remove splash screen.
* Also update _pre-commit.sh to update appstore build number automatically.
* Also remove splash screen images, add store listing CSV and toggle App builds to manual.
* Closes #1690
This commit is contained in:
Pete Batard 2021-02-05 17:20:54 +00:00
parent 2707f11313
commit e4372a9f57
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
12 changed files with 248 additions and 45 deletions

View file

@ -120,7 +120,7 @@ BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fa
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE, app_changed_size = FALSE;
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE;
BOOL write_as_image = FALSE, write_as_esp = FALSE, installed_uefi_ntfs = FALSE, use_vds = FALSE, ignore_boot_marker = FALSE;
BOOL windows_to_go_selected = FALSE;
BOOL windows_to_go_selected = FALSE, appstore_version = FALSE;
float fScale = 1.0f;
int dialog_showing = 0, selection_default = BT_IMAGE, persistence_unit_selection = -1;
int default_fs, fs_type, boot_type, partition_type, target_type; // file system, boot type, partition type, target type
@ -3101,6 +3101,7 @@ 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'},
@ -3145,13 +3146,14 @@ 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);
if (pf__wgetmainargs != NULL) {
BOOL list_params = TRUE; // TODO: Remove this once we've seen more from AppStore
pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si);
argv = (char**)calloc(argc, sizeof(char*));
if (argv != NULL) {
// Non getopt parameter check
for (i = 0; i < argc; i++) {
argv[i] = wchar_to_utf8(wargv[i]);
// Check for " /W" (wait for mutex release for pre 1.3.3 versions)
// Check for "/W" (wait for mutex release for pre 1.3.3 versions)
if (strcmp(argv[i], "/W") == 0)
wait_for_mutex = 150; // Try to acquire the mutex for 15 seconds
// We need to find if we need to disable the hogger BEFORE we start
@ -3159,6 +3161,14 @@ 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
// 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");
appstore_version = TRUE;
goto skip_args_processing;
}
}
// If our application name contains a 'p' (for "portable") create a 'rufus.ini'
// NB: argv[0] is populated in the previous loop
@ -3173,6 +3183,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!disable_hogger) {
// Reattach the console, if we were started from commandline
if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
uprintf("Enabling console line hogger");
attached_console = TRUE;
IGNORE_RETVAL(freopen("CONIN$", "r", stdin));
IGNORE_RETVAL(freopen("CONOUT$", "w", stdout));
@ -3182,11 +3193,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
}
while ((opt = getopt_long(argc, argv, "?xghf:i:w:l:", long_options, &option_index)) != EOF) {
while ((opt = getopt_long(argc, argv, "xghf:i:w:l:", long_options, &option_index)) != EOF) {
switch (opt) {
case 'x':
enable_HDDs = TRUE;
break;
case 'a':
case 'g':
// No need to reprocess that option
break;
@ -3227,18 +3239,26 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
case 'w':
wait_for_mutex = atoi(optarg);
break;
case '?':
case 'h':
default:
PrintUsage(argv[0]);
goto out;
// getopt_long returns '?' for any option it doesn't recognize
default:
list_params = TRUE;
break;
}
}
if (list_params) {
uprintf("Command line arguments:");
for (i = 1; i < argc; i++)
uprintf(argv[i]);
}
}
} else {
uprintf("Could not access UTF-16 args");
}
skip_args_processing:
// Retrieve various app & system directories
if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) {
uprintf("Could not get current directory: %s", WindowsErrorString());
@ -3379,14 +3399,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
Sleep(100);
mutex = CreateMutexA(NULL, TRUE, "Global/" APPLICATION_NAME);
}
//if ((mutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS)) {
// // Load the translation before we print the error
// get_loc_data_file(loc_file, selected_locale);
// right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT);
// // Set MB_SYSTEMMODAL to prevent Far Manager from stealing focus...
// MessageBoxExU(NULL, lmprintf(MSG_002), lmprintf(MSG_001), MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL, selected_langid);
// goto out;
//}
if ((mutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS)) {
// Load the translation before we print the error
get_loc_data_file(loc_file, selected_locale);
right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT);
// Set MB_SYSTEMMODAL to prevent Far Manager from stealing focus...
MessageBoxExU(NULL, lmprintf(MSG_002), lmprintf(MSG_001), MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL, selected_langid);
goto out;
}
// Save instance of the application for further reference
hMainInstance = hInstance;