Skip to content

Commit 69ef7b6

Browse files
Merge pull request #398 from supdrewin/main
Add support to get the file path of loaded image
2 parents 68b204e + 25c8cae commit 69ef7b6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/proto/loaded_image.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//! `LoadedImage` protocol.
22
33
use crate::{
4-
data_types::FromSliceWithNulError, proto::Protocol, table::boot::MemoryType, unsafe_guid,
5-
CStr16, Handle, Status,
4+
data_types::FromSliceWithNulError,
5+
proto::{device_path::DevicePath, Protocol},
6+
table::boot::MemoryType,
7+
unsafe_guid, CStr16, Handle, Status,
68
};
79
use core::{ffi::c_void, mem, slice};
810

@@ -17,7 +19,7 @@ pub struct LoadedImage {
1719

1820
// Source location of the image
1921
device_handle: Handle,
20-
_file_path: *const c_void, // TODO: not supported yet
22+
file_path: *const DevicePath,
2123
_reserved: *const c_void,
2224

2325
// Image load options
@@ -53,6 +55,14 @@ impl LoadedImage {
5355
self.device_handle
5456
}
5557

58+
/// Get a reference to the `file_path`.
59+
///
60+
/// Return `None` if the pointer to the file path portion specific to
61+
/// DeviceHandle that the EFI Image was loaded from is null.
62+
pub fn file_path(&self) -> Option<&DevicePath> {
63+
unsafe { self.file_path.as_ref() }
64+
}
65+
5666
/// Get the load options of the image as a [`&CStr16`].
5767
///
5868
/// Load options are typically used to pass command-line options as

0 commit comments

Comments
 (0)