RtlEnumerateGenericTableLikeADirectory

PVOID __stdcall RtlEnumerateGenericTableLikeADirectory(
        PRTL_AVL_TABLE Table,
        PRTL_AVL_MATCH_FUNCTION MatchFunction,
        PVOID MatchData,
        UINT32 NextFlag,
        PVOID *RestartKey,
        PULONG DeleteCount,
        PVOID Buffer){
  bool v7; 
  UINT32 v8; 
  PVOID *v9; 
  RTL_BALANCED_LINKS *v12; 
  PULONG v13; 
  __int64(__fastcall *v14)(PRTL_AVL_TABLE, RTL_BALANCED_LINKS *, PVOID); 
  unsigned int v15; 
  RTL_BALANCED_LINKS *v16; 
  int v17; 
  TABLE_SEARCH_RESULT NodeOrParent; 
  void *v20; 
  RTL_SPLAY_LINKS **v21; 
  v7 = Table->NumberGenericTableElements == 0;
  v8 = NextFlag;
  v9 = RestartKey;
  v12 = (RTL_BALANCED_LINKS *)*RestartKey;
  RestartKey = (PVOID *)*RestartKey;
  if( v7 )
  {
    *v9 = 0i64;
    return 0i64;
  }
  v13 = DeleteCount;
  v14 = (__int64(__fastcall *)(PRTL_AVL_TABLE, RTL_BALANCED_LINKS *, PVOID))HalSystemVectorDispatchEntry;
  v15 = Table->DeleteCount;
  v16 = v12;
  if( MatchFunction )
    v14 = (__int64(__fastcall *)(PRTL_AVL_TABLE, RTL_BALANCED_LINKS *, PVOID))MatchFunction;
  if( *DeleteCount != v15 )
  {
    v12 = 0i64;
    RestartKey = 0i64;
    v16 = 0i64;
  }
  if( v16 )
    goto LABEL_7;
  NodeOrParent = FindNodeOrParent(
                   Table,
                   Buffer,
                   (RTL_BALANCED_LINKS **)&RestartKey,
                   *(RTL_GENERIC_TABLE **)&NextFlag,
                   v20,
                   v21);
  if( NodeOrParent == TableFoundNode )
  {
    v12 = (RTL_BALANCED_LINKS *)RestartKey;
    goto LABEL_7;
  }
  v8 = 0;
  if( NodeOrParent == TableInsertAsRight )
  {
    v12 = RealSuccessor((RTL_BALANCED_LINKS *)RestartKey);
LABEL_7:
    if( v8 )
      v12 = RealSuccessor(v12);
    goto LABEL_9;
  }
  v12 = (RTL_BALANCED_LINKS *)RestartKey;
LABEL_9:
  if( v12 )
  {
    while( 1 )
    {
      v17 = v14(Table, v12 + 1, MatchData);
      if( v17 != -1073741198 )
        break;
      v12 = RealSuccessor(v12);
      if( !v12 )
        return 0i64;
    }
    *v9 = v12;
    *v13 = Table->DeleteCount;
    if( !v17 )
      return &v12[1];
  }
  return 0i64;
}

Referenced by:

PiDmEnumObjectsWithCallback