diff --git a/xtldr2/xtldr.c b/xtldr2/xtldr.c index 09d786a..be50e7d 100644 --- a/xtldr2/xtldr.c +++ b/xtldr2/xtldr.c @@ -113,10 +113,10 @@ BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList) PWCHAR ModulesList, ProtocolName; PLIST_ENTRY OptionsListEntry; PXTBL_CONFIG_ENTRY Option; + SIZE_T ModuleListLength; EFI_STATUS Status; /* Set default values */ - ModulesList = NULL; ProtocolName = NULL; /* Iterate through all options provided by boot menu entry */ @@ -134,8 +134,19 @@ BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList) } else if(RtlCompareWideStringInsensitive(Option->Name, L"BOOTMODULES", 0) == 0) { - /* Set protocol name */ - ModulesList = Option->Value; + /* Check a length of modules list */ + ModuleListLength = RtlWideStringLength(Option->Value, 0); + + Status = BlMemoryAllocatePool(sizeof(PWCHAR) * ModuleListLength, (PVOID *)&ModulesList); + if(Status != STATUS_EFI_SUCCESS) + { + /* Failed to allocate memory, print error message and return status code */ + BlDebugPrint(L"ERROR: Memory allocation failure (Status Code: 0x%lx)\n"); + return STATUS_EFI_OUT_OF_RESOURCES; + } + + /* Make a copy of modules list */ + RtlCopyMemory(ModulesList, Option->Value, sizeof(PWCHAR) * ModuleListLength); } /* Move to the next option entry */