renamed CMSWindowsRelauncher to CMSWindowsWatchdog
This commit is contained in:
parent
499cd47e63
commit
d09ee887d8
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CMSWindowsRelauncher.h"
|
#include "CMSWindowsWatchdog.h"
|
||||||
#include "CThread.h"
|
#include "CThread.h"
|
||||||
#include "TMethodJob.h"
|
#include "TMethodJob.h"
|
||||||
#include "CLog.h"
|
#include "CLog.h"
|
||||||
|
@ -41,7 +41,7 @@ enum {
|
||||||
|
|
||||||
typedef VOID (WINAPI *SendSas)(BOOL asUser);
|
typedef VOID (WINAPI *SendSas)(BOOL asUser);
|
||||||
|
|
||||||
CMSWindowsRelauncher::CMSWindowsRelauncher(
|
CMSWindowsWatchdog::CMSWindowsWatchdog(
|
||||||
bool autoDetectCommand,
|
bool autoDetectCommand,
|
||||||
CIpcServer& ipcServer,
|
CIpcServer& ipcServer,
|
||||||
CIpcLogOutputter& ipcLogOutputter) :
|
CIpcLogOutputter& ipcLogOutputter) :
|
||||||
|
@ -59,22 +59,22 @@ CMSWindowsRelauncher::CMSWindowsRelauncher(
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CMSWindowsRelauncher::~CMSWindowsRelauncher()
|
CMSWindowsWatchdog::~CMSWindowsWatchdog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::startAsync()
|
CMSWindowsWatchdog::startAsync()
|
||||||
{
|
{
|
||||||
m_thread = new CThread(new TMethodJob<CMSWindowsRelauncher>(
|
m_thread = new CThread(new TMethodJob<CMSWindowsWatchdog>(
|
||||||
this, &CMSWindowsRelauncher::mainLoop, nullptr));
|
this, &CMSWindowsWatchdog::mainLoop, nullptr));
|
||||||
|
|
||||||
m_outputThread = new CThread(new TMethodJob<CMSWindowsRelauncher>(
|
m_outputThread = new CThread(new TMethodJob<CMSWindowsWatchdog>(
|
||||||
this, &CMSWindowsRelauncher::outputLoop, nullptr));
|
this, &CMSWindowsWatchdog::outputLoop, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::stop()
|
CMSWindowsWatchdog::stop()
|
||||||
{
|
{
|
||||||
m_monitoring = false;
|
m_monitoring = false;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ CMSWindowsRelauncher::stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
CMSWindowsRelauncher::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security)
|
CMSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security)
|
||||||
{
|
{
|
||||||
HANDLE sourceToken;
|
HANDLE sourceToken;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ CMSWindowsRelauncher::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTE
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
CMSWindowsRelauncher::getUserToken(LPSECURITY_ATTRIBUTES security)
|
CMSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security)
|
||||||
{
|
{
|
||||||
// always elevate if we are at the vista/7 login screen. we could also
|
// always elevate if we are at the vista/7 login screen. we could also
|
||||||
// elevate for the uac dialog (consent.exe) but this would be pointless,
|
// elevate for the uac dialog (consent.exe) but this would be pointless,
|
||||||
|
@ -142,7 +142,7 @@ CMSWindowsRelauncher::getUserToken(LPSECURITY_ATTRIBUTES security)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::mainLoop(void*)
|
CMSWindowsWatchdog::mainLoop(void*)
|
||||||
{
|
{
|
||||||
shutdownExistingProcesses();
|
shutdownExistingProcesses();
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ CMSWindowsRelauncher::mainLoop(void*)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CMSWindowsRelauncher::isProcessRunning()
|
CMSWindowsWatchdog::isProcessRunning()
|
||||||
{
|
{
|
||||||
bool running;
|
bool running;
|
||||||
if (m_launched) {
|
if (m_launched) {
|
||||||
|
@ -256,7 +256,7 @@ CMSWindowsRelauncher::isProcessRunning()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::startProcess(std::string& command)
|
CMSWindowsWatchdog::startProcess(std::string& command)
|
||||||
{
|
{
|
||||||
m_commandChanged = false;
|
m_commandChanged = false;
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ CMSWindowsRelauncher::startProcess(std::string& command)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::setCommand(const std::string& command, bool elevate)
|
CMSWindowsWatchdog::setCommand(const std::string& command, bool elevate)
|
||||||
{
|
{
|
||||||
LOG((CLOG_INFO "service command updated"));
|
LOG((CLOG_INFO "service command updated"));
|
||||||
m_command = command;
|
m_command = command;
|
||||||
|
@ -327,7 +327,7 @@ CMSWindowsRelauncher::setCommand(const std::string& command, bool elevate)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
CMSWindowsRelauncher::getCommand() const
|
CMSWindowsWatchdog::getCommand() const
|
||||||
{
|
{
|
||||||
if (!m_autoDetectCommand) {
|
if (!m_autoDetectCommand) {
|
||||||
return m_command;
|
return m_command;
|
||||||
|
@ -353,7 +353,7 @@ CMSWindowsRelauncher::getCommand() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::outputLoop(void*)
|
CMSWindowsWatchdog::outputLoop(void*)
|
||||||
{
|
{
|
||||||
// +1 char for \0
|
// +1 char for \0
|
||||||
CHAR buffer[kOutputBufferSize + 1];
|
CHAR buffer[kOutputBufferSize + 1];
|
||||||
|
@ -380,7 +380,7 @@ CMSWindowsRelauncher::outputLoop(void*)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::shutdownProcess(HANDLE handle, DWORD pid, int timeout)
|
CMSWindowsWatchdog::shutdownProcess(HANDLE handle, DWORD pid, int timeout)
|
||||||
{
|
{
|
||||||
DWORD exitCode;
|
DWORD exitCode;
|
||||||
GetExitCodeProcess(handle, &exitCode);
|
GetExitCodeProcess(handle, &exitCode);
|
||||||
|
@ -420,7 +420,7 @@ CMSWindowsRelauncher::shutdownProcess(HANDLE handle, DWORD pid, int timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsRelauncher::shutdownExistingProcesses()
|
CMSWindowsWatchdog::shutdownExistingProcesses()
|
||||||
{
|
{
|
||||||
// first we need to take a snapshot of the running processes
|
// first we need to take a snapshot of the running processes
|
||||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
|
@ -16,8 +16,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: rename class to CMSWindowsWatchdog
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
@ -31,13 +29,13 @@ class CThread;
|
||||||
class CIpcLogOutputter;
|
class CIpcLogOutputter;
|
||||||
class CIpcServer;
|
class CIpcServer;
|
||||||
|
|
||||||
class CMSWindowsRelauncher {
|
class CMSWindowsWatchdog {
|
||||||
public:
|
public:
|
||||||
CMSWindowsRelauncher(
|
CMSWindowsWatchdog(
|
||||||
bool autoDetectCommand,
|
bool autoDetectCommand,
|
||||||
CIpcServer& ipcServer,
|
CIpcServer& ipcServer,
|
||||||
CIpcLogOutputter& ipcLogOutputter);
|
CIpcLogOutputter& ipcLogOutputter);
|
||||||
virtual ~CMSWindowsRelauncher();
|
virtual ~CMSWindowsWatchdog();
|
||||||
|
|
||||||
void startAsync();
|
void startAsync();
|
||||||
std::string getCommand() const;
|
std::string getCommand() const;
|
|
@ -29,7 +29,7 @@ if (WIN32)
|
||||||
CMSWindowsScreen.h
|
CMSWindowsScreen.h
|
||||||
CMSWindowsScreenSaver.h
|
CMSWindowsScreenSaver.h
|
||||||
CMSWindowsUtil.h
|
CMSWindowsUtil.h
|
||||||
CMSWindowsRelauncher.h
|
CMSWindowsWatchdog.h
|
||||||
CMSWindowsHookLibraryLoader.h
|
CMSWindowsHookLibraryLoader.h
|
||||||
IMSWindowsClipboardFacade.h
|
IMSWindowsClipboardFacade.h
|
||||||
CMSWindowsDebugOutputter.h
|
CMSWindowsDebugOutputter.h
|
||||||
|
@ -50,7 +50,7 @@ if (WIN32)
|
||||||
CMSWindowsScreen.cpp
|
CMSWindowsScreen.cpp
|
||||||
CMSWindowsScreenSaver.cpp
|
CMSWindowsScreenSaver.cpp
|
||||||
CMSWindowsUtil.cpp
|
CMSWindowsUtil.cpp
|
||||||
CMSWindowsRelauncher.cpp
|
CMSWindowsWatchdog.cpp
|
||||||
CMSWindowsHookLibraryLoader.cpp
|
CMSWindowsHookLibraryLoader.cpp
|
||||||
CMSWindowsDebugOutputter.cpp
|
CMSWindowsDebugOutputter.cpp
|
||||||
CMSWindowsSession.cpp
|
CMSWindowsSession.cpp
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include "XArchWindows.h"
|
#include "XArchWindows.h"
|
||||||
#include "CScreen.h"
|
#include "CScreen.h"
|
||||||
#include "CMSWindowsScreen.h"
|
#include "CMSWindowsScreen.h"
|
||||||
#include "CMSWindowsRelauncher.h"
|
|
||||||
#include "CMSWindowsDebugOutputter.h"
|
#include "CMSWindowsDebugOutputter.h"
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
@ -210,7 +209,7 @@ CDaemonApp::mainLoop(bool logToFile)
|
||||||
CLOG->insert(m_ipcLogOutputter);
|
CLOG->insert(m_ipcLogOutputter);
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
m_relauncher = new CMSWindowsRelauncher(false, *m_ipcServer, *m_ipcLogOutputter);
|
m_relauncher = new CMSWindowsWatchdog(false, *m_ipcServer, *m_ipcLogOutputter);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_events->adoptHandler(
|
m_events->adoptHandler(
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "CIpcServer.h"
|
#include "CIpcServer.h"
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
#include "CMSWindowsRelauncher.h"
|
#include "CMSWindowsWatchdog.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -48,8 +48,7 @@ public:
|
||||||
static CDaemonApp* s_instance;
|
static CDaemonApp* s_instance;
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
CMSWindowsRelauncher*
|
CMSWindowsWatchdog* m_relauncher;
|
||||||
m_relauncher;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue