diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 0aec895..79c126f 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -9,6 +9,7 @@ use sysinfo::{System, Disks}; use wmi::{COMLibrary, WMIConnection}; use std::fs; use std::path::Path; +// [修复] 移除了未使用的 Write use std::io::Read; use std::process::Command; use tauri::Emitter; @@ -231,16 +232,16 @@ where T: Deref }) } -// [修复] BlueScreenView 外部调用分析 (使用 CSV crate 解析) +// [修复] BlueScreenView 外部调用分析 (适配新的命令行格式和 CSV 列) fn analyze_with_bluescreenview(dump_path: &Path) -> Result { let bsv_exe = "BlueScreenView.exe"; let mut temp_csv_path = std::env::temp_dir(); temp_csv_path.push(format!("bsod_report_{}.csv", chrono::Utc::now().timestamp_millis())); + // [修改] 命令行格式: BlueScreenView.exe /scomma let status = Command::new(bsv_exe) - .arg("/LoadFrom") - .arg(dump_path.to_string_lossy().to_string()) + .arg(dump_path.to_string_lossy().to_string()) // 直接传文件路径 .arg("/scomma") .arg(temp_csv_path.to_string_lossy().to_string()) .status(); @@ -256,36 +257,28 @@ fn analyze_with_bluescreenview(dump_path: &Path) -> Result= 9 { - // 跳过可能的表头行 - if &record[0] == "Dump File" { continue; } - + if record.len() > 15 { + // 第一行就是数据,不需要跳过 Header let bug_check_string = &record[2]; let bug_check_code = &record[3]; - let caused_by_driver = &record[8]; // Index 8 是最常见的 Caused By Driver 位置 - - // 尝试获取崩溃地址,如果不够长就填 N/A - let crash_addr = if record.len() > 15 { &record[15] } else { "N/A" }; + let caused_by_driver = &record[8]; + let crash_addr = &record[15]; let (human, recommend) = translate_bugcheck_str(bug_check_code); - // 优先使用 Bug Check String,如果为空则使用翻译结果 + // 优先使用 BlueScreenView 识别出的 Bug Check String let final_reason = if !bug_check_string.is_empty() { bug_check_string.to_string() } else { human }; return Ok(BsodAnalysisReport { @@ -300,7 +293,7 @@ fn analyze_with_bluescreenview(dump_path: &Path) -> Result) -> Result { - // [修复] 先将 Minidump::read 错误转为 String,确保链式调用类型一致 + // [修复] 修复 Error 类型转换 let native_result = Minidump::read(file_content.clone()) .map_err(|e| e.to_string()) .and_then(|dump| analyze_dump_data_native(dump)); @@ -413,7 +406,6 @@ async fn analyze_minidump_bytes(file_content: Vec) -> Result