RtlpLookupOrCreateLowBox

_RTL_ATOM_TABLE_REFERENCE *__stdcall RtlpLookupOrCreateLowBox(
        _RTL_ATOM_TABLE *AtomTable,
        _RTL_ATOM_TABLE_ENTRY *AtomEntry,
        UINT8 Lookup){
  unsigned int LowBoxId; 
  _RTL_ATOM_TABLE_REFERENCE **p_Reference; 
  _RTL_ATOM_TABLE_REFERENCE *result; 
  unsigned __int16 Flags; 
  unsigned __int16 ReferenceCount; 
  _RTL_ATOM_TABLE_REFERENCE *v10; 
  unsigned __int16 v11; 

  if( (AtomTable->Flags & 1) != 0 )
    LowBoxId = 0;
  else
    LowBoxId = RtlpQueryLowBoxId();
  p_Reference = (_RTL_ATOM_TABLE_REFERENCE **)&AtomEntry->Reference;
  if( !LowBoxId )
    return &AtomEntry->Reference;
  for( result = *p_Reference;
        result != (_RTL_ATOM_TABLE_REFERENCE *)p_Reference;
        result = (_RTL_ATOM_TABLE_REFERENCE *)result->LowBoxList.Flink )
  {
    if( result->LowBoxID == LowBoxId )
    {
      if( Lookup )
      {
        Flags = result->Flags;
        if( (Flags & 4) == 0 )
        {
          ReferenceCount = result->ReferenceCount;
          if( ReferenceCount == 0xFFFF )
            Flags |= 1u;
          else
            result->ReferenceCount = ReferenceCount + 1;
          result->Flags = Flags | 4;
        }
      }
      return result;
    }
  }
  result = (_RTL_ATOM_TABLE_REFERENCE *)RtlpAllocateAtom(0x18ui64, 0x4C6D7441ui64);
  if( result )
  {
    v10 = *p_Reference;
    if( (_RTL_ATOM_TABLE_REFERENCE **)(*p_Reference)->LowBoxList.Blink != p_Reference )
      __fastfail(3u);
    result->LowBoxList.Flink = &v10->LowBoxList;
    result->LowBoxList.Blink = (_LIST_ENTRY *)p_Reference;
    v10->LowBoxList.Blink = &result->LowBoxList;
    *p_Reference = result;
    *(_DWORD *)&result->ReferenceCount = 0;
    result->LowBoxID = LowBoxId;
    if( Lookup )
    {
      *(_DWORD *)&result->ReferenceCount = 262145;
      v11 = AtomEntry->Reference.ReferenceCount;
      if( v11 == 0xFFFF )
        AtomEntry->Reference.Flags |= 1u;
      else
        AtomEntry->Reference.ReferenceCount = v11 + 1;
    }
  }
  return result;
}

Referenced by:

RtlpHashStringToAtom