Skip to main content

finestre_sys/kernel32/
mod.rs

1mod consts;
2pub use consts::*;
3use crate::typedefs::*;
4
5
6#[link(name = "Kernel32")]
7unsafe extern "system" {
8    pub unsafe fn GetLastError() -> DWORD;
9    pub unsafe fn GetCurrentProcessId() -> DWORD;
10    pub unsafe fn GlobalAddAtomW(atom_name: LPCWSTR) -> ATOM;
11    pub unsafe fn GlobalDeleteAtom(atom: ATOM) -> ATOM;
12    pub unsafe fn CloseHandle(handle: HANDLE) -> BOOL;
13
14
15    pub unsafe fn CreateFileMappingW(
16        file: HANDLE,
17        file_mapping_attributes: *const SecurityAttributes,
18        page_protection: DWORD,
19        max_size_high: DWORD,
20        max_size_low: DWORD,
21        name: LPCWSTR,
22    ) -> HANDLE;
23
24    pub unsafe fn UnmapViewOfFile(
25        base_address: LPCVOID,
26    ) -> BOOL;
27
28    pub unsafe fn MapViewOfFile(
29        file_mapping_object: HANDLE,
30        desired_access: DWORD,
31        file_offset_high: DWORD,
32        file_offset_low: DWORD,
33        number_of_bytes_to_map: SIZE_T,
34    ) -> LPVOID;
35
36    pub unsafe fn GetModuleHandleW(
37        module_name: LPCWSTR
38    ) -> HMODULE;
39}
40
41
42#[repr(C)]
43#[derive(finestre_init_with_size_derive::InitWithSize)]
44pub struct SecurityAttributes {
45    #[size_field]
46    pub length: DWORD,
47    pub security_descriptor: LPVOID,
48    pub inherit_handle: BOOL,
49}