track and report memory access errors in verbose mode

This commit is contained in:
Adir Shitrit
2025-11-08 12:22:19 +02:00
parent 30614fe77e
commit 6a7c66e382

View File

@@ -62,6 +62,8 @@ fn main() -> Result<()> {
println!("Scanning {} processes...\n", processes.len());
let mut detections = Vec::new();
let mut scanned_count = 0;
let mut error_count = 0;
for proc in &processes {
// Skip known safe system processes for performance
@@ -69,17 +71,31 @@ fn main() -> Result<()> {
continue;
}
if let Ok(regions) = memory::enumerate_memory_regions(proc.pid) {
// Get thread information if available
let threads = thread::enumerate_threads(proc.pid).ok();
let result = engine.analyze_process(proc, &regions, threads.as_deref());
scanned_count += 1;
if result.threat_level != ThreatLevel::Clean {
detections.push(result);
match memory::enumerate_memory_regions(proc.pid) {
Ok(regions) => {
// Get thread information if available
let threads = thread::enumerate_threads(proc.pid).ok();
let result = engine.analyze_process(proc, &regions, threads.as_deref());
if result.threat_level != ThreatLevel::Clean {
detections.push(result);
}
}
Err(_) => {
error_count += 1;
if verbose {
println!("Warning: Could not scan process {} (PID: {})", proc.name, proc.pid);
}
}
}
}
if verbose && error_count > 0 {
println!("Scan completed with {} access errors", error_count);
}
if detections.is_empty() {
println!("No suspicious activity detected.");
} else {