We must use SendSAS (Secure Attention Sequence) to simulate Ctrl+Alt+Del (since Windows Vista). According to the MS docs: > To successfully call the SendSAS function, an application must either be running as a > service or have the uiAccess attribute of the requestedExecutionLevel element set to "true" > in its application manifest. Since the daemon is running as a service, we can use it to send
| 763 | // as a backup but this ability was removed by Microsoft for security in favor of requiring the |
| 764 | // `SendSAS` event to be used, which makes DoS and social engineering attacks more difficult. |
| 765 | bool MSWindowsKeyState::fakeCtrlAltDel() |
| 766 | { |
| 767 | // The daemon creates this event with default permissions, which means this process must be |
| 768 | // elevated to be able to open it. If not elevated, an access denied error will be returned. |
| 769 | MSWindowsHandle sendSasEvent(OpenEvent(EVENT_MODIFY_STATE, FALSE, LPCWSTR(kSendSasEventName))); |
| 770 | if (!sendSasEvent.get()) { |
| 771 | LOG_ERR( |
| 772 | "couldn't open SAS event, unable to simulate ctrl+alt+del, error: %s", |
| 773 | windowsErrorToString(GetLastError()).c_str() |
| 774 | ); |
| 775 | return false; |
| 776 | } |
| 777 | |
| 778 | // Note: We don't directly call SendSAS, but rather we tell the daemon to do it by setting the event. |
| 779 | LOG_DEBUG("setting SAS event to simulate ctrl+alt+del"); |
| 780 | if (!SetEvent(sendSasEvent.get())) { |
| 781 | LOG_ERR( |
| 782 | "failed to set SAS event, unable to simulate ctrl+alt+del, error: %s", |
| 783 | windowsErrorToString(GetLastError()).c_str() |
| 784 | ); |
| 785 | return false; |
| 786 | } |
| 787 | |
| 788 | return true; |
| 789 | } |
| 790 | |
| 791 | KeyModifierMask MSWindowsKeyState::pollActiveModifiers() const |
| 792 | { |
nothing calls this directly
no test coverage detected