diff --git a/boot_diags/src/app.rs b/boot_diags/src/app.rs index 468f2d2..b122a6b 100644 --- a/boot_diags/src/app.rs +++ b/boot_diags/src/app.rs @@ -56,7 +56,7 @@ use tracing::{debug, info}; use crate::diags::{ DiagGroup, Type as DiagType, get_diag_type, parse_bcd, parse_bitlocker, parse_chkdsk, - parse_dism, parse_system_files, + parse_dism, parse_registry_hives, parse_system_files, }; pub struct App { @@ -473,7 +473,23 @@ impl App { parse_system_files(current_group, task_result.clone()); } } - _ => (), + DiagType::Registry => { + if let Some(task_result) = &task.result { + match &task.task_type { + TaskType::CommandWait(_, cmd_args) => { + parse_registry_hives( + current_group, + task_result.clone(), + cmd_args.clone(), + ); + } + _ => {} + } + } + } + DiagType::Unknown => { + panic!("This shouldn't happen?"); + } } self.action_tx.send(Action::DiagLineUpdate { result: current_group.get_pass_fail_warn(), diff --git a/boot_diags/src/diags.rs b/boot_diags/src/diags.rs index de59419..0a089ac 100644 --- a/boot_diags/src/diags.rs +++ b/boot_diags/src/diags.rs @@ -383,6 +383,74 @@ pub fn parse_dism(diag_group: &mut DiagGroup, task_result: TaskResult) { } } +pub fn parse_registry_hives( + diag_group: &mut DiagGroup, + task_result: TaskResult, + cmd_args: Vec, +) { + if !cfg!(windows) { + sleep(Duration::from_millis(500)); + return (); + } + let hive = cmd_args.get(2); + match task_result { + TaskResult::Error(err) => { + diag_group.passed.push(false); + diag_group.result = String::from("Error"); + diag_group.logs.push(Log { + label: String::from("Registry"), + summary: if hive.is_some() { + vec![DVLine { + line_parts: vec![ + format!("Registry ({}): ", hive.unwrap()), + String::from("Error"), + ], + line_colors: vec![Color::Reset, Color::Red], + }] + } else { + Vec::new() + }, + raw: err, + }); + } + TaskResult::Output(stdout, stderr, passed) => { + let output_text = if stderr.is_empty() { + stdout.clone() + } else { + format!("{stdout}\n\n{stderr}") + }; + + if passed { + diag_group.passed.push(true); + diag_group.result = String::from("OK"); + diag_group.logs.push(Log { + label: String::from("Registry"), + summary: Vec::new(), + raw: output_text, + }); + } else { + diag_group.passed.push(false); + diag_group.result = String::from("Error"); + diag_group.logs.push(Log { + label: String::from("Registry"), + summary: if hive.is_some() { + vec![DVLine { + line_parts: vec![ + format!("Registry ({}): ", hive.unwrap()), + String::from("Error"), + ], + line_colors: vec![Color::Reset, Color::Red], + }] + } else { + Vec::new() + }, + raw: output_text, + }); + } + } + } +} + pub fn parse_system_files(diag_group: &mut DiagGroup, task_result: TaskResult) { if !cfg!(windows) { sleep(Duration::from_millis(500));