(Might be worth mentioning, I'm using POSIX-UEFI and not GNU-EFI)
I've removed error handling code from the code snippets.
This snippet is to give some context. In the next code snippet is where I have an error.
Code: Select all
// efi_file_handle_t* rootDir = .....; // Was initialized earlier
// Opening the bootloader file
efi_file_handle_t* winBootMgrHandle = NULL;
uint16_t path[] = u"EFI\\Microsoft\\Boot\\bootmgfw.efi";
rootDir->Open(rootDir, &winBootMgrHandle, path, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY);
// Getting file information in order to create a buffer of the right size
efi_guid_t infoGuid = EFI_FILE_INFO_GUID;
efi_file_info_t fileInfo;
uintn_t infoSize = sizeof(fileInfo);
winBootMgrHandle->GetInfo(winBootMgrHandle, &infoGuid, &infoSize, &fileInfo);
// Reading the file into a buffer
uintn_t winBootMgrSize = fileInfo.FileSize;
char* winBootMgrData = (char*)malloc(winBootMgrSize + 1);
winBootMgrData[winBootMgrSize] = 0;
winBootMgrHandle->Read(winBootMgrHandle, &winBootMgrSize, winBootMgrData);
IM is the image handle which was passed to the main function of my bootloader.
LIP is the loaded image protocol of IM.
BS is boot services.
Code: Select all
efi_handle_t imgHandle;
BS->LoadImage(0, IM, LIP->FilePath, winBootMgrData, winBootMgrSize, &imgHandle);
BS->StartImage(imgHandle, NULL, NULL); // Invalid parameter error here