1
1
//! `LoadedImage` protocol.
2
2
3
3
use crate :: {
4
- data_types:: FromSliceWithNulError , proto:: Protocol , table :: boot :: MemoryType , unsafe_guid ,
5
- CStr16 , Handle , Status ,
4
+ data_types:: FromSliceWithNulError , proto:: device_path :: DevicePath , proto :: Protocol ,
5
+ table :: boot :: MemoryType , unsafe_guid , CStr16 , Char16 , Handle , Status ,
6
6
} ;
7
7
use core:: { ffi:: c_void, mem, slice} ;
8
8
@@ -17,7 +17,7 @@ pub struct LoadedImage {
17
17
18
18
// Source location of the image
19
19
device_handle : Handle ,
20
- _file_path : * const c_void , // TODO: not supported yet
20
+ file_path : * const c_void ,
21
21
_reserved : * const c_void ,
22
22
23
23
// Image load options
@@ -53,6 +53,19 @@ impl LoadedImage {
53
53
self . device_handle
54
54
}
55
55
56
+ /// Return a NULL-terminated Path string including directory and file names.
57
+ pub fn file_path ( & self ) -> & CStr16 {
58
+ // file_path is a pointer to the file path portion specific to
59
+ // DeviceHandle that the EFI Image was loaded from.
60
+ let file_path = self . file_path as * const DevicePath ;
61
+
62
+ unsafe {
63
+ // path name follows the DevicePathHeader.
64
+ let path_name = file_path. offset ( 1 ) ;
65
+ CStr16 :: from_ptr ( path_name. cast :: < Char16 > ( ) )
66
+ }
67
+ }
68
+
56
69
/// Get the load options of the image as a [`&CStr16`].
57
70
///
58
71
/// Load options are typically used to pass command-line options as
0 commit comments