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()); println!("Scanning {} processes...\n", processes.len());
let mut detections = Vec::new(); let mut detections = Vec::new();
let mut scanned_count = 0;
let mut error_count = 0;
for proc in &processes { for proc in &processes {
// Skip known safe system processes for performance // Skip known safe system processes for performance
@@ -69,7 +71,10 @@ fn main() -> Result<()> {
continue; continue;
} }
if let Ok(regions) = memory::enumerate_memory_regions(proc.pid) { scanned_count += 1;
match memory::enumerate_memory_regions(proc.pid) {
Ok(regions) => {
// Get thread information if available // Get thread information if available
let threads = thread::enumerate_threads(proc.pid).ok(); let threads = thread::enumerate_threads(proc.pid).ok();
let result = engine.analyze_process(proc, &regions, threads.as_deref()); let result = engine.analyze_process(proc, &regions, threads.as_deref());
@@ -78,6 +83,17 @@ fn main() -> Result<()> {
detections.push(result); 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() { if detections.is_empty() {