Deskflow 1.26.0.207
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
MSWindowsProcess.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2025 Symless Ltd.
4 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
5 */
6
7#pragma once
8
9#define WIN32_LEAN_AND_MEAN
10#include <Windows.h>
11
12#include <string>
13
14namespace deskflow::platform {
15
16namespace { // NOSONAR -- Deliberate anonymous
17const auto kDefaultShutdownTimeout = 10;
18}
19
21{
22public:
23 explicit MSWindowsProcess(const std::wstring &command, HANDLE stdOutput = nullptr, HANDLE stdError = nullptr);
25
27 BOOL startAsUser(HANDLE userToken, LPSECURITY_ATTRIBUTES sa);
28 void shutdown(int timeout = kDefaultShutdownTimeout);
30 void createPipes();
31 std::wstring readStdOutput();
32 std::wstring readStdError();
33
34 PROCESS_INFORMATION info() const
35 {
36 return m_info;
37 }
38
39 static void shutdown(HANDLE handle, DWORD pid, int timeout = kDefaultShutdownTimeout);
40
43 static bool startDetachedAsSessionUser(const std::wstring &command);
44
45private:
46 void setStartupInfo(STARTUPINFO &si);
47
48 static std::wstring readOutput(HANDLE handle);
49
50 std::wstring m_command;
51 HANDLE m_stdOutput;
52 HANDLE m_stdError;
53 HANDLE m_outputPipe = nullptr;
54 HANDLE m_errorPipe = nullptr;
55 PROCESS_INFORMATION m_info;
56 BOOL m_createProcessResult = FALSE;
57};
58
59} // namespace deskflow::platform
static const WSAEVENT FAR DWORD
Definition ArchNetworkWinsock.cpp:55
static const WSAEVENT FAR BOOL
Definition ArchNetworkWinsock.cpp:55
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:40
MSWindowsProcess(const std::wstring &command, HANDLE stdOutput=nullptr, HANDLE stdError=nullptr)
Definition MSWindowsProcess.cpp:25
BOOL startAsUser(HANDLE userToken, LPSECURITY_ATTRIBUTES sa)
Definition MSWindowsProcess.cpp:58
~MSWindowsProcess()
Definition MSWindowsProcess.cpp:32
std::wstring readStdError()
Definition MSWindowsProcess.cpp:270
BOOL startInForeground()
Definition MSWindowsProcess.cpp:40
void createPipes()
Definition MSWindowsProcess.cpp:237
PROCESS_INFORMATION info() const
Definition MSWindowsProcess.h:34
DWORD waitForExit()
Definition MSWindowsProcess.cpp:94
static bool startDetachedAsSessionUser(const std::wstring &command)
Definition MSWindowsProcess.cpp:192
std::wstring readStdOutput()
Definition MSWindowsProcess.cpp:265
void shutdown(int timeout=kDefaultShutdownTimeout)
Definition MSWindowsProcess.cpp:120
Definition PlatformInfo.h:13