IopGetSetStreamIdentifier

INT64 __stdcall IopGetSetStreamIdentifier(
        FILE_OBJECT *FileObject,
        UINT64 Length,
        VOID *Signature,
        VOID **StreamIdentifier,
        UINT8 SetOperation){
  unsigned int v5; 
  INT64 result; 
  UINT64 v10; 
  _QWORD *v11; 
  unsigned __int64 *p_IrpListLock; 
  unsigned __int8 v13; 
  unsigned __int64 v14; 
  _QWORD *v15; 
  UINT64 v16; 
  _QWORD *PoolWithTag; 
  unsigned __int8 v18; 
  unsigned __int64 v19; 
  _QWORD *v20; 
  _QWORD *v21; 
  __int64 v22[8]; 
  unsigned int v23; 
  v23 = Length;
  v5 = 0;
  v22[0] = 0i64;
  v21 = 0i64;
  IopGetSetSpecificExtension(FileObject, FoExtTypeSfio, 0x10ui64, SetOperation, (PVOID *)&v21, (PVOID *)v22);
  if( (int)result < 0 )
    goto LABEL_19;
  v11 = v21;
  if( !v21 )
  {
LABEL_18:
    result = 0i64;
LABEL_19:
    *StreamIdentifier = 0i64;
    return result;
  }
  p_IrpListLock = &FileObject->IrpListLock;
  KeAcquireSpinLockRaiseToDpc(p_IrpListLock, v10);
  v14 = v13;
  v15 = (_QWORD *)*v11;
  if( !*v11 )
  {
    v11[1] = v11;
    v15 = v11;
    *v11 = v11;
  }
  while( v15 != v11 )
  {
    if( (VOID *)v15[3] == Signature )
    {
      if( SetOperation )
      {
        *StreamIdentifier = 0i64;
        KxReleaseSpinLock(p_IrpListLock);
        v5 = -1073741791;
      }
      else
      {
        *StreamIdentifier = (VOID *)v15[2];
        KxReleaseSpinLock(p_IrpListLock);
      }
      __writecr8(v14);
      return v5;
    }
    v15 = (_QWORD *)*v15;
  }
  KxReleaseSpinLock(p_IrpListLock);
  __writecr8(v14);
  if( !SetOperation )
    goto LABEL_18;
  PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, v23 + 32i64, 0x74536F49ui64);
  if( !PoolWithTag )
  {
    result = 3221225626i64;
    goto LABEL_19;
  }
  KeAcquireSpinLockRaiseToDpc(p_IrpListLock, v16);
  v19 = v18;
  v20 = (_QWORD *)v11[1];
  if( (_QWORD *)*v20 != v11 )
    __fastfail(3u);
  PoolWithTag[1] = v20;
  *PoolWithTag = v11;
  *v20 = PoolWithTag;
  v11[1] = PoolWithTag;
  PoolWithTag[3] = Signature;
  PoolWithTag[2] = PoolWithTag + 4;
  *StreamIdentifier = PoolWithTag + 4;
  KxReleaseSpinLock(p_IrpListLock);
  __writecr8(v19);
  return 0i64;
}

Referenced by:

IoAllocateSfioStreamIdentifier
IoGetSfioStreamIdentifier