ViInitializeLocalSystemDescriptor

PVOID __stdcall ViInitializeLocalSystemDescriptor(){
  void *PoolWithTag; 
  void *v1; 
  UINT32 v2; 
  struct _ACL *v3; 
  ACL *v4; 
  NTSTATUS Acl; 
  if( !ViLocalSystemDescriptor )
  {
    if( SeLocalSystemSid )
    {
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x28ui64, 0x55667256ui64);
      v1 = PoolWithTag;
      if( PoolWithTag )
      {
        if( RtlCreateSecurityDescriptor(PoolWithTag, 1ui64) < 0 )
          goto LABEL_13;
        v2 = RtlLengthSid(SeLocalSystemSid) + 20;
        v3 = (struct _ACL *)ExAllocatePoolWithTag(PagedPool, v2, 0x55667256ui64);
        v4 = v3;
        if( !v3 )
          goto LABEL_13;
        Acl = RtlCreateAcl(v3, v2, 2u);
        if( Acl < 0 )
          goto LABEL_17;
        Acl = RtlAddAccessAllowedAce(v4, 2u, 1u, SeLocalSystemSid);
        if( Acl < 0 )
          goto LABEL_17;
        Acl = RtlSetDaclSecurityDescriptor(v1, 1u, v4, 0);
        if( Acl < 0 )
          goto LABEL_17;
        if( _InterlockedCompareExchange64(
               (volatile signed __int64 *)&ViLocalSystemDescriptor,
               (signed __int64)v1,
               0i64) )
        {
          Acl = -1073741595;
        }
        if( Acl < 0 )
        {
LABEL_17:
          ExFreePoolWithTag(v4, 0x55667256u);
          if( Acl < 0 )
LABEL_13:
            ExFreePoolWithTag(v1, 0x55667256u);
        }
      }
    }
  }
  return ViLocalSystemDescriptor;
}

Referenced by:

VfUtilIsLocalSystem