IopInitActivityIdIrp

VOID __stdcall IopInitActivityIdIrp(_IRP *Irp){
  char v2; 
  GUID *RelatedActivityId; 
  EVENT_DESCRIPTOR *v4; 
  _ETHREAD *CurrentThread; 
  GUID *v6; 
  char v7; 
  __int64 v8; 
  UINT64 v9; 
  char v10; 
  GUID ActivityId; 
  __m128i v12; 
  ActivityId = 0i64;
  v12 = 0i64;
  v2 = 0;
  RelatedActivityId = 0i64;
  v4 = 0i64;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  if( (*((_DWORD *)KeGetPcr() + 3243) & 0x10001) == 0 )
  {
    v6 = (GUID *)*((_QWORD *)CurrentThread + 180);
    if( v6 )
    {
      if( IopIsActivityTracingEventEnabled((EVENT_DESCRIPTOR *)&IoTrace_KernelIo_AllocateIrp) )
      {
        RelatedActivityId = v6;
        v4 = (EVENT_DESCRIPTOR *)&IoTrace_KernelIo_AllocateIrp;
        goto LABEL_18;
      }
      ActivityId = *v6;
LABEL_17:
      v2 = 1;
      goto LABEL_18;
    }
    PnpIsSafeToExamineUserModeTeb((INT64)Irp);
    if( v7 && (*((_BYTE *)Irp + 71) & 0x21) != 33 )
    {
      v10 = 0;
      if( *((_QWORD *)KeGetPcr() + 6) )
      {
        v12 = *(__m128i *)(*((_QWORD *)KeGetPcr() + 6) + 5904i64);
        v10 = 1;
      }
      if( v10 )
      {
        v8 = *(_QWORD *)&NullGuid.Data1 - v12.m128i_i64[0];
        if( *(_QWORD *)&NullGuid.Data1 == v12.m128i_i64[0] )
          v8 = *(_QWORD *)NullGuid.Data4 - _mm_srli_si128(v12, 8).m128i_u64[0];
        if( v8 )
        {
          if( IopIsActivityTracingEventEnabled((EVENT_DESCRIPTOR *)&IoTrace_UserInitiatedIo) )
          {
            RelatedActivityId = (GUID *)&v12;
            v4 = (EVENT_DESCRIPTOR *)&IoTrace_UserInitiatedIo;
            goto LABEL_18;
          }
          ActivityId = (GUID)v12;
          goto LABEL_17;
        }
      }
    }
  }
LABEL_18:
  if( !v2 )
    EtwActivityIdControl(3u, &ActivityId);
  if( IoSetActivityIdIrp(Irp, &ActivityId) >= 0 )
  {
    **((_WORD **)Irp + 25) |= 2u;
    if( RelatedActivityId )
    {
      LODWORD(v9) = 0;
      EtwWriteEx(IoTraceHandle, v4, 0i64, 0i64, &ActivityId, RelatedActivityId, v9, 0i64);
    }
  }
}

Referenced by:

IopAllocateBackpocketIrp
IopAllocateIrpPrivate
IopAllocateIrpWithExtension
IopAllocateReserveIrp
IovAllocateIrp