mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
drop privileges if running elevated
make sure the Settings process is not running elevated otherwise the WebView control will fail to start
This commit is contained in:
committed by
Enrico Giordani
parent
25510b23e1
commit
298a8787d5
@@ -6,6 +6,7 @@
|
||||
#include <ShellScalingApi.h>
|
||||
#include "resource.h"
|
||||
#include <common/dpi_aware.h>
|
||||
#include <common/common.h>
|
||||
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
#pragma comment(lib, "shcore.lib")
|
||||
@@ -424,12 +425,21 @@ void initialize_message_pipe() {
|
||||
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) {
|
||||
CoInitialize(nullptr);
|
||||
|
||||
if (is_process_elevated()) {
|
||||
if (!drop_elevated_privileges()) {
|
||||
MessageBox(NULL, L"Failed to drop admin privileges.\nPlease report the bug to https://github.com/microsoft/PowerToys/issues.", L"PowerToys Settings Error", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
g_hinst = hInstance;
|
||||
initialize_message_pipe();
|
||||
register_classes(hInstance);
|
||||
g_main_wnd = create_main_window(hInstance);
|
||||
if (g_main_wnd == nullptr) {
|
||||
MessageBox(NULL, L"Failed to create main window.\nPlease report the bug to https://github.com/microsoft/PowerToys/issues.", L"PowerToys Settings Error", MB_OK);
|
||||
}
|
||||
initialize_webview();
|
||||
WINRT_VERIFY(ShowWindow(g_main_wnd, nShowCmd));
|
||||
ShowWindow(g_main_wnd, nShowCmd);
|
||||
|
||||
// Main message loop.
|
||||
MSG msg;
|
||||
|
||||
Reference in New Issue
Block a user