Skip to content

Commit

Permalink
Updating a few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
levitation committed Oct 12, 2024
1 parent 3c7f132 commit fbdac19
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mods/classic-theme-enable-with-extended-compatibility.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit fbdac19

Please sign in to comment.