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

Function FileDevicePathToXStringW

rEFIt_UEFI/refit/lib.cpp:1644–1672  ·  view source on GitHub ↗

Aptio UEFI returns File DevPath as 2 nodes (dir, file) and DevicePathToStr connects them with /, but we need '\\'

Source from the content-addressed store, hash-verified

1642// Aptio UEFI returns File DevPath as 2 nodes (dir, file)
1643// and DevicePathToStr connects them with /, but we need '\\'
1644XStringW FileDevicePathToXStringW(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
1645{
1646 CHAR16 *FilePath;
1647 CHAR16 *Char;
1648 CONST CHAR16 *Tail;
1649
1650 FilePath = ConvertDevicePathToText(DevPath, TRUE, TRUE);
1651 // fix / into '\\'
1652 if (FilePath != NULL) {
1653 for (Char = FilePath; *Char != L'\0'; Char++) {
1654 if (*Char == L'/') {
1655 *Char = L'\\';
1656 }
1657 }
1658 }
1659 // "\\\\" into '\\'
1660 Char = (CHAR16*)StrStr(FilePath, L"\\\\"); // cast is ok because FilePath is not const, and we know that StrStr returns a pointer in FilePath. Will disappear when using a string object instead of CHAR16*
1661 while (Char != NULL) {
1662// StrCpyS(Char, 4, Char + 1); //can't overlap
1663 Tail = Char + 1;
1664 while (*Char != 0) {
1665 *(Char++) = *(Tail++);
1666 }
1667 Char = (CHAR16*)StrStr(FilePath, L"\\\\"); // cast is ok because FilePath is not const, and we know that StrStr returns a pointer in FilePath. Will disappear when using a string object instead of CHAR16*
1668 }
1669 XStringW returnValue;
1670 returnValue.stealValueFrom(FilePath); // do not FreePool FilePath, it's now owned by returnValue
1671 return returnValue;
1672}
1673
1674XStringW FileDevicePathFileToXStringW(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
1675{

Callers 15

InitRefitLibFunction · 0.85
ReinitSelfLibFunction · 0.85
ScanVolumeFunction · 0.85
ReinitVolumesFunction · 0.85
DumpVariableFunction · 0.85
PrintBootOptionFunction · 0.85
FindBootOptionForFileFunction · 0.85
AddBootOptionFunction · 0.85
FindStartupDiskVolumeFunction · 0.85
IsOsxHibernatedFunction · 0.85

Calls 2

StrStrFunction · 0.85
stealValueFromMethod · 0.80

Tested by

no test coverage detected