Struct uefi::proto::loaded_image::LoadedImage
source · [−]#[repr(C)]pub struct LoadedImage { /* private fields */ }
Expand description
The LoadedImage protocol. This can be opened on any image handle using the HandleProtocol
boot service.
Implementations
sourceimpl LoadedImage
impl LoadedImage
sourcepub fn device(&self) -> Handle
pub fn device(&self) -> Handle
Returns a handle to the storage device on which the image is located.
sourcepub fn load_options_as_cstr16(&self) -> Result<&CStr16, LoadOptionsError>
pub fn load_options_as_cstr16(&self) -> Result<&CStr16, LoadOptionsError>
Get the load options of the image as a &CStr16
.
Load options are typically used to pass command-line options as
a null-terminated UCS-2 string. This format is not required
though; use load_options_as_bytes
to access the raw bytes.
sourcepub fn load_options_as_bytes(&self) -> Option<&[u8]>
pub fn load_options_as_bytes(&self) -> Option<&[u8]>
Get the load options of the image as raw bytes.
UEFI allows arbitrary binary data in load options, but typically
the data is a null-terminated UCS-2 string. Use
load_options_as_cstr16
to more conveniently access the load
options as a string.
Returns None
if load options are not set.
sourcepub unsafe fn set_image(&mut self, data: *const c_void, size: u64)
pub unsafe fn set_image(&mut self, data: *const c_void, size: u64)
Set the image data address and size.
This is useful in the following scenario:
- Secure boot is enabled, so images loaded with
LoadImage
must be signed with an appropriate key known to the firmware. - The bootloader has its own key embedded, and uses that key to
verify the next stage. This key is not known to the firmware, so
the next stage’s image can’t be loaded with
LoadImage
. - Since image handles are created by
LoadImage
, which we can’t call, we have to make use of an existing image handle – the one passed into the bootloader’s entry function. By modifying that image handle (after appropriately verifying the signature of the new data), we can repurpose the image handle for the next stage.
See shim for an example of this scenario.
Safety
This function takes data
as a raw pointer because the data is not
owned by LoadedImage
. The caller must ensure that the memory lives
long enough.
sourcepub unsafe fn set_load_options(&mut self, options: *const u8, size: u32)
pub unsafe fn set_load_options(&mut self, options: *const u8, size: u32)
Set the load options for the image. This can be used prior to
calling BootServices.start_image
to control the command line
passed to the image.
size
is in bytes.
Safety
This function takes options
as a raw pointer because the
load options data is not owned by LoadedImage
. The caller
must ensure that the memory lives long enough.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more