Fix bad object allocation, remove some REFIT_MENU_SCREEN ctors.

This commit is contained in:
jief 2020-03-04 18:27:41 +03:00
parent 2fca0d97a5
commit 6417348844
7 changed files with 123 additions and 104 deletions

View File

@ -5035,7 +5035,7 @@ GetUserSettings(
DEV_PROPERTY **Child;
if (Count > 0) {
DBG("Add %d devices:\n", Count);
DBG("Add %d devices (kTagTypeDict):\n", Count);
for (i = 0; i < Count; i++) {
Prop2 = NULL;
@ -5155,7 +5155,7 @@ GetUserSettings(
DEV_PROPERTY *DevProp;
if (Count > 0) {
DBG ("Add %d devices:\n", Count);
DBG ("Add %d devices (Arbitrary):\n", Count);
for (Index = 0; Index < Count; Index++) {
UINTN DeviceAddr = 0U;
CHAR8 *Label;

View File

@ -149,8 +149,8 @@ LOADER_ENTRY * DuplicateLoaderEntry(IN LOADER_ENTRY *Entry)
return NULL;
}
DuplicateEntry = (__typeof__(DuplicateEntry))AllocateZeroPool(sizeof(LOADER_ENTRY));
// DuplicateEntry = new LOADER_ENTRY();
// DuplicateEntry = (__typeof__(DuplicateEntry))AllocateZeroPool(sizeof(LOADER_ENTRY));
DuplicateEntry = new LOADER_ENTRY();
if (DuplicateEntry) {
// DuplicateEntry->Tag = Entry->Tag;
DuplicateEntry->AtClick = ActionEnter;
@ -353,9 +353,7 @@ STATIC void CreateInfoLines(IN CONST CHAR16 *Message, OUT XStringWArray* Informa
extern REFIT_MENU_ITEM_RETURN MenuEntryReturn;
//STATIC REFIT_MENU_ENTRY *AlertMessageEntries[] = { &MenuEntryReturn };
STATIC REFIT_MENU_SCREEN AlertMessageMenu = {0, NULL, NULL, &MenuEntryReturn,
0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
{ 0, 0, 0, 0 } , NULL };
STATIC REFIT_MENU_SCREEN AlertMessageMenu(0, NULL, NULL, &MenuEntryReturn, NULL);
// Display an alert message
VOID AlertMessage(IN CONST CHAR16 *Title, IN CONST CHAR16 *Message)
@ -388,9 +386,7 @@ VOID AlertMessage(IN CONST CHAR16 *Title, IN CONST CHAR16 *Message)
STATIC REFIT_SIMPLE_MENU_ENTRY_TAG YesMessageEntry = { L"Yes", TAG_YES, ActionEnter };
STATIC REFIT_SIMPLE_MENU_ENTRY_TAG NoMessageEntry = { L"No", TAG_NO, ActionEnter };
//STATIC REFIT_MENU_ENTRY *YesNoMessageEntries[] = { &YesMessageEntry, &NoMessageEntry };
STATIC REFIT_MENU_SCREEN YesNoMessageMenu = {0, NULL, NULL, &YesMessageEntry, &NoMessageEntry,
0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
{ 0, 0, 0, 0 } , NULL };
STATIC REFIT_MENU_SCREEN YesNoMessageMenu(0, NULL, NULL, &YesMessageEntry, &NoMessageEntry);
// Display a yes/no prompt
BOOLEAN YesNoMessage(IN CHAR16 *Title, IN CONST CHAR16 *Message)
@ -438,9 +434,10 @@ BOOLEAN AskUserForFilePathFromDir(IN CHAR16 *Title OPTIONAL, IN REFIT_VOLUME *Vo
#define TAG_OFFSET 1000
STATIC REFIT_MENU_SCREEN InitialMenu = {0, L"Please Select File...", NULL, 0, NULL,
0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
{ 0, 0, 0, 0 }, NULL};
//STATIC REFIT_MENU_SCREEN InitialMenu = {0, L"Please Select File...", NULL, 0, NULL,
// 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
// { 0, 0, 0, 0 }, NULL};
STATIC REFIT_MENU_SCREEN InitialMenu(0, L"Please Select File...", NULL);
// Ask user for file path from volumes menu
BOOLEAN AskUserForFilePathFromVolumes(IN CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **Result)

View File

@ -118,8 +118,8 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
VolDesc = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : L"HD";
//DBG("VolDesc=%s\n", VolDesc);
// prepare the menu entry
Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LEGACY_ENTRY));
// Entry = new LEGACY_ENTRY();
// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LEGACY_ENTRY));
Entry = new LEGACY_ENTRY();
if (FullTitle) {
Entry->Title = EfiStrDuplicate(FullTitle);
} else {
@ -164,8 +164,8 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
SubScreen->TitleImage = Entry->Image;
SubScreen->AnimeRun = SubScreen->GetAnime();
// default entry
SubEntry = (__typeof__(SubEntry))AllocateZeroPool(sizeof(LEGACY_ENTRY));
// SubEntry = new LEGACY_ENTRY();
// SubEntry = (__typeof__(SubEntry))AllocateZeroPool(sizeof(LEGACY_ENTRY));
SubEntry = new LEGACY_ENTRY();
SubEntry->Title = PoolPrint(L"Boot %s", LoaderTitle);
// SubEntry->Tag = TAG_LEGACY;
SubEntry->Volume = Entry->Volume;

View File

@ -556,8 +556,8 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
}
// prepare the menu entry
Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY));
// Entry = new LOADER_ENTRY();
// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY));
Entry = new LOADER_ENTRY();
// Entry->Tag = TAG_LOADER;
Entry->Row = 0;
Entry->Volume = Volume;

View File

@ -83,8 +83,8 @@ STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTi
return FALSE;
}
// Allocate the entry
Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(*Entry));
// Entry = new REFIT_MENU_ENTRY_LOADER_TOOL();
// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(*Entry));
Entry = new REFIT_MENU_ENTRY_LOADER_TOOL();
if (Entry == NULL) {
return FALSE;
}

View File

@ -407,88 +407,106 @@ public:
TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
Film(0), mAction(ActionNone), mItemID(0), mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
REFIT_MENU_SCREEN( UINTN ID_,
CONST CHAR16 *Title_,
EG_IMAGE *TitleImage_,
// INTN InfoLineCount_,
// CONST CHAR16 **InfoLines_,
INTN TimeoutSeconds_,
CONST CHAR16 *TimeoutText_,
CONST CHAR16 *Theme_,
BOOLEAN AnimeRun_,
BOOLEAN Once_,
UINT64 LastDraw_,
INTN CurrentFrame_,
INTN Frames_,
UINTN FrameTime_,
EG_RECT FilmPlace_,
EG_IMAGE **Film_)
: ID(ID_), Title(Title_), TitleImage(TitleImage_),
/*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
Film(Film_)
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText)
: ID(ID), Title(Title), TitleImage(0),
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0), mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
REFIT_MENU_SCREEN( UINTN ID_,
CONST CHAR16 *Title_,
EG_IMAGE *TitleImage_,
// INTN InfoLineCount_,
// CONST CHAR16 **InfoLines_,
REFIT_ABSTRACT_MENU_ENTRY* entry,
INTN TimeoutSeconds_,
CONST CHAR16 *TimeoutText_,
CONST CHAR16 *Theme_,
BOOLEAN AnimeRun_,
BOOLEAN Once_,
UINT64 LastDraw_,
INTN CurrentFrame_,
INTN Frames_,
UINTN FrameTime_,
EG_RECT FilmPlace_,
EG_IMAGE **Film_)
: ID(ID_), Title(Title_), TitleImage(TitleImage_),
/*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
Film(Film_)
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
: ID(ID), Title(Title), TitleImage(0),
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0), mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{
Entries.AddReference(entry, false);
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);
};
REFIT_MENU_SCREEN( UINTN ID_,
CONST CHAR16 *Title_,
EG_IMAGE *TitleImage_,
// INTN InfoLineCount_,
// CONST CHAR16 **InfoLines_,
REFIT_ABSTRACT_MENU_ENTRY* entry1,
REFIT_ABSTRACT_MENU_ENTRY* entry2,
INTN TimeoutSeconds_,
CONST CHAR16 *TimeoutText_,
CONST CHAR16 *Theme_,
BOOLEAN AnimeRun_,
BOOLEAN Once_,
UINT64 LastDraw_,
INTN CurrentFrame_,
INTN Frames_,
UINTN FrameTime_,
EG_RECT FilmPlace_,
EG_IMAGE **Film_)
: ID(ID_), Title(Title_), TitleImage(TitleImage_),
/*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
Film(Film_)
{
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);
};
// REFIT_MENU_SCREEN( UINTN ID_,
// CONST CHAR16 *Title_,
// EG_IMAGE *TitleImage_,
//// INTN InfoLineCount_,
//// CONST CHAR16 **InfoLines_,
// INTN TimeoutSeconds_,
// CONST CHAR16 *TimeoutText_,
// CONST CHAR16 *Theme_,
// BOOLEAN AnimeRun_,
// BOOLEAN Once_,
// UINT64 LastDraw_,
// INTN CurrentFrame_,
// INTN Frames_,
// UINTN FrameTime_,
// EG_RECT FilmPlace_,
// EG_IMAGE **Film_)
// : ID(ID_), Title(Title_), TitleImage(TitleImage_),
// /*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
// TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
// Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
// Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
// Film(Film_), mAction(ActionNone), mItemID(0), mPointer(NULL)
// {};
//
// REFIT_MENU_SCREEN( UINTN ID_,
// CONST CHAR16 *Title_,
// EG_IMAGE *TitleImage_,
//// INTN InfoLineCount_,
//// CONST CHAR16 **InfoLines_,
// REFIT_ABSTRACT_MENU_ENTRY* entry,
// INTN TimeoutSeconds_,
// CONST CHAR16 *TimeoutText_,
// CONST CHAR16 *Theme_,
// BOOLEAN AnimeRun_,
// BOOLEAN Once_,
// UINT64 LastDraw_,
// INTN CurrentFrame_,
// INTN Frames_,
// UINTN FrameTime_,
// EG_RECT FilmPlace_,
// EG_IMAGE **Film_)
// : ID(ID_), Title(Title_), TitleImage(TitleImage_),
// /*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
// TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
// Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
// Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
// Film(Film_), mAction(ActionNone), mItemID(0), mPointer(NULL)
// {
// Entries.AddReference(entry, false);
// };
// REFIT_MENU_SCREEN( UINTN ID_,
// CONST CHAR16 *Title_,
// EG_IMAGE *TitleImage_,
//// INTN InfoLineCount_,
//// CONST CHAR16 **InfoLines_,
// REFIT_ABSTRACT_MENU_ENTRY* entry1,
// REFIT_ABSTRACT_MENU_ENTRY* entry2,
// INTN TimeoutSeconds_,
// CONST CHAR16 *TimeoutText_,
// CONST CHAR16 *Theme_,
// BOOLEAN AnimeRun_,
// BOOLEAN Once_,
// UINT64 LastDraw_,
// INTN CurrentFrame_,
// INTN Frames_,
// UINTN FrameTime_,
// EG_RECT FilmPlace_,
// EG_IMAGE **Film_)
// : ID(ID_), Title(Title_), TitleImage(TitleImage_),
// /*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
// TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
// Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
// Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
// Film(Film_), mAction(ActionNone), mItemID(0), mPointer(NULL)
// {
// Entries.AddReference(entry1, false);
// Entries.AddReference(entry2, false);
// };
//Scroll functions
VOID InitScroll(IN INTN ItemCount, IN UINTN MaxCount,
IN UINTN VisibleSpace, IN INTN Selected);

View File

@ -68,7 +68,8 @@ CONST CHAR16 *VBIOS_BIN = L"EFI\\CLOVER\\misc\\c0000.bin";
// scrolling definitions
static INTN MaxItemOnScreen = -1;
REFIT_MENU_SCREEN OptionMenu(4, L"Options", NULL, /*InfoLineCount*/0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL );
//REFIT_MENU_SCREEN OptionMenu(4, L"Options", NULL, /*InfoLineCount*/0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL );
REFIT_MENU_SCREEN OptionMenu(4, L"Options", NULL);
extern REFIT_MENU_ITEM_RETURN MenuEntryReturn;
extern UINTN ThemesNum;
extern CHAR16 *ThemesList[];
@ -225,9 +226,12 @@ REFIT_MENU_ITEM_RETURN MenuEntryReturn (L"Return", 0, 0, 0, ActionEnter);
REFIT_MENU_SCREEN MainMenu = {1, L"Main Menu", NULL, 0, NULL, 0, L"Automatic boot", NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL};
REFIT_MENU_SCREEN AboutMenu = {2, L"About", NULL, 0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL};
REFIT_MENU_SCREEN HelpMenu = {3, L"Help", NULL, 0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL};
//REFIT_MENU_SCREEN MainMenu = {1, L"Main Menu", NULL, 0, NULL, 0, L"Automatic boot", NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL};
//REFIT_MENU_SCREEN AboutMenu = {2, L"About", NULL, 0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL};
//REFIT_MENU_SCREEN HelpMenu = {3, L"Help", NULL, 0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL};
REFIT_MENU_SCREEN MainMenu(1, L"Main Menu", L"Automatic boot");
REFIT_MENU_SCREEN AboutMenu(2, L"About", NULL);
REFIT_MENU_SCREEN HelpMenu(3, L"Help", NULL);
CONST CHAR16* ArgOptional[NUM_OPT] = {
L"arch=i386", //0
@ -2160,7 +2164,7 @@ VOID REFIT_MENU_SCREEN::UpdateScroll(IN UINTN Movement)
VOID REFIT_MENU_SCREEN::HidePointer()
{
mPointer->Hide();
if ( mPointer ) mPointer->Hide();
}
EFI_STATUS REFIT_MENU_SCREEN::MouseBirth()
@ -4371,8 +4375,8 @@ VOID NewEntry(REFIT_MENU_ENTRY_OTHER **Entry, REFIT_MENU_SCREEN **SubScreen, ACT
VOID NewEntry(LOADER_ENTRY **Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title)
{
//create entry
*Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); // carefull, **Entry is not a LOADER_ENTRY. Don't use sizeof.
// *Entry = new LOADER_ENTRY();
// *Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); // carefull, **Entry is not a LOADER_ENTRY. Don't use sizeof.
*Entry = new LOADER_ENTRY();
NewEntry_(*Entry, SubScreen, AtClick, ID, Title); // cast ok because super class
}