FsRtlAcquireFileExclusiveCommon

NTSTATUS __stdcall FsRtlAcquireFileExclusiveCommon(
        FILE_OBJECT *FileObject,
        FS_FILTER_SECTION_SYNC_TYPE SyncType,
        UINT64 SectionPageProtection,
        FS_FILTER_SECTION_SYNC_OUTPUT *OutputInformation){
  int v6; 
  INT64 *v7; 
  char v8; 
  _DEVICE_OBJECT *RelatedDeviceObject; 
  __int64 v10; 
  _DEVICE_OBJECT *BaseFileSystemDeviceObject; 
  __int64 v12; 
  __int64 v13; 
  __int64 v14; 
  __int64 v15; 
  NTSTATUS v16; 
  _ETHREAD *v17; 
  int v18; 
  int v19; 
  _ETHREAD *CurrentThread; 
  char v21; 
  __int64 v22; 
  void(__fastcall *v23)(FILE_OBJECT *); 
  void *FsContext; 
  ERESOURCE *v25; 
  int a4; 
  int v27; 
  int v28; 
  __int64 v29; 
  __int64 v30; 
  INT64 result[3]; 
  FS_FILTER_SECTION_SYNC_TYPE v32; 
  int v33; 
  __int64 v34; 
  int v35; 
  char v36; 
  __int64 v37; 
  v27 = SectionPageProtection;
  v29 = v37;
  v28 = (int)OutputInformation;
  memset((INT64)result, 0i64);
  v6 = 0;
  v7 = result;
  a4 = 0;
  v8 = 0;
  RelatedDeviceObject = IoGetRelatedDeviceObject(FileObject);
  BaseFileSystemDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
  v12 = *((_QWORD *)BaseFileSystemDeviceObject + 1);
  v13 = *(_QWORD *)(v12 + 80);
  v14 = *(_QWORD *)(v12 + 48);
  v30 = v13;
  v15 = *(_QWORD *)(v14 + 48);
  if( v15 && (*(_DWORD *)v15 >= 0x10u && *(_QWORD *)(v15 + 8) || *(_DWORD *)v15 >= 0x18u && *(_QWORD *)(v15 + 16)) )
    v8 = 1;
  if( RelatedDeviceObject == BaseFileSystemDeviceObject && !v8 )
  {
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    v7 = 0i64;
    --*((_WORD *)CurrentThread + 242);
    goto LABEL_10;
  }
  if( SyncType == SyncTypeCreateSection )
    LOBYTE(v6) = 1;
  v16 = FsFilterCtrlInit((__int64)result, 255, (__int64)RelatedDeviceObject, v10, (__int64)FileObject, v6);
  if( v16 >= 0 )
  {
    v33 = v27;
    v34 = v29;
    v35 = v28;
    v32 = SyncType;
    v17 = (_ETHREAD *)KeGetCurrentThread();
    --*((_WORD *)v17 + 242);
    v18 = FsFilterPerformCallbacks((INT64)result, v6, v6, &a4);
    v13 = v30;
    v6 = v18;
LABEL_10:
    if( v6 >= 0 )
    {
      if( v6 )
      {
        v19 = 0;
        if( v6 != 294 )
          v19 = v6;
        v6 = v19;
      }
      else
      {
        if( v7 && (FileObject = (FILE_OBJECT *)result[2], (v36 & 4) != 0) )
        {
          BaseFileSystemDeviceObject = IoGetDeviceAttachmentBaseRef((_DEVICE_OBJECT *)result[1]);
          v21 = 1;
          v22 = *((_QWORD *)BaseFileSystemDeviceObject + 1);
          v13 = *(_QWORD *)(v22 + 80);
          v15 = *(_QWORD *)(*(_QWORD *)(v22 + 48) + 48i64);
        }
        else
        {
          v21 = 0;
        }
        if( !v15
          || (*(_DWORD *)v15 < 0x10u || !*(_QWORD *)(v15 + 8)) && (*(_DWORD *)v15 < 0x18u || !*(_QWORD *)(v15 + 16)) )
        {
          if( v13 && *(_DWORD *)v13 >= 0x60u && (v23 = *(void(__fastcall **)(FILE_OBJECT *))(v13 + 88)) != 0i64 )
            v23(FileObject);
          else
            v6 = -1073741808;
          a4 |= 1u;
        }
        if( v21 )
          HalPutDmaAdapter((PADAPTER_OBJECT)BaseFileSystemDeviceObject);
      }
    }
    if( v6 == -1073741808 && (a4 & 1) != 0 )
    {
      FsContext = FileObject->FsContext;
      if( FsContext )
      {
        v25 = (ERESOURCE *)*((_QWORD *)FsContext + 1);
        if( v25 )
          ExAcquireResourceExclusiveLite(v25, 1u);
      }
      v6 = 0;
    }
    if( v7 )
    {
      if( *((_WORD *)v7 + 37) )
        FsFilterPerformCompletionCallbacks((__int64)result, v6);
      FsFilterCtrlFree((__int64)result);
    }
    if( v6 < 0 )
      KeLeaveCriticalRegion();
    return v6;
  }
  return v16;
}

Referenced by:

FsRtlAcquireFileExclusive
FsRtlAcquireToCreateMappedSection