Types v0.1.0

Source
The Win32 scalar and handle types.

Handle

pub type Handle = *var opaque

An opaque kernel object reference. Pointer-sized and owned by the kernel. A handle is valid until CloseHandle takes it, after which the number may be reused by the next object opened — so a stale handle does not fail, it addresses something else.

Source

ModuleHandle

pub type ModuleHandle = *var opaque

A module reference, as LoadLibraryW returns one.

Source

Bool

pub type Bool = int32

Win32's BOOL: a 32-bit integer where zero is false and anything else is true. Not a one-byte boolean, and not bool. A call returning one reports failure as zero and success as anything else, which is why comparing against 1 is wrong.

Source

Dword

pub type Dword = uint32

Win32's DWORD: a 32-bit unsigned integer.

Source

WideChar

pub type WideChar = char16

A UTF-16 code unit, which is what every *W entry point takes. Not a character: a scalar outside the basic plane occupies two of these.

Source

NtStatus

pub type NtStatus = int32

An NTSTATUS: the status code the native and cryptographic interfaces report with. Zero and above is success; below zero is failure. This is a different scheme from GetLastError, and a value of one must never be read as the other.

Source

InvalidHandleValue

pub const InvalidHandleValue: uint64 = 0xFFFFFFFFFFFFFFFF;

The value a handle-returning call reports failure with. -1 cast to a pointer, which is not null. CreateFileW and FindFirstFileW report failure this way; a memory-returning call such as VirtualAlloc reports null instead.

Source