FsRtlReleaseFile

VOID __stdcall FsRtlReleaseFile(_FILE_OBJECT *FileObject){
  UINT8 v2; 
  _FS_FILTER_CTRL *v3; 
  int v4; 
  char v5; 
  _DEVICE_OBJECT *v6; 
  _DEVICE_OBJECT *v7; 
  _ADAPTER_OBJECT *v8; 
  INT64 v9; 
  INT64 v10; 
  _DEVICE_OBJECT *v11; 
  _DMA_OPERATIONS *DmaOperations; 
  unsigned int(__fastcall *ReadDmaCounter)(_DMA_ADAPTER *); 
  __int64 v14; 
  NTSTATUS v15; 
  _ADAPTER_OBJECT *v16; 
  char v17; 
  void(__fastcall *v18)(_FILE_OBJECT *); 
  int v19; 
  _ADAPTER_OBJECT *v20; 
  _DMA_OPERATIONS *v21; 
  void *FsContext; 
  _ERESOURCE *v23; 
  UINT8 BaseFsFailedOp[4]; 
  PADAPTER_OBJECT DmaAdapter; 
  _FS_FILTER_CTRL FsFilterCtrl[144]; 

  memset(FsFilterCtrl, 0i64, 0x238u);
  v2 = 0;
  v3 = FsFilterCtrl;
  *(_DWORD *)BaseFsFailedOp = 0;
  v4 = 0;
  v5 = 0;
  LODWORD(v6) = IoGetRelatedDeviceObject((INT64)FileObject);
  v7 = v6;
  LODWORD(v8) = IoGetBaseFileSystemDeviceObject((INT64)FileObject);
  DmaAdapter = v8;
  DmaOperations = v8->AdapterObject.DmaHeader.DmaOperations;
  ReadDmaCounter = DmaOperations->ReadDmaCounter;
  v14 = *((_QWORD *)DmaOperations->FreeAdapterChannel + 6);
  if( v14 && (*(_DWORD *)v14 >= 0x20u && *(_QWORD *)(v14 + 24) || *(_DWORD *)v14 >= 0x28u && *(_QWORD *)(v14 + 32)) )
    v5 = 1;
  if( v7 != (_DEVICE_OBJECT *)v8 || v5 )
  {
    FsFilterCtrlInit(FsFilterCtrl, 0xFEu, v7, v11, FileObject, 0);
    v15 = FsFilterPerformCallbacks(FsFilterCtrl, 0, 0, BaseFsFailedOp);
    v2 = BaseFsFailedOp[0];
    v4 = v15;
  }
  else
  {
    v3 = 0i64;
  }
  if( v4 >= 0 )
  {
    if( v4 )
    {
      v19 = 0;
      if( v4 != 294 )
        v19 = v4;
      v4 = v19;
    }
    else
    {
      if( v3 && (FileObject = *(_FILE_OBJECT **)&FsFilterCtrl[4], (FsFilterCtrl[16] & 4) != 0) )
      {
        LODWORD(v20) = IoGetDeviceAttachmentBaseRef(*(INT64 *)&FsFilterCtrl[2], v9, v10);
        v16 = v20;
        v17 = 1;
        v21 = v20->AdapterObject.DmaHeader.DmaOperations;
        ReadDmaCounter = v21->ReadDmaCounter;
        v14 = *((_QWORD *)v21->FreeAdapterChannel + 6);
      }
      else
      {
        v16 = DmaAdapter;
        v17 = 0;
      }
      if( !v14
        || (*(_DWORD *)v14 < 0x20u || !*(_QWORD *)(v14 + 24)) && (*(_DWORD *)v14 < 0x28u || !*(_QWORD *)(v14 + 32)) )
      {
        if( ReadDmaCounter
          && *(_DWORD *)ReadDmaCounter >= 0x68u
          && (v18 = (void(__fastcall *)(_FILE_OBJECT *))*((_QWORD *)ReadDmaCounter + 12)) != 0i64 )
        {
          v18(FileObject);
        }
        else
        {
          v4 = -1073741808;
        }
        v2 |= 1u;
      }
      if( v17 )
        HalPutDmaAdapter(v16);
    }
  }
  if( v4 == -1073741808 && (v2 & 1) != 0 )
  {
    FsContext = FileObject->FsContext;
    if( FsContext )
    {
      v23 = (_ERESOURCE *)*((_QWORD *)FsContext + 1);
      if( v23 )
        ExReleaseResourceLite(v23);
    }
    v4 = 0;
  }
  if( v3 )
  {
    if( *((_WORD *)v3 + 37) )
      FsFilterPerformCompletionCallbacks(FsFilterCtrl, (unsigned int)v4);
    FsFilterCtrlFree(FsFilterCtrl);
  }
  KeLeaveCriticalRegion();
}

Referenced by:

CcDeleteSharedCacheMap
CcWriteBehindInternal
CcZeroEndOfLastPage
FsRtlCreateSectionForDataScan
MiReferenceControlArea
MiShareExistingControlArea