From be86e41d975325d30145e30369912a409012b76b Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 13 Nov 2019 15:37:21 +1100 Subject: [PATCH] std: add CTL_CODE function for windows --- lib/std/os/windows/bits.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/std/os/windows/bits.zig b/lib/std/os/windows/bits.zig index 3dc772a7c3..2f65c27e47 100644 --- a/lib/std/os/windows/bits.zig +++ b/lib/std/os/windows/bits.zig @@ -166,6 +166,14 @@ pub const FILE_ANY_ACCESS = 0; pub const FILE_READ_ACCESS = 1; pub const FILE_WRITE_ACCESS = 2; +/// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/defining-i-o-control-codes +pub fn CTL_CODE(deviceType: u16, function: u12, method: TransferType, access: u2) DWORD { + return (@as(DWORD, deviceType) << 16) | + (@as(DWORD, access) << 14) | + (@as(DWORD, function) << 2) | + @enumToInt(method); +} + pub const INVALID_HANDLE_VALUE = @intToPtr(HANDLE, maxInt(usize)); pub const INVALID_FILE_ATTRIBUTES = @as(DWORD, maxInt(DWORD));