MCPcopy Create free account
hub / github.com/StephanvanSchaik/windows-kernel-rs / write_memory

Function write_memory

windows-kernel-rs/src/memory.rs:158–185  ·  view source on GitHub ↗
(
    target: CopyAddress,
    buffer: &[u8],
)

Source from the content-addressed store, hash-verified

156
157#[cfg(feature = "system")]
158pub fn write_memory(
159 target: CopyAddress,
160 buffer: &[u8],
161) -> Result<usize, Error> {
162 use windows_kernel_sys::ntoskrnl::MmCopyMemory;
163
164 let mut copy_addr: MM_COPY_ADDRESS = unsafe { core::mem::zeroed() };
165 let mut bytes = 0;
166
167 let target = match target {
168 CopyAddress::Virtual(addr) => addr,
169 CopyAddress::Physical(addr) => get_virtual_for_physical(addr),
170 };
171
172 copy_addr.__bindgen_anon_1.VirtualAddress = buffer.as_ptr() as _;
173
174 unsafe {
175 MmCopyMemory(
176 target as _,
177 copy_addr,
178 buffer.len() as _,
179 MM_COPY_MEMORY_VIRTUAL,
180 &mut bytes,
181 )
182 }.into_result()?;
183
184 Ok(bytes as _)
185}

Callers

nothing calls this directly

Calls 3

get_virtual_for_physicalFunction · 0.85
as_ptrMethod · 0.80
into_resultMethod · 0.80

Tested by

no test coverage detected