mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +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:
@@ -186,7 +186,28 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||
}
|
||||
std::wstring_view action{ args[1] };
|
||||
|
||||
if (action == L"-install_dotnet")
|
||||
|
||||
if (action == L"-start_PowerLauncher")
|
||||
{
|
||||
if (is_process_elevated(false) == true)
|
||||
{
|
||||
drop_elevated_privileges();
|
||||
}
|
||||
|
||||
HANDLE hMapFile = OpenFileMappingW(FILE_MAP_WRITE, FALSE, POWER_LAUNCHER_PID_SHARED_FILE);
|
||||
PDWORD pidBuffer = reinterpret_cast<PDWORD>(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(DWORD)));
|
||||
if (pidBuffer)
|
||||
{
|
||||
*pidBuffer = 0;
|
||||
run_non_elevated(L"modules\\launcher\\PowerLauncher.exe", L"", pidBuffer);
|
||||
FlushViewOfFile(pidBuffer, sizeof(DWORD));
|
||||
UnmapViewOfFile(pidBuffer);
|
||||
}
|
||||
|
||||
FlushFileBuffers(hMapFile);
|
||||
CloseHandle(hMapFile);
|
||||
}
|
||||
else if (action == L"-install_dotnet")
|
||||
{
|
||||
if (dotnet_is_installed())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user