RtlpGetPolicyValueForSystemCapability

NTSTATUS __stdcall RtlpGetPolicyValueForSystemCapability(PCUNICODE_STRING Source, PUNICODE_STRING UnicodeString){
  VOID *PoolWithQuotaTag; 
  __int64 v5; 
  wchar_t *StringRoutine; 
  wchar_t *v7; 
  signed int appended; 
  unsigned int v9; 
  size_t v10; 
  wchar_t *v11; 
  wchar_t *v12; 
  __int64 v13; 
  wchar_t *v14; 
  unsigned __int16 v15; 
  _UNICODE_STRING Destination; 
  UINT64 NumberOfBytes; 
  UINT64 Type; 

  LODWORD(NumberOfBytes) = 0;
  LODWORD(Type) = 0;
  PoolWithQuotaTag = 0i64;
  Destination = 0i64;
  if( !Source || !UnicodeString )
  {
    appended = -1073741811;
    goto LABEL_21;
  }
  v5 = (unsigned __int16)(Source->Length + 56);
  StringRoutine = (wchar_t *)ExpAllocateStringRoutine((unsigned __int16)v5);
  v7 = StringRoutine;
  if( !StringRoutine )
  {
LABEL_4:
    appended = -1073741801;
    goto LABEL_22;
  }
  memset(StringRoutine, 0i64, (unsigned __int16)v5);
  Destination.MaximumLength = v5;
  Destination.Buffer = v7;
  appended = RtlAppendUnicodeStringToString(&Destination, (_UNICODE_STRING *)&stru_140009638 + 1);
  if( appended < 0 )
    goto LABEL_22;
  appended = RtlAppendUnicodeStringToString(&Destination, (_UNICODE_STRING *)Source);
  if( appended < 0 )
    goto LABEL_22;
  appended = ZwQueryLicenseValue(&Destination, &Type, 0i64, 0i64, &NumberOfBytes);
  if( appended != -1073741789 )
  {
LABEL_21:
    if( appended >= 0 )
      goto LABEL_26;
    goto LABEL_22;
  }
  v9 = NumberOfBytes;
  v10 = NumberOfBytes;
  PoolWithQuotaTag = ExAllocatePoolWithQuotaTag((POOL_TYPE)520, (unsigned int)NumberOfBytes, 0x62507452ui64);
  appended = ZwQueryLicenseValue(&Destination, &Type, PoolWithQuotaTag, v9, &NumberOfBytes);
  if( appended < 0 )
    goto LABEL_22;
  if( (_DWORD)Type != 1 || !v9 || (v9 & 1) != 0 )
  {
    appended = -1073741823;
    goto LABEL_22;
  }
  v11 = (wchar_t *)ExpAllocateStringRoutine(v9);
  v12 = v11;
  if( !v11 )
    goto LABEL_4;
  memmove(v11, PoolWithQuotaTag, v10);
  *UnicodeString = 0i64;
  v13 = 0x7FFFi64;
  v14 = v12;
  do
  {
    if( !*v14 )
      break;
    ++v14;
    --v13;
  }
  while( v13 );
  appended = v13 == 0 ? 0xC000000D : 0;
  if( !v13 )
  {
LABEL_22:
    if( UnicodeString )
      RtlFreeAnsiString(UnicodeString);
    goto LABEL_24;
  }
  v15 = 2 * (v13 != 0 ? 0x7FFF - v13 : 0);
  UnicodeString->Buffer = v12;
  UnicodeString->Length = v15;
  UnicodeString->MaximumLength = v15 + 2;
  appended = 0;
LABEL_24:
  if( PoolWithQuotaTag )
    ExFreePoolWithTag(PoolWithQuotaTag, 0);
LABEL_26:
  RtlFreeAnsiString(&Destination);
  return appended;
}

Referenced by:

RtlpCapabilityCheckSystemCapability