]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiHiiLib/HiiLib.c
Change the behavior of the HII Library function HiiGetHiiHandles() when the PackageLi...
[mirror_edk2.git] / MdeModulePkg / Library / UefiHiiLib / HiiLib.c
index f87ab8233c9343d5c21a90de34e8a5276de2e8f3..2a42cd799e1e8aa3e1a5e0d51bdd548077392f01 100644 (file)
@@ -272,18 +272,19 @@ HiiRemovePackages (
 \r
 \r
 /**\r
-  Retrieves the array of all the HII Handles or the HII handle of a specific\r
-  package list in the HII Database.\r
+  Retrieves the array of all the HII Handles or the HII handles of a specific\r
+  package list GUID in the HII Database.\r
   This array is terminated with a NULL HII Handle.\r
   This function allocates the returned array using AllocatePool().\r
   The caller is responsible for freeing the array with FreePool().\r
 \r
   @param[in]  PackageListGuid  An optional parameter that is used to request \r
-                               an HII Handle that is associatd with a specific\r
-                               Package List GUID.  If this parameter is NULL\r
+                               HII Handles associated with a specific\r
+                               Package List GUID.  If this parameter is NULL,\r
                                then all the HII Handles in the HII Database\r
-                               are returned.  If this parameter is not NULL\r
-                               then at most 1 HII Handle is returned.\r
+                               are returned.  If this parameter is not NULL,\r
+                               then zero or more HII Handles associated with \r
+                               PackageListGuid are returned.\r
 \r
   @retval NULL   No HII handles were found in the HII database\r
   @retval NULL   The array of HII Handles could not be retrieved\r
@@ -301,7 +302,8 @@ HiiGetHiiHandles (
   EFI_HII_HANDLE  TempHiiHandleBuffer;\r
   EFI_HII_HANDLE  *HiiHandleBuffer;\r
   EFI_GUID        Guid;\r
-  UINTN           Index;\r
+  UINTN           Index1;\r
+  UINTN           Index2;\r
 \r
   //\r
   // Retrieve the size required for the buffer of all HII handles.\r
@@ -364,17 +366,20 @@ HiiGetHiiHandles (
     //\r
     return HiiHandleBuffer;\r
   } else {\r
-    for (Index = 0; HiiHandleBuffer[Index] != NULL; Index++) {\r
-      Status = InternalHiiExtractGuidFromHiiHandle (HiiHandleBuffer[Index], &Guid);\r
+    for (Index1 = 0, Index2 = 0; HiiHandleBuffer[Index1] != NULL; Index1++) {\r
+      Status = InternalHiiExtractGuidFromHiiHandle (HiiHandleBuffer[Index1], &Guid);\r
       ASSERT_EFI_ERROR (Status);\r
       if (CompareGuid (&Guid, PackageListGuid)) {\r
-        HiiHandleBuffer[0] = HiiHandleBuffer[Index];\r
-        HiiHandleBuffer[1] = NULL;\r
-        return HiiHandleBuffer;\r
+        HiiHandleBuffer[Index2++] = HiiHandleBuffer[Index1];       \r
       }\r
     }\r
-    FreePool (HiiHandleBuffer);\r
-    return NULL;\r
+    if (Index2 > 0) {\r
+      HiiHandleBuffer[Index2] = NULL;\r
+      return HiiHandleBuffer;\r
+    } else {\r
+      FreePool (HiiHandleBuffer);\r
+      return NULL;\r
+    }\r
   }\r
 }\r
 \r