RtlQueryAtomInAtomTable

NTSTATUS __stdcall RtlQueryAtomInAtomTable(
        VOID *AtomTableHandle,
        UINT64 Atom,
        UINT64 *AtomUsage,
        UINT64 *AtomFlags,
        WCHAR *AtomName,
        UINT64 *AtomNameLength){
  int v8; 
  _RTL_ATOM_TABLE_ENTRY *v10; 
  _RTL_ATOM_TABLE_ENTRY *v11; 
  size_t v12; 
  unsigned int v13; 
  size_t v14; 
  unsigned int v15; 
  NTSTATUS v17; 
  wchar_t DstBuf[16]; 

  v8 = (unsigned __int16)Atom;
  if( !RtlpLockAtomTable((_RTL_ATOM_TABLE *)AtomTableHandle) )
    return -1073741811;
  if( (unsigned __int16)v8 >= 0xC000u )
  {
    v17 = -1073741816;
    v10 = RtlpAtomMapAtomToHandleEntry((_RTL_ATOM_TABLE *)AtomTableHandle, v8 & 0x3FFF);
    v11 = v10;
    if( !v10 || v10->Atom != (_WORD)v8 || !RtlpLookupLowBox((_RTL_ATOM_TABLE *)AtomTableHandle, v10, 0) )
      goto LABEL_32;
    v17 = 0;
    if( AtomUsage )
      *(_DWORD *)AtomUsage = v11->Reference.ReferenceCount;
    if( AtomFlags )
      *(_DWORD *)AtomFlags = v11->Reference.Flags;
    if( !AtomName )
      goto LABEL_32;
    v12 = 2 * v11->NameLength;
    v13 = *(_DWORD *)AtomNameLength;
    if( v12 >= *(_DWORD *)AtomNameLength )
    {
      if( v13 < 2 )
      {
        *(_DWORD *)AtomNameLength = v12;
LABEL_31:
        v17 = -1073741789;
        goto LABEL_32;
      }
      v12 = v13 - 2;
    }
    if( v12 )
    {
      memmove(AtomName, v11->Name, v12);
      AtomName[(unsigned __int64)v12 >> 1] = 0;
      *(_DWORD *)AtomNameLength = v12;
      goto LABEL_32;
    }
    goto LABEL_31;
  }
  if( !(_WORD)v8 )
  {
    v17 = -1073741811;
    goto LABEL_32;
  }
  v17 = 0;
  if( AtomUsage )
    *(_DWORD *)AtomUsage = 1;
  if( AtomFlags )
    *(_DWORD *)AtomFlags = 1;
  if( !AtomName )
    goto LABEL_32;
  v15 = *(_DWORD *)AtomNameLength;
  if( v14 >= *(_DWORD *)AtomNameLength )
  {
    if( v15 < 2 )
      goto LABEL_29;
    v14 = v15 - 2;
  }
  if( !v14 )
  {
LABEL_29:
    v17 = -1073741789;
    goto LABEL_32;
  }
  memmove(AtomName, DstBuf, v14);
  AtomName[(unsigned __int64)v14 >> 1] = 0;
  *(_DWORD *)AtomNameLength = v14;
LABEL_32:
  if( (_InterlockedExchangeAdd64((volatile signed __int64 *)AtomTableHandle + 1, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock((_EX_PUSH_LOCK *)AtomTableHandle + 1);
  KeAbPostRelease((char *)AtomTableHandle + 8);
  KeLeaveCriticalRegion();
  return v17;
}

Referenced by:

NtQueryInformationAtom