From 2d5d058d2f10de78d759aba4512d195736a5606d Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Sat, 19 Dec 2020 11:05:24 -0800 Subject: [PATCH] dll: FspFsctlStartService:make thread safe --- src/dll/fsctl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dll/fsctl.c b/src/dll/fsctl.c index f666b847..9fad2ae1 100644 --- a/src/dll/fsctl.c +++ b/src/dll/fsctl.c @@ -254,6 +254,7 @@ FSP_API NTSTATUS FspFsctlPreflight(PWSTR DevicePath) static NTSTATUS FspFsctlStartService(VOID) { + static SRWLOCK Lock = SRWLOCK_INIT; PWSTR DriverName = L"" FSP_FSCTL_DRIVER_NAME; SC_HANDLE ScmHandle = 0; SC_HANDLE SvcHandle = 0; @@ -261,6 +262,8 @@ static NTSTATUS FspFsctlStartService(VOID) DWORD LastError; NTSTATUS Result; + AcquireSRWLockExclusive(&Lock); + /* Determine if we are running inside container. * * See https://github.com/microsoft/perfview/blob/V1.9.65/src/TraceEvent/TraceEventSession.cs#L525 @@ -331,6 +334,8 @@ exit: if (0 != ScmHandle) CloseServiceHandle(ScmHandle); + ReleaseSRWLockExclusive(&Lock); + return Result; }