Handle deletion of the 'HKLM\Software\NVIDIA Corporation' key

This commit is contained in:
Cameron Gutman 2020-10-10 13:35:05 -05:00
parent 8a45ea2066
commit f511b830ea

View File

@ -846,14 +846,18 @@ void ResetLogFile(bool standaloneExe)
DWORD WINAPI GameStreamStateChangeThread(PVOID Context)
{
HKEY key;
DWORD err;
do {
// We're watching this key that way we can still detect GameStream turning on
// if GFE wasn't even installed when our service started
DWORD err = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\NVIDIA Corporation", 0, KEY_READ | KEY_WOW64_64KEY, &key);
do {
err = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\NVIDIA Corporation", 0, KEY_READ | KEY_WOW64_64KEY, &key);
if (err != ERROR_SUCCESS) {
printf("RegOpenKeyExA() failed: %d" NL, err);
return err;
// Wait 10 seconds and try again
Sleep(10000);
}
} while (err != ERROR_SUCCESS);
// Notify the main thread when the GameStream state changes
bool lastGameStreamState = IsGameStreamEnabled();
@ -865,7 +869,10 @@ DWORD WINAPI GameStreamStateChangeThread(PVOID Context)
lastGameStreamState = currentGameStreamState;
}
printf("RegNotifyChangeKeyValue() failed: %d" NL, err);
// If the key is deleted (by DDU or similar), we will hit this code path and poll until it comes back.
RegCloseKey(key);
} while (err == ERROR_KEY_DELETED);
return err;
}