IoAsynchronousPageWrite

NTSTATUS __fastcall IoAsynchronousPageWrite(
        _FILE_OBJECT *a1,
        __int64 a2,
        _QWORD *a3,
        void (__fastcall *a4)(__int64, __int64, _QWORD),
        __int64 a5,
        int a6,
        int a7,
        char a8,
        __int64 a9,
        __int64 a10,
        _QWORD *a11){
  _SECTION_OBJECT_POINTERS *SectionObjectPointer; 
  _DEVICE_OBJECT *RelatedDeviceObject; 
  IRP *Irp; 
  __int64 v18; 
  _ETHREAD *CurrentThread; 
  NTSTATUS result; 
  _LARGE_INTEGER v21; 
  IRP *ReserveIrp; 
  unsigned __int8 CurrentIrql; 
  VOID *retaddr; 
  SectionObjectPointer = a1->SectionObjectPointer;
  if( SectionObjectPointer && SectionObjectPointer->SharedCacheMap )
  {
    __incgsdword(0x8134u);
    __addgsdword(0x8138u, (unsigned int)(*(_DWORD *)(a2 + 40) + 4095) >> 12);
  }
  RelatedDeviceObject = IoGetRelatedDeviceObject(a1);
  Irp = IopAllocateIrpExReturn(RelatedDeviceObject, *((_BYTE *)RelatedDeviceObject + 76), 0, retaddr);
  if( !Irp )
  {
    if( (unsigned int)MmIsFileObjectAPagingFile(a1) )
    {
      _InterlockedAdd(&IoAsynchronousPageWriteIrpAllocationFailure, 1u);
      ReserveIrp = IopAllocateReserveIrp(v21, *((_BYTE *)RelatedDeviceObject + 76), 1i64);
    }
    else
    {
      _InterlockedAdd(&IoAsynchronousPageWriteNonPagefileIrpAllocationFailure, 1u);
      ReserveIrp = IopAllocateBackpocketIrp(RelatedDeviceObject, *((_BYTE *)RelatedDeviceObject + 76), 0);
    }
    Irp = ReserveIrp;
    if( !ReserveIrp )
      return -1073741670;
  }
  if( a11 )
    *a11 = Irp;
  *((_BYTE *)Irp + 71) |= 0x20u;
  v18 = *((_QWORD *)Irp + 23);
  *((_QWORD *)Irp + 1) = a2;
  *((_DWORD *)Irp + 4) = ((a6 + 1) << 17) | 3;
  *((_QWORD *)Irp + 19) = KeGetCurrentThread();
  *((_QWORD *)Irp + 24) = a1;
  *((_QWORD *)Irp + 14) = *(_QWORD *)(a2 + 32) + *(unsigned int *)(a2 + 44);
  *((_BYTE *)Irp + 64) = 0;
  *((_QWORD *)Irp + 9) = a10;
  *((_QWORD *)Irp + 11) = a4;
  *((_QWORD *)Irp + 12) = a5;
  *(_BYTE *)(v18 - 72) = 4;
  *(_DWORD *)(v18 - 64) = *(_DWORD *)(a2 + 40);
  *(_QWORD *)(v18 - 48) = *a3;
  *(_BYTE *)(v18 - 70) |= a8;
  *(_QWORD *)(v18 - 24) = a1;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  if( a9 )
    IopSetDiskIoAttributionExtension(Irp, *(_QWORD *)(a9 + 24));
  else
    IoSetDiskIoAttributionFromThread(Irp, CurrentThread);
  IopQueueThreadIrp(Irp);
  if( a7 )
    StRtlIoStorInfoSetNvCachePriority(Irp, a7);
  result = IofCallDriver(RelatedDeviceObject, Irp);
  if( (result & 0xC0000000) == -1073741824 )
  {
    *(_QWORD *)(a10 + 8) = 0i64;
    *(_DWORD *)a10 = result;
    CurrentIrql = KeGetCurrentIrql();
    __writecr8(1ui64);
    a4(a5, a10, 0i64);
    __writecr8(CurrentIrql);
    return 259;
  }
  return result;
}

Referenced by:

MiGatherMappedPages
MiGatherPagefilePages
MiIssueAsynchronousFlush