SeDefaultObjectMethod

NTSTATUS __stdcall SeDefaultObjectMethod(
        VOID *Object,
        _SECURITY_OPERATION_CODE OperationCode,
        UINT64 *SecurityInformation,
        VOID *SecurityDescriptor,
        UINT64 *CapturedLength,
        VOID **ObjectsSecurityDescriptor,
        POOL_TYPE PoolType,
        _GENERIC_MAPPING *GenericMapping,
        INT8 Mode){
  __int32 v11; 
  __int32 v12; 
  NTSTATUS v13; 
  int v14; 
  unsigned __int64 v16; 
  unsigned int v17; 
  volatile signed __int64 *v18; 
  signed __int64 v19; 
  signed __int64 v20; 
  signed __int64 v21; 
  _ETHREAD *CurrentThread; 
  _EX_PUSH_LOCK *v23; 
  _EX_PUSH_LOCK *v24; 
  signed __int64 v25; 
  volatile signed __int64 *i; 
  VOID **v27; 
  PVOID OutputSecurityDescriptor; 

  if( OperationCode == SetSecurityDescriptor )
    return ObSetSecurityDescriptorInfo(
             Object,
             SecurityInformation,
             SecurityDescriptor,
             ObjectsSecurityDescriptor,
             PoolType,
             GenericMapping);
  v11 = OperationCode - 1;
  if( !v11 )
    return ObQuerySecurityDescriptorInfo(Object, SecurityInformation, SecurityDescriptor, CapturedLength, v27);
  v12 = v11 - 1;
  if( v12 )
  {
    v13 = 0;
    if( v12 != 1 )
      KeBugCheckEx(0x29u, 0i64, (PVOID)0xFFFFFFFFC000000Di64, 0i64, 0i64);
    OutputSecurityDescriptor = 0i64;
    if( SecurityDescriptor )
    {
      v14 = ObLogSecurityDescriptor(SecurityDescriptor, &OutputSecurityDescriptor, 0x10ui64);
      if( v14 >= 0 )
      {
        ExFreePoolWithTag(SecurityDescriptor, 0);
        if( OutputSecurityDescriptor )
          *((_QWORD *)Object - 1) = (char *)OutputSecurityDescriptor + 15;
        else
          *((_QWORD *)Object - 1) = 0i64;
      }
      return v14;
    }
    else
    {
      *((_QWORD *)Object - 1) = 0i64;
    }
    return v13;
  }
  else
  {
    v16 = (unsigned __int64)*ObjectsSecurityDescriptor;
    *ObjectsSecurityDescriptor = 0i64;
    v17 = (v16 & 0xF) + 1;
    v18 = (volatile signed __int64 *)((v16 & 0xFFFFFFFFFFFFFFF0ui64) - 32);
    _m_prefetchw((const void *)(v18 + 1));
    v19 = *((_QWORD *)v18 + 1);
    v20 = v19 - v17;
    if( v20 <= 0 )
    {
LABEL_16:
      if( v20 )
        __fastfail(0xEu);
      CurrentThread = (_ETHREAD *)KeGetCurrentThread();
      v23 = (_EX_PUSH_LOCK *)((char *)&ObsSecurityDescriptorCache + 16 * (unsigned __int8)*((_DWORD *)v18 + 4));
      --CurrentThread->Tcb.KernelApcDisable;
      v24 = v23 + 1;
      ExAcquirePushLockExclusiveEx(v23, 0i64);
      v25 = _InterlockedExchangeAdd64(v18 + 1, -v17) - v17;
      if( v25 > 0 )
      {
        if( (_InterlockedExchangeAdd64(&v23->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
          ExfTryToWakePushLock(v23);
        KeAbPostRelease(v23);
        KeLeaveCriticalRegionThread(&CurrentThread->Tcb);
      }
      else
      {
        if( v25 )
          __fastfail(0xEu);
        for( i = (volatile signed __int64 *)v24->_bf_0; i != v18; i = (volatile signed __int64 *)*i )
          v24 = (_EX_PUSH_LOCK *)i;
        v24->_bf_0 = *(__int64 *)v18;
        if( (_InterlockedExchangeAdd64(&v23->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
          ExfTryToWakePushLock(v23);
        KeAbPostRelease(v23);
        KeLeaveCriticalRegionThread(&CurrentThread->Tcb);
        ExFreePoolWithTag((PVOID)v18, 0x6353624Fu);
      }
    }
    else
    {
      while( 1 )
      {
        v21 = v19;
        v19 = _InterlockedCompareExchange64(v18 + 1, v20, v19);
        if( v21 == v19 )
          break;
        v20 = v19 - v17;
        if( v20 <= 0 )
          goto LABEL_16;
      }
    }
    return 0;
  }
}

Referenced by:

No references.