From 64155019df7deda5c588e22ec3a5f3708aede881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 11 Mar 2024 17:22:37 +0100 Subject: [PATCH] [FREELDR] Minor formatting for MsgBox functions + add SAL annotations --- boot/freeldr/freeldr/include/ui.h | 29 +++++++------- boot/freeldr/freeldr/include/ui/gui.h | 26 +++++++------ boot/freeldr/freeldr/include/ui/noui.h | 10 ++++- boot/freeldr/freeldr/include/ui/tui.h | 12 +++++- boot/freeldr/freeldr/ui/directui.c | 9 +++-- boot/freeldr/freeldr/ui/gui.c | 8 +++- boot/freeldr/freeldr/ui/noui.c | 26 ++++++------- boot/freeldr/freeldr/ui/tui.c | 8 +++- boot/freeldr/freeldr/ui/ui.c | 52 ++++++++++++++------------ 9 files changed, 108 insertions(+), 72 deletions(-) diff --git a/boot/freeldr/freeldr/include/ui.h b/boot/freeldr/freeldr/include/ui.h index 7a7e5cfc6e3..1b47cc89447 100644 --- a/boot/freeldr/freeldr/include/ui.h +++ b/boot/freeldr/freeldr/include/ui.h @@ -49,11 +49,7 @@ extern CHAR UiTimeText[260]; extern const PCSTR UiMonthNames[12]; -/////////////////////////////////////////////////////////////////////////////////////// -// -// User Interface Functions -// -/////////////////////////////////////////////////////////////////////////////////////// +/* User Interface Functions **************************************************/ BOOLEAN UiInitialize(BOOLEAN ShowUi); // Initialize User-Interface VOID UiUnInitialize(PCSTR BootText); // Un-initialize User-Interface @@ -91,10 +87,21 @@ UiDrawCenteredText( VOID UiDrawStatusText(PCSTR StatusText); // Draws text at the very bottom line on the screen VOID UiUpdateDateTime(VOID); // Updates the date and time -VOID UiInfoBox(PCSTR MessageText); // Displays a info box on the screen -VOID UiMessageBox(PCSTR Format, ...); // Displays a message box on the screen with an ok button -VOID UiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources +/* Displays an info box on the screen */ +VOID +UiInfoBox( + _In_ PCSTR MessageText); + +/* Displays a message box on the screen with an ok button */ +VOID +UiMessageBox( + _In_ PCSTR Format, ...); + +/* Displays a message box on the screen with an ok button using no system resources */ +VOID +UiMessageBoxCritical( + _In_ PCSTR MessageText); /* Loading Progress-Bar Functions ********************************************/ @@ -192,11 +199,7 @@ UCHAR UiTextToFillStyle(PCSTR FillStyleText); // Converts the VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in VOID UiFadeOut(VOID); // Fades the screen out -/////////////////////////////////////////////////////////////////////////////////////// -// -// Menu Functions -// -/////////////////////////////////////////////////////////////////////////////////////// +/* Menu Functions ************************************************************/ typedef struct tagUI_MENU_INFO { diff --git a/boot/freeldr/freeldr/include/ui/gui.h b/boot/freeldr/freeldr/include/ui/gui.h index a2ce9373ad3..044b6235382 100644 --- a/boot/freeldr/freeldr/include/ui/gui.h +++ b/boot/freeldr/freeldr/include/ui/gui.h @@ -21,11 +21,8 @@ #define TITLE_BOX_CHAR_HEIGHT 5 -/////////////////////////////////////////////////////////////////////////////////////// -// -// Graphical User Interface Functions -// -/////////////////////////////////////////////////////////////////////////////////////// +/* Graphical User Interface Functions ****************************************/ + VOID GuiDrawBackdrop(VOID); // Fills the entire screen with a backdrop VOID GuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr VOID GuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified @@ -36,18 +33,23 @@ VOID GuiDrawStatusText(PCSTR StatusText); // Draws text at VOID GuiUpdateDateTime(VOID); // Updates the date and time VOID GuiSaveScreen(PUCHAR Buffer); // Saves the screen so that it can be restored later VOID GuiRestoreScreen(PUCHAR Buffer); // Restores the screen from a previous save -VOID GuiMessageBox(PCSTR MessageText); // Displays a message box on the screen with an ok button -VOID GuiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources + +/* Displays a message box on the screen with an ok button */ +VOID +GuiMessageBox( + _In_ PCSTR MessageText); + +/* Displays a message box on the screen with an ok button using no system resources */ +VOID +GuiMessageBoxCritical( + _In_ PCSTR MessageText); + VOID GuiDrawProgressBar(ULONG Position, ULONG Range); // Draws the progress bar showing nPos percent filled UCHAR GuiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value UCHAR GuiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value -/////////////////////////////////////////////////////////////////////////////////////// -// -// Menu Functions -// -/////////////////////////////////////////////////////////////////////////////////////// +/* Menu Functions ************************************************************/ BOOLEAN GuiDisplayMenu( diff --git a/boot/freeldr/freeldr/include/ui/noui.h b/boot/freeldr/freeldr/include/ui/noui.h index 72eca1a9298..df986bfd178 100644 --- a/boot/freeldr/freeldr/include/ui/noui.h +++ b/boot/freeldr/freeldr/include/ui/noui.h @@ -47,8 +47,14 @@ NoUiDrawCenteredText( VOID NoUiDrawStatusText(PCSTR StatusText); VOID NoUiUpdateDateTime(VOID); -VOID NoUiMessageBox(PCSTR MessageText); -VOID NoUiMessageBoxCritical(PCSTR MessageText); + +VOID +NoUiMessageBox( + _In_ PCSTR MessageText); + +VOID +NoUiMessageBoxCritical( + _In_ PCSTR MessageText); /* Loading Progress-Bar Functions ********************************************/ diff --git a/boot/freeldr/freeldr/include/ui/tui.h b/boot/freeldr/freeldr/include/ui/tui.h index cb90ae214a3..1f61c1ada27 100644 --- a/boot/freeldr/freeldr/include/ui/tui.h +++ b/boot/freeldr/freeldr/include/ui/tui.h @@ -103,8 +103,16 @@ VOID TuiDrawStatusText(PCSTR StatusText); // Draws text at VOID TuiUpdateDateTime(VOID); // Updates the date and time VOID TuiSaveScreen(PUCHAR Buffer); // Saves the screen so that it can be restored later VOID TuiRestoreScreen(PUCHAR Buffer); // Restores the screen from a previous save -VOID TuiMessageBox(PCSTR MessageText); // Displays a message box on the screen with an ok button -VOID TuiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources + +/* Displays a message box on the screen with an ok button */ +VOID +TuiMessageBox( + _In_ PCSTR MessageText); + +/* Displays a message box on the screen with an ok button using no system resources */ +VOID +TuiMessageBoxCritical( + _In_ PCSTR MessageText); BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length); UCHAR TuiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value diff --git a/boot/freeldr/freeldr/ui/directui.c b/boot/freeldr/freeldr/ui/directui.c index 8bd47b2be0e..197061927d2 100644 --- a/boot/freeldr/freeldr/ui/directui.c +++ b/boot/freeldr/freeldr/ui/directui.c @@ -93,19 +93,22 @@ UiDrawStatusText(IN PCSTR StatusText) } VOID -UiInfoBox(IN PCSTR MessageText) +UiInfoBox( + _In_ PCSTR MessageText) { TuiPrintf(MessageText); } VOID -UiMessageBox(IN PCSTR MessageText) +UiMessageBox( + _In_ PCSTR MessageText) { TuiPrintf(MessageText); } VOID -UiMessageBoxCritical(IN PCSTR MessageText) +UiMessageBoxCritical( + _In_ PCSTR MessageText) { TuiPrintf(MessageText); } diff --git a/boot/freeldr/freeldr/ui/gui.c b/boot/freeldr/freeldr/ui/gui.c index d3160199ac9..38ec69b81d9 100644 --- a/boot/freeldr/freeldr/ui/gui.c +++ b/boot/freeldr/freeldr/ui/gui.c @@ -59,11 +59,15 @@ VOID GuiRestoreScreen(PUCHAR Buffer) { } -VOID GuiMessageBox(PCSTR MessageText) +VOID +GuiMessageBox( + _In_ PCSTR MessageText) { } -VOID GuiMessageBoxCritical(PCSTR MessageText) +VOID +GuiMessageBoxCritical( + _In_ PCSTR MessageText) { } diff --git a/boot/freeldr/freeldr/ui/noui.c b/boot/freeldr/freeldr/ui/noui.c index 1e7c21d1554..e79598bec63 100644 --- a/boot/freeldr/freeldr/ui/noui.c +++ b/boot/freeldr/freeldr/ui/noui.c @@ -77,23 +77,23 @@ VOID NoUiUpdateDateTime(VOID) { } -VOID NoUiMessageBox(PCSTR MessageText) +VOID +NoUiMessageBox( + _In_ PCSTR MessageText) { - // We have not yet displayed the user interface - // We are probably still reading the .ini file - // and have encountered an error. Just use printf() - // and return. - printf("%s\n", MessageText); - printf("Press any key\n"); - MachConsGetCh(); + NoUiMessageBoxCritical(MessageText); } -VOID NoUiMessageBoxCritical(PCSTR MessageText) +VOID +NoUiMessageBoxCritical( + _In_ PCSTR MessageText) { - // We have not yet displayed the user interface - // We are probably still reading the .ini file - // and have encountered an error. Just use printf() - // and return. + /* + * We have not yet displayed the user interface + * We are probably still reading the .ini file + * and have encountered an error. Just use printf() + * and return. + */ printf("%s\n", MessageText); printf("Press any key\n"); MachConsGetCh(); diff --git a/boot/freeldr/freeldr/ui/tui.c b/boot/freeldr/freeldr/ui/tui.c index d8669ea196b..e42599208d8 100644 --- a/boot/freeldr/freeldr/ui/tui.c +++ b/boot/freeldr/freeldr/ui/tui.c @@ -629,7 +629,9 @@ VOID TuiRestoreScreen(PUCHAR Buffer) VideoCopyOffScreenBufferToVRAM(); } -VOID TuiMessageBox(PCSTR MessageText) +VOID +TuiMessageBox( + _In_ PCSTR MessageText) { PVOID ScreenBuffer; @@ -646,7 +648,9 @@ VOID TuiMessageBox(PCSTR MessageText) FrLdrTempFree(ScreenBuffer, TAG_TUI_SCREENBUFFER); } -VOID TuiMessageBoxCritical(PCSTR MessageText) +VOID +TuiMessageBoxCritical( + _In_ PCSTR MessageText) { int width = 8; unsigned int height = 1; diff --git a/boot/freeldr/freeldr/ui/ui.c b/boot/freeldr/freeldr/ui/ui.c index 7d1b379d3e0..87b065388a7 100644 --- a/boot/freeldr/freeldr/ui/ui.c +++ b/boot/freeldr/freeldr/ui/ui.c @@ -293,22 +293,24 @@ VOID UiUpdateDateTime(VOID) UiVtbl.UpdateDateTime(); } -VOID UiInfoBox(PCSTR MessageText) +VOID +UiInfoBox( + _In_ PCSTR MessageText) { - SIZE_T TextLength; - ULONG BoxWidth; - ULONG BoxHeight; - ULONG LineBreakCount; - SIZE_T Index; - SIZE_T LastIndex; - ULONG Left; - ULONG Top; - ULONG Right; - ULONG Bottom; + SIZE_T TextLength; + ULONG BoxWidth; + ULONG BoxHeight; + ULONG LineBreakCount; + SIZE_T Index; + SIZE_T LastIndex; + ULONG Left; + ULONG Top; + ULONG Right; + ULONG Bottom; TextLength = strlen(MessageText); - // Count the new lines and the box width + /* Count the new lines and the box width */ LineBreakCount = 0; BoxWidth = 0; LastIndex = 0; @@ -328,17 +330,17 @@ VOID UiInfoBox(PCSTR MessageText) } } - // Calc the box width & height + /* Calc the box width & height */ BoxWidth += 6; BoxHeight = LineBreakCount + 4; - // Calc the box coordinates + /* Calc the box coordinates */ Left = (UiScreenWidth / 2) - (BoxWidth / 2); - Top =(UiScreenHeight / 2) - (BoxHeight / 2); - Right = (UiScreenWidth / 2) + (BoxWidth / 2); + Top = (UiScreenHeight / 2) - (BoxHeight / 2); + Right = (UiScreenWidth / 2) + (BoxWidth / 2); Bottom = (UiScreenHeight / 2) + (BoxHeight / 2); - // Draw the box + /* Draw the box */ UiDrawBox(Left, Top, Right, @@ -347,17 +349,18 @@ VOID UiInfoBox(PCSTR MessageText) HORZ, TRUE, TRUE, - ATTR(UiMenuFgColor, UiMenuBgColor) - ); + ATTR(UiMenuFgColor, UiMenuBgColor)); - // Draw the text + /* Draw the text */ UiDrawCenteredText(Left, Top, Right, Bottom, MessageText, ATTR(UiTextColor, UiMenuBgColor)); } -VOID UiMessageBox(PCSTR Format, ...) +VOID +UiMessageBox( + _In_ PCSTR Format, ...) { - CHAR Buffer[256]; va_list ap; + CHAR Buffer[256]; va_start(ap, Format); vsnprintf(Buffer, sizeof(Buffer) - sizeof(CHAR), Format, ap); @@ -365,7 +368,9 @@ VOID UiMessageBox(PCSTR Format, ...) va_end(ap); } -VOID UiMessageBoxCritical(PCSTR MessageText) +VOID +UiMessageBoxCritical( + _In_ PCSTR MessageText) { UiVtbl.MessageBoxCritical(MessageText); } @@ -631,3 +636,4 @@ BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length) return UiVtbl.EditBox(MessageText, EditTextBuffer, Length); } +/* EOF */