PnpWatchdogEtwWrite

int __fastcall PnpWatchdogEtwWrite(__int64 a1, char a2){
  __int64 ElapsedTime; 
  __int64 v5; 
  __int64 v6; 
  __int64 v7; 
  __int64 v8; 
  __int64 v9; 
  _LIST_ENTRY *CurrentThreadId; 
  _LIST_ENTRY *Flink; 
  int v12; 
  int v13; 
  int v14; 
  int v15; 
  int v16; 
  __int64 *v17; 
  int v18; 
  int v19; 
  int v20; 
  int v21; 
  __int64 *v22; 
  _LIST_ENTRY *v24; 
  __int64 v25; 
  __int64 v26; 

  v25 = 0i64;
  v26 = 0i64;
  v24 = 0i64;
  ElapsedTime = (unsigned int)PnpWatchdogGetElapsedTime((_QWORD *)a1);
  v5 = 0i64;
  v6 = 0i64;
  PnpWatchdogExtractTriageInformation(v7, &v25, &v24, 0i64, &v26);
  if( v25 )
    v5 = *(_QWORD *)(v25 + 48);
  LODWORD(CurrentThreadId) = v26;
  if( v26 && (v8 = *(_QWORD *)(v26 + 48), *(_WORD *)(v8 + 24)) )
  {
    v6 = *(_QWORD *)(v8 + 32);
  }
  else if( v25 && *(_WORD *)(v25 + 56) )
  {
    v6 = *(_QWORD *)(v25 + 64);
  }
  if( v24 )
  {
    Flink = v24[72].Flink;
  }
  else
  {
    CurrentThreadId = (_LIST_ENTRY *)PsGetCurrentThreadId();
    Flink = CurrentThreadId;
  }
  v12 = *(_DWORD *)(a1 + 16);
  if( !a2 )
  {
    v18 = v12 - 1;
    if( v18 )
    {
      v19 = v18 - 1;
      if( v19 )
      {
        v20 = v19 - 1;
        if( v20 )
        {
          v21 = v20 - 1;
          if( v21 )
          {
            if( v21 != 1 )
              goto LABEL_35;
            if( (byte_140C130BB & 0x40) == 0 )
              return(int)CurrentThreadId;
            v22 = KMPnPEvt_Watchdog_DriverEntry_Stop;
          }
          else
          {
            if( (byte_140C130BB & 0x40) == 0 )
              return(int)CurrentThreadId;
            v22 = KMPnPEvt_Watchdog_AddDevice_Stop;
          }
        }
        else
        {
          if( (byte_140C130BB & 0x40) == 0 )
            return(int)CurrentThreadId;
          v22 = KMPnPEvt_Watchdog_DelayedRemoveWorker_Stop;
        }
      }
      else
      {
        if( (byte_140C130BB & 0x40) == 0 )
          return(int)CurrentThreadId;
        v22 = KMPnPEvt_Watchdog_CompletionQueue_Stop;
      }
    }
    else
    {
      if( (byte_140C130BB & 0x40) == 0 )
        return(int)CurrentThreadId;
      v22 = KMPnPEvt_Watchdog_EventWorker_Stop;
    }
    LODWORD(CurrentThreadId) = McTemplateK0izzx_EtwWriteTransfer(
                                 v8,
                                 (const _EVENT_DESCRIPTOR *)v22,
                                 v9,
                                 Flink,
                                 v5,
                                 v6,
                                 ElapsedTime);
    return(int)CurrentThreadId;
  }
  v13 = v12 - 1;
  if( !v13 )
  {
    if( (byte_140C130BB & 0x20) != 0 )
    {
      v17 = KMPnPEvt_Watchdog_EventWorker_Start;
      goto LABEL_28;
    }
    goto LABEL_29;
  }
  v14 = v13 - 1;
  if( !v14 )
  {
    if( (byte_140C130BB & 0x20) != 0 )
    {
      v17 = KMPnPEvt_Watchdog_CompletionQueue_Start;
      goto LABEL_28;
    }
    goto LABEL_29;
  }
  v15 = v14 - 1;
  if( !v15 )
  {
    if( (byte_140C130BB & 0x20) != 0 )
    {
      v17 = KMPnPEvt_Watchdog_DelayedRemoveWorker_Start;
      goto LABEL_28;
    }
    goto LABEL_29;
  }
  v16 = v15 - 1;
  if( v16 )
  {
    if( v16 == 1 )
    {
      if( (byte_140C130BB & 0x20) != 0 )
      {
        v17 = KMPnPEvt_Watchdog_DriverEntry_Start;
LABEL_28:
        LODWORD(CurrentThreadId) = McTemplateK0izzx_EtwWriteTransfer(
                                     v8,
                                     (const _EVENT_DESCRIPTOR *)v17,
                                     v9,
                                     Flink,
                                     v5,
                                     v6,
                                     ElapsedTime);
        goto LABEL_29;
      }
      goto LABEL_29;
    }
LABEL_35:
    __fastfail(5u);
  }
  if( (byte_140C130BB & 0x20) != 0 )
  {
    v17 = KMPnPEvt_Watchdog_AddDevice_Start;
    goto LABEL_28;
  }
LABEL_29:
  *(_BYTE *)(a1 + 32) = 1;
  return(int)CurrentThreadId;
}

Referenced by:

PnpCallDriverEntry
PnpDisableWatchdog
PnpWatchdogWorkItem