[WINLOGON] Temporarily hack around a bug in PSEH for GCC

Commit 51ee32f5f8 moved the `WNetClearConnections()` in the main
Winlogon thread, where it now runs.

`WNetClearConnections()` calls a 3rd-party module (nfs41_np.dll)
that invokes `kernel32!OutputDebugStringA()`.
The SEH usage pattern in `OutputDebugStringA()`, when compiled with
GCC and PSEH, generates an erroneous chain of exception handlers, that,
when running in an execution environment like that of winlogon.exe,
triggers a crash. See CORE-20316 for more details and testing.

As a temporary measure, hackfix away the problem by surrounding the
`WNetClearConnections()` call in a `_SEH2_TRY/_SEH2_EXCEPT` block
(the net effect is to "add" the missing exception handler entry).

Hack for commit 51ee32f5f8
CORE-20307 CORE-20309 CORE-20316
This commit is contained in:
Hermès Bélusca-Maïto
2025-08-25 20:54:47 +02:00
parent 6a06b0a05a
commit ddbe9719c9

View File

@@ -497,7 +497,13 @@ CloseAllConnections(
{
if (!Session->UserToken || !ImpersonateLoggedOnUser(Session->UserToken))
return;
WNetClearConnections(NULL);
_SEH2_TRY // Temporary HACK to avoid SEH crashes triggered by OutputDebugStringA()
{ // calls from WNetClearConnections(). CORE-20307, CORE-20309, CORE-20316
WNetClearConnections(NULL);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{}
_SEH2_END;
RevertToSelf();
}