RtlEnumerateGenericTableLikeADirectory

_RTL_BALANCED_LINKS *__stdcall RtlEnumerateGenericTableLikeADirectory(
        _RTL_AVL_TABLE *Table,
        INT64 *MatchFunction,
        _RTL_AVL_TABLE *a3,
        VOID *a4,
        VOID *RestartKey,
        VOID *MatchData,
        UINT64 NextFlag,
        VOID **a8,
        UINT64 *DeleteCount,
        VOID *Buffer){
  bool v10; 
  int v11; 
  _QWORD *v12; 
  _RTL_BALANCED_LINKS *v15; 
  _DWORD *v16; 
  INT64 *v17; 
  unsigned int v18; 
  _RTL_BALANCED_LINKS *v19; 
  int v20; 
  _TABLE_SEARCH_RESULT NodeOrParent; 
  VOID *v23; 
  _RTL_SPLAY_LINKS **v24; 

  v10 = Table->NumberGenericTableElements == 0;
  v11 = (int)a4;
  v12 = RestartKey;
  v15 = *(_RTL_BALANCED_LINKS **)RestartKey;
  RestartKey = *(VOID **)RestartKey;
  if( v10 )
  {
    *v12 = 0i64;
    return 0i64;
  }
  v16 = MatchData;
  v17 = (INT64 *)HalSystemVectorDispatchEntry;
  v18 = Table->DeleteCount;
  v19 = v15;
  if( MatchFunction )
    v17 = MatchFunction;
  if( *(_DWORD *)MatchData != v18 )
  {
    v15 = 0i64;
    RestartKey = 0i64;
    v19 = 0i64;
  }
  if( v19 )
    goto LABEL_7;
  NodeOrParent = FindNodeOrParent(
                   (_RTL_GENERIC_TABLE *)Table,
                   (VOID *)NextFlag,
                   (_RTL_SPLAY_LINKS **)&RestartKey,
                   a4,
                   v23,
                   v24);
  if( NodeOrParent == TableFoundNode )
  {
    v15 = (_RTL_BALANCED_LINKS *)RestartKey;
    goto LABEL_7;
  }
  v11 = 0;
  if( NodeOrParent == TableInsertAsRight )
  {
    v15 = RealSuccessor((_RTL_BALANCED_LINKS *)RestartKey);
LABEL_7:
    if( v11 )
      v15 = RealSuccessor(v15);
    goto LABEL_9;
  }
  v15 = (_RTL_BALANCED_LINKS *)RestartKey;
LABEL_9:
  if( v15 )
  {
    while( 1 )
    {
      v20 = ((__int64(__fastcall *)(_RTL_AVL_TABLE *, _RTL_BALANCED_LINKS *, _RTL_AVL_TABLE *))v17)(Table, &v15[1], a3);
      if( v20 != -1073741198 )
        break;
      v15 = RealSuccessor(v15);
      if( !v15 )
        return 0i64;
    }
    *v12 = v15;
    *v16 = Table->DeleteCount;
    if( !v20 )
      return v15 + 1;
  }
  return 0i64;
}

Referenced by:

PiDmEnumObjectsWithCallback