IoCreateStreamFileObjectEx2

NTSTATUS __stdcall IoCreateStreamFileObjectEx2(
        _IO_CREATE_STREAM_FILE_OPTIONS *CreateOptions,
        _FILE_OBJECT *FileObject,
        _DEVICE_OBJECT *DeviceObject,
        _FILE_OBJECT **StreamFileObject,
        VOID **FileHandle,
        INT64 a6,
        INT64 a7,
        INT64 a8){
  VOID **v8; 
  __int16 v9; 
  _DEVICE_OBJECT *v10; 
  int v12; 
  _QWORD *v13; 
  struct _KPRCB *CurrentPrcb; 
  _SLIST_ENTRY *v15; 
  _GENERAL_LOOKASIDE *P; 
  _ADAPTER_OBJECT *v17; 
  _VPB *Vpb; 
  NTSTATUS result; 
  int v20; 
  VOID *Flags; 
  UINT64 Flagsa; 
  UINT64 ObjectBodySize; 
  UINT64 PagedPoolCharge; 
  UINT64 NonPagedPoolCharge; 
  PVOID Handle; 
  VOID *TypeExt; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  PVOID NewObject; 
  _FILE_OBJECT **v30; 

  v30 = StreamFileObject;
  v8 = FileHandle;
  v9 = *((_WORD *)CreateOptions + 1) & 2;
  NewObject = 0i64;
  v10 = DeviceObject;
  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  Handle = 0i64;
  *StreamFileObject = 0i64;
  if( v8 )
    *v8 = 0i64;
  if( *(_WORD *)CreateOptions != 16 )
  {
    if( (*((_BYTE *)CreateOptions + 2) & 1) != 0 )
      RtlRaiseStatus(-1073741637);
    return -1073741637;
  }
  if( v9 && v8 )
    goto LABEL_33;
  if( FileObject )
  {
    v10 = FileObject->DeviceObject;
    goto LABEL_8;
  }
  if( !DeviceObject )
  {
LABEL_33:
    if( (*((_BYTE *)CreateOptions + 2) & 1) != 0 )
      RtlRaiseStatus(-1073741811);
    return -1073741811;
  }
LABEL_8:
  IopIncrementDeviceObjectRefCount(v10, 1u);
  LODWORD(NonPagedPoolCharge) = 0;
  LODWORD(PagedPoolCharge) = 216;
  LODWORD(ObjectBodySize) = 216;
  ObjectAttributes.Length = 48;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.Attributes = 512;
  ObjectAttributes.ObjectName = 0i64;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  LOWORD(FileHandle) = 1;
  v12 = ObCreateObjectEx(
          0i64,
          (_OBJECT_TYPE *)IoFileObjectType,
          &ObjectAttributes,
          0i64,
          Flags,
          ObjectBodySize,
          PagedPoolCharge,
          NonPagedPoolCharge,
          &NewObject,
          (_OB_EXTENDED_CREATION_INFO *)&FileHandle);
  if( v12 < 0 )
  {
    IopDecrementDeviceObjectRef(v10, 0, 0);
    if( (*((_BYTE *)CreateOptions + 2) & 1) != 0 )
      RtlRaiseStatus(v12);
    return v12;
  }
  v13 = NewObject;
  memset(NewObject, 0i64, 0xD8u);
  *(_DWORD *)v13 = 14155781;
  v13[1] = v10;
  *((_DWORD *)v13 + 20) = 256;
  KeInitializeEvent((INT64)(v13 + 19), 1, 0);
  v13[23] = 0i64;
  v13[25] = v13 + 24;
  v13[24] = v13 + 24;
  if( v9 )
  {
    CurrentPrcb = KeGetCurrentPrcb();
    v15 = (_SLIST_ENTRY *)*(v13 - 2);
    P = CurrentPrcb->PPLookasideList[4].P;
    ++P->TotalFrees;
    if( LOWORD(P->ListHead.Alignment) < P->Depth
      || (++P->FreeMisses,
          P = CurrentPrcb->PPLookasideList[4].L,
          ++P->TotalFrees,
          LOWORD(P->ListHead.Alignment) < P->Depth) )
    {
      RtlpInterlockedPushEntrySList(&P->ListHead, v15);
    }
    else
    {
      ++P->FreeMisses;
      ((void(__fastcall *)(_SLIST_ENTRY *))P->FreeEx)(v15);
    }
    *(v13 - 2) = 0i64;
LABEL_13:
    v17 = (_ADAPTER_OBJECT *)NewObject;
    *((_DWORD *)NewObject + 20) |= 0x40000u;
    Vpb = v10->Vpb;
    if( Vpb )
      IopIncrementVpbRefCount(Vpb, 1u);
    if( !v9 )
    {
      if( v8 )
      {
        *v8 = Handle;
        HalPutDmaAdapter(v17);
      }
      else
      {
        ObCloseHandle(Handle, 0);
      }
    }
    if( *((_QWORD *)CreateOptions + 1) )
    {
      TypeExt = 0i64;
      IopGetSetSpecificExtension((_FILE_OBJECT *)v17, FoExtTypeInternal, 0x20ui64, 1u, &TypeExt, 0i64);
      v12 = v20;
      if( v20 < 0 )
      {
        if( v8 )
        {
          ObCloseHandle(*v8, 0);
          *v8 = 0i64;
        }
        else
        {
          HalPutDmaAdapter(v17);
        }
        if( (*((_BYTE *)CreateOptions + 2) & 1) != 0 )
          RtlRaiseStatus(v12);
        return v12;
      }
      *(_QWORD *)TypeExt = *((_QWORD *)CreateOptions + 1);
    }
    *v30 = (_FILE_OBJECT *)v17;
    return v12;
  }
  LODWORD(Flagsa) = 0;
  result = ObInsertObjectEx(v13, 0i64, 1ui64, 1ui64, Flagsa, &NewObject, &Handle);
  v12 = result;
  if( result >= 0 )
    goto LABEL_13;
  if( (*((_BYTE *)CreateOptions + 2) & 1) != 0 )
    RtlRaiseStatus(result);
  return result;
}

Referenced by:

IoCreateStreamFileObject
IoCreateStreamFileObjectEx
IoCreateStreamFileObjectLite