我想检查efi图像路径是否有效,这是代码。
gBS->LocateHandleBuffer (
ByProtocol,
&gEfiSimpleFileSystemProtocolGuid,
NULL,
&NumberSimpleFileSystemHandles,
&SimpleFileSystemHandles
);
for (Index = 0; Index < NumberSimpleFileSystemHandles; Index++) {
TempImagePath = FileDevicePath (SimpleFileSystemHandles[Index], L"\\EFI\\BOOT\\boo.efi");
if(IsDevicePathValid(TempImagePath,sizeof(EFI_DEVICE_PATH_PROTOCOL)) == TRUE){
//OK
}
这段代码总是返回路径无效,我想这是在第二个参数上出了问题 IsDevicePathValid
.
是什么问题?
谢谢,我想检查efi图像路径是否有效,这是代码:gBS->LocateHandleBuffer ( ByProtocol, &gEfiSimpleFile)
如果设备路径的总长度超过第二个参数MaxPath的值,IsDevicePathValid返回false。很明显,它超过了 sizeof (EFI_DEVICE_PATH_PROTOCOL),也就是 4,你应该为这个参数传递 0。