diff --git a/hypervisor/src/intel/hooks/hook_manager.rs b/hypervisor/src/intel/hooks/hook_manager.rs index d8e1e0b..9e58a32 100644 --- a/hypervisor/src/intel/hooks/hook_manager.rs +++ b/hypervisor/src/intel/hooks/hook_manager.rs @@ -67,7 +67,9 @@ pub struct HookManager { /// KiSetCacheInformation -> KiSetCacheInformationIntel -> KiSetStandardizedCacheInformation -> __cpuid(4, 0) pub has_cpuid_cache_info_been_called: bool, - pub stack_memory: Vec<(usize, usize)>, + /// A vector to keep track of allocated memory ranges for debugging and management purposes. + /// Each element is a tuple where the first value is the start address and the second value is the size of the allocation. + pub allocated_memory_ranges: Vec<(usize, usize)>, } lazy_static! { @@ -89,7 +91,7 @@ lazy_static! { ntoskrnl_base_pa: 0, ntoskrnl_size: 0, has_cpuid_cache_info_been_called: false, - stack_memory: Vec::with_capacity(128), + allocated_memory_ranges: Vec::with_capacity(128), }); } @@ -119,12 +121,12 @@ impl HookManager { /// * `start` - The start address of the memory allocation. /// * `size` - The size of the memory allocation. pub fn record_allocation(&mut self, start: usize, size: usize) { - self.stack_memory.push((start, size)); + self.allocated_memory_ranges.push((start, size)); } /// Prints the allocated memory ranges for debugging purposes. pub fn print_allocated_memory(&self) { - self.stack_memory.iter().for_each(|(start, size)| { + self.allocated_memory_ranges.iter().for_each(|(start, size)| { debug!("Memory Range: Start = {:#x}, Size = {:#x}", start, size); }); } @@ -218,7 +220,7 @@ impl HookManager { /// Returns `Ok(())` if the hooks were successfully installed, `Err(HypervisorError)` otherwise. pub fn hide_hypervisor_memory(&mut self, vm: &mut Vm, page_permissions: AccessType) -> Result<(), HypervisorError> { let pages: Vec = self - .stack_memory + .allocated_memory_ranges .iter() .step_by(BASE_PAGE_SIZE) .map(|(start, _size)| *start as u64)