[host] detect switch user event and wait instead of terminating

Fixes #22
This commit is contained in:
Geoffrey McRae 2017-12-17 04:50:04 +11:00
parent bf85358715
commit 9d8f3a79b0
2 changed files with 9 additions and 0 deletions

View File

@ -46,6 +46,7 @@ Service::Service() :
m_cursorData(NULL),
m_shapePending(false)
{
m_consoleSessionID = WTSGetActiveConsoleSessionId();
m_ivshmem = IVSHMEM::Get();
}
@ -233,6 +234,13 @@ bool Service::Process()
case GRAB_STATUS_REINIT:
DEBUG_INFO("ReInitialize Requested");
if(WTSGetActiveConsoleSessionId() != m_consoleSessionID)
{
DEBUG_INFO("User switch detected, waiting to regain control");
while (WTSGetActiveConsoleSessionId() != m_consoleSessionID)
Sleep(100);
}
if (!m_capture->ReInitialize() || !InitPointers())
{
DEBUG_ERROR("ReInitialize Failed");

View File

@ -49,6 +49,7 @@ private:
~Service();
bool m_initialized;
DWORD m_consoleSessionID;
uint8_t * m_memory;
IVSHMEM * m_ivshmem;
HANDLE m_timer;