diff --git a/src/internals/configuration.rs b/src/internals/configuration.rs index fa93ca0..7108544 100644 --- a/src/internals/configuration.rs +++ b/src/internals/configuration.rs @@ -38,6 +38,18 @@ pub fn set_max_match_data(value: u32) -> Result<(), YaraError> { } } +/// Set the maximum size of chunks scanned from a process memory. +/// +/// This is mapped to the YR_CONFIG_MAX_PROCESS_MEMORY_CHUNK property. +pub fn set_max_process_memory_chunk(value: u64) -> Result<(), YaraError> { + unsafe { + set_cfg( + yara_sys::_YR_CONFIG_NAME_YR_CONFIG_MAX_PROCESS_MEMORY_CHUNK, + &value as *const u64 as *mut c_void, + ) + } +} + /// Get the stack size. /// /// This is mapped to the YR_CONFIG_STACK_SIZE property. @@ -59,6 +71,13 @@ pub fn get_max_match_data() -> Result { unsafe { get_cfg(yara_sys::_YR_CONFIG_NAME_YR_CONFIG_MAX_MATCH_DATA) } } +/// Get the maximum size of chunks scanned from a process memory. +/// +/// This is mapped to the YR_CONFIG_MAX_PROCESS_MEMORY_CHUNK property. +pub fn get_max_process_memory_chunk() -> Result { + unsafe { get_cfg(yara_sys::_YR_CONFIG_NAME_YR_CONFIG_MAX_PROCESS_MEMORY_CHUNK) } +} + /// Safety: /// /// The value pointer must point to a value of the right size for the given config. diff --git a/src/lib.rs b/src/lib.rs index 134a685..14662a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -156,6 +156,11 @@ impl Yara { configuration::set_max_match_data(value) } + /// Set the maximum size of chunks scanned from a process memory. + pub fn set_configuration_max_process_memory_chunk(&self, value: u64) -> Result<(), YaraError> { + configuration::set_max_process_memory_chunk(value) + } + /// Get the configured stack size. pub fn get_configuration_stack_size(&self) -> Result { configuration::get_stack_size() @@ -171,6 +176,11 @@ impl Yara { configuration::get_max_match_data() } + /// Get the maximum size of chunks scanned from a process memory. + pub fn get_configuration_max_process_memory_chunk(&self) -> Result { + configuration::get_max_process_memory_chunk() + } + /// Create and initialize the library. #[deprecated = "Use new"] pub fn create() -> Result { diff --git a/tests/tests.rs b/tests/tests.rs index e7bba64..d436975 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -66,6 +66,14 @@ fn test_configuration() { let yara = Yara::new().expect("Should be Ok"); assert_eq!(Ok(()), yara.set_configuration_stack_size(100)); assert_eq!(Ok(100), yara.get_configuration_stack_size()); + assert_eq!( + Ok(()), + yara.set_configuration_max_process_memory_chunk(u64::MAX) + ); + assert_eq!( + Ok(u64::MAX), + yara.get_configuration_max_process_memory_chunk() + ); } #[test]