IopBuildAsynchronousFsdRequest

_IRP *__stdcall IopBuildAsynchronousFsdRequest(
        UINT64 MajorFunction,
        _DEVICE_OBJECT *DeviceObject,
        VOID *Buffer,
        UINT64 Length,
        _LARGE_INTEGER *StartingOffset,
        _IO_STATUS_BLOCK *IoStatusBlock,
        VOID *ReturnAddress){
  UINT64 v7; 
  unsigned int v10; 
  _IRP *Irp; 
  _IO_STACK_LOCATION *CurrentStackLocation; 
  int v13; 
  unsigned int Flags; 
  unsigned int DeviceType; 
  _MDL *Mdl; 
  VOID **Pool_1; 
  int v19; 
  int v20; 

  v20 = Length;
  v7 = (unsigned int)Length;
  v10 = MajorFunction;
  Irp = IopAllocateIrpExReturn(DeviceObject, DeviceObject->StackSize, 0, ReturnAddress);
  if( Irp )
  {
    Irp->Tail.Thread = (_ETHREAD *)KeGetCurrentThread();
    CurrentStackLocation = Irp->Tail.CurrentStackLocation;
    CurrentStackLocation[-1].MajorFunction = v10;
    if( v10 <= 0x1B )
    {
      v13 = 138478080;
      if( _bittest(&v13, v10) )
      {
LABEL_4:
        Irp->Flags = Irp->Flags & 0xFFF1FFFF | ((PsGetIoPriorityThread(Irp->Tail.Thread) + 1) << 17);
        Irp->UserIosb = IoStatusBlock;
        return Irp;
      }
    }
    Flags = DeviceObject->Flags;
    if( (Flags & 4) != 0 )
    {
      Pool_1 = IopVerifierExAllocatePool_1(0x204ui64, v7);
      Irp->AssociatedIrp.MasterIrp = (_IRP *)Pool_1;
      if( Pool_1 )
      {
        if( v10 == 4 )
        {
          memmove(Pool_1, Buffer, v7);
          v19 = 48;
        }
        else
        {
          Irp->UserBuffer = Buffer;
          v19 = 112;
        }
        Irp->Flags = v19;
        LODWORD(v7) = v20;
        goto LABEL_8;
      }
    }
    else
    {
      if( (Flags & 0x10) == 0 )
      {
        Irp->UserBuffer = Buffer;
LABEL_8:
        LODWORD(CurrentStackLocation[-1].Parameters.SecurityContext) = v7;
        if( StartingOffset )
          *(_LARGE_INTEGER *)&CurrentStackLocation[-1].Parameters.FileAttributes = *StartingOffset;
        DeviceType = DeviceObject->DeviceType;
        if( DeviceType >= 7 && (DeviceType <= 9 || DeviceType == 36) )
          IoSetDiskIoAttributionFromThread(Irp, Irp->Tail.Thread);
        goto LABEL_4;
      }
      Mdl = IoAllocateMdl(Buffer, (unsigned int)v7, 0, 0, 0i64);
      Irp->MdlAddress = Mdl;
      if( Mdl )
      {
        IopProbeAndLockPages();
        goto LABEL_8;
      }
    }
    IoFreeIrp(Irp);
  }
  return 0i64;
}

Referenced by:

IoBuildAsynchronousFsdRequest
IopBuildSynchronousFsdRequest