From a1e5f562052cff4583e0711565572afd595598ad Mon Sep 17 00:00:00 2001 From: Daniel Maslowski Date: Sat, 18 Oct 2025 17:51:45 +0200 Subject: [PATCH] me: implement scan() helper This is for the case that an image is provided that is not as expected. For upgrade images, some vendors do not declare regions (partitions) as if they were when residing in flash, probably applied with a certain logic during the upgrade. This has been encountered with samples from MSI Cyborg 15 and 17 devices; see the respective support downloads: https://www.msi.com/Laptop/Cyborg-15-A12VX https://www.msi.com/Laptop/Cyborg-17-B2RWX Signed-off-by: Daniel Maslowski --- src/me.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/me.rs b/src/me.rs index ef3ea15..074ba3f 100644 --- a/src/me.rs +++ b/src/me.rs @@ -133,6 +133,17 @@ impl ME { } } + // Find an ME partition in a given slice, and if an FPT is detected, get the + // parse result, which includes the offset as its base address. + pub fn scan(data: &[u8], debug: bool) -> Option> { + for o in (0..data.len() - FPT_SIZE - 0x10).step_by(0x40) { + if let Some(r) = Self::parse(&data[o..], o, debug) { + return Some(r); + } + } + None + } + // Scan for all CPDs (there may be some not listed in FPT) pub fn cpd_scan(data: &[u8]) -> Vec { let mut gen3dirs = Vec::::new();