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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! # `minwindef.h` macros for use in Rust with the windows-rs and windows-sys crates
//! This module defines equivalents to the macros defined in Include/<version>/shared/minwindef.h
//! as part of the Windows SDK. These macros serve to (un)pack numeric values into and from larger
//! numeric types.
//!
//! Besides the existing `#define`s, this module adds a couple functions useful for those working
//! with 64-bit integers and pointers:
//! - [`lodword`] and [`hidword`] to get the lower and higher 32 bits from them
//! - [`makelonglong`] to pack two 32-bit ints into a 64-bit int.
//! These were added because they're useful for working with e.g. `CreateFileMapping*` functions.
//!
//! Lastly some additional methods were added for splitting and returning both values at once.
//! Consider them syntactical sugar over the others, as that really is all they are.
//! They just return a tuple containing (in order) the low order and high order components. This
//! is achieved by just calling both of those functions one after the other.
//!
//! ```
//! use windows_ext::minwindef::*;
//! // existing minwindef.h macros:
//! let full: u32 = 9548625;
//! let lo1 = loword(full);
//! let hi1 = hiword(full);
//!
//! // convenience wrapper:
//! let full: u32 = 9548625;
//! let (lo2, hi2) = splitdword(full);
//! assert_eq!(lo1, lo2);
//! assert_eq!(hi1, hi2);
//! ```
/// Get the low order word as u16
pub const
/// Get the high order word as u16
pub const
/// Split a single dword (`u32`) in both of its words (`u16`s) ordered (low, high)
pub const
/// Get the low order byte from a word (u16)
pub const
/// Get the high order byte from a word (u16)
pub const
/// Split a single word (`u16`) in both of its bytes (`u8`s) ordered (low, high)
pub const
/// Get the low order double word from a u64
pub const
/// Get the high order double word from a u64
pub const
/// Split a single dword (`u32`) in both of its words (`u16`s) ordered (low, high)
pub const
/// Turn two bytes into a word
pub const
/// Turn two words into a dword/long
/// docs are somewhat weird, the macro is named "MAKELONG" but returns a DWORD?
pub const
/// Not part of the standard macros, but a logical step to accommodate 64-bit
/// Named after the underlying C datatype, in Win32 terms this would be a QWORD
pub const