Make a copy of dialog box message as it gets modified by RtlTokenizeWideString()
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 27s
Builds / ExectOS (i686) (push) Successful in 45s

This commit is contained in:
Rafal Kupiec 2024-01-07 15:20:13 +01:00
parent 5653393002
commit fbcdc0d8d0
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4

View File

@ -1182,19 +1182,34 @@ VOID
BlpDrawDialogMessage(IN PXTBL_DIALOG_HANDLE Handle, BlpDrawDialogMessage(IN PXTBL_DIALOG_HANDLE Handle,
IN PWCHAR Message) IN PWCHAR Message)
{ {
PWCHAR MsgLine, LastMsgLine; PWCHAR Msg, MsgLine, LastMsgLine;
SIZE_T Index, Length; SIZE_T Index, Length, LineLength;
EFI_STATUS Status;
ULONG Line; ULONG Line;
/* Allocate memory for dialog box message */
Length = RtlWideStringLength(Message, 0);
Status = BlMemoryAllocatePool(Length * sizeof(WCHAR), (PVOID *)&Msg);
if(Status != STATUS_EFI_SUCCESS)
{
/* Memory allocation failure, print debug message and return */
BlDebugPrint(L"ERROR: Memory allocation failure (Status Code: 0x%lx)\n", Status);
return;
}
/* Make a copy of dialog box message */
RtlCopyMemory(Msg, Message, Length * sizeof(WCHAR));
Msg[Length] = 0;
/* Tokenize dialog box message */ /* Tokenize dialog box message */
MsgLine = RtlTokenizeWideString(Message, L"\n", &LastMsgLine); MsgLine = RtlTokenizeWideString(Msg, L"\n", &LastMsgLine);
/* Iterate through message lines */ /* Iterate through message lines */
Line = 0; Line = 0;
while(MsgLine) while(MsgLine)
{ {
/* Determine line length */ /* Determine line length */
Length = RtlWideStringLength(Message, 0); LineLength = RtlWideStringLength(MsgLine, 0);
/* Write line in the dialog box */ /* Write line in the dialog box */
BlSetCursorPosition(Handle->PosX + 2, Handle->PosY + 2 + Line); BlSetCursorPosition(Handle->PosX + 2, Handle->PosY + 2 + Line);
@ -1202,10 +1217,10 @@ BlpDrawDialogMessage(IN PXTBL_DIALOG_HANDLE Handle,
BlConsolePrint(L"%S", MsgLine); BlConsolePrint(L"%S", MsgLine);
/* Check if message line is shorter than the dialog box working area */ /* Check if message line is shorter than the dialog box working area */
if(Length < Handle->Width - 4) if(LineLength < Handle->Width - 4)
{ {
/* Fill the rest of the line with spaces */ /* Fill the rest of the line with spaces */
for(Index = Length; Index < Handle->Width - 4; Index++) for(Index = LineLength; Index < Handle->Width - 4; Index++)
{ {
BlConsolePrint(L" "); BlConsolePrint(L" ");
} }