FsRtlReleaseFileForCcFlush

VOID __stdcall FsRtlReleaseFileForCcFlush(_FILE_OBJECT *FileObject){
  unsigned int v2; 
  INT64 *v3; 
  char v4; 
  __int64 v5; 
  _DEVICE_OBJECT *BaseFileSystemDeviceObject; 
  __int64 v7; 
  __int64 v8; 
  __int64 v9; 
  int v10; 
  char v11; 
  __int64(__fastcall *v12)(_FILE_OBJECT *, _DEVICE_OBJECT *); 
  __int64 v13; 
  void *FsContext; 
  struct _ERESOURCE *v15; 
  struct _ERESOURCE *v16; 
  _DWORD a4[2]; 
  _DEVICE_OBJECT *RelatedDeviceObject; 
  INT64 result[8]; 
  char v20; 
  memset((INT64)result, 0i64);
  v2 = 0;
  v3 = result;
  a4[1] = 0;
  v4 = 0;
  RelatedDeviceObject = IoGetRelatedDeviceObject(FileObject);
  BaseFileSystemDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
  v7 = *((_QWORD *)BaseFileSystemDeviceObject + 1);
  v8 = *(_QWORD *)(v7 + 80);
  v9 = *(_QWORD *)(*(_QWORD *)(v7 + 48) + 48i64);
  if( v9 && (*(_DWORD *)v9 >= 0x40u && *(_QWORD *)(v9 + 56) || *(_DWORD *)v9 >= 0x48u && *(_QWORD *)(v9 + 64)) )
    v4 = 1;
  if( RelatedDeviceObject == BaseFileSystemDeviceObject && !v4 )
  {
    v3 = 0i64;
    goto LABEL_10;
  }
  FsFilterCtrlInit((__int64)result, 250, (__int64)RelatedDeviceObject, v5, (__int64)FileObject, 0);
  v10 = FsFilterPerformCallbacks((INT64)result, 0, 1, &a4[1]);
  v2 = v10;
  if( v10 < 0 )
    goto LABEL_23;
  if( !v10 )
  {
    FileObject = (_FILE_OBJECT *)result[2];
    if( (v20 & 4) != 0 )
    {
      BaseFileSystemDeviceObject = IoGetDeviceAttachmentBaseRef((_DEVICE_OBJECT *)result[1]);
      v11 = 1;
      v13 = *((_QWORD *)BaseFileSystemDeviceObject + 1);
      v8 = *(_QWORD *)(v13 + 80);
      v9 = *(_QWORD *)(*(_QWORD *)(v13 + 48) + 48i64);
LABEL_11:
      if( !v9 || (*(_DWORD *)v9 < 0x40u || !*(_QWORD *)(v9 + 56)) && (*(_DWORD *)v9 < 0x48u || !*(_QWORD *)(v9 + 64)) )
      {
        if( v8
          && *(_DWORD *)v8 >= 0xE0u
          && (v12 = *(__int64(__fastcall **)(_FILE_OBJECT *, _DEVICE_OBJECT *))(v8 + 216)) != 0i64 )
        {
          v2 = v12(FileObject, BaseFileSystemDeviceObject);
        }
        else
        {
          v2 = -1073741808;
        }
        a4[1] |= 1u;
      }
      if( v11 )
        HalPutDmaAdapter((PADAPTER_OBJECT)BaseFileSystemDeviceObject);
      goto LABEL_23;
    }
LABEL_10:
    v11 = 0;
    goto LABEL_11;
  }
  v2 = 0;
  if( v10 != 294 )
    v2 = v10;
LABEL_23:
  if( v2 == -1073741808 && (a4[1] & 1) != 0 )
  {
    FsContext = FileObject->FsContext;
    v15 = (struct _ERESOURCE *)*((_QWORD *)FsContext + 2);
    if( v15 )
      ExReleaseResourceLite(v15);
    v16 = (struct _ERESOURCE *)*((_QWORD *)FsContext + 1);
    if( v16 )
      ExReleaseResourceLite(v16);
    v2 = 0;
  }
  if( v3 )
  {
    if( *((_WORD *)v3 + 37) )
      FsFilterPerformCompletionCallbacks((__int64)result, v2);
    FsFilterCtrlFree((__int64)result);
  }
  KeLeaveCriticalRegion();
}

Referenced by:

MiDeleteCachedSubsection
MiDestroySection
MiFlushControlArea
MmFlushSection
MmFlushVirtualMemory