From e5316a0ac46db0e33f1fcf7aec60f62c08dac7e4 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 15 Jun 2025 01:16:46 +0800 Subject: [PATCH] Check Process.Start usage --- Flow.Launcher/App.xaml.cs | 3 ++- .../Flow.Launcher.Plugin.Explorer/ContextMenu.cs | 13 ++++--------- .../Search/Everything/EverythingSearchManager.cs | 2 +- .../ViewModels/SettingsViewModel.cs | 1 + Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 5 +++++ .../Helper/ResultHelper.cs | 1 + 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 4c05ea5f1..95c6b15c0 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -367,7 +367,8 @@ namespace Flow.Launcher UseShellExecute = true, Verb = Win32Helper.IsAdministrator() || forceAdmin ? "runas" : "" }; - Process.Start(startInfo); // No need to de-elevate since we are restarting + // No need to de-elevate since we are restarting Flow Launcher which cannot bring security risks + Process.Start(startInfo); Thread.Sleep(500); Environment.Exit(0); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index c331c4985..0fa5fd562 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -360,11 +360,7 @@ namespace Flow.Launcher.Plugin.Explorer { try { - Process.Start(new ProcessStartInfo() - { - FileName = editorPath, - ArgumentList = { record.FullPath } - }); + Main.Context.API.StartProcess(editorPath, arguments: record.FullPath); return true; } catch (Exception e) @@ -394,10 +390,7 @@ namespace Flow.Launcher.Plugin.Explorer { try { - Process.Start(new ProcessStartInfo() - { - FileName = shellPath, WorkingDirectory = record.FullPath - }); + Main.Context.API.StartProcess(shellPath, workingDirectory: record.FullPath); return true; } catch (Exception e) @@ -462,6 +455,7 @@ namespace Flow.Launcher.Plugin.Explorer Arguments = "srchadmin.dll" }; + // No need to de-elevate since we are opening windows settings which cannot bring security risks Process.Start(psi); return true; } @@ -486,6 +480,7 @@ namespace Flow.Launcher.Plugin.Explorer SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"), Action = _ => { + // No need to de-elevate since we are opening windows settings which cannot bring security risks Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}"); return true; }, diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs index ce71c94ba..4e92b7f10 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs @@ -57,7 +57,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything } Settings.EverythingInstalledPath = installedPath; - Process.Start(installedPath, "-startup"); + Main.Context.API.StartProcess(installedPath, arguments: "-startup"); return true; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 5aa6a13be..abff4d9cd 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -488,6 +488,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels Arguments = Constants.WindowsIndexingOptions }; + // No need to de-elevate since we are opening windows settings which cannot bring security risks Process.Start(psi); } diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index 39bf49654..a0f3467a5 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -210,6 +210,7 @@ namespace Flow.Launcher.Plugin.Sys if (EnableShutdownPrivilege()) PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON); else + // No need to de-elevate since we already have message box asking for confirmation Process.Start("shutdown", "/s /t 0"); return true; @@ -231,6 +232,7 @@ namespace Flow.Launcher.Plugin.Sys if (EnableShutdownPrivilege()) PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON); else + // No need to de-elevate since we already have message box asking for confirmation Process.Start("shutdown", "/r /t 0"); return true; @@ -252,6 +254,7 @@ namespace Flow.Launcher.Plugin.Sys if (EnableShutdownPrivilege()) PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON); else + // No need to de-elevate since we already have message box asking for confirmation Process.Start("shutdown", "/r /o /t 0"); return true; @@ -315,6 +318,7 @@ namespace Flow.Launcher.Plugin.Sys Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe773"), Action = c => { + // No need to de-elevate since we are opening windows settings which cannot bring security risks Process.Start("control.exe", "srchadmin.dll"); return true; } @@ -351,6 +355,7 @@ namespace Flow.Launcher.Plugin.Sys CopyText = recycleBinFolder, Action = c => { + // No need to de-elevate since we are opening windows settings which cannot bring security risks Process.Start("explorer", recycleBinFolder); return true; } diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs index e1bdd2462..7b8df532c 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs @@ -208,6 +208,7 @@ namespace Flow.Launcher.Plugin.WindowsSettings.Helper { processStartInfo.UseShellExecute = true; processStartInfo.Verb = "runas"; + // No need to de-elevate since we are opening windows settings which cannot bring security risks Process.Start(processStartInfo); return true; }