From b7beb073a5a3a448eb7a2b108e98a0af866e8ae4 Mon Sep 17 00:00:00 2001 From: Download-Fritz Date: Mon, 7 Oct 2019 21:23:46 +0200 Subject: [PATCH] OcBootManagementLib: Assign image LoadOptions as Unicode --- .../OcBootManagementLib/DefaultEntryChoice.c | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Library/OcBootManagementLib/DefaultEntryChoice.c b/Library/OcBootManagementLib/DefaultEntryChoice.c index ae430813..39ea0fa9 100644 --- a/Library/OcBootManagementLib/DefaultEntryChoice.c +++ b/Library/OcBootManagementLib/DefaultEntryChoice.c @@ -872,6 +872,8 @@ InternalLoadBootEntry ( EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; VOID *EntryData; UINT32 EntryDataSize; + CONST CHAR8 *Args; + UINT32 ArgsLen; ASSERT (BootPolicy != NULL); ASSERT (BootEntry != NULL); @@ -974,16 +976,24 @@ InternalLoadBootEntry ( BootEntry->LoadOptions )); + LoadedImage->LoadOptionsSize = 0; + LoadedImage->LoadOptions = NULL; + if (BootEntry->LoadOptions == NULL && (BootEntry->Type == OcBootApple || BootEntry->Type == OcBootAppleRecovery)) { - LoadedImage->LoadOptionsSize = (UINT32)AsciiStrLen (Context->AppleBootArgs); - if (LoadedImage->LoadOptionsSize > 0) { - LoadedImage->LoadOptionsSize += 1; - LoadedImage->LoadOptions = Context->AppleBootArgs; - } + Args = Context->AppleBootArgs; + ArgsLen = (UINT32)AsciiStrLen (Args); } else { - LoadedImage->LoadOptionsSize = BootEntry->LoadOptionsSize; - LoadedImage->LoadOptions = BootEntry->LoadOptions; + Args = BootEntry->LoadOptions; + ArgsLen = BootEntry->LoadOptionsSize; + ASSERT (ArgsLen == AsciiStrLen (Args)); + } + + if (ArgsLen > 0) { + LoadedImage->LoadOptions = AsciiStrCopyToUnicode (Args, ArgsLen); + if (LoadedImage->LoadOptions != NULL) { + LoadedImage->LoadOptionsSize = ArgsLen * sizeof (CHAR16) + sizeof (CHAR16); + } } if (BootEntry->Type == OcBootCustom) {