- // NOTE: Below commented-out line could be more efficient if file were read ahead of
- // time and passed as a pre-loaded image to LoadImage(), but it doesn't work on my
- // 32-bit Mac Mini or my 64-bit Intel box when launching a Linux kernel; the
- // kernel returns a "Failed to handle fs_proto" error message.
- // TODO: Track down the cause of this error and fix it, if possible.
- // ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex],
- // ImageData, ImageSize, &ChildImageHandle);
- ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex],
- NULL, 0, &ChildImageHandle);
+ FindVolumeAndFilename(DevicePaths[DevicePathIndex], &Volume, &Filename);
+ // Some EFIs crash if attempting to load driver for invalid architecture, so
+ // protect for this condition; but sometimes Volume comes back NULL, so provide
+ // an exception. (TODO: Handle this special condition better.)
+ if ((LoaderType == TYPE_LEGACY) || (Volume == NULL) || IsValidLoader(Volume->RootDir, Filename)) {
+ if (Filename && (LoaderType != TYPE_LEGACY)) {
+ Temp = PoolPrint(L"\\%s %s", Filename, FullLoadOptions ? FullLoadOptions : L"");
+ if (Temp != NULL) {
+ MyFreePool(FullLoadOptions);
+ FullLoadOptions = Temp;
+ }
+ } // if (Filename)
+
+ // NOTE: Below commented-out line could be more efficient if file were read ahead of
+ // time and passed as a pre-loaded image to LoadImage(), but it doesn't work on my
+ // 32-bit Mac Mini or my 64-bit Intel box when launching a Linux kernel; the
+ // kernel returns a "Failed to handle fs_proto" error message.
+ // TODO: Track down the cause of this error and fix it, if possible.
+ // ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex],
+ // ImageData, ImageSize, &ChildImageHandle);
+ ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex],
+ NULL, 0, &ChildImageHandle);
+ } else {
+ Print(L"Invalid loader file!\n");
+ ReturnStatus = EFI_LOAD_ERROR;
+ }