2017-10-31 16:53:06 +00:00
|
|
|
/*
|
2017-12-03 15:31:16 +00:00
|
|
|
Looking Glass - KVM FrameRelay (KVMFR) Client
|
2017-10-31 16:53:06 +00:00
|
|
|
Copyright (C) 2017 Geoffrey McRae <geoff@hostfission.com>
|
2017-12-11 17:30:47 +00:00
|
|
|
https://looking-glass.hostfission.com
|
2017-10-31 16:53:06 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2017-10-31 12:21:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define W32_LEAN_AND_MEAN
|
2017-12-14 19:11:41 +00:00
|
|
|
#include <windows.h>
|
2017-10-31 12:21:05 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2017-10-31 12:22:55 +00:00
|
|
|
#include "IVSHMEM.h"
|
2017-10-31 12:21:05 +00:00
|
|
|
#include "ICapture.h"
|
|
|
|
|
2018-07-25 17:08:52 +00:00
|
|
|
#define MAX_FRAMES 2
|
|
|
|
|
2017-10-31 12:21:05 +00:00
|
|
|
class Service
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static Service * Get()
|
|
|
|
{
|
|
|
|
if (!m_instance)
|
|
|
|
m_instance = new Service();
|
|
|
|
return m_instance;
|
|
|
|
}
|
|
|
|
|
2017-11-16 09:53:22 +00:00
|
|
|
bool Initialize(ICapture * captureDevice);
|
2017-10-31 12:21:05 +00:00
|
|
|
void DeInitialize();
|
2017-10-31 16:23:46 +00:00
|
|
|
bool Process();
|
2017-10-31 12:21:05 +00:00
|
|
|
|
|
|
|
private:
|
2017-12-07 19:24:17 +00:00
|
|
|
bool InitPointers();
|
|
|
|
|
2017-10-31 12:21:05 +00:00
|
|
|
static Service * m_instance;
|
2018-09-26 11:20:17 +00:00
|
|
|
int m_tryTarget;
|
|
|
|
int m_lastTryCount;
|
2017-10-31 12:21:05 +00:00
|
|
|
|
|
|
|
Service();
|
|
|
|
~Service();
|
|
|
|
|
|
|
|
bool m_initialized;
|
2017-12-16 17:50:04 +00:00
|
|
|
DWORD m_consoleSessionID;
|
2017-12-07 19:24:17 +00:00
|
|
|
uint8_t * m_memory;
|
2017-10-31 12:21:05 +00:00
|
|
|
IVSHMEM * m_ivshmem;
|
2017-12-13 15:22:41 +00:00
|
|
|
HANDLE m_timer;
|
2017-10-31 12:21:05 +00:00
|
|
|
ICapture * m_capture;
|
2017-12-03 11:03:22 +00:00
|
|
|
|
2017-12-15 23:04:56 +00:00
|
|
|
KVMFRHeader * m_shmHeader;
|
2018-05-24 01:24:24 +00:00
|
|
|
|
2018-07-25 17:08:52 +00:00
|
|
|
bool m_haveFrame;
|
|
|
|
uint8_t * m_frame[MAX_FRAMES];
|
2017-12-11 20:56:50 +00:00
|
|
|
size_t m_frameSize;
|
2018-07-25 17:08:52 +00:00
|
|
|
uint64_t m_dataOffset[MAX_FRAMES];
|
2017-12-11 20:56:50 +00:00
|
|
|
int m_frameIndex;
|
2017-12-13 10:45:58 +00:00
|
|
|
|
2018-05-24 01:24:24 +00:00
|
|
|
static DWORD WINAPI _CursorThread(LPVOID lpParameter) { return ((Service *)lpParameter)->CursorThread(); }
|
|
|
|
DWORD CursorThread();
|
|
|
|
|
2018-05-24 06:43:16 +00:00
|
|
|
HANDLE m_cursorThread;
|
|
|
|
HANDLE m_cursorEvent;
|
|
|
|
CRITICAL_SECTION m_cursorCS;
|
|
|
|
size_t m_cursorDataSize;
|
|
|
|
uint8_t * m_cursorData;
|
|
|
|
uint64_t m_cursorOffset;
|
2017-10-31 16:53:06 +00:00
|
|
|
};
|