From dd77ac67d0fa45f08885a9b511125268ae93860d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 14 Apr 2020 22:58:22 +0200 Subject: [PATCH] [CSRSRV] Protect the Server DLL entrypoint calls under SEH. --- subsystems/win32/csrsrv/server.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/subsystems/win32/csrsrv/server.c b/subsystems/win32/csrsrv/server.c index c161bb4166b..4fa35367927 100644 --- a/subsystems/win32/csrsrv/server.c +++ b/subsystems/win32/csrsrv/server.c @@ -205,6 +205,9 @@ CsrLoadServerDll(IN PCHAR DllString, else { /* No handle, so we are loading ourselves */ +#ifdef CSR_DBG + RtlInitAnsiString(&EntryPointString, "CsrServerDllInitialization"); +#endif ServerDllInitProcedure = CsrServerDllInitialization; Status = STATUS_SUCCESS; } @@ -212,8 +215,21 @@ CsrLoadServerDll(IN PCHAR DllString, /* Check if we got the pointer, and call it */ if (NT_SUCCESS(Status)) { - /* Get the result from the Server DLL */ - Status = ServerDllInitProcedure(ServerDll); + /* Call the Server DLL entrypoint */ + _SEH2_TRY + { + Status = ServerDllInitProcedure(ServerDll); + } + _SEH2_EXCEPT(CsrUnhandledExceptionFilter(_SEH2_GetExceptionInformation())) + { + Status = _SEH2_GetExceptionCode(); +#ifdef CSR_DBG + DPRINT1("CSRSS: Exception 0x%lx while calling Server DLL entrypoint %Z!%Z()\n", + Status, &DllName, &EntryPointString); +#endif + } + _SEH2_END; + if (NT_SUCCESS(Status)) { /*