mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-07-09 20:09:28 +02:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary Mitigation for issue #47556 — `KERNEL_SECURITY_CHECK_FAILURE` BSOD originating in `win32kfull!DdcciGetCapabilitiesStringFromMonitor` when PowerDisplay calls DDC/CI capability APIs against monitors with malformed capability strings. After a detected crash, PowerDisplay auto-disables itself via `settings.json`, shows an error InfoBar at the top of the PowerDisplay settings page (page is locked except the Ignore button), so users can avoid getting stuck in an infinite reboot loop after a crash. And the user must explicitly dismiss the warning before re-enabling the module. The actual kernel-side fix is the Windows team's responsibility — this PR only prevents users from BSOD-ing repeatedly on the same monitor without warning. settings page: <img width="1743" height="1475" alt="image" src="https://github.com/user-attachments/assets/8cf1b72f-c51a-4955-82d7-213cae49fd4e" /> ## Mechanism 1. `CrashDetectionScope` IDisposable wraps Phase 2 capability fetch in `DdcCiController.DiscoverMonitorsAsync`, writing `discovery.lock` (`WriteThrough` + `Flush(flushToDisk: true)`) before, deleting it on Dispose. 2. If the process is killed externally (BSOD, FailFast), the lock survives. 3. On next PowerDisplay.exe startup (Phase 0), `CrashRecovery` detects the orphan lock and runs a strict fail-fast sequence: write `crash_detected.flag` → set `enabled.PowerDisplay=false` in global `settings.json` → signal the new `POWER_DISPLAY_AUTO_DISABLE_EVENT` → delete the lock (commit point). 4. The runner-loaded `PowerDisplayModuleInterface.dll` runs a one-shot listener thread that wakes on the event and calls `disable()` to sync `m_enabled`. 5. `PowerDisplayViewModel` reads the flag at construction and binds `IsCrashLockActive` to lock the page. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes: #47556 <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed --------- Co-authored-by: Yu Leng <yuleng@microsoft.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
317 lines
10 KiB
C++
317 lines
10 KiB
C++
#include "pch.h"
|
|
#include "Constants.h"
|
|
#include "Constants.g.cpp"
|
|
#include "shared_constants.h"
|
|
#include <ShlObj.h>
|
|
|
|
namespace winrt::PowerToys::Interop::implementation
|
|
{
|
|
uint32_t Constants::VK_WIN_BOTH()
|
|
{
|
|
return CommonSharedConstants::VK_WIN_BOTH;
|
|
}
|
|
hstring Constants::AppDataPath()
|
|
{
|
|
PWSTR local_app_path;
|
|
winrt::check_hresult(SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &local_app_path));
|
|
winrt::hstring result{ local_app_path };
|
|
CoTaskMemFree(local_app_path);
|
|
result = result + L"\\" + CommonSharedConstants::APPDATA_PATH;
|
|
return result;
|
|
}
|
|
hstring Constants::PowerLauncherSharedEvent()
|
|
{
|
|
return CommonSharedConstants::POWER_LAUNCHER_SHARED_EVENT;
|
|
}
|
|
hstring Constants::PowerLauncherCentralizedHookSharedEvent()
|
|
{
|
|
return CommonSharedConstants::POWER_LAUNCHER_CENTRALIZED_HOOK_SHARED_EVENT;
|
|
}
|
|
hstring Constants::RunSendSettingsTelemetryEvent()
|
|
{
|
|
return CommonSharedConstants::RUN_SEND_SETTINGS_TELEMETRY_EVENT;
|
|
}
|
|
hstring Constants::RunExitEvent()
|
|
{
|
|
return CommonSharedConstants::RUN_EXIT_EVENT;
|
|
}
|
|
hstring Constants::FZEExitEvent()
|
|
{
|
|
return CommonSharedConstants::FZE_EXIT_EVENT;
|
|
}
|
|
hstring Constants::FZEToggleEvent()
|
|
{
|
|
return CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT;
|
|
}
|
|
hstring Constants::ColorPickerSendSettingsTelemetryEvent()
|
|
{
|
|
return CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT;
|
|
}
|
|
hstring Constants::ShowColorPickerSharedEvent()
|
|
{
|
|
return CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT;
|
|
}
|
|
hstring Constants::TerminateColorPickerSharedEvent()
|
|
{
|
|
return CommonSharedConstants::TERMINATE_COLOR_PICKER_SHARED_EVENT;
|
|
}
|
|
hstring Constants::AdvancedPasteShowUIMessage()
|
|
{
|
|
return CommonSharedConstants::ADVANCED_PASTE_SHOW_UI_MESSAGE;
|
|
}
|
|
hstring Constants::AdvancedPasteMarkdownMessage()
|
|
{
|
|
return CommonSharedConstants::ADVANCED_PASTE_MARKDOWN_MESSAGE;
|
|
}
|
|
hstring Constants::AdvancedPasteJsonMessage()
|
|
{
|
|
return CommonSharedConstants::ADVANCED_PASTE_JSON_MESSAGE;
|
|
}
|
|
hstring Constants::AdvancedPasteAdditionalActionMessage()
|
|
{
|
|
return CommonSharedConstants::ADVANCED_PASTE_ADDITIONAL_ACTION_MESSAGE;
|
|
}
|
|
hstring Constants::AdvancedPasteCustomActionMessage()
|
|
{
|
|
return CommonSharedConstants::ADVANCED_PASTE_CUSTOM_ACTION_MESSAGE;
|
|
}
|
|
hstring Constants::AdvancedPasteShowUIEvent()
|
|
{
|
|
return CommonSharedConstants::ADVANCED_PASTE_SHOW_UI_EVENT;
|
|
}
|
|
hstring Constants::AdvancedPasteTerminateAppMessage()
|
|
{
|
|
return CommonSharedConstants::ADVANCED_PASTE_TERMINATE_APP_MESSAGE;
|
|
}
|
|
hstring Constants::AlwaysOnTopPinEvent()
|
|
{
|
|
return CommonSharedConstants::ALWAYS_ON_TOP_PIN_EVENT;
|
|
}
|
|
hstring Constants::FindMyMouseTriggerEvent()
|
|
{
|
|
return CommonSharedConstants::FIND_MY_MOUSE_TRIGGER_EVENT;
|
|
}
|
|
hstring Constants::MouseHighlighterTriggerEvent()
|
|
{
|
|
return CommonSharedConstants::MOUSE_HIGHLIGHTER_TRIGGER_EVENT;
|
|
}
|
|
hstring Constants::MouseCrosshairsTriggerEvent()
|
|
{
|
|
return CommonSharedConstants::MOUSE_CROSSHAIRS_TRIGGER_EVENT;
|
|
}
|
|
hstring Constants::CursorWrapTriggerEvent()
|
|
{
|
|
return CommonSharedConstants::CURSOR_WRAP_TRIGGER_EVENT;
|
|
}
|
|
hstring Constants::LightSwitchToggleEvent()
|
|
{
|
|
return CommonSharedConstants::LIGHTSWITCH_TOGGLE_EVENT;
|
|
}
|
|
hstring Constants::ZoomItZoomEvent()
|
|
{
|
|
return CommonSharedConstants::ZOOMIT_ZOOM_EVENT;
|
|
}
|
|
hstring Constants::ZoomItDrawEvent()
|
|
{
|
|
return CommonSharedConstants::ZOOMIT_DRAW_EVENT;
|
|
}
|
|
hstring Constants::ZoomItBreakEvent()
|
|
{
|
|
return CommonSharedConstants::ZOOMIT_BREAK_EVENT;
|
|
}
|
|
hstring Constants::ZoomItLiveZoomEvent()
|
|
{
|
|
return CommonSharedConstants::ZOOMIT_LIVEZOOM_EVENT;
|
|
}
|
|
hstring Constants::ZoomItSnipEvent()
|
|
{
|
|
return CommonSharedConstants::ZOOMIT_SNIP_EVENT;
|
|
}
|
|
hstring Constants::ZoomItRecordEvent()
|
|
{
|
|
return CommonSharedConstants::ZOOMIT_RECORD_EVENT;
|
|
}
|
|
hstring Constants::ShowPowerOCRSharedEvent()
|
|
{
|
|
return CommonSharedConstants::SHOW_POWEROCR_SHARED_EVENT;
|
|
}
|
|
hstring Constants::TerminatePowerOCRSharedEvent()
|
|
{
|
|
return CommonSharedConstants::TERMINATE_POWEROCR_SHARED_EVENT;
|
|
}
|
|
hstring Constants::MouseJumpShowPreviewEvent()
|
|
{
|
|
return CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT;
|
|
}
|
|
hstring Constants::TerminateMouseJumpSharedEvent()
|
|
{
|
|
return CommonSharedConstants::TERMINATE_MOUSE_JUMP_SHARED_EVENT;
|
|
}
|
|
hstring Constants::AwakeExitEvent()
|
|
{
|
|
return CommonSharedConstants::AWAKE_EXIT_EVENT;
|
|
}
|
|
hstring Constants::ShowPeekEvent()
|
|
{
|
|
return CommonSharedConstants::SHOW_PEEK_SHARED_EVENT;
|
|
}
|
|
hstring Constants::TerminatePeekEvent()
|
|
{
|
|
return CommonSharedConstants::TERMINATE_PEEK_SHARED_EVENT;
|
|
}
|
|
hstring Constants::PowerAccentExitEvent()
|
|
{
|
|
return CommonSharedConstants::POWERACCENT_EXIT_EVENT;
|
|
}
|
|
hstring Constants::ShortcutGuideTriggerEvent()
|
|
{
|
|
return CommonSharedConstants::SHORTCUT_GUIDE_TRIGGER_EVENT;
|
|
}
|
|
hstring Constants::RegistryPreviewTriggerEvent()
|
|
{
|
|
return CommonSharedConstants::REGISTRY_PREVIEW_TRIGGER_EVENT;
|
|
}
|
|
hstring Constants::MeasureToolTriggerEvent()
|
|
{
|
|
return CommonSharedConstants::MEASURE_TOOL_TRIGGER_EVENT;
|
|
}
|
|
hstring Constants::GcodePreviewResizeEvent()
|
|
{
|
|
return CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT;
|
|
}
|
|
hstring Constants::BgcodePreviewResizeEvent()
|
|
{
|
|
return CommonSharedConstants::BGCODE_PREVIEW_RESIZE_EVENT;
|
|
}
|
|
hstring Constants::QoiPreviewResizeEvent()
|
|
{
|
|
return CommonSharedConstants::QOI_PREVIEW_RESIZE_EVENT;
|
|
}
|
|
hstring Constants::DevFilesPreviewResizeEvent()
|
|
{
|
|
return CommonSharedConstants::DEV_FILES_PREVIEW_RESIZE_EVENT;
|
|
}
|
|
hstring Constants::MarkdownPreviewResizeEvent()
|
|
{
|
|
return CommonSharedConstants::MARKDOWN_PREVIEW_RESIZE_EVENT;
|
|
}
|
|
hstring Constants::PdfPreviewResizeEvent()
|
|
{
|
|
return CommonSharedConstants::PDF_PREVIEW_RESIZE_EVENT;
|
|
}
|
|
hstring Constants::SvgPreviewResizeEvent()
|
|
{
|
|
return CommonSharedConstants::SVG_PREVIEW_RESIZE_EVENT;
|
|
}
|
|
hstring Constants::ShowHostsSharedEvent()
|
|
{
|
|
return CommonSharedConstants::SHOW_HOSTS_EVENT;
|
|
}
|
|
hstring Constants::ShowHostsAdminSharedEvent()
|
|
{
|
|
return CommonSharedConstants::SHOW_HOSTS_ADMIN_EVENT;
|
|
}
|
|
hstring Constants::TerminateHostsSharedEvent()
|
|
{
|
|
return CommonSharedConstants::TERMINATE_HOSTS_EVENT;
|
|
}
|
|
hstring Constants::CropAndLockThumbnailEvent()
|
|
{
|
|
return CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT;
|
|
}
|
|
hstring Constants::CropAndLockReparentEvent()
|
|
{
|
|
return CommonSharedConstants::CROP_AND_LOCK_REPARENT_EVENT;
|
|
}
|
|
hstring Constants::CropAndLockScreenshotEvent()
|
|
{
|
|
return CommonSharedConstants::CROP_AND_LOCK_SCREENSHOT_EVENT;
|
|
}
|
|
hstring Constants::ShowEnvironmentVariablesSharedEvent()
|
|
{
|
|
return CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_EVENT;
|
|
}
|
|
hstring Constants::ShowEnvironmentVariablesAdminSharedEvent()
|
|
{
|
|
return CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_ADMIN_EVENT;
|
|
}
|
|
hstring Constants::WorkspacesLaunchEditorEvent()
|
|
{
|
|
return CommonSharedConstants::WORKSPACES_LAUNCH_EDITOR_EVENT;
|
|
}
|
|
hstring Constants::WorkspacesHotkeyEvent()
|
|
{
|
|
return CommonSharedConstants::WORKSPACES_HOTKEY_EVENT;
|
|
}
|
|
hstring Constants::PowerToysRunnerTerminateSettingsEvent()
|
|
{
|
|
return CommonSharedConstants::TERMINATE_SETTINGS_SHARED_EVENT;
|
|
}
|
|
hstring Constants::ShowCmdPalEvent()
|
|
{
|
|
return CommonSharedConstants::CMDPAL_SHOW_EVENT;
|
|
}
|
|
hstring Constants::TogglePowerDisplayEvent()
|
|
{
|
|
return CommonSharedConstants::TOGGLE_POWER_DISPLAY_EVENT;
|
|
}
|
|
hstring Constants::TerminatePowerDisplayEvent()
|
|
{
|
|
return CommonSharedConstants::TERMINATE_POWER_DISPLAY_EVENT;
|
|
}
|
|
hstring Constants::AutoDisablePowerDisplayEvent()
|
|
{
|
|
return CommonSharedConstants::POWER_DISPLAY_AUTO_DISABLE_EVENT;
|
|
}
|
|
hstring Constants::RefreshPowerDisplayMonitorsEvent()
|
|
{
|
|
return CommonSharedConstants::REFRESH_POWER_DISPLAY_MONITORS_EVENT;
|
|
}
|
|
hstring Constants::SettingsUpdatedPowerDisplayEvent()
|
|
{
|
|
return CommonSharedConstants::SETTINGS_UPDATED_POWER_DISPLAY_EVENT;
|
|
}
|
|
hstring Constants::PowerDisplaySendSettingsTelemetryEvent()
|
|
{
|
|
return CommonSharedConstants::POWER_DISPLAY_SEND_SETTINGS_TELEMETRY_EVENT;
|
|
}
|
|
hstring Constants::HotkeyUpdatedPowerDisplayEvent()
|
|
{
|
|
return CommonSharedConstants::HOTKEY_UPDATED_POWER_DISPLAY_EVENT;
|
|
}
|
|
hstring Constants::RescanPowerDisplayMonitorsEvent()
|
|
{
|
|
return CommonSharedConstants::RESCAN_POWER_DISPLAY_MONITORS_EVENT;
|
|
}
|
|
hstring Constants::PowerDisplayToggleMessage()
|
|
{
|
|
return CommonSharedConstants::POWER_DISPLAY_TOGGLE_MESSAGE;
|
|
}
|
|
hstring Constants::PowerDisplayApplyProfileMessage()
|
|
{
|
|
return CommonSharedConstants::POWER_DISPLAY_APPLY_PROFILE_MESSAGE;
|
|
}
|
|
hstring Constants::PowerDisplayTerminateAppMessage()
|
|
{
|
|
return CommonSharedConstants::POWER_DISPLAY_TERMINATE_APP_MESSAGE;
|
|
}
|
|
hstring Constants::MWBToggleEasyMouseEvent()
|
|
{
|
|
return CommonSharedConstants::MWB_TOGGLE_EASY_MOUSE_EVENT;
|
|
}
|
|
hstring Constants::MWBReconnectEvent()
|
|
{
|
|
return CommonSharedConstants::MWB_RECONNECT_EVENT;
|
|
}
|
|
|
|
hstring Constants::OpenNewKeyboardManagerEvent()
|
|
{
|
|
return CommonSharedConstants::OPEN_NEW_KEYBOARD_MANAGER_EVENT;
|
|
}
|
|
hstring Constants::KeyboardManagerEngineInstanceMutex()
|
|
{
|
|
return CommonSharedConstants::KEYBOARD_MANAGER_ENGINE_INSTANCE_MUTEX;
|
|
}
|
|
}
|
|
|