ObpAllocateAndQuerySecurityDescriptorInfo

NTSTATUS __stdcall ObpAllocateAndQuerySecurityDescriptorInfo(
        VOID *Object,
        UINT64 SecurityInformation,
        VOID **SecurityDescriptor){
  VOID ***v3; 
  VOID ***v4; 
  __int64 v6; 
  VOID **v7; 
  VOID **v8; 
  VOID **v9; 
  __int64(__fastcall *v10)(VOID *, __int64, UINT64 *, VOID **, UINT64 *, PSECURITY_DESCRIPTOR, _DWORD, __int64, int); 
  NTSTATUS v11; 
  VOID **PoolWithTag; 
  NTSTATUS v14; 
  VOID **v15; 
  int v16; 
  int v17; 
  __int64(__fastcall *v18)(VOID *, __int64, UINT64 *, VOID **, UINT64 *, PSECURITY_DESCRIPTOR, _DWORD, __int64, int); 
  UINT64 Length; 
  UINT64 SecurityInformationa; 
  PSECURITY_DESCRIPTOR ObjectsSecurityDescriptor; 

  ObjectsSecurityDescriptor = SecurityDescriptor;
  LODWORD(SecurityInformationa) = SecurityInformation;
  LODWORD(Length) = 0;
  v4 = v3;
  v6 = ObTypeIndexTable[(unsigned __int8)ObHeaderCookie ^ (unsigned __int8)*((char *)Object - 24) ^ (unsigned __int64)(unsigned __int8)((unsigned __int16)((_WORD)Object - 48) >> 8)];
  if( SecurityDescriptor )
  {
    SeQuerySecurityDescriptorInfo(&SecurityInformationa, 0i64, &Length, &ObjectsSecurityDescriptor);
    PoolWithTag = ExAllocatePoolWithTag(1ui64, (unsigned int)Length, 1901290063i64);
    v8 = PoolWithTag;
    if( PoolWithTag )
    {
      v14 = SeQuerySecurityDescriptorInfo(&SecurityInformationa, PoolWithTag, &Length, &ObjectsSecurityDescriptor);
LABEL_11:
      v11 = v14;
      goto LABEL_4;
    }
    return -1073741670;
  }
  LODWORD(Length) = ObpDefaultSecurityDescriptorLength;
  v7 = ExAllocatePoolWithTag(1ui64, (unsigned int)ObpDefaultSecurityDescriptorLength, 1901290063i64);
  v8 = v7;
  if( !v7 )
    return -1073741670;
  v9 = v7;
  v16 = *(_DWORD *)(v6 + 100);
  v10 = *(__int64(__fastcall **)(VOID *, __int64, UINT64 *, VOID **, UINT64 *, PSECURITY_DESCRIPTOR, _DWORD, __int64, int))(v6 + 152);
  ObjectsSecurityDescriptor = (char *)Object - 8;
  v18 = v10;
  v11 = v10(Object, 1i64, &SecurityInformationa, v9, &Length, (char *)Object - 8, v16, v6 + 76, 0);
  if( v11 == -1073741789 )
  {
    ExFreePoolWithTag(v8, 0x7153624Fu);
    v15 = ExAllocatePoolWithTag(1ui64, (unsigned int)Length, 1901290063i64);
    v8 = v15;
    if( v15 )
    {
      LOBYTE(v17) = 0;
      v14 = v18(
              Object,
              1i64,
              &SecurityInformationa,
              v15,
              &Length,
              ObjectsSecurityDescriptor,
              *(_DWORD *)(v6 + 100),
              v6 + 76,
              v17);
      goto LABEL_11;
    }
    return -1073741670;
  }
LABEL_4:
  if( v11 < 0 )
    ExFreePoolWithTag(v8, 0x7153624Fu);
  else
    *v4 = v8;
  return v11;
}

Referenced by:

NtSetSecurityObject
ObpCreateHandle