chore: arch: Remove XArch exception class
XArch no longer contains any extra functionality in addition to what
std::runtime_error nor it signifies a particular type of error.
based-on: 5b991692af
ported-by: sithlord48
This commit is contained in:
parent
cab1eb9cee
commit
5ee3fc41bd
8 changed files with 41 additions and 51 deletions
|
|
@ -46,24 +46,14 @@ cleanup but before leaving or returning from the handler.
|
||||||
} catch (...) { \
|
} catch (...) { \
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Generic exception architecture dependent library
|
|
||||||
class XArch : public std::runtime_error
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit XArch(const std::string &msg) : std::runtime_error(msg)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
~XArch() throw() override = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Generic network exception
|
//! Generic network exception
|
||||||
/*!
|
/*!
|
||||||
Exceptions derived from this class are used by the networking
|
Exceptions derived from this class are used by the networking
|
||||||
library to indicate various errors.
|
library to indicate various errors.
|
||||||
*/
|
*/
|
||||||
class XArchNetwork : public XArch
|
class XArchNetwork : public std::runtime_error
|
||||||
{
|
{
|
||||||
using XArch::XArch;
|
using std::runtime_error::runtime_error;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Operation was interrupted
|
//! Operation was interrupted
|
||||||
|
|
@ -185,9 +175,9 @@ class XArchNetworkNameUnsupported : public XArchNetworkName
|
||||||
Exceptions derived from this class are used by the daemon
|
Exceptions derived from this class are used by the daemon
|
||||||
library to indicate various errors.
|
library to indicate various errors.
|
||||||
*/
|
*/
|
||||||
class XArchDaemon : public XArch
|
class XArchDaemon : public std::runtime_error
|
||||||
{
|
{
|
||||||
using XArch::XArch;
|
using std::runtime_error::runtime_error;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Could not daemonize
|
//! Could not daemonize
|
||||||
|
|
|
||||||
|
|
@ -410,7 +410,7 @@ std::string ArchMiscWindows::getActiveDesktopName()
|
||||||
HDESK desk = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
HDESK desk = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
||||||
if (desk == nullptr) {
|
if (desk == nullptr) {
|
||||||
LOG((CLOG_ERR "could not open input desktop"));
|
LOG((CLOG_ERR "could not open input desktop"));
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD size;
|
DWORD size;
|
||||||
|
|
@ -531,7 +531,7 @@ bool ArchMiscWindows::isProcessElevated()
|
||||||
|
|
||||||
HANDLE hToken = nullptr;
|
HANDLE hToken = nullptr;
|
||||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) {
|
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) {
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TOKEN_ELEVATION elevation;
|
TOKEN_ELEVATION elevation;
|
||||||
|
|
@ -539,7 +539,7 @@ bool ArchMiscWindows::isProcessElevated()
|
||||||
try {
|
try {
|
||||||
DWORD dwSize = sizeof(TOKEN_ELEVATION);
|
DWORD dwSize = sizeof(TOKEN_ELEVATION);
|
||||||
if (!GetTokenInformation(hToken, TokenElevation, &elevation, sizeof(elevation), &dwSize)) {
|
if (!GetTokenInformation(hToken, TokenElevation, &elevation, sizeof(elevation), &dwSize)) {
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
CloseHandle(hToken);
|
CloseHandle(hToken);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
AppUtilWindows::AppUtilWindows(IEventQueue *events) : m_events(events), m_exitMode(kExitModeNormal)
|
AppUtilWindows::AppUtilWindows(IEventQueue *events) : m_events(events), m_exitMode(kExitModeNormal)
|
||||||
{
|
{
|
||||||
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE) == FALSE) {
|
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE) == FALSE) {
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_eventThread = std::thread(&AppUtilWindows::eventLoop, this); // NOSONAR - No jthread on Windows
|
m_eventThread = std::thread(&AppUtilWindows::eventLoop, this); // NOSONAR - No jthread on Windows
|
||||||
|
|
@ -192,7 +192,7 @@ void AppUtilWindows::eventLoop()
|
||||||
HANDLE hCloseEvent = CreateEventA(nullptr, TRUE, FALSE, 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(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("windows event loop running");
|
LOG_DEBUG("windows event loop running");
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ BOOL MSWindowsProcess::startAsUser(HANDLE userToken, LPSECURITY_ATTRIBUTES sa)
|
||||||
LPVOID environment;
|
LPVOID environment;
|
||||||
if (!CreateEnvironmentBlock(&environment, userToken, FALSE)) {
|
if (!CreateEnvironmentBlock(&environment, userToken, FALSE)) {
|
||||||
LOG((CLOG_ERR "could not create environment block"));
|
LOG((CLOG_ERR "could not create environment block"));
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory(&m_info, sizeof(PROCESS_INFORMATION));
|
ZeroMemory(&m_info, sizeof(PROCESS_INFORMATION));
|
||||||
|
|
@ -96,13 +96,13 @@ DWORD MSWindowsProcess::waitForExit()
|
||||||
if (WaitForSingleObject(m_info.hProcess, kMaxWaitMilliseconds) != WAIT_OBJECT_0) {
|
if (WaitForSingleObject(m_info.hProcess, kMaxWaitMilliseconds) != WAIT_OBJECT_0) {
|
||||||
LOG_ERR("process did not exit within the expected time");
|
LOG_ERR("process did not exit within the expected time");
|
||||||
TerminateProcess(m_info.hProcess, 1);
|
TerminateProcess(m_info.hProcess, 1);
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD exitCode = 0;
|
DWORD exitCode = 0;
|
||||||
if (!GetExitCodeProcess(m_info.hProcess, &exitCode)) {
|
if (!GetExitCodeProcess(m_info.hProcess, &exitCode)) {
|
||||||
LOG_ERR("failed to get exit code, error: %lu", GetLastError());
|
LOG_ERR("failed to get exit code, error: %lu", GetLastError());
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
|
|
@ -195,22 +195,22 @@ void MSWindowsProcess::createPipes()
|
||||||
|
|
||||||
if (!CreatePipe(&m_outputPipe, &m_stdOutput, &saAttr, 0)) {
|
if (!CreatePipe(&m_outputPipe, &m_stdOutput, &saAttr, 0)) {
|
||||||
LOG_ERR("could not create output pipe");
|
LOG_ERR("could not create output pipe");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreatePipe(&m_errorPipe, &m_stdError, &saAttr, 0)) {
|
if (!CreatePipe(&m_errorPipe, &m_stdError, &saAttr, 0)) {
|
||||||
LOG_ERR("could not create error pipe");
|
LOG_ERR("could not create error pipe");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the pipes to non-blocking mode
|
// Set the pipes to non-blocking mode
|
||||||
DWORD mode = PIPE_NOWAIT;
|
DWORD mode = PIPE_NOWAIT;
|
||||||
if (!SetNamedPipeHandleState(m_outputPipe, &mode, nullptr, nullptr)) {
|
if (!SetNamedPipeHandleState(m_outputPipe, &mode, nullptr, nullptr)) {
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SetNamedPipeHandleState(m_errorPipe, &mode, nullptr, nullptr)) {
|
if (!SetNamedPipeHandleState(m_errorPipe, &mode, nullptr, nullptr)) {
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ std::string MSWindowsProcess::readOutput(HANDLE handle)
|
||||||
// Check if there is data available in the pipe, which prevents `ReadFile` from freezing execution.
|
// Check if there is data available in the pipe, which prevents `ReadFile` from freezing execution.
|
||||||
if (!PeekNamedPipe(handle, nullptr, 0, nullptr, &totalBytesAvail, &bytesLeftThisMessage)) {
|
if (!PeekNamedPipe(handle, nullptr, 0, nullptr, &totalBytesAvail, &bytesLeftThisMessage)) {
|
||||||
LOG_ERR("could not peek into pipe");
|
LOG_ERR("could not peek into pipe");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalBytesAvail == 0) {
|
if (totalBytesAvail == 0) {
|
||||||
|
|
@ -245,7 +245,7 @@ std::string MSWindowsProcess::readOutput(HANDLE handle)
|
||||||
|
|
||||||
if (!ReadFile(handle, buffer, kOutputBufferSize, &bytesRead, nullptr)) {
|
if (!ReadFile(handle, buffer, kOutputBufferSize, &bytesRead, nullptr)) {
|
||||||
LOG_ERR("could not read from pipe");
|
LOG_ERR("could not read from pipe");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(buffer, bytesRead);
|
return std::string(buffer, bytesRead);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = nu
|
||||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
if (snapshot == INVALID_HANDLE_VALUE) {
|
if (snapshot == INVALID_HANDLE_VALUE) {
|
||||||
LOG((CLOG_ERR "could not get process snapshot"));
|
LOG((CLOG_ERR "could not get process snapshot"));
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESSENTRY32 entry;
|
PROCESSENTRY32 entry;
|
||||||
|
|
@ -34,7 +34,7 @@ bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = nu
|
||||||
BOOL gotEntry = Process32First(snapshot, &entry);
|
BOOL gotEntry = Process32First(snapshot, &entry);
|
||||||
if (!gotEntry) {
|
if (!gotEntry) {
|
||||||
LOG((CLOG_ERR "could not get first process entry"));
|
LOG((CLOG_ERR "could not get first process entry"));
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// used to record process names for debug info
|
// used to record process names for debug info
|
||||||
|
|
@ -106,7 +106,7 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security)
|
||||||
HANDLE sourceToken;
|
HANDLE sourceToken;
|
||||||
if (!WTSQueryUserToken(m_activeSessionId, &sourceToken)) {
|
if (!WTSQueryUserToken(m_activeSessionId, &sourceToken)) {
|
||||||
LOG((CLOG_ERR "could not get token from session %d", m_activeSessionId));
|
LOG((CLOG_ERR "could not get token from session %d", m_activeSessionId));
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE newToken;
|
HANDLE newToken;
|
||||||
|
|
@ -115,7 +115,7 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security)
|
||||||
)) {
|
)) {
|
||||||
|
|
||||||
LOG((CLOG_ERR "could not duplicate token"));
|
LOG((CLOG_ERR "could not duplicate token"));
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG((CLOG_DEBUG "duplicated, new token: %i", newToken));
|
LOG((CLOG_DEBUG "duplicated, new token: %i", newToken));
|
||||||
|
|
@ -149,7 +149,7 @@ BOOL MSWindowsSession::nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry)
|
||||||
// files' error then it's probably something serious.
|
// files' error then it's probably something serious.
|
||||||
if (err != ERROR_NO_MORE_FILES) {
|
if (err != ERROR_NO_MORE_FILES) {
|
||||||
LOG((CLOG_ERR "could not get next process entry"));
|
LOG((CLOG_ERR "could not get next process entry"));
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ HANDLE openProcessForKill(const PROCESSENTRY32 &entry)
|
||||||
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
|
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
LOG_ERR("could not open process handle for kill");
|
LOG_ERR("could not open process handle for kill");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only shut down if not current process (daemon is now the same unified binary).
|
// only shut down if not current process (daemon is now the same unified binary).
|
||||||
|
|
@ -126,7 +126,7 @@ MSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES s
|
||||||
|
|
||||||
if (!tokenRet) {
|
if (!tokenRet) {
|
||||||
LOG_ERR("could not open token, process handle: %d", process);
|
LOG_ERR("could not open token, process handle: %d", process);
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("got token %i, duplicating", sourceToken);
|
LOG_DEBUG("got token %i, duplicating", sourceToken);
|
||||||
|
|
@ -138,7 +138,7 @@ MSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES s
|
||||||
|
|
||||||
if (!duplicateRet) {
|
if (!duplicateRet) {
|
||||||
LOG_ERR("could not duplicate token %i", sourceToken);
|
LOG_ERR("could not duplicate token %i", sourceToken);
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("duplicated, new token: %i", newToken);
|
LOG_DEBUG("duplicated, new token: %i", newToken);
|
||||||
|
|
@ -156,12 +156,12 @@ MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security, bool elevatedTok
|
||||||
|
|
||||||
HANDLE process;
|
HANDLE process;
|
||||||
if (!m_session.isProcessInSession("winlogon.exe", &process)) {
|
if (!m_session.isProcessInSession("winlogon.exe", &process)) {
|
||||||
throw XArch("cannot get user token without winlogon.exe");
|
throw std::runtime_error("cannot get user token without winlogon.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return duplicateProcessToken(process, security);
|
return duplicateProcessToken(process, security);
|
||||||
} catch (XArch &e) {
|
} catch (std::runtime_error &e) {
|
||||||
LOG_ERR("failed to duplicate user token from winlogon.exe");
|
LOG_ERR("failed to duplicate user token from winlogon.exe");
|
||||||
CloseHandle(process);
|
CloseHandle(process);
|
||||||
throw e;
|
throw e;
|
||||||
|
|
@ -269,7 +269,7 @@ bool MSWindowsWatchdog::isProcessRunning()
|
||||||
void MSWindowsWatchdog::startProcess()
|
void MSWindowsWatchdog::startProcess()
|
||||||
{
|
{
|
||||||
if (m_command.empty()) {
|
if (m_command.empty()) {
|
||||||
throw XArch("cannot start process, command is empty");
|
throw std::runtime_error("cannot start process, command is empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_process != nullptr) {
|
if (m_process != nullptr) {
|
||||||
|
|
@ -304,7 +304,7 @@ void MSWindowsWatchdog::startProcess()
|
||||||
LOG_ERR("daemon failed to run command, exit code: %d", exitCode);
|
LOG_ERR("daemon failed to run command, exit code: %d", exitCode);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERR("daemon failed to run command, unknown exit code");
|
LOG_ERR("daemon failed to run command, unknown exit code");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Wait for program to fail. This needs to be 1 second, as the process may take some time to fail.
|
// Wait for program to fail. This needs to be 1 second, as the process may take some time to fail.
|
||||||
|
|
@ -313,7 +313,7 @@ void MSWindowsWatchdog::startProcess()
|
||||||
|
|
||||||
if (!isProcessRunning()) {
|
if (!isProcessRunning()) {
|
||||||
m_process.reset();
|
m_process.reset();
|
||||||
throw XArch("process immediately stopped");
|
throw std::runtime_error("process immediately stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("started core process from watchdog");
|
LOG_DEBUG("started core process from watchdog");
|
||||||
|
|
@ -388,7 +388,7 @@ void MSWindowsWatchdog::shutdownExistingProcesses()
|
||||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, kAllProcesses);
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, kAllProcesses);
|
||||||
if (snapshot == INVALID_HANDLE_VALUE) {
|
if (snapshot == INVALID_HANDLE_VALUE) {
|
||||||
LOG_ERR("could not get process snapshot");
|
LOG_ERR("could not get process snapshot");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESSENTRY32 entry;
|
PROCESSENTRY32 entry;
|
||||||
|
|
@ -399,7 +399,7 @@ void MSWindowsWatchdog::shutdownExistingProcesses()
|
||||||
BOOL gotEntry = Process32First(snapshot, &entry);
|
BOOL gotEntry = Process32First(snapshot, &entry);
|
||||||
if (!gotEntry) {
|
if (!gotEntry) {
|
||||||
LOG_ERR("could not get first process entry");
|
LOG_ERR("could not get first process entry");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// now just iterate until we can find winlogon.exe pid
|
// now just iterate until we can find winlogon.exe pid
|
||||||
|
|
@ -420,7 +420,7 @@ void MSWindowsWatchdog::shutdownExistingProcesses()
|
||||||
|
|
||||||
// only worry about error if it's not the end of the snapshot
|
// only worry about error if it's not the end of the snapshot
|
||||||
LOG_ERR("could not get next process entry");
|
LOG_ERR("could not get next process entry");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -482,14 +482,14 @@ void MSWindowsWatchdog::initOutputReadPipe()
|
||||||
|
|
||||||
if (!CreatePipe(&m_outputReadPipe, &m_outputWritePipe, &saAttr, 0)) {
|
if (!CreatePipe(&m_outputReadPipe, &m_outputWritePipe, &saAttr, 0)) {
|
||||||
LOG_ERR("could not create output pipe");
|
LOG_ERR("could not create output pipe");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the pipe to non-blocking mode, which allows us to stop the output reader thread immediately
|
// Set the pipe to non-blocking mode, which allows us to stop the output reader thread immediately
|
||||||
// in order to speed up the shutdown process when the Windows service needs to stop.
|
// in order to speed up the shutdown process when the Windows service needs to stop.
|
||||||
if (DWORD mode = PIPE_NOWAIT; !SetNamedPipeHandleState(m_outputReadPipe, &mode, nullptr, nullptr)) {
|
if (DWORD mode = PIPE_NOWAIT; !SetNamedPipeHandleState(m_outputReadPipe, &mode, nullptr, nullptr)) {
|
||||||
LOG_ERR("could not set pipe to non-blocking mode");
|
LOG_ERR("could not set pipe to non-blocking mode");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -500,14 +500,14 @@ void MSWindowsWatchdog::initSasFunc()
|
||||||
HINSTANCE sasLib = LoadLibrary("sas.dll");
|
HINSTANCE sasLib = LoadLibrary("sas.dll");
|
||||||
if (!sasLib) {
|
if (!sasLib) {
|
||||||
LOG_ERR("could not load sas.dll");
|
LOG_ERR("could not load sas.dll");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("loaded sas.dll, used to simulate ctrl-alt-del");
|
LOG_DEBUG("loaded sas.dll, used to simulate ctrl-alt-del");
|
||||||
m_sendSasFunc = (SendSas)GetProcAddress(sasLib, "SendSAS");
|
m_sendSasFunc = (SendSas)GetProcAddress(sasLib, "SendSAS");
|
||||||
if (!m_sendSasFunc) {
|
if (!m_sendSasFunc) {
|
||||||
LOG_ERR("could not find SendSAS function in sas.dll");
|
LOG_ERR("could not find SendSAS function in sas.dll");
|
||||||
throw XArch(windowsErrorToString(GetLastError()));
|
throw std::runtime_error(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("found SendSAS function in sas.dll");
|
LOG_DEBUG("found SendSAS function in sas.dll");
|
||||||
|
|
@ -518,7 +518,7 @@ void MSWindowsWatchdog::sasLoop(void *) // NOSONAR - Thread entry point signatur
|
||||||
LOG_DEBUG3("watchdog creating sas event");
|
LOG_DEBUG3("watchdog creating sas event");
|
||||||
|
|
||||||
if (m_sendSasFunc == nullptr) {
|
if (m_sendSasFunc == nullptr) {
|
||||||
throw XArch("SendSAS function not initialized");
|
throw std::runtime_error("SendSAS function not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (m_running) {
|
while (m_running) {
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ OSXScreen::OSXScreen(
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
// we can't pass options to show the dialog, this must be done by the gui.
|
// we can't pass options to show the dialog, this must be done by the gui.
|
||||||
if (!AXIsProcessTrusted()) {
|
if (!AXIsProcessTrusted()) {
|
||||||
throw XArch("assistive devices does not trust this process, allow it in system settings.");
|
throw std::runtime_error("assistive devices does not trust this process, allow it in system settings.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ XWindowsScreen::XWindowsScreen(
|
||||||
if (!disableXInitThreads) {
|
if (!disableXInitThreads) {
|
||||||
// initializes Xlib support for concurrent threads.
|
// initializes Xlib support for concurrent threads.
|
||||||
if (XInitThreads() == 0)
|
if (XInitThreads() == 0)
|
||||||
throw XArch("XInitThreads() returned zero");
|
throw std::runtime_error("XInitThreads() returned zero");
|
||||||
} else {
|
} else {
|
||||||
LOG((CLOG_DEBUG "skipping XInitThreads()"));
|
LOG((CLOG_DEBUG "skipping XInitThreads()"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue