IoReuseIrp

VOID *__stdcall IoReuseIrp(PIRP Irp, NTSTATUS Iostatus){
  char v2; 
  __int64 StackCount; 
  unsigned __int8 v6; 
  size_t Size; 
  _BYTE *IrpExtension; 
  signed __int8 AllocationFlags; 
  char *v10; 
  void *v11; 
  unsigned __int16 AllocationProcessorNumber; 
  unsigned __int8 ApcStateIndex; 
  VOID *result; 
  _GUID Guid; 
  _LPGUID ActivityId[4]; 
  VOID *retaddr; 

  v2 = 0;
  Guid = 0i64;
  if( (MmVerifierData & 0x10) != 0 )
  {
    VfIoInitializeIrp(Irp, retaddr, 1u);
    IovpLogStackTrace(Irp);
  }
  StackCount = Irp->StackCount;
  v6 = Irp->AllocationFlags & 0x6D;
  Size = Irp->Size;
  IrpExtension = Irp->Tail.IrpExtension;
  AllocationFlags = Irp->AllocationFlags;
  if( AllocationFlags >= 0 && IrpExtension && (IrpExtension[2] & 1) != 0 )
  {
    v10 = (char *)Irp->Tail.IrpExtension;
    v2 = 1;
    v11 = v10;
    Guid = *(_GUID *)(v10 + 24);
  }
  else
  {
    v10 = (char *)Irp->Tail.IrpExtension;
    v11 = v10;
    if( AllocationFlags < 0 )
    {
      Irp->Tail.IrpExtension = 0i64;
      Irp->AllocationFlags = AllocationFlags & 0x7F;
      v11 = 0i64;
      goto LABEL_8;
    }
  }
  if( v10 )
  {
    if( (Irp->AllocationFlags & 0x80u) == 0 && (v10[2] & 0x20) != 0 )
      *((_QWORD *)v10 + 5) = 0i64;
    *((_WORD *)v10 + 1) = 0;
    v11 = Irp->Tail.IrpExtension;
  }
LABEL_8:
  AllocationProcessorNumber = Irp->AllocationProcessorNumber;
  memset(Irp, 0i64, Size);
  Irp->Size = Size;
  Irp->Type = 6;
  Irp->CurrentLocation = StackCount + 1;
  Irp->StackCount = StackCount;
  ApcStateIndex = KeGetCurrentThread()->ApcStateIndex;
  Irp->ThreadListEntry.Blink = &Irp->ThreadListEntry;
  Irp->ThreadListEntry.Flink = &Irp->ThreadListEntry;
  Irp->ApcEnvironment = ApcStateIndex;
  Irp->AllocationProcessorNumber = AllocationProcessorNumber;
  Irp->AllocationFlags = v6;
  Irp->IoStatus.Status = Iostatus;
  result = (char *)&Irp[1] + 64 * StackCount + 8 * StackCount;
  Irp->Tail.CurrentStackLocation = (_IO_STACK_LOCATION *)result;
  if( v11 )
  {
    Irp->Tail.IrpExtension = v11;
    if( v2 == 1 )
      IoSetActivityIdIrp(Irp, &Guid);
    result = (VOID *)*(&stru_140CF2E80 + 1624);
    if( (*(&stru_140CF2E80 + 6496) & 4) != 0 )
    {
      result = (VOID *)*(&stru_140CF2E80 + 1626);
      if( (*(&stru_140CF2E80 + 6504) & 1) != 0 )
      {
        if( !IopIrpHasExtensionType(Irp, 0i64)
          || (LOBYTE(result) = IopIsActivityTracingEventEnabled(&IoTrace_KernelIo_ReuseIrp), (_BYTE)result) )
        {
          *(_OWORD *)ActivityId = 0i64;
          EtwActivityIdControl(3ui64, (_GUID *)ActivityId);
          if( IopIsActivityTracingEventEnabled(&IoTrace_KernelIo_ReuseIrp) )
            EtwWriteEx(
              *(&stru_140C452E0 + 328),
              &IoTrace_KernelIo_ReuseIrp,
              0i64,
              0,
              (_DWORD)v11 + 24,
              (_LPCGUID)ActivityId,
              0,
              0i64);
          LODWORD(result) = IoSetActivityIdIrp(Irp, (_GUID *)ActivityId);
        }
      }
    }
  }
  return result;
}

Referenced by:

PopAllocateIrp
PopPrepareIoctl
SmKmFileInfoCleanup