WdipSemEnableContextProvider

__int64 __fastcall WdipSemEnableContextProvider(__int64 a1){
  _ETHREAD *CurrentThread; 
  int v2; 
  __int64 v4; 
  UINT8 v5; 
  UINT8 v6; 
  __int64 v7; 
  int v8; 
  __int64 v9; 
  int v10; 
  UINT64 EnableProperty; 
  UINT64 ControlCode; 
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v2 = 0;
  --*((_WORD *)CurrentThread + 242);
  ExAcquirePushLockExclusiveEx((UINT64)&qword_140C1C3C8, 0i64);
  if( !a1 )
  {
    v2 = -1073741811;
    goto LABEL_9;
  }
  if( *(_DWORD *)(a1 + 32) != 1 )
  {
    v4 = *(_QWORD *)(a1 + 40);
    v5 = *(_BYTE *)(a1 + 18);
    v6 = *(_BYTE *)(v4 + 48);
    v7 = *(_QWORD *)(v4 + 56);
    v8 = *(_DWORD *)(v4 + 64);
    if( v5 <= v6 )
      v5 = *(_BYTE *)(v4 + 48);
    v9 = v7 | *(_QWORD *)(a1 + 24);
    v10 = v8 | *(_DWORD *)(a1 + 36);
    if( *(_BYTE *)(v4 + 69) && v9 == v7 && v5 == v6 && v10 == v8 )
      goto LABEL_8;
    LODWORD(ControlCode) = 1;
    LODWORD(EnableProperty) = v8 | *(_DWORD *)(a1 + 36);
    v2 = WdipSemEnableDisableTrace(
           _InterlockedExchange(&WdipContextLoggerId, WdipContextLoggerId),
           (const _GUID *)a1,
           v5,
           v7 | *(_QWORD *)(a1 + 24),
           EnableProperty,
           ControlCode);
    if( v2 >= 0 )
    {
      *(_BYTE *)(v4 + 69) = 1;
      *(_QWORD *)(v4 + 56) = v9;
      *(_BYTE *)(v4 + 48) = v5;
      *(_DWORD *)(v4 + 64) = v10;
LABEL_8:
      ++*(_DWORD *)(v4 + 72);
    }
  }
LABEL_9:
  ExReleasePushLockEx((UINT64)&qword_140C1C3C8, 0i64);
  KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
  return(unsigned int)v2;
}

Referenced by:

WdipSemEnableContextProviders