CmpWaitForHiveMount

UINT8 __stdcall CmpWaitForHiveMount(_UNICODE_STRING *Path, UINT64 *IndexToWaitOn){
  _DWORD *v2; 
  _UNICODE_STRING v3; 
  UINT8 v4; 
  _DWORD *v5; 
  unsigned __int16 v6; 
  wchar_t *Buffer; 
  unsigned __int16 v8; 
  unsigned int v9; 
  int v10; 
  unsigned __int16 v11; 
  __int64 v12; 
  __int64 v14; 
  __int64 v15; 
  bool v16; 
  _UNICODE_STRING Component[2]; 

  v3 = *Path;
  v4 = 0;
  v5 = v2;
  v6 = _mm_cvtsi128_si32(*(__m128i *)Path);
  Component[0] = v3;
  Component[0].Length = v6;
  if( !v6 )
    goto LABEL_18;
  Buffer = Component[0].Buffer;
  do
  {
    if( *Buffer != 92 )
      break;
    ++Buffer;
    v16 = v6 == 2;
    v6 -= 2;
    Component[0].Length = v6;
  }
  while( !v16 );
  Component[0].Buffer = Buffer;
  if( v6 )
  {
    v8 = 0;
    v9 = 1;
    do
    {
      if( Buffer[v8] == 92 )
        break;
      ++v8;
      v6 -= 2;
    }
    while( v6 );
    Component[0].Length = 2 * v8;
    v10 = CmpHashUnicodeComponent(Component);
    v11 = 0;
    while( 1 )
    {
      v12 = 3i64 * v11;
      if( *((_DWORD *)&stru_140C00F40 + 6 * v11 + 387) == v10 )
        break;
      if( ++v11 >= 8u )
      {
        _interlockedbittestandset((_DWORD *)&stru_140C00F40 + 388, 2u);
        return 0;
      }
    }
    _interlockedbittestandset((volatile signed __int32 *)&stru_140C00F40 + 6 * v11 + 388, 3u);
    _InterlockedAdd((volatile signed __int32 *)&stru_140C00F40 + 6 * v11 + 389, 1u);
    v14 = 3i64 * v11;
    KeSetEvent((PRKEVENT)((char *)&stru_140C00F40 + 200 * *((unsigned int *)&stru_140C00F40 + 6 * v11 + 386)), 0, 0);
    v15 = *((unsigned int *)&stru_140C00F40 + 2 * v14 + 386);
    if( !*((_DWORD *)&stru_140C00F40 + 50 * v15 + 13) )
    {
      v4 = 1;
      *v5 = v15;
      v9 = 5;
    }
    _interlockedbittestandset((volatile signed __int32 *)&stru_140C00F40 + 2 * v12 + 388, v9);
    return v4;
  }
  else
  {
LABEL_18:
    _interlockedbittestandset((_DWORD *)&stru_140C00F40 + 388, 0);
    return 0;
  }
}

Referenced by:

CmpDoParseKey
CmpPerformCompleteKcbCacheLookup