RtlpMuiRegGetOrAddStringToPool

NTSTATUS __stdcall RtlpMuiRegGetOrAddStringToPool(
        _MUISTRINGPOOL *Pool,
        WCHAR *NewString,
        UINT8 CreateIfMissing,
        INT64 *PoolSpaceNeededRtrn){
  NTSTATUS StringIndexInPool; 
  __int64 v9; 
  NTSTATUS v10; 
  __int64 v11; 
  ULONGLONG v12; 
  __int16 v13; 
  __int64 v14; 
  size_t v15; 
  __int64 v16; 
  UINT64 pullResult; 

  pullResult = 0i64;
  StringIndexInPool = RtlpMuiRegGetStringIndexInPool(Pool, NewString);
  LODWORD(v9) = StringIndexInPool;
  if( PoolSpaceNeededRtrn )
    *(_DWORD *)PoolSpaceNeededRtrn = 0;
  if( StringIndexInPool >= 0 )
    return v9;
  v10 = -1;
  if( Pool && NewString )
  {
    v11 = -1i64;
    do
      ++v11;
    while( NewString[v11] );
    v12 = v11 + 1;
    if( v12 + *((unsigned __int16 *)Pool + 5) > *((unsigned __int16 *)Pool + 4) )
    {
      if( PoolSpaceNeededRtrn )
        *(_DWORD *)PoolSpaceNeededRtrn = v12;
    }
    else if( CreateIfMissing
           && *((_WORD *)Pool + 3) < *((_WORD *)Pool + 2)
           && RtlULongLongMult(v12, 2ui64, &pullResult) >= 0 )
    {
      v14 = *((__int16 *)Pool + 5);
      v9 = *((unsigned __int16 *)Pool + 3);
      v15 = pullResult;
      *((_WORD *)Pool + 3) = v13 + v9;
      *((_WORD *)Pool + 5) = v13 + v14;
      memmove((VOID *)(*((_QWORD *)Pool + 3) + 2 * v14), NewString, v15);
      v16 = *((_QWORD *)Pool + 2);
      *((_WORD *)Pool + 5) += v12;
      *(_WORD *)(v16 + 2 * v9) = v14;
      return v9;
    }
  }
  return v10;
}

Referenced by:

RtlpMuiRegGetOrAddString