Deskflow 1.22.0.197
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::string &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::string readStdOutput();
32 std::string 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
41private:
42 void setStartupInfo(STARTUPINFO &si);
43
44 static std::string readOutput(HANDLE handle);
45
46 std::string m_command;
47 HANDLE m_stdOutput;
48 HANDLE m_stdError;
49 HANDLE m_outputPipe = nullptr;
50 HANDLE m_errorPipe = nullptr;
51 PROCESS_INFORMATION m_info;
52 BOOL m_createProcessResult = FALSE;
53};
54
55} // namespace deskflow::platform
static const WSAEVENT FAR DWORD
Definition ArchNetworkWinsock.cpp:54
static const WSAEVENT FAR BOOL
Definition ArchNetworkWinsock.cpp:54
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:39
BOOL startAsUser(HANDLE userToken, LPSECURITY_ATTRIBUTES sa)
Definition MSWindowsProcess.cpp:58
~MSWindowsProcess()
Definition MSWindowsProcess.cpp:32
BOOL startInForeground()
Definition MSWindowsProcess.cpp:40
void createPipes()
Definition MSWindowsProcess.cpp:191
PROCESS_INFORMATION info() const
Definition MSWindowsProcess.h:34
std::string readStdError()
Definition MSWindowsProcess.cpp:224
DWORD waitForExit()
Definition MSWindowsProcess.cpp:93
MSWindowsProcess(const std::string &command, HANDLE stdOutput=nullptr, HANDLE stdError=nullptr)
Definition MSWindowsProcess.cpp:25
void shutdown(int timeout=kDefaultShutdownTimeout)
Definition MSWindowsProcess.cpp:119
std::string readStdOutput()
Definition MSWindowsProcess.cpp:219
Definition MSWindowsProcess.cpp:23