From d65aff2920beb30f0cf031488eae0dee4bfac065 Mon Sep 17 00:00:00 2001 From: pandaadir05 Date: Fri, 21 Nov 2025 15:24:18 +0200 Subject: [PATCH] fix: add yara-scanning feature gate to read_process_memory functions - Fixes dead code warning when yara-scanning feature is not enabled - read_process_memory is only used by scan_process which requires yara-scanning feature --- ghost-core/src/yara_engine.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ghost-core/src/yara_engine.rs b/ghost-core/src/yara_engine.rs index bc6b998..d19f479 100644 --- a/ghost-core/src/yara_engine.rs +++ b/ghost-core/src/yara_engine.rs @@ -408,7 +408,7 @@ impl DynamicYaraEngine { } /// Read memory from a specific process and region - #[cfg(target_os = "windows")] + #[cfg(all(target_os = "windows", feature = "yara-scanning"))] fn read_process_memory(pid: u32, region: &MemoryRegion) -> Result, GhostError> { use windows::Win32::Foundation::CloseHandle; use windows::Win32::System::Diagnostics::Debug::ReadProcessMemory; @@ -446,8 +446,7 @@ impl DynamicYaraEngine { } /// Read memory from a specific process and region (Linux implementation) - #[cfg(target_os = "linux")] - #[allow(dead_code)] + #[cfg(all(target_os = "linux", feature = "yara-scanning"))] fn read_process_memory(pid: u32, region: &MemoryRegion) -> Result, GhostError> { use std::fs::File; use std::io::{Read, Seek, SeekFrom}; @@ -472,8 +471,7 @@ impl DynamicYaraEngine { } /// Read memory from a specific process and region (macOS implementation) - #[cfg(target_os = "macos")] - #[allow(dead_code)] + #[cfg(all(target_os = "macos", feature = "yara-scanning"))] fn read_process_memory(_pid: u32, _region: &MemoryRegion) -> Result, GhostError> { Err(GhostError::PlatformNotSupported { feature: "Memory reading not implemented for macOS".to_string(),