chore: Move Windows event constants to constants file
This commit is contained in:
parent
d26c75a784
commit
3bcc1e11ed
6 changed files with 7 additions and 14 deletions
|
|
@ -41,12 +41,3 @@ enum
|
||||||
kExitArgs = 3, // bad arguments
|
kExitArgs = 3, // bad arguments
|
||||||
kExitConfig = 4, // cannot read configuration
|
kExitConfig = 4, // cannot read configuration
|
||||||
};
|
};
|
||||||
|
|
||||||
#if WINAPI_MSWINDOWS
|
|
||||||
namespace deskflow::common {
|
|
||||||
|
|
||||||
const auto kCloseEventName = "Global\\DeskflowClose";
|
|
||||||
const auto kSendSasEventName = "Global\\DeskflowSendSAS";
|
|
||||||
|
|
||||||
} // namespace deskflow::common
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -47,5 +47,7 @@ const auto kWindowsRuntimeMinor = @REQUIRED_MSVC_RUNTIME_MINOR@;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
const auto kWindowsRegistryKey = "SOFTWARE\\@CMAKE_PROJECT_PROPER_NAME@";
|
const auto kWindowsRegistryKey = "SOFTWARE\\@CMAKE_PROJECT_PROPER_NAME@";
|
||||||
|
const auto kCloseEventName = "Global\\DeskflowClose";
|
||||||
|
const auto kSendSasEventName = "Global\\DeskflowSendSAS";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/log_outputters.h"
|
#include "base/log_outputters.h"
|
||||||
#include "common/common.h"
|
#include "common/constants.h"
|
||||||
#include "deskflow/App.h"
|
#include "deskflow/App.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
#include "deskflow/ArgsBase.h"
|
||||||
#include "deskflow/Screen.h"
|
#include "deskflow/Screen.h"
|
||||||
|
|
@ -261,7 +261,7 @@ void AppUtilWindows::showNotification(const std::string &title, const std::strin
|
||||||
|
|
||||||
void AppUtilWindows::eventLoop()
|
void AppUtilWindows::eventLoop()
|
||||||
{
|
{
|
||||||
HANDLE hCloseEvent = CreateEventA(nullptr, TRUE, FALSE, deskflow::common::kCloseEventName);
|
HANDLE hCloseEvent = CreateEventA(nullptr, TRUE, FALSE, kCloseEventName);
|
||||||
if (!hCloseEvent) {
|
if (!hCloseEvent) {
|
||||||
LOG_CRIT("failed to create event for windows event loop");
|
LOG_CRIT("failed to create event for windows event loop");
|
||||||
throw XArch(new XArchEvalWindows());
|
throw XArch(new XArchEvalWindows());
|
||||||
|
|
|
||||||
|
|
@ -760,7 +760,7 @@ bool MSWindowsKeyState::fakeCtrlAltDel()
|
||||||
// History: It used to be possible to use `PostMessage` to send `MOD_CONTROL | MOD_ALT, VK_DELETE`
|
// 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
|
// 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.
|
// `SendSAS` event to be used, which makes DoS and social engineering attacks more difficult.
|
||||||
HANDLE hSendSasEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, deskflow::common::kSendSasEventName);
|
HANDLE hSendSasEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, kSendSasEventName);
|
||||||
if (hSendSasEvent) {
|
if (hSendSasEvent) {
|
||||||
LOG_DEBUG("found SendSAS event, simulating ctrl+alt+del");
|
LOG_DEBUG("found SendSAS event, simulating ctrl+alt+del");
|
||||||
SetEvent(hSendSasEvent);
|
SetEvent(hSendSasEvent);
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ void MSWindowsProcess::shutdown(HANDLE handle, DWORD pid, int timeout)
|
||||||
LOG_DEBUG("shutting down process %d", pid);
|
LOG_DEBUG("shutting down process %d", pid);
|
||||||
|
|
||||||
LOG_DEBUG("sending close event to close process gracefully");
|
LOG_DEBUG("sending close event to close process gracefully");
|
||||||
HANDLE hCloseEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, deskflow::common::kCloseEventName);
|
HANDLE hCloseEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, kCloseEventName);
|
||||||
if (hCloseEvent != nullptr) { // NOSONAR -- Readability
|
if (hCloseEvent != nullptr) { // NOSONAR -- Readability
|
||||||
SetEvent(hCloseEvent);
|
SetEvent(hCloseEvent);
|
||||||
CloseHandle(hCloseEvent);
|
CloseHandle(hCloseEvent);
|
||||||
|
|
|
||||||
|
|
@ -567,7 +567,7 @@ void MSWindowsWatchdog::sendSas() const
|
||||||
throw XArch("SendSAS function not initialized");
|
throw XArch("SendSAS function not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE sendSasEvent = CreateEvent(nullptr, FALSE, FALSE, deskflow::common::kSendSasEventName);
|
HANDLE sendSasEvent = CreateEvent(nullptr, FALSE, FALSE, kSendSasEventName);
|
||||||
if (sendSasEvent == nullptr) {
|
if (sendSasEvent == nullptr) {
|
||||||
LOG_ERR("could not create SendSAS event");
|
LOG_ERR("could not create SendSAS event");
|
||||||
throw XArch(new XArchEvalWindows());
|
throw XArch(new XArchEvalWindows());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue