mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
[idd] helper: added new helper service
Some checks are pending
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / module (push) Waiting to run
build / host-linux (push) Waiting to run
build / host-windows-cross (push) Waiting to run
build / host-windows-native (push) Waiting to run
build / obs (clang) (push) Waiting to run
build / obs (gcc) (push) Waiting to run
build / docs (push) Waiting to run
Some checks are pending
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / module (push) Waiting to run
build / host-linux (push) Waiting to run
build / host-windows-cross (push) Waiting to run
build / host-windows-native (push) Waiting to run
build / obs (clang) (push) Waiting to run
build / obs (gcc) (push) Waiting to run
build / docs (push) Waiting to run
As the IDD itself runs in a WUMDF sandbox, it doesn't have enough access to perform interactive operations such as moving the cursor. This helper service communicates with the IDD over a named pipe, so that we can perform these things, as well as in the future provide a configuration GUI.
This commit is contained in:
@@ -1,198 +0,0 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#include "CDebug.h"
|
||||
|
||||
CDebug g_debug;
|
||||
|
||||
CDebug::CDebug()
|
||||
{
|
||||
// don't redirect the debug output if running under a debugger
|
||||
if (IsDebuggerPresent())
|
||||
return;
|
||||
|
||||
// get the system temp directory
|
||||
char tempPath[MAX_PATH];
|
||||
DWORD pathLen = GetTempPathA(sizeof(tempPath), tempPath);
|
||||
if (pathLen == 0)
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to get the temp path");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string folder = tempPath;
|
||||
std::string baseName = "looking-glass-idd";
|
||||
std::string ext = ".txt";
|
||||
std::string logFile = folder + baseName + ext;
|
||||
|
||||
//rotate out old logs
|
||||
DeleteFileA((folder + baseName + ".5" + ext).c_str());
|
||||
for (int i = 4; i >= 0; --i)
|
||||
{
|
||||
std::string oldPath;
|
||||
std::string newPath;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
oldPath = logFile;
|
||||
newPath = folder + baseName + ".1" + ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldPath = folder + baseName + "." + std::to_string(i) + ext;
|
||||
newPath = folder + baseName + "." + std::to_string(i + 1) + ext;
|
||||
}
|
||||
|
||||
MoveFileA(oldPath.c_str(), newPath.c_str());
|
||||
}
|
||||
|
||||
/// open the new log file
|
||||
std::ofstream stream(logFile, std::ios::out | std::ios::trunc);
|
||||
if (!stream.is_open())
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to open the log file %s", logFile.c_str());
|
||||
return;
|
||||
}
|
||||
else
|
||||
DEBUG_INFO("Logging to: %s", logFile.c_str());
|
||||
|
||||
m_stream = std::move(stream);
|
||||
}
|
||||
|
||||
void CDebug::Log(CDebug::Level level, const char * function, int line, const char * fmt, ...)
|
||||
{
|
||||
if (level < 0 || level >= LEVEL_MAX)
|
||||
level = LEVEL_NONE;
|
||||
|
||||
static const char* fmtTemplate = "[%s] %40s:%-4d | ";
|
||||
const char* levelStr = m_levelStr[level];
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
int length = 0;
|
||||
length = _scprintf(fmtTemplate, levelStr, function, line);
|
||||
length += _vscprintf(fmt, args);
|
||||
length += 2;
|
||||
|
||||
/* Depending on the size of the format string, allocate space on the stack or the heap. */
|
||||
PCHAR buffer;
|
||||
buffer = (PCHAR)_malloca(length);
|
||||
if (!buffer)
|
||||
{
|
||||
va_end(args);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Populate the buffer with the contents of the format string. */
|
||||
StringCbPrintfA(buffer, length, fmtTemplate, levelStr, function, line);
|
||||
|
||||
size_t offset = 0;
|
||||
StringCbLengthA(buffer, length, &offset);
|
||||
StringCbVPrintfA(&buffer[offset], length - offset, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
buffer[length-2] = '\n';
|
||||
buffer[length-1] = '\0';
|
||||
|
||||
Write(buffer);
|
||||
|
||||
_freea(buffer);
|
||||
}
|
||||
|
||||
void CDebug::LogHR(CDebug::Level level, HRESULT hr, const char * function, int line, const char * fmt, ...)
|
||||
{
|
||||
if (level < 0 || level >= LEVEL_MAX)
|
||||
level = LEVEL_NONE;
|
||||
|
||||
char * hrBuffer;
|
||||
if (!FormatMessageA(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
hr,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(char*)&hrBuffer,
|
||||
1024,
|
||||
NULL
|
||||
))
|
||||
{
|
||||
DEBUG_INFO("FormatMessage failed with code 0x%08x", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove trailing CRLF in hrBuffer
|
||||
size_t len = strlen(hrBuffer);
|
||||
while (len && (hrBuffer[len - 1] == '\n' || hrBuffer[len - 1] == '\r'))
|
||||
hrBuffer[--len] = '\0';
|
||||
|
||||
static const char* fmtTemplate = "[%s] %40s:%-4d | ";
|
||||
const char* levelStr = m_levelStr[level];
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
int length = 0;
|
||||
length = _scprintf(fmtTemplate, levelStr, function, line);
|
||||
length += _vscprintf(fmt, args);
|
||||
length += 2 + 4 + (int)strlen(hrBuffer) + 1;
|
||||
|
||||
/* Depending on the size of the format string, allocate space on the stack or the heap. */
|
||||
PCHAR buffer;
|
||||
buffer = (PCHAR)_malloca(length);
|
||||
if (!buffer)
|
||||
{
|
||||
va_end(args);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Populate the buffer with the contents of the format string. */
|
||||
StringCbPrintfA(buffer, length, fmtTemplate, levelStr, function, line);
|
||||
|
||||
size_t offset = 0;
|
||||
StringCbLengthA(buffer, length, &offset);
|
||||
StringCbVPrintfA(&buffer[offset], length - offset, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
/* append the formatted error */
|
||||
StringCbLengthA(buffer, length, &offset);
|
||||
StringCbPrintfA(&buffer[offset], length - offset, " (%s)\n", hrBuffer);
|
||||
|
||||
Write(buffer);
|
||||
|
||||
_freea(buffer);
|
||||
LocalFree(hrBuffer);
|
||||
}
|
||||
|
||||
void CDebug::Write(const char * line)
|
||||
{
|
||||
if (m_stream.is_open())
|
||||
{
|
||||
m_stream << line;
|
||||
m_stream.flush();
|
||||
}
|
||||
else
|
||||
OutputDebugStringA(line);
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
#include <wdf.h>
|
||||
#include <fstream>
|
||||
|
||||
class CDebug
|
||||
{
|
||||
private:
|
||||
std::ofstream m_stream;
|
||||
void Write(const char * line);
|
||||
|
||||
public:
|
||||
CDebug();
|
||||
|
||||
enum Level
|
||||
{
|
||||
LEVEL_NONE = 0,
|
||||
LEVEL_INFO,
|
||||
LEVEL_WARN,
|
||||
LEVEL_ERROR,
|
||||
LEVEL_TRACE,
|
||||
LEVEL_FIXME,
|
||||
LEVEL_FATAL,
|
||||
|
||||
LEVEL_MAX
|
||||
};
|
||||
|
||||
void Log(CDebug::Level level, const char * function, int line, const char * fmt, ...);
|
||||
void LogHR(CDebug::Level level, HRESULT hr, const char* function, int line, const char* fmt, ...);
|
||||
|
||||
private:
|
||||
const char* m_levelStr[LEVEL_MAX] =
|
||||
{
|
||||
" ",
|
||||
"I",
|
||||
"W",
|
||||
"E",
|
||||
"T",
|
||||
"!",
|
||||
"F"
|
||||
};
|
||||
};
|
||||
|
||||
extern CDebug g_debug;
|
||||
|
||||
#define DEBUG_INFO(fmt, ...) g_debug.Log(CDebug::LEVEL_INFO, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_WARN(fmt, ...) g_debug.Log(CDebug::LEVEL_WARN, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_ERROR(fmt, ...) g_debug.Log(CDebug::LEVEL_ERROR, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_TRACE(fmt, ...) g_debug.Log(CDebug::LEVEL_TRACE, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_FIXME(fmt, ...) g_debug.Log(CDebug::LEVEL_FIXME, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_FATAL(fmt, ...) g_debug.Log(CDebug::LEVEL_FATAL, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
#define DEBUG_INFO_HR(hr, fmt, ...) g_debug.LogHR(CDebug::LEVEL_INFO, hr, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_WARN_HR(hr, fmt, ...) g_debug.LogHR(CDebug::LEVEL_WARN, hr, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_ERROR_HR(hr, fmt, ...) g_debug.LogHR(CDebug::LEVEL_ERROR, hr, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_TRACE_HR(hr, fmt, ...) g_debug.LogHR(CDebug::LEVEL_TRACE, hr, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_FIXME_HR(hr, fmt, ...) g_debug.LogHR(CDebug::LEVEL_FIXME, hr, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG_FATAL_HR(hr, fmt, ...) g_debug.LogHR(CDebug::LEVEL_FATAL, hr, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
@@ -22,6 +22,7 @@
|
||||
#include "CIndirectMonitorContext.h"
|
||||
|
||||
#include "CPlatformInfo.h"
|
||||
#include "CPipeServer.h"
|
||||
#include "CDebug.h"
|
||||
#include "VersionInfo.h"
|
||||
|
||||
@@ -114,7 +115,7 @@ void CIndirectDeviceContext::InitAdapter()
|
||||
factory->Release();
|
||||
|
||||
auto * wrapper = WdfObjectGet_CIndirectDeviceContextWrapper(m_adapter);
|
||||
wrapper->context = this;
|
||||
wrapper->context = this;
|
||||
}
|
||||
|
||||
static const BYTE EDID[] =
|
||||
@@ -172,6 +173,11 @@ void CIndirectDeviceContext::FinishInit(UINT connectorIndex)
|
||||
|
||||
IDARG_OUT_MONITORARRIVAL out;
|
||||
status = IddCxMonitorArrival(m_monitor, &out);
|
||||
if (FAILED(status))
|
||||
{
|
||||
DEBUG_ERROR_HR(status, "IddCxMonitorArrival Failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool CIndirectDeviceContext::SetupLGMP(size_t alignSize)
|
||||
@@ -386,8 +392,8 @@ void CIndirectDeviceContext::LGMPTimer()
|
||||
{
|
||||
case KVMFR_MESSAGE_SETCURSORPOS:
|
||||
{
|
||||
KVMFRSetCursorPos *sp = (KVMFRSetCursorPos *)msg;
|
||||
SetCursorPos(sp->x, sp->y);
|
||||
KVMFRSetCursorPos* sp = (KVMFRSetCursorPos*)msg;
|
||||
g_pipe.SetCursorPos(sp->x, sp->y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
163
idd/LGIdd/CPipeServer.cpp
Normal file
163
idd/LGIdd/CPipeServer.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright <20> 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "CPipeServer.h"
|
||||
#include "CDebug.h"
|
||||
|
||||
CPipeServer g_pipe;
|
||||
|
||||
bool CPipeServer::Init()
|
||||
{
|
||||
_DeInit();
|
||||
|
||||
m_pipe.Attach(CreateNamedPipeA(
|
||||
LG_PIPE_NAME,
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||
1,
|
||||
1024,
|
||||
1024,
|
||||
0,
|
||||
NULL));
|
||||
|
||||
if (!m_pipe.IsValid())
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to create the named pipe");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_running = true;
|
||||
m_thread.Attach(CreateThread(
|
||||
NULL,
|
||||
0,
|
||||
_pipeThread,
|
||||
(LPVOID)this,
|
||||
0,
|
||||
NULL));
|
||||
|
||||
if (!m_thread.IsValid())
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to create the pipe thread");
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_TRACE("Pipe Initialized");
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPipeServer::_DeInit()
|
||||
{
|
||||
m_running = false;
|
||||
m_connected = false;
|
||||
|
||||
if (m_thread.IsValid())
|
||||
{
|
||||
CancelSynchronousIo(m_thread.Get());
|
||||
WaitForSingleObject(m_thread.Get(), INFINITE);
|
||||
m_thread.Close();
|
||||
}
|
||||
|
||||
if (m_pipe.IsValid())
|
||||
{
|
||||
FlushFileBuffers(m_pipe.Get());
|
||||
m_pipe.Close();
|
||||
}
|
||||
}
|
||||
|
||||
void CPipeServer::DeInit()
|
||||
{
|
||||
DEBUG_TRACE("Pipe Stopping");
|
||||
_DeInit();
|
||||
DEBUG_TRACE("Pipe Stopped");
|
||||
}
|
||||
|
||||
void CPipeServer::Thread()
|
||||
{
|
||||
DEBUG_TRACE("Pipe thread started");
|
||||
while(m_running)
|
||||
{
|
||||
m_connected = false;
|
||||
bool result = ConnectNamedPipe(m_pipe.Get(), NULL);
|
||||
DWORD err = GetLastError();
|
||||
if (!result && err != ERROR_PIPE_CONNECTED)
|
||||
{
|
||||
// if graceful shutdown
|
||||
if ((err == ERROR_OPERATION_ABORTED && !m_running) ||
|
||||
err == ERROR_NO_DATA)
|
||||
break;
|
||||
|
||||
// if timeout
|
||||
if (err == ERROR_SEM_TIMEOUT)
|
||||
continue;
|
||||
|
||||
DEBUG_FATAL_HR(err, "Error connecting to the named pipe");
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_TRACE("Client connected");
|
||||
|
||||
m_connected = true;
|
||||
while (m_running && m_connected)
|
||||
{
|
||||
//TODO: Read messages from the client
|
||||
Sleep(1000);
|
||||
}
|
||||
|
||||
DEBUG_TRACE("Client disconnected");
|
||||
DisconnectNamedPipe(m_pipe.Get());
|
||||
}
|
||||
|
||||
m_running = false;
|
||||
m_connected = false;
|
||||
DEBUG_TRACE("Pipe thread shutdown");
|
||||
}
|
||||
|
||||
void CPipeServer::WriteMsg(LGPipeMsg & msg)
|
||||
{
|
||||
DWORD written;
|
||||
if (!WriteFile(m_pipe.Get(), &msg, sizeof(msg), &written, NULL))
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
if (err == ERROR_BROKEN_PIPE || err == ERROR_NO_DATA)
|
||||
{
|
||||
DEBUG_WARN_HR(err, "Client disconnected, failed to write");
|
||||
m_connected = false;
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_WARN_HR(err, "WriteFile failed on the pipe");
|
||||
return;
|
||||
}
|
||||
|
||||
FlushFileBuffers(m_pipe.Get());
|
||||
}
|
||||
|
||||
void CPipeServer::SetCursorPos(uint32_t x, uint32_t y)
|
||||
{
|
||||
if (!m_connected)
|
||||
return;
|
||||
|
||||
LGPipeMsg msg;
|
||||
msg.size = sizeof(msg);
|
||||
msg.type = LGPipeMsg::SETCURSORPOS;
|
||||
msg.curorPos.x = x;
|
||||
msg.curorPos.y = y;
|
||||
WriteMsg(msg);
|
||||
}
|
59
idd/LGIdd/CPipeServer.h
Normal file
59
idd/LGIdd/CPipeServer.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright <20> 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <wdf.h>
|
||||
#include <stdint.h>
|
||||
#include <wrl.h>
|
||||
|
||||
#include "PipeMsg.h"
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Microsoft::WRL::Wrappers;
|
||||
using namespace Microsoft::WRL::Wrappers::HandleTraits;
|
||||
|
||||
class CPipeServer
|
||||
{
|
||||
private:
|
||||
HandleT<HANDLENullTraits> m_pipe;
|
||||
HandleT<HANDLENullTraits> m_thread;
|
||||
|
||||
bool m_running = false;
|
||||
bool m_connected = false;
|
||||
|
||||
void _DeInit();
|
||||
|
||||
static DWORD WINAPI _pipeThread(LPVOID lpParam) { ((CPipeServer*)lpParam)->Thread(); return 0; }
|
||||
void Thread();
|
||||
|
||||
void WriteMsg(LGPipeMsg & msg);
|
||||
|
||||
public:
|
||||
~CPipeServer() { DeInit(); }
|
||||
|
||||
bool Init();
|
||||
void DeInit();
|
||||
|
||||
void SetCursorPos(uint32_t x, uint32_t y);
|
||||
};
|
||||
|
||||
extern CPipeServer g_pipe;
|
@@ -24,21 +24,30 @@
|
||||
#include "CDebug.h"
|
||||
#include "CPlatformInfo.h"
|
||||
#include "VersionInfo.h"
|
||||
#include "CPipeServer.h"
|
||||
|
||||
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
g_debug.Init("looking-glass-idd");
|
||||
DEBUG_INFO("Looking Glass IDD Driver (" LG_VERSION_STR ")");
|
||||
|
||||
WDF_DRIVER_CONFIG config;
|
||||
NTSTATUS status;
|
||||
WDF_OBJECT_ATTRIBUTES attributes;
|
||||
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
|
||||
WPP_INIT_TRACING(MYDRIVER_TRACING_ID);
|
||||
#else
|
||||
WPP_INIT_TRACING(DriverObject, RegistryPath);
|
||||
#endif
|
||||
|
||||
if (!g_pipe.Init())
|
||||
{
|
||||
status = STATUS_UNSUCCESSFUL;
|
||||
DEBUG_ERROR("Failed to setup IPC pipe");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
WDF_DRIVER_CONFIG config;
|
||||
WDF_OBJECT_ATTRIBUTES attributes;
|
||||
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
|
||||
@@ -82,6 +91,8 @@ VOID LGIddEvtDriverContextCleanup(_In_ WDFOBJECT DriverObject)
|
||||
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
|
||||
|
||||
g_pipe.DeInit();
|
||||
|
||||
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
|
||||
WPP_CLEANUP();
|
||||
#else
|
||||
|
Binary file not shown.
@@ -40,6 +40,7 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="$(SolutionDir)LGCommon/*.cpp" />
|
||||
<ClCompile Include="CD3D12CommandQueue.cpp" />
|
||||
<ClCompile Include="CFrameBufferPool.cpp" />
|
||||
<ClCompile Include="CFrameBufferResource.cpp" />
|
||||
@@ -48,15 +49,16 @@
|
||||
<ClCompile Include="CInteropResourcePool.cpp" />
|
||||
<ClCompile Include="CInteropResource.cpp" />
|
||||
<ClCompile Include="CIVSHMEM.cpp" />
|
||||
<ClCompile Include="CPipeServer.cpp" />
|
||||
<ClCompile Include="CPlatformInfo.cpp" />
|
||||
<ClCompile Include="CSwapChainProcessor.cpp" />
|
||||
<ClCompile Include="CD3D12Device.cpp" />
|
||||
<ClCompile Include="CDebug.cpp" />
|
||||
<ClCompile Include="Device.cpp" />
|
||||
<ClCompile Include="CD3D11Device.cpp" />
|
||||
<ClCompile Include="Driver.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="$(SolutionDir)/LGCommon/*.h" />
|
||||
<ClInclude Include="CD3D12CommandQueue.h" />
|
||||
<ClInclude Include="CFrameBufferPool.h" />
|
||||
<ClInclude Include="CFrameBufferResource.h" />
|
||||
@@ -64,10 +66,10 @@
|
||||
<ClInclude Include="CInteropResourcePool.h" />
|
||||
<ClInclude Include="CInteropResource.h" />
|
||||
<ClInclude Include="CIVSHMEM.h" />
|
||||
<ClInclude Include="CPipeServer.h" />
|
||||
<ClInclude Include="CPlatformInfo.h" />
|
||||
<ClInclude Include="CSwapChainProcessor.h" />
|
||||
<ClInclude Include="CD3D12Device.h" />
|
||||
<ClInclude Include="CDebug.h" />
|
||||
<ClInclude Include="Device.h" />
|
||||
<ClInclude Include="CD3D11Device.h" />
|
||||
<ClInclude Include="Driver.h" />
|
||||
@@ -99,12 +101,10 @@
|
||||
<DriverTargetPlatform>Universal</DriverTargetPlatform>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<DriverTargetPlatform>Universal</DriverTargetPlatform>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<DriverTargetPlatform>Universal</DriverTargetPlatform>
|
||||
</PropertyGroup>
|
||||
@@ -164,6 +164,7 @@
|
||||
<UMDF_VERSION_MINOR>25</UMDF_VERSION_MINOR>
|
||||
<UMDF_MINIMUM_VERSION_REQUIRED>25</UMDF_MINIMUM_VERSION_REQUIRED>
|
||||
<_NT_TARGET_VERSION>0xA000005</_NT_TARGET_VERSION>
|
||||
<PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
@@ -176,6 +177,7 @@
|
||||
<UMDF_VERSION_MINOR>25</UMDF_VERSION_MINOR>
|
||||
<UMDF_MINIMUM_VERSION_REQUIRED>25</UMDF_MINIMUM_VERSION_REQUIRED>
|
||||
<_NT_TARGET_VERSION>0xA000005</_NT_TARGET_VERSION>
|
||||
<PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
@@ -268,7 +270,7 @@
|
||||
<WppRecorderEnabled>true</WppRecorderEnabled>
|
||||
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
|
||||
<AdditionalOptions>/EHsc /D_ATL_NO_WIN_SUPPORT /DIDDCX_VERSION_MAJOR=1 /DIDDCX_VERSION_MINOR=9 /DIDDCX_MINIMUM_VERSION_REQUIRED=4 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\repos\LGMP\lgmp\include;$(ProjectDir)..\..\vendor;$(ProjectDir)..\..\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)LGCommon;$(SolutionDir)..\repos\LGMP\lgmp\include;$(SolutionDir)..\vendor;$(SolutionDir)..\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib;d3d12.lib</AdditionalDependencies>
|
||||
@@ -283,7 +285,7 @@
|
||||
<WppRecorderEnabled>true</WppRecorderEnabled>
|
||||
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
|
||||
<AdditionalOptions>/EHsc /D_ATL_NO_WIN_SUPPORT /DIDDCX_VERSION_MAJOR=1 /DIDDCX_VERSION_MINOR=9 /DIDDCX_MINIMUM_VERSION_REQUIRED=4 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\repos\LGMP\lgmp\include;$(ProjectDir)..\..\vendor;$(ProjectDir)..\..\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)LGCommon;$(SolutionDir)..\repos\LGMP\lgmp\include;$(SolutionDir)..\vendor;$(SolutionDir)..\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib;d3d12.lib</AdditionalDependencies>
|
||||
@@ -330,11 +332,10 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports">
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\GitVersion.MsBuild.6.1.0\build\GitVersion.MsBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GitVersion.MsBuild.6.1.0\build\GitVersion.MsBuild.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSBuilder.Git.0.3.0\build\MSBuilder.Git.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuilder.Git.0.3.0\build\MSBuilder.Git.props'))" />
|
||||
</Target>
|
||||
<Target Name="GenerateVersionInfo" BeforeTargets="ClCompile">
|
||||
|
Reference in New Issue
Block a user