mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[PowerToys Run] run non-elevated when runner is elevated (#3451)
* run Launcher non-elevated * Implemented acquiring PID of Launcher Co-authored-by: ivan100sic <ivan100sic@gmail.com>
This commit is contained in:
@@ -461,7 +461,7 @@ bool run_elevated(const std::wstring& file, const std::wstring& params)
|
||||
}
|
||||
}
|
||||
|
||||
bool run_non_elevated(const std::wstring& file, const std::wstring& params)
|
||||
bool run_non_elevated(const std::wstring& file, const std::wstring& params, DWORD* returnPid)
|
||||
{
|
||||
auto executable_args = L"\"" + file + L"\"";
|
||||
if (!params.empty())
|
||||
@@ -521,8 +521,14 @@ bool run_non_elevated(const std::wstring& file, const std::wstring& params)
|
||||
nullptr,
|
||||
&siex.StartupInfo,
|
||||
&process_info);
|
||||
|
||||
if (process_info.hProcess)
|
||||
{
|
||||
if (returnPid)
|
||||
{
|
||||
*returnPid = GetProcessId(process_info.hProcess);
|
||||
}
|
||||
|
||||
CloseHandle(process_info.hProcess);
|
||||
}
|
||||
if (process_info.hThread)
|
||||
|
||||
@@ -69,8 +69,8 @@ bool drop_elevated_privileges();
|
||||
// Run command as elevated user, returns true if succeeded
|
||||
bool run_elevated(const std::wstring& file, const std::wstring& params);
|
||||
|
||||
// Run command as non-elevated user, returns true if succeeded
|
||||
bool run_non_elevated(const std::wstring& file, const std::wstring& params);
|
||||
// Run command as non-elevated user, returns true if succeeded, puts the process id into returnPid if returnPid != NULL
|
||||
bool run_non_elevated(const std::wstring& file, const std::wstring& params, DWORD* returnPid);
|
||||
|
||||
// Run command with the same elevation, returns true if succedded
|
||||
bool run_same_elevation(const std::wstring& file, const std::wstring& params);
|
||||
@@ -136,3 +136,5 @@ struct overloaded : Ts...
|
||||
};
|
||||
template<class... Ts>
|
||||
overloaded(Ts...)->overloaded<Ts...>;
|
||||
|
||||
#define POWER_LAUNCHER_PID_SHARED_FILE L"Global\\3cbfbad4-199b-4e2c-9825-942d5d3d3c74"
|
||||
|
||||
Reference in New Issue
Block a user