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

Function InitRefitLib

rEFIt_UEFI/refit/lib.cpp:176–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174//
175
176EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle)
177{
178 EFI_STATUS Status;
179 XStringW FilePathAsString;
180 UINTN i;
181 UINTN DevicePathSize;
182 EFI_DEVICE_PATH_PROTOCOL* TmpDevicePath;
183
184 SelfImageHandle = ImageHandle;
185 Status = gBS->HandleProtocol(SelfImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &SelfLoadedImage);
186 if (CheckFatalError(Status, L"while getting a LoadedImageProtocol handle"))
187 return Status;
188
189 SelfDeviceHandle = SelfLoadedImage->DeviceHandle;
190 TmpDevicePath = DevicePathFromHandle (SelfDeviceHandle);
191 DevicePathSize = GetDevicePathSize (TmpDevicePath);
192 SelfDevicePath = (__typeof__(SelfDevicePath))AllocateAlignedPages(EFI_SIZE_TO_PAGES(DevicePathSize), 64);
193 CopyMem(SelfDevicePath, TmpDevicePath, DevicePathSize);
194
195 DBG("SelfDevicePath=%ls @%llX\n", FileDevicePathToXStringW(SelfDevicePath).wc_str(), (uintptr_t)SelfDeviceHandle);
196
197 // find the current directory
198 FilePathAsString = FileDevicePathToXStringW(SelfLoadedImage->FilePath);
199 if (FilePathAsString.notEmpty()) {
200 SelfFullDevicePath = FileDevicePath(SelfDeviceHandle, FilePathAsString);
201 for (i = FilePathAsString.length(); i > 0 && FilePathAsString[i] != '\\'; i--) ;
202 if (i > 0) {
203 FilePathAsString = FilePathAsString.subString(0, i);
204 } else {
205 FilePathAsString = L"\\"_XSW;
206 }
207 } else {
208 FilePathAsString = L"\\"_XSW;
209 }
210 SelfDirPath = FilePathAsString;
211
212 DBG("SelfDirPath = %ls\n", SelfDirPath.wc_str());
213
214 return FinishInitRefitLib();
215}
216
217VOID UninitRefitLib(VOID)
218{

Callers 1

RefitMainFunction · 0.85

Calls 10

CheckFatalErrorFunction · 0.85
FileDevicePathToXStringWFunction · 0.85
FinishInitRefitLibFunction · 0.85
subStringMethod · 0.80
FileDevicePathFunction · 0.70
GetDevicePathSizeFunction · 0.50
CopyMemFunction · 0.50
wc_strMethod · 0.45
notEmptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected