Skip to content

Commit

Permalink
Fixes from PR
Browse files Browse the repository at this point in the history
- Update system table crc32

Signed-off-by: Ayush Singh <[email protected]>
  • Loading branch information
Ayush1325 committed Mar 30, 2024
1 parent b7b6bce commit 57bb9de
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion library/std/src/sys/pal/uefi/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ mod uefi_command_internal {
}
}

pub fn start_image(&self) -> io::Result<r_efi::efi::Status> {
pub fn start_image(&mut self) -> io::Result<r_efi::efi::Status> {
self.update_st_crc32()?;

let boot_services: NonNull<r_efi::efi::BootServices> = boot_services()
.ok_or_else(|| const_io_error!(io::ErrorKind::NotFound, "Boot Services not found"))?
.cast();
Expand Down Expand Up @@ -476,6 +478,27 @@ mod uefi_command_internal {

self.args = Some(args);
}

fn update_st_crc32(&mut self) -> io::Result<()> {
let bt: NonNull<r_efi::efi::BootServices> = boot_services().unwrap().cast();
let st_size = self.st.hdr.header_size as usize;
let mut crc32: u32 = 0;

let r = unsafe {
((*bt.as_ptr()).calculate_crc32)(
self.st.as_mut() as *mut r_efi::efi::SystemTable as *mut crate::ffi::c_void,
st_size,
&mut crc32,
)
};

if r.is_error() {
Err(io::Error::from_raw_os_error(r.as_usize()))
} else {
self.st.hdr.crc32 = crc32;
Ok(())
}
}
}

impl Drop for Command {
Expand Down

0 comments on commit 57bb9de

Please sign in to comment.