From 3343ebb22503b186751040b25c8b5bff09c59bca Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 10 Aug 2020 21:50:52 -0700 Subject: [PATCH] Don't allow testing while a stream is active --- mist/mist.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mist/mist.cpp b/mist/mist.cpp index 5c847d9..bef92b0 100644 --- a/mist/mist.cpp +++ b/mist/mist.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #pragma comment(lib, "miniupnpc.lib") #pragma comment(lib, "libnatpmp.lib") @@ -268,6 +269,28 @@ bool IsGameStreamEnabled() } } +bool IsCurrentlyStreaming() +{ + bool ret = false; + HANDLE processSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + + PROCESSENTRY32 procEntry; + procEntry.dwSize = sizeof(procEntry); + Process32First(processSnapshot, &procEntry); + + do { + // If we find nvstreamer.exe running, we're currently streaming + if (_stricmp(procEntry.szExeFile, "nvstreamer.exe") == 0) { + ret = true; + break; + } + } while (Process32Next(processSnapshot, &procEntry)); + + CloseHandle(processSnapshot); + + return ret; +} + bool IsConsoleSessionActive() { PWTS_SESSION_INFO_1 sessionInfo; @@ -1203,6 +1226,12 @@ int main(int argc, char* argv[]) return -1; } + if (IsCurrentlyStreaming()) { + DisplayMessage("The test cannot proceed because a GameStream session is currently running on this PC.\n\n" + "Quit the currently running app on this host within Moonlight, or reboot your PC."); + return -1; + } + if (!IsConsoleSessionActive()) { DisplayMessage("The system display is currently locked. You must sign in to your PC again to use GameStream.\n\n" "This is most often due to Microsoft Remote Desktop locking the screen. Use an alternate GameStream-compatible remote desktop solution like Chrome Remote Desktop or TeamViewer to unlock the PC and prevent this error in the future.",