+// Creates a copy of a menu screen.
+// Returns a pointer to the copy of the menu screen.
+static REFIT_MENU_SCREEN* CopyMenuScreen(REFIT_MENU_SCREEN *Entry) {
+ REFIT_MENU_SCREEN *NewEntry;
+ UINTN i;
+
+ NewEntry = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
+ if ((Entry != NULL) && (NewEntry != NULL)) {
+ CopyMem(NewEntry, Entry, sizeof(REFIT_MENU_SCREEN));
+ NewEntry->Title = StrDuplicate(Entry->Title);
+ NewEntry->TimeoutText = StrDuplicate(Entry->TimeoutText);
+ if (Entry->TitleImage != NULL) {
+ NewEntry->TitleImage = AllocatePool(sizeof(EG_IMAGE));
+ if (NewEntry->TitleImage != NULL)
+ CopyMem(NewEntry->TitleImage, Entry->TitleImage, sizeof(EG_IMAGE));
+ } // if
+ NewEntry->InfoLines = (CHAR16**) AllocateZeroPool(Entry->InfoLineCount * (sizeof(CHAR16*)));
+ for (i = 0; i < Entry->InfoLineCount && NewEntry->InfoLines; i++) {
+ NewEntry->InfoLines[i] = StrDuplicate(Entry->InfoLines[i]);
+ } // for
+ NewEntry->Entries = (REFIT_MENU_ENTRY**) AllocateZeroPool(Entry->EntryCount * (sizeof (REFIT_MENU_ENTRY*)));
+ for (i = 0; i < Entry->EntryCount && NewEntry->Entries; i++) {
+ AddMenuEntry(NewEntry, Entry->Entries[i]);
+ } // for
+ } // if
+ return (NewEntry);
+} // static REFIT_MENU_SCREEN* CopyMenuScreen()
+
+// Creates a copy of a menu entry. Intended to enable moving a stack-based
+// menu entry (such as the ones for the "reboot" and "exit" functions) to
+// to the heap. This enables easier deletion of the whole set of menu
+// entries when re-scanning.
+// Returns a pointer to the copy of the menu entry.
+static REFIT_MENU_ENTRY* CopyMenuEntry(REFIT_MENU_ENTRY *Entry) {
+ REFIT_MENU_ENTRY *NewEntry;
+
+ NewEntry = AllocateZeroPool(sizeof(REFIT_MENU_ENTRY));
+ if ((Entry != NULL) && (NewEntry != NULL)) {
+ CopyMem(NewEntry, Entry, sizeof(REFIT_MENU_ENTRY));
+ NewEntry->Title = StrDuplicate(Entry->Title);
+ if (Entry->BadgeImage != NULL) {
+ NewEntry->BadgeImage = AllocatePool(sizeof(EG_IMAGE));
+ if (NewEntry->BadgeImage != NULL)
+ CopyMem(NewEntry->BadgeImage, Entry->BadgeImage, sizeof(EG_IMAGE));
+ }
+ if (Entry->Image != NULL) {
+ NewEntry->Image = AllocatePool(sizeof(EG_IMAGE));
+ if (NewEntry->Image != NULL)
+ CopyMem(NewEntry->Image, Entry->Image, sizeof(EG_IMAGE));
+ }
+ if (Entry->SubScreen != NULL) {
+ NewEntry->SubScreen = CopyMenuScreen(Entry->SubScreen);
+// NewEntry->SubScreen = AllocatePool(sizeof(REFIT_MENU_SCREEN));
+// if (NewEntry->SubScreen != NULL)
+// CopyMem(NewEntry->SubScreen, Entry->SubScreen, sizeof(REFIT_MENU_SCREEN));
+ }
+ } // if
+ return (NewEntry);
+} // REFIT_MENU_ENTRY* CopyMenuEntry()
+