From fbdac1904f6f044584b7ba9e31c041259ecc639d Mon Sep 17 00:00:00 2001 From: Roland Pihlakas Date: Sat, 12 Oct 2024 09:40:42 +0300 Subject: [PATCH] Updating a few comments --- ...eme-enable-with-extended-compatibility.wh.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mods/classic-theme-enable-with-extended-compatibility.wh.cpp b/mods/classic-theme-enable-with-extended-compatibility.wh.cpp index ece16e3ce..73824b363 100644 --- a/mods/classic-theme-enable-with-extended-compatibility.wh.cpp +++ b/mods/classic-theme-enable-with-extended-compatibility.wh.cpp @@ -516,7 +516,10 @@ BOOL TryInit(bool* abort, DWORD* retryInterval) { if (pConnectState) WTSFreeMemory(pConnectState); - if (!sessionConnected) { //Modify RDP sessions only when they reach active state else RDP connections will fail + //Modify RDP sessions only when they reach active state else RDP connections will fail. + //Console sessions will not fail, but video driver might fail if the session is modified too early. + //Therefore console sessions should also be modified only when they reach active state. + if (!sessionConnected) { if (sessionId == WTSGetActiveConsoleSessionId()) { @@ -657,9 +660,16 @@ DWORD WINAPI InitThreadFunc(LPVOID param) { #ifdef _DEBUG DWORD retryInterval = 1000; #else - DWORD retryInterval = 1; //TODO!!! use low poll rate in console session while an RDP session is active + DWORD retryInterval = 1; #endif -retry: //If Windhawk loads the mod too early then the classic theme initialisation will fail. Therefore we need to loop until the initialisation succeeds. Also if the mod is loaded into a RDP session too early then for some reason that would block the RDP session from successfully connecting. So we need to wait for session "active" state in case of RDP sessions. This is another reason for having a loop here. + //If Windhawk loads the mod too early then the classic theme initialisation will fail. + //Therefore we need to loop until the initialisation succeeds. Also if the mod is loaded + //into a RDP session too early then for some reason that would block the RDP session from + //successfully connecting. So we need to wait for session "active" state in case of RDP + //sessions. This is another reason for having a loop here. + //Console sessions will not fail, but video driver might fail if the session is modified + //too early. Waiting for the session active state helps with that as well. +retry: if (isRetry) { if (WaitForSingleObject(g_initThreadStopSignal, retryInterval) != WAIT_TIMEOUT) { Wh_Log(L"Shutting down InitThreadFunc before success");