1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![allow(non_camel_case_types, non_snake_case)]
use crate::co;
use crate::decl::*;
use crate::guard::*;
use crate::kernel::{ffi, privs::*};
handle! { HFILEMAP;
/// Handle to a
/// [file mapping](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-createfilemappingw).
/// Originally just a `HANDLE`.
///
/// Unless you need something specific, consider using the
/// [`FileMapped`](crate::FileMapped) high-level abstraction.
}
impl HFILEMAP {
/// [`MapViewOfFile`](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile)
/// function.
#[must_use]
pub fn MapViewOfFile(
&self,
desired_access: co::FILE_MAP,
offset: u64,
number_of_bytes_to_map: Option<usize>,
) -> SysResult<UnmapViewOfFileGuard> {
unsafe {
PtrRet(ffi::MapViewOfFileFromApp(
self.ptr(),
desired_access.raw(),
offset,
number_of_bytes_to_map.unwrap_or_default(),
))
.to_sysresult_handle()
.map(|h| UnmapViewOfFileGuard::new(h))
}
}
}