IoSetInformation

NTSTATUS __stdcall IoSetInformation(
        PFILE_OBJECT FileObject,
        _FILE_INFORMATION_CLASS FileInformationClass,
        UINT64 Length,
        VOID *FileInformation){
  char v4; 
  char v5; 
  _ETHREAD *CurrentThread; 
  bool v10; 
  _BYTE *v11; 
  _DEVICE_OBJECT *v12; 
  _IRP *Irp; 
  _IRP *v14; 
  __int128 *p_Object; 
  _IO_STACK_LOCATION *CurrentStackLocation; 
  int v17; 
  unsigned __int64 v18; 
  __int64 v19; 
  int FinalStatus; 
  NTSTATUS v22; 
  unsigned int Flags; 
  unsigned int v24; 
  int v25; 
  unsigned int v26; 
  _CCHAR v27; 
  char v28; 
  char v29; 
  char v30; 
  _DEVICE_OBJECT *DeviceObject; 
  VOID *Handle; 
  __int128 v33; 
  __int128 Object; 
  __int64 v35; 
  VOID *retaddr; 
  INT64 v37; 
  UINT64 a3; 

  LODWORD(a3) = Length;
  v4 = 0;
  Handle = 0i64;
  Object = 0i64;
  v35 = 0i64;
  v5 = 0;
  v33 = 0i64;
  v29 = 0;
  ObfReferenceObject(FileObject);
  if( (FileObject->Flags & 2) != 0 )
  {
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    v10 = (FileObject->Flags & 4) != 0;
    --CurrentThread->Tcb.KernelApcDisable;
    v11 = KeAbPreAcquire(FileObject->gap80, 0i64, 0i64);
    LOBYTE(v37) = 0;
    if( _InterlockedExchange((volatile __int32 *)&FileObject->Busy, 1) )
    {
      v22 = IopWaitAndAcquireFileObjectLock(FileObject, 0, v10, v11, (INT64)&v37);
      if( (_BYTE)v37 )
      {
        HalPutDmaAdapter((PADAPTER_OBJECT)FileObject);
        return v22;
      }
    }
    else
    {
      if( v11 )
        v11[26] |= 1u;
      ObfReferenceObject(FileObject);
    }
    KeResetEvent((_KEVENT *)&FileObject->gap80[24]);
    v4 = 1;
  }
  else
  {
    KeInitializeEvent((INT64)&Object, 1, 0);
  }
  v30 = v4;
  LODWORD(v12) = IoGetRelatedDeviceObject((INT64)FileObject);
  DeviceObject = v12;
  switch( FileInformationClass )
  {
    case FileRenameInformationBypassAccessCheck:
      FileInformationClass = FileRenameInformation;
LABEL_38:
      v5 = 1;
      break;
    case FileRenameInformationExBypassAccessCheck:
      FileInformationClass = FileRenameInformationEx;
      goto LABEL_38;
    case FileLinkInformationBypassAccessCheck:
      FileInformationClass = FileLinkInformation;
      goto LABEL_38;
    case FileLinkInformationExBypassAccessCheck:
      FileInformationClass = FileLinkInformationEx;
      goto LABEL_38;
    case FileCaseSensitiveInformationForceAccessCheck:
      FileInformationClass = FileCaseSensitiveInformation;
      v29 = 1;
      break;
  }
  Irp = IopAllocateIrpExReturn(v12, v12->StackSize, v4 ^ 1u, retaddr);
  v14 = Irp;
  if( !Irp )
  {
    IopAllocateIrpCleanup(FileObject, 0i64);
    return -1073741670;
  }
  Irp->Tail.OriginalFileObject = FileObject;
  Irp->Tail.Thread = (_ETHREAD *)KeGetCurrentThread();
  Irp->RequestorMode = 0;
  if( v4 )
  {
    Irp->AllocationFlags |= 2u;
    p_Object = 0i64;
  }
  else
  {
    Irp->Flags = 4;
    p_Object = &Object;
  }
  v14->UserEvent = (_KEVENT *)p_Object;
  CurrentStackLocation = v14->Tail.CurrentStackLocation;
  v14->UserIosb = (_IO_STATUS_BLOCK *)&v33;
  v17 = a3;
  CurrentStackLocation[-1].MajorFunction = 6;
  CurrentStackLocation[-1].FileObject = FileObject;
  v14->Flags |= 0x10u;
  v14->AssociatedIrp.MasterIrp = (_IRP *)FileInformation;
  LODWORD(CurrentStackLocation[-1].Parameters.SecurityContext) = v17;
  CurrentStackLocation[-1].Parameters.Options = FileInformationClass;
  if( v5 )
  {
    CurrentStackLocation[-1].Flags |= 1u;
  }
  else if( v29 )
  {
    CurrentStackLocation[-1].Flags |= 1u;
  }
  IopQueueThreadIrp(v14);
  if( FileInformationClass == FileModeInformation )
  {
    Flags = FileObject->Flags;
    if( (Flags & 8) == 0 )
    {
      if( (*(_DWORD *)FileInformation & 2) != 0 )
        Flags |= 0x10u;
      else
        Flags &= ~0x10u;
      FileObject->Flags = Flags;
    }
    v24 = Flags & 0xFFFFFFDF;
    v25 = Flags | 0x20;
    if( (*(_DWORD *)FileInformation & 4) == 0 )
      v25 = v24;
    FileObject->Flags = v25;
    if( (*(_DWORD *)FileInformation & 2) != 0 )
    {
      if( (*(_DWORD *)FileInformation & 0x10) != 0 )
        v26 = v25 | 4;
      else
        v26 = v25 & 0xFFFFFFFB;
      FileObject->Flags = v26;
    }
    --v14->CurrentLocation;
    FinalStatus = 0;
    --v14->Tail.CurrentStackLocation;
    v27 = 0;
    v14->IoStatus.Status = 0;
    v14->IoStatus.Information = 0i64;
    goto LABEL_68;
  }
  v18 = (unsigned int)(FileInformationClass - 10);
  if( (unsigned int)v18 <= 0x3E )
  {
    v19 = 0x4080000000000003i64;
    if( _bittest64(&v19, v18) )
    {
      if( FileInformationClass != FileMoveClusterInformation )
      {
        if( FileInformationClass == FileRenameInformationEx || FileInformationClass == FileLinkInformationEx )
          v28 = *(_BYTE *)FileInformation & 1;
        else
          v28 = *(_BYTE *)FileInformation;
        LOBYTE(CurrentStackLocation[-1].Parameters.EaLength) = v28;
        goto LABEL_63;
      }
LABEL_62:
      CurrentStackLocation[-1].Parameters.EaLength = *(_DWORD *)FileInformation;
LABEL_63:
      if( *((_WORD *)FileInformation + 10) != 92 && !*((_QWORD *)FileInformation + 1) )
        goto LABEL_24;
      FinalStatus = IopOpenLinkOrRenameTarget(&Handle, v14, FileInformation, FileObject);
      if( FinalStatus >= 0 )
        goto LABEL_24;
      LOBYTE(v27) = 2;
      goto LABEL_67;
    }
  }
  if( FileInformationClass == FileMoveClusterInformation )
    goto LABEL_62;
  if( FileInformationClass == FileMemoryPartitionInformation )
  {
    FinalStatus = IopSetFileMemoryPartitionInformation(FileObject, (INT64)FileInformation, (unsigned int)a3);
    v14->IoStatus.Status = FinalStatus;
    v27 = 0;
    v14->IoStatus.Information = 0i64;
LABEL_67:
    --v14->CurrentLocation;
    --v14->Tail.CurrentStackLocation;
LABEL_68:
    IofCompleteRequest(v14, v27);
    goto LABEL_25;
  }
LABEL_24:
  FinalStatus = IofCallDriver((UINT64)DeviceObject, (UINT64)v14);
LABEL_25:
  if( v30 )
  {
    if( FinalStatus == 259 )
    {
      if( KeWaitForSingleObject((UINT64)&FileObject->gap80[24], 0, 0, (FileObject->Flags & 4) != 0, 0i64) == 257 )
        IopCancelAlertedRequest(&FileObject->gap80[24], v14);
      FinalStatus = FileObject->FinalStatus;
    }
    IopReleaseFileObjectLock((PADAPTER_OBJECT)FileObject);
  }
  else if( FinalStatus == 259 )
  {
    KeWaitForSingleObject((UINT64)&Object, 0, 0, 0, 0i64);
    FinalStatus = v33;
  }
  if( Handle )
    ObCloseHandle(Handle, 0);
  return FinalStatus;
}

Referenced by:

MiAttemptPageFileExtension
MiAttemptPageFileReduction