dll: FspFsctlStartService:make thread safe

This commit is contained in:
Bill Zissimopoulos 2020-12-19 11:05:24 -08:00
parent a372c6ee40
commit 2d5d058d2f
No known key found for this signature in database
GPG Key ID: 3D4F95D52C7B3EA3

View File

@ -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;
}