MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / StartEFILoadedImage

Function StartEFILoadedImage

rEFIt_UEFI/refit/main.cpp:200–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198
199
200static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle,
201 IN CONST XString8Array& LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
202 IN CONST XStringW& ImageTitle,
203 OUT UINTN *ErrorInStep)
204{
205 EFI_STATUS Status, ReturnStatus;
206 EFI_LOADED_IMAGE_PROTOCOL *ChildLoadedImage;
207 CHAR16 ErrorInfo[256];
208// CHAR16 *FullLoadOptions = NULL;
209 XStringW loadOptionsW; // This has to be declared here, so it's not be freed before calling StartImage
210
211// DBG("Starting %ls\n", ImageTitle);
212 if (ErrorInStep != NULL) {
213 *ErrorInStep = 0;
214 }
215 ReturnStatus = Status = EFI_NOT_FOUND; // in case no image handle was specified
216 if (ChildImageHandle == NULL) {
217 if (ErrorInStep != NULL) *ErrorInStep = 1;
218 goto bailout;
219 }
220
221 // set load options
222 if (!LoadOptions.isEmpty()) {
223 ReturnStatus = Status = gBS->HandleProtocol(ChildImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ChildLoadedImage);
224 if (CheckError(Status, L"while getting a LoadedImageProtocol handle")) {
225 if (ErrorInStep != NULL)
226 *ErrorInStep = 2;
227 goto bailout_unload;
228 }
229
230 if (LoadOptionsPrefix != NULL) {
231 // NOTE: That last space is also added by the EFI shell and seems to be significant
232 // when passing options to Apple's boot.efi...
233 loadOptionsW = SWPrintf("%ls %s ", LoadOptionsPrefix, LoadOptions.ConcatAll(" "_XS8).c_str());
234 }else{
235 loadOptionsW = SWPrintf("%s ", LoadOptions.ConcatAll(" "_XS8).c_str()); // Jief : should we add a space ? Wasn't the case before big refactoring. Yes, a space required.
236 }
237 // NOTE: We also include the terminating null in the length for safety.
238 ChildLoadedImage->LoadOptionsSize = (UINT32)loadOptionsW.sizeInBytes() + sizeof(wchar_t);
239 ChildLoadedImage->LoadOptions = loadOptionsW.wc_str(); //will it be deleted after the procedure exit? Yes, if we don't copy loadOptionsW, so it'll be freed at the end of method
240 //((UINT32)StrLen(LoadOptions) + 1) * sizeof(CHAR16);
241 DBG("start image '%ls'\n", ImageTitle.s());
242 DBG("Using load options '%ls'\n", (CHAR16*)ChildLoadedImage->LoadOptions);
243
244 }
245 //DBG("Image loaded at: %p\n", ChildLoadedImage->ImageBase);
246 //PauseForKey(L"continue");
247
248 // close open file handles
249 UninitRefitLib();
250
251 // turn control over to the image
252 //
253 // Before calling the image, enable the Watchdog Timer for
254 // the 5 Minute period - Slice - NO! For slow driver and slow disk we need more
255 //
256 gBS->SetWatchdogTimer (600, 0x0000, 0x00, NULL);
257

Callers 2

StartEFIImageFunction · 0.85
StartLoaderMethod · 0.85

Calls 10

CheckErrorFunction · 0.85
SWPrintfFunction · 0.85
UninitRefitLibFunction · 0.85
ConcatAllMethod · 0.80
sizeInBytesMethod · 0.80
sMethod · 0.80
isEmptyMethod · 0.45
c_strMethod · 0.45
wc_strMethod · 0.45
notEmptyMethod · 0.45

Tested by

no test coverage detected