Module windows_ext::minwindef

source ·
Expand description

§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//shared/minwindef.h as part of the Windows SDK. These macros serve to (un)pack numeric values into larger numeric types.

Besides the existing #defines, 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 needed 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.

// existing minwindef.h macros:
let full: u32 = 9548625;
let lo = loword(full);
let hi = hiword(full);

// convenience wrapper:
let full: u32 = 9548625;
let (hi, lo) = splitdword(full)

Functions§

  • Get the high order byte from a word (u16)
  • Get the high order double word from a u64
  • Get the high order word as u16
  • Get the low order byte from a word (u16)
  • Get the low order double word from a u64
  • Get the low order word as u16
  • Turn two words into a dword/long docs are somewhat weird, the macro is named “MAKELONG” but returns a DWORD?
  • 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
  • Turn two bytes into a word
  • Split a single dword (u32) in both of its words (u16s)
  • Split a single dword (u32) in both of its words (u16s)
  • Split a single word (u16) in both of its bytes (u8s)