Extract the image data from the display capsule to a file
(data: &[u8], header: &DisplayCapsule, filename: &str)
| 193 | |
| 194 | /// Extract the image data from the display capsule to a file |
| 195 | pub fn dump_winux_image(data: &[u8], header: &DisplayCapsule, filename: &str) { |
| 196 | let header_len = std::mem::size_of::<DisplayCapsule>(); |
| 197 | let image_size = header.capsule_header.capsule_image_size as usize - header_len; |
| 198 | |
| 199 | let image = &data[header_len..image_size]; |
| 200 | |
| 201 | #[cfg(not(feature = "uefi"))] |
| 202 | { |
| 203 | let mut file = File::create(filename).unwrap(); |
| 204 | file.write_all(image).unwrap(); |
| 205 | } |
| 206 | #[cfg(feature = "uefi")] |
| 207 | { |
| 208 | let ret = crate::fw_uefi::fs::shell_write_file(filename, image); |
| 209 | if let Err(err) = ret { |
| 210 | println!("Failed to dump winux image: {:?}", err); |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | #[cfg(test)] |
| 216 | mod tests { |
no test coverage detected