WdipSemWriteSemActionsEvent

NTSTATUS __stdcall WdipSemWriteSemActionsEvent(GUID *ActivityId, INT64 a2){
  __int64 v4; 
  in6_addr *v5; 
  NTSTATUS v6; 
  int v7; 
  UINT64 v8; 
  int v9; 
  PSLIST_ENTRY v10; 
  __int64 v11; 
  __int64 v12; 
  int v13; 
  __int64 *v14; 
  int v16; 
  int TraceInformation; 
  __int64 Buffer; 
  UINT64 AddressStringLength; 
  __int64 v20[255]; 
  __int64 result[124]; 
  memset((INT64)result, 0i64);
  v16 = 0;
  v4 = 0i64;
  if( !ActivityId )
    return -1073741811;
  if( !a2 )
    return -1073741811;
  LODWORD(Buffer) = _InterlockedExchange(&WdipContextLoggerId, WdipContextLoggerId);
  TraceInformation = 0;
  if( !(_DWORD)Buffer )
    return -1073741811;
  v6 = WmiQueryTraceInformation(LoggerEventsLostClass, &TraceInformation, 4ui64, 0i64, &Buffer);
  v7 = v16;
  if( v6 >= 0 )
    v7 = TraceInformation;
  v16 = v7;
  if( v6 >= 0 )
  {
    v8 = *(_QWORD *)(a2 + 32);
    v9 = *(_DWORD *)(v8 + 48);
    v20[1] = v8 + 16;
    v20[3] = (__int64)&v16;
    AddressStringLength = v8;
    v20[0] = 16i64;
    v20[2] = 2i64;
    v20[4] = 4i64;
    v20[5] = v8 + 48;
    v20[6] = 4i64;
    if( *(_DWORD *)(v8 + 48) )
    {
      while( 1 )
      {
        Buffer = *(_QWORD *)(v8 + 8 * v4 + 56);
        v10 = WdipSemFastAllocate(4, 0x28u);
        v11 = (__int64)v10;
        if( !v10 )
          break;
        v12 = Buffer;
        result[v4] = (__int64)v10;
        *v10 = *(PSLIST_ENTRY)v12;
        LOBYTE(v10[1].Next) = *(_BYTE *)(v12 + 18);
        *((_QWORD *)&v10[1].Next + 1) = *(_QWORD *)(v12 + 24);
        LODWORD(v10[2].Next) = *(_DWORD *)(v12 + 36);
        v5 = (in6_addr *)(2i64 * (unsigned int)(v4 + 4));
        v13 = *(_DWORD *)(a2 + 4 * v4 + 48);
        v4 = (unsigned int)(v4 + 1);
        *(_DWORD *)(v11 + 36) = v13;
        HIDWORD(v20[(_QWORD)v5]) = 0;
        v20[(_QWORD)v5 - 1] = v11;
        LODWORD(v20[(_QWORD)v5]) = 40;
        if( (unsigned int)v4 >= *(_DWORD *)(v8 + 48) )
          goto LABEL_10;
      }
      v6 = -1073741670;
    }
    else
    {
LABEL_10:
      v6 = WdipSemWriteEvent(v5, (UINT64)ActivityId, a2 + 16, (INT8 *)(unsigned int)(v9 + 4), &AddressStringLength);
    }
    if( (_DWORD)v4 )
    {
      v14 = result;
      do
      {
        WdipSemFastFree(4i64, (struct SLIST_ENTRY *)*v14++);
        --v4;
      }
      while( v4 );
    }
  }
  return v6;
}

Referenced by:

WdipSemDisableScenario
WdipSemEnableScenario