memf_core/proto_pte.rs
1//! Prototype PTE resolution for shared memory sections.
2
3/// Resolves prototype PTEs to their backing physical address.
4///
5/// In Windows, when a PTE has bit 10 set (not-present), it indicates the page
6/// is shared via a prototype PTE. Implementations of this trait decode the raw
7/// PTE value and return the resolved physical address of the backing page.
8pub trait PrototypePteSource: Send + Sync {
9 /// Given the raw non-present PTE value (with bit 10 set), return the
10 /// resolved physical address of the backing page, or `None` if unavailable.
11 fn resolve(&self, pte_value: u64) -> Option<u64>;
12}
13
14#[cfg(test)]
15mod tests {
16 use super::*;
17 use crate::test_builders::MockPrototypePteSource;
18
19 #[test]
20 fn mock_source_returns_mapped_address() {
21 let source = MockPrototypePteSource::new(vec![(1 << 10, 0x00A0_0000)]);
22 assert_eq!(source.resolve(1 << 10), Some(0x00A0_0000));
23 }
24
25 #[test]
26 fn mock_source_returns_none_for_unmapped() {
27 let source = MockPrototypePteSource::new(vec![]);
28 assert_eq!(source.resolve(1 << 10), None);
29 }
30}