chore: Remove old ctrl+alt+del PostMessage call (for Windows XP and below)

This commit is contained in:
Nick Bolton 2025-03-10 12:16:38 +00:00 committed by Chris Rizzitello
parent 39e7f60c5a
commit 3344644d2e
2 changed files with 12 additions and 30 deletions

View file

@ -752,38 +752,23 @@ bool MSWindowsKeyState::fakeKeyRepeat(
bool MSWindowsKeyState::fakeCtrlAltDel() bool MSWindowsKeyState::fakeCtrlAltDel()
{ {
// to fake ctrl+alt+del on the NT family we broadcast a suitable // We must use SendSAS (Secure Attention Sequence) to simulate Ctrl+Alt+Del as of Windows Vista.
// hotkey to all windows on the winlogon desktop. however, the // The SoftwareSASGeneration registry key must be set for this to work:
// current thread must be on that desktop to do the broadcast // Set-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\Policies\System
// and we can't switch just any thread because some own windows // -Name SoftwareSASGeneration -Value 1
// or hooks. so start a new thread to do the real work. //
// History: It used to be possible to use `PostMessage` to send `MOD_CONTROL | MOD_ALT, VK_DELETE`
// as a backup but this ability was removed by Microsoft for security in favor of requiring the
// `SendSAS` event to be used, which makes DoS and social engineering attacks more difficult.
HANDLE hEvtSendSas = OpenEvent(EVENT_MODIFY_STATE, FALSE, "Global\\SendSAS"); HANDLE hEvtSendSas = OpenEvent(EVENT_MODIFY_STATE, FALSE, "Global\\SendSAS");
if (hEvtSendSas) { if (hEvtSendSas) {
LOG((CLOG_DEBUG "found the SendSAS event - signaling my launcher to " LOG_DEBUG("found SendSAS event, simulating ctrl+alt+del");
"simulate ctrl+alt+del"));
SetEvent(hEvtSendSas); SetEvent(hEvtSendSas);
CloseHandle(hEvtSendSas); CloseHandle(hEvtSendSas);
return true;
} else { } else {
Thread cad(new FunctionJob(&MSWindowsKeyState::ctrlAltDelThread)); LOG_ERR("couldn't find SendSAS event, unable to simulate ctrl+alt+del");
cad.wait(); return false;
}
return true;
}
void MSWindowsKeyState::ctrlAltDelThread(void *)
{
// get the Winlogon desktop at whatever privilege we can
HDESK desk = OpenDesktop("Winlogon", 0, FALSE, MAXIMUM_ALLOWED);
if (desk != NULL) {
if (SetThreadDesktop(desk)) {
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELPARAM(MOD_CONTROL | MOD_ALT, VK_DELETE));
} else {
LOG((CLOG_DEBUG "can't switch to Winlogon desk: %d", GetLastError()));
}
CloseDesktop(desk);
} else {
LOG((CLOG_DEBUG "can't open Winlogon desk: %d", GetLastError()));
} }
} }

View file

@ -171,9 +171,6 @@ protected:
private: private:
using GroupList = std::vector<HKL>; using GroupList = std::vector<HKL>;
// send ctrl+alt+del hotkey event on NT family
static void ctrlAltDelThread(void *);
bool getGroups(GroupList &) const; bool getGroups(GroupList &) const;
void setWindowGroup(int32_t group); void setWindowGroup(int32_t group);