+ if (secure_mode() && ShimLoaded()) {
+ // Load ourself into memory. This is a trick to work around a bug in Shim 0.8,
+ // which ties itself into the BS->LoadImage() and BS->StartImage() functions and
+ // then unregisters itself from the EFI system table when its replacement
+ // StartImage() function is called *IF* the previous LoadImage() was for the same
+ // program. The result is that rEFInd can validate only the first program it
+ // launches (often a filesystem driver). Loading a second program (rEFInd itself,
+ // here, to keep it smaller than a kernel) works around this problem. See the
+ // replacements.c file in Shim, and especially its start_image() function, for
+ // the source of the problem.
+ // NOTE: This doesn't check the return status or handle errors. It could
+ // conceivably do weird things if, say, rEFInd were on a USB drive that the
+ // user pulls before launching a program.
+ refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, GlobalConfig.SelfDevicePath,
+ NULL, 0, &ChildImageHandle2);
+ }