IopCallDriverReference

NTSTATUS __stdcall IopCallDriverReference(
        _DEVICE_OBJECT *DeviceObject,
        _IRP *Irp,
        UINT8 SynchronousIo,
        _FILE_OBJECT *FileObject,
        _TRANSFER_TYPE TransferType){
  _DWORD *FileObjectExtension; 
  int v10; 
  KDPC *CurrentThread; 
  int v12; 
  __int64 v13; 
  unsigned int v14; 
  int v15; 
  unsigned int v16; 
  int v17; 
  int v18; 
  __int64 v19; 
  NTSTATUS v20; 
  __int64 v22; 
  int v23; 
  __int64 v24; 
  _ETHREAD *v25; 
  __int64 v26; 
  __int128 v27; 
  if( !SynchronousIo )
  {
    if( ObpTraceFlags )
      ObpPushStackInfo((INT64)&FileObject[-1].Event.Header.WaitListHead.Blink, 1, 1i64, 1953261124i64);
    ObpIncrPointerCount((volatile INT64 *)&FileObject[-1].Event.Header.WaitListHead.Blink);
  }
  FileObjectExtension = FileObject->FileObjectExtension;
  v10 = 2;
  if( FileObjectExtension && FileObjectExtension[20] )
  {
    v14 = *((_DWORD *)Irp + 4) & 0xFFF1FFFF;
    *((_DWORD *)Irp + 4) = v14;
    v15 = FileObjectExtension[20] << 17;
  }
  else
  {
    CurrentThread = (KDPC *)KeGetCurrentThread();
    PsGetBaseIoPriorityThread(CurrentThread, (PVOID)2, CurrentThread, FileObject);
    if( v12 < v10 && (struct _KTHREAD *)v13 == KeGetCurrentThread() && *(_DWORD *)(v13 + 1360) )
      v12 = v10;
    v14 = *((_DWORD *)Irp + 4) & 0xFFF1FFFF;
    v15 = (v12 << 17) + 0x20000;
  }
  v16 = v14 | v15;
  *((_DWORD *)Irp + 4) = v16;
  v17 = (v16 >> 17) & 7;
  if( !v17 )
  {
    v18 = v10;
LABEL_7:
    v10 = v18;
    goto LABEL_8;
  }
  v18 = v17 - 1;
  if( v18 >= v10 )
    goto LABEL_7;
  v24 = *((_QWORD *)Irp + 19);
  if( !v24 || !*(_DWORD *)(v24 + 1360) )
    goto LABEL_7;
LABEL_8:
  if( !*((_BYTE *)Irp + 64) )
  {
    if( v10 >= 2 )
      goto LABEL_10;
    v22 = *((_QWORD *)Irp + 19);
    if( !v22 || (*(_DWORD *)(v22 + 116) & 0x400) == 0 && (*(_DWORD *)(v22 + 1300) & 0x80u) == 0 )
    {
      v23 = *((_DWORD *)Irp + 4);
      ++IoKernelIssuedIoBoostedCount;
      *((_DWORD *)Irp + 4) = v23 & 0xFFF1FFFF | 0x60000;
      goto LABEL_10;
    }
  }
  if( v10 < 2 )
  {
    if( TransferType )
    {
      if( TransferType == WriteTransfer )
        ++IoLowPriorityWriteOperationCount;
    }
    else
    {
      ++*(_DWORD *)IoLowPriorityReadOperationCount;
    }
  }
LABEL_10:
  if( *((char *)Irp + 71) >= 0 && (v19 = *((_QWORD *)Irp + 25)) != 0 && (*(_BYTE *)v19 & 2) != 0 )
  {
    v27 = *(_OWORD *)(v19 + 24);
    v25 = (_ETHREAD *)KeGetCurrentThread();
    v26 = *((_QWORD *)v25 + 180);
    *((_QWORD *)v25 + 180) = &v27;
    v20 = IofCallDriver(DeviceObject, Irp);
    *((_QWORD *)KeGetCurrentThread() + 180) = v26;
  }
  else
  {
    v20 = IofCallDriver(DeviceObject, Irp);
  }
  if( !SynchronousIo )
    ObDereferenceObjectDeferDeleteWithTag(FileObject, 0x746C6644ui64);
  return v20;
}

Referenced by:

NtQueryInformationFile
NtSetInformationFile