()
| 9 | use uefi_raw::protocol::shell_params::ShellFileHandle; |
| 10 | |
| 11 | fn get_shell_protocol() -> &'static ShellProtocol { |
| 12 | let handle = boot::get_handle_for_protocol::<Shell>().expect("No Shell handles"); |
| 13 | |
| 14 | // Use GetProtocol instead of Exclusive since we're running inside the shell |
| 15 | let shell = unsafe { |
| 16 | boot::open_protocol::<Shell>( |
| 17 | OpenProtocolParams { |
| 18 | handle, |
| 19 | agent: boot::image_handle(), |
| 20 | controller: None, |
| 21 | }, |
| 22 | OpenProtocolAttributes::GetProtocol, |
| 23 | ) |
| 24 | .expect("Failed to open Shell protocol") |
| 25 | }; |
| 26 | |
| 27 | // SAFETY: The Shell wrapper contains the raw ShellProtocol |
| 28 | unsafe { |
| 29 | let proto: &ShellProtocol = core::mem::transmute(shell.get().unwrap()); |
| 30 | // Leak to get 'static lifetime - protocol stays valid while shell is running |
| 31 | core::mem::forget(shell); |
| 32 | proto |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | pub fn shell_read_file(path: &str) -> Option<Vec<u8>> { |
| 37 | let shell = get_shell_protocol(); |
no test coverage detected