Don't allow testing while a stream is active

This commit is contained in:
Cameron Gutman
2020-08-10 21:50:52 -07:00
parent 05413a554c
commit 3343ebb225

View File

@@ -9,6 +9,7 @@
#include <wtsapi32.h>
#include <powerbase.h>
#include <VersionHelpers.h>
#include <tlhelp32.h>
#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.",