mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std: add and improve some system API bindings
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
This commit is contained in:
parent
58e3c2cefd
commit
279e3bdde5
6 changed files with 698 additions and 407 deletions
|
|
@ -10967,6 +10967,16 @@ pub const ptrace = switch (native_os) {
|
|||
else => {},
|
||||
};
|
||||
|
||||
pub extern "c" fn semget(key: std.posix.key_t, nsems: c_int, semflg: c_int) c_int;
|
||||
pub extern "c" fn semctl(semid: c_int, semnum: c_int, op: c_int, ...) c_int;
|
||||
pub extern "c" fn semop(semid: c_int, sops: [*]std.posix.sembuf, nsops: usize) c_int;
|
||||
pub extern "c" fn semtimedop(
|
||||
semid: c_int,
|
||||
sops: [*]std.posix.sembuf,
|
||||
nsops: usize,
|
||||
timeout: ?*const timespec,
|
||||
) c_int;
|
||||
|
||||
pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int;
|
||||
pub extern "c" fn sem_destroy(sem: *sem_t) c_int;
|
||||
pub extern "c" fn sem_open(name: [*:0]const u8, flag: c_int, mode: mode_t, value: c_uint) *sem_t;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,9 @@ pub fn values(comptime E: type) []const E {
|
|||
/// panic when `e` has no tagged value.
|
||||
/// Returns the tag name for `e` or null if no tag exists.
|
||||
pub fn tagName(comptime E: type, e: E) ?[:0]const u8 {
|
||||
return inline for (@typeInfo(E).@"enum".fields) |f| {
|
||||
const fields = @typeInfo(E).@"enum".fields;
|
||||
@setEvalBranchQuota(fields.len);
|
||||
return inline for (fields) |f| {
|
||||
if (@intFromEnum(e) == f.value) break f.name;
|
||||
} else null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ pub fn isCygwinPty(file: File) bool {
|
|||
.SUCCESS => {},
|
||||
else => return false,
|
||||
}
|
||||
if (device_info.DeviceType != windows.FILE_DEVICE_NAMED_PIPE) return false;
|
||||
if (device_info.DeviceType.FileDevice != .NAMED_PIPE) return false;
|
||||
}
|
||||
|
||||
const name_bytes_offset = @offsetOf(windows.FILE_NAME_INFO, "FileName");
|
||||
|
|
|
|||
|
|
@ -28,9 +28,19 @@ pub const ws2_32 = @import("windows/ws2_32.zig");
|
|||
pub const crypt32 = @import("windows/crypt32.zig");
|
||||
pub const nls = @import("windows/nls.zig");
|
||||
|
||||
pub const self_process_handle = @as(HANDLE, @ptrFromInt(maxInt(usize)));
|
||||
|
||||
const Self = @This();
|
||||
// ntdef.h
|
||||
pub const EVENT_TYPE = enum(c_int) {
|
||||
Notification,
|
||||
Synchronization,
|
||||
};
|
||||
pub const TIMER_TYPE = enum(c_int) {
|
||||
Notification,
|
||||
Synchronization,
|
||||
};
|
||||
pub const WAIT_TYPE = enum(c_int) {
|
||||
All,
|
||||
Any,
|
||||
};
|
||||
|
||||
pub const OpenError = error{
|
||||
IsDir,
|
||||
|
|
@ -60,6 +70,9 @@ pub const OpenFileOptions = struct {
|
|||
/// If false, tries to open path as a reparse point without dereferencing it.
|
||||
/// Defaults to true.
|
||||
follow_symlinks: bool = true,
|
||||
/// Whether to try and perform a case-sensitive lookup for the file name. Windows will not honor
|
||||
/// this flag unless the user has set a system setting.
|
||||
case_sensitive: bool = true,
|
||||
|
||||
pub const Filter = enum {
|
||||
/// Causes `OpenFile` to return `error.IsDir` if the opened handle would be a directory.
|
||||
|
|
@ -82,18 +95,22 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
|
|||
var result: HANDLE = undefined;
|
||||
|
||||
const path_len_bytes = math.cast(u16, sub_path_w.len * 2) orelse return error.NameTooLong;
|
||||
var nt_name = UNICODE_STRING{
|
||||
var nt_name: UNICODE_STRING = .{
|
||||
.Length = path_len_bytes,
|
||||
.MaximumLength = path_len_bytes,
|
||||
.Buffer = @constCast(sub_path_w.ptr),
|
||||
};
|
||||
var attr = OBJECT_ATTRIBUTES{
|
||||
const attr: OBJECT_ATTRIBUTES = .{
|
||||
.Length = @sizeOf(OBJECT_ATTRIBUTES),
|
||||
.RootDirectory = if (std.fs.path.isAbsoluteWindowsWtf16(sub_path_w)) null else options.dir,
|
||||
.Attributes = if (options.sa) |ptr| blk: { // Note we do not use OBJ_CASE_INSENSITIVE here.
|
||||
const inherit: ULONG = if (ptr.bInheritHandle == TRUE) OBJ_INHERIT else 0;
|
||||
break :blk inherit;
|
||||
} else 0,
|
||||
.Attributes = attrs: {
|
||||
var attrs: ULONG = 0;
|
||||
if (!options.case_sensitive) attrs |= OBJ_CASE_INSENSITIVE;
|
||||
if (options.sa) |ptr| {
|
||||
if (ptr.bInheritHandle == TRUE) attrs |= OBJ_INHERIT;
|
||||
}
|
||||
break :attrs attrs;
|
||||
},
|
||||
.ObjectName = &nt_name,
|
||||
.SecurityDescriptor = if (options.sa) |ptr| ptr.lpSecurityDescriptor else null,
|
||||
.SecurityQualityOfService = null,
|
||||
|
|
@ -311,6 +328,15 @@ pub const DeviceIoControlError = error{
|
|||
/// The volume does not contain a recognized file system. File system
|
||||
/// drivers might not be loaded, or the volume may be corrupt.
|
||||
UnrecognizedVolume,
|
||||
Pending,
|
||||
/// Attempted to connect a named pipe in the "closing" state, meaning a previous client has
|
||||
/// has closed their handle but we have not yet disconnected the pipe.
|
||||
PipeClosing,
|
||||
/// Attempted to connect a named pipe in the "connected" state, meaning a client has already
|
||||
/// opened the pipe; there is a good connection between client and server.
|
||||
PipeAlreadyConnected,
|
||||
/// Attempted to connect a non-blocking named pipe which is already listening for connections.
|
||||
PipeAlreadyListening,
|
||||
Unexpected,
|
||||
};
|
||||
|
||||
|
|
@ -319,60 +345,89 @@ pub const DeviceIoControlError = error{
|
|||
/// as a direct substitute for that call.
|
||||
/// TODO work out if we need to expose other arguments to the underlying syscalls.
|
||||
pub fn DeviceIoControl(
|
||||
h: HANDLE,
|
||||
ioControlCode: ULONG,
|
||||
in: ?[]const u8,
|
||||
out: ?[]u8,
|
||||
device: HANDLE,
|
||||
io_control_code: CTL_CODE,
|
||||
opts: struct {
|
||||
event: ?HANDLE = null,
|
||||
apc_routine: ?IO_APC_ROUTINE = null,
|
||||
apc_context: ?*anyopaque = null,
|
||||
io_status_block: ?*IO_STATUS_BLOCK = null,
|
||||
in: []const u8 = &.{},
|
||||
out: []u8 = &.{},
|
||||
},
|
||||
) DeviceIoControlError!void {
|
||||
// Logic from: https://doxygen.reactos.org/d3/d74/deviceio_8c.html
|
||||
const is_fsctl = (ioControlCode >> 16) == FILE_DEVICE_FILE_SYSTEM;
|
||||
|
||||
var io: IO_STATUS_BLOCK = undefined;
|
||||
const in_ptr = if (in) |i| i.ptr else null;
|
||||
const in_len = if (in) |i| @as(ULONG, @intCast(i.len)) else 0;
|
||||
const out_ptr = if (out) |o| o.ptr else null;
|
||||
const out_len = if (out) |o| @as(ULONG, @intCast(o.len)) else 0;
|
||||
|
||||
const rc = blk: {
|
||||
if (is_fsctl) {
|
||||
break :blk ntdll.NtFsControlFile(
|
||||
h,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
&io,
|
||||
ioControlCode,
|
||||
in_ptr,
|
||||
in_len,
|
||||
out_ptr,
|
||||
out_len,
|
||||
);
|
||||
} else {
|
||||
break :blk ntdll.NtDeviceIoControlFile(
|
||||
h,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
&io,
|
||||
ioControlCode,
|
||||
in_ptr,
|
||||
in_len,
|
||||
out_ptr,
|
||||
out_len,
|
||||
);
|
||||
}
|
||||
var io_status_block: IO_STATUS_BLOCK = undefined;
|
||||
const rc = switch (io_control_code.DeviceType) {
|
||||
.FILE_SYSTEM, .NAMED_PIPE => ntdll.NtFsControlFile(
|
||||
device,
|
||||
opts.event,
|
||||
opts.apc_routine,
|
||||
opts.apc_context,
|
||||
opts.io_status_block orelse &io_status_block,
|
||||
io_control_code,
|
||||
if (opts.in.len > 0) opts.in.ptr else null,
|
||||
@intCast(opts.in.len),
|
||||
if (opts.out.len > 0) opts.out.ptr else null,
|
||||
@intCast(opts.out.len),
|
||||
),
|
||||
else => ntdll.NtDeviceIoControlFile(
|
||||
device,
|
||||
opts.event,
|
||||
opts.apc_routine,
|
||||
opts.apc_context,
|
||||
opts.io_status_block orelse &io_status_block,
|
||||
io_control_code,
|
||||
if (opts.in.len > 0) opts.in.ptr else null,
|
||||
@intCast(opts.in.len),
|
||||
if (opts.out.len > 0) opts.out.ptr else null,
|
||||
@intCast(opts.out.len),
|
||||
),
|
||||
};
|
||||
switch (rc) {
|
||||
.SUCCESS => {},
|
||||
.PIPE_CLOSING => return error.PipeClosing,
|
||||
.PIPE_CONNECTED => return error.PipeAlreadyConnected,
|
||||
.PIPE_LISTENING => return error.PipeAlreadyListening,
|
||||
.PRIVILEGE_NOT_HELD => return error.AccessDenied,
|
||||
.ACCESS_DENIED => return error.AccessDenied,
|
||||
.INVALID_DEVICE_REQUEST => return error.AccessDenied, // Not supported by the underlying filesystem
|
||||
.INVALID_PARAMETER => unreachable,
|
||||
.UNRECOGNIZED_VOLUME => return error.UnrecognizedVolume,
|
||||
.PENDING => return error.Pending,
|
||||
else => return unexpectedStatus(rc),
|
||||
}
|
||||
}
|
||||
|
||||
pub const FILE_PIPE_WAIT_FOR_BUFFER = extern struct {
|
||||
Timeout: LARGE_INTEGER = WAIT_FOREVER,
|
||||
NameLength: ULONG,
|
||||
TimeoutSpecified: BOOLEAN,
|
||||
Name: [PATH_MAX_WIDE]WCHAR,
|
||||
|
||||
pub const WAIT_FOREVER: LARGE_INTEGER = std.math.minInt(LARGE_INTEGER);
|
||||
|
||||
pub fn init(basename: []const WCHAR, Timeout: ?LARGE_INTEGER) FILE_PIPE_WAIT_FOR_BUFFER {
|
||||
var fpwfb: FILE_PIPE_WAIT_FOR_BUFFER = .{
|
||||
.Timeout = Timeout orelse undefined,
|
||||
.NameLength = @intCast(@sizeOf(WCHAR) * basename.len),
|
||||
.TimeoutSpecified = @intFromBool(Timeout != null),
|
||||
.Name = undefined,
|
||||
};
|
||||
@memcpy(fpwfb.Name[0..basename.len], basename);
|
||||
@memset(fpwfb.Name[basename.len..std.mem.alignForward(usize, basename.len, 2)], 0);
|
||||
return fpwfb;
|
||||
}
|
||||
|
||||
pub fn getName(fpwfb: *const FILE_PIPE_WAIT_FOR_BUFFER) []WCHAR {
|
||||
return fpwfb.Name[@sizeOf(FILE_PIPE_WAIT_FOR_BUFFER)..][0..fpwfb.NameLength];
|
||||
}
|
||||
|
||||
pub fn toBuffer(fpwfb: *const FILE_PIPE_WAIT_FOR_BUFFER) []const u8 {
|
||||
const start: [*]const u8 = @ptrCast(fpwfb);
|
||||
return start[0..std.mem.alignForward(ULONG, @offsetOf(FILE_PIPE_WAIT_FOR_BUFFER, "Name") + fpwfb.NameLength, 4)];
|
||||
}
|
||||
};
|
||||
|
||||
pub fn GetOverlappedResult(h: HANDLE, overlapped: *OVERLAPPED, wait: bool) !DWORD {
|
||||
var bytes: DWORD = undefined;
|
||||
if (kernel32.GetOverlappedResult(h, overlapped, &bytes, @intFromBool(wait)) == 0) {
|
||||
|
|
@ -860,7 +915,12 @@ pub fn CreateSymbolicLink(
|
|||
@memcpy(buffer[@sizeOf(SYMLINK_DATA)..][0 .. final_target_path.len * 2], @as([*]const u8, @ptrCast(final_target_path)));
|
||||
const paths_start = @sizeOf(SYMLINK_DATA) + final_target_path.len * 2;
|
||||
@memcpy(buffer[paths_start..][0 .. final_target_path.len * 2], @as([*]const u8, @ptrCast(final_target_path)));
|
||||
_ = try DeviceIoControl(symlink_handle, FSCTL_SET_REPARSE_POINT, buffer[0..buf_len], null);
|
||||
_ = DeviceIoControl(symlink_handle, FSCTL.SET_REPARSE_POINT, buffer[0..buf_len], null) catch |err| switch (err) {
|
||||
error.PipeClosing => unreachable,
|
||||
error.PipeAlreadyConnected => unreachable,
|
||||
error.PipeAlreadyListening => unreachable,
|
||||
else => |e| return e,
|
||||
};
|
||||
}
|
||||
|
||||
pub const ReadLinkError = error{
|
||||
|
|
@ -894,7 +954,10 @@ pub fn ReadLink(dir: ?HANDLE, sub_path_w: []const u16, out_buffer: []u16) ReadLi
|
|||
defer CloseHandle(result_handle);
|
||||
|
||||
var reparse_buf: [MAXIMUM_REPARSE_DATA_BUFFER_SIZE]u8 align(@alignOf(REPARSE_DATA_BUFFER)) = undefined;
|
||||
_ = DeviceIoControl(result_handle, FSCTL_GET_REPARSE_POINT, null, reparse_buf[0..]) catch |err| switch (err) {
|
||||
_ = DeviceIoControl(result_handle, FSCTL.GET_REPARSE_POINT, null, reparse_buf[0..]) catch |err| switch (err) {
|
||||
error.PipeClosing => unreachable,
|
||||
error.PipeAlreadyConnected => unreachable,
|
||||
error.PipeAlreadyListening => unreachable,
|
||||
error.AccessDenied => return error.Unexpected,
|
||||
error.UnrecognizedVolume => return error.Unexpected,
|
||||
else => |e| return e,
|
||||
|
|
@ -1462,8 +1525,12 @@ pub fn GetFinalPathNameByHandle(
|
|||
input_struct.DeviceNameLength = @intCast(volume_name_u16.len * 2);
|
||||
@memcpy(input_buf[@sizeOf(MOUNTMGR_MOUNT_POINT)..][0 .. volume_name_u16.len * 2], @as([*]const u8, @ptrCast(volume_name_u16.ptr)));
|
||||
|
||||
DeviceIoControl(mgmt_handle, IOCTL_MOUNTMGR_QUERY_POINTS, &input_buf, &output_buf) catch |err| switch (err) {
|
||||
DeviceIoControl(mgmt_handle, IOCTL.MOUNTMGR.QUERY_POINTS, .{ .in = &input_buf, .out = &output_buf }) catch |err| switch (err) {
|
||||
error.PipeClosing => unreachable,
|
||||
error.PipeAlreadyConnected => unreachable,
|
||||
error.PipeAlreadyListening => unreachable,
|
||||
error.AccessDenied => return error.Unexpected,
|
||||
error.Pending => unreachable,
|
||||
else => |e| return e,
|
||||
};
|
||||
const mount_points_struct: *const MOUNTMGR_MOUNT_POINTS = @ptrCast(&output_buf[0]);
|
||||
|
|
@ -1517,8 +1584,12 @@ pub fn GetFinalPathNameByHandle(
|
|||
vol_input_struct.DeviceNameLength = @intCast(symlink.len * 2);
|
||||
@memcpy(@as([*]WCHAR, &vol_input_struct.DeviceName)[0..symlink.len], symlink);
|
||||
|
||||
DeviceIoControl(mgmt_handle, IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH, &vol_input_buf, &vol_output_buf) catch |err| switch (err) {
|
||||
DeviceIoControl(mgmt_handle, IOCTL.MOUNTMGR.QUERY_DOS_VOLUME_PATH, .{ .in = &vol_input_buf, .out = &vol_output_buf }) catch |err| switch (err) {
|
||||
error.PipeClosing => unreachable,
|
||||
error.PipeAlreadyConnected => unreachable,
|
||||
error.PipeAlreadyListening => unreachable,
|
||||
error.AccessDenied => return error.Unexpected,
|
||||
error.Pending => unreachable,
|
||||
else => |e| return e,
|
||||
};
|
||||
const volume_paths_struct: *const MOUNTMGR_VOLUME_PATHS = @ptrCast(&vol_output_buf[0]);
|
||||
|
|
@ -1758,7 +1829,7 @@ pub fn VirtualProtect(lpAddress: ?LPVOID, dwSize: SIZE_T, flNewProtect: DWORD, l
|
|||
// ntdll takes an extra level of indirection here
|
||||
var addr = lpAddress;
|
||||
var size = dwSize;
|
||||
switch (ntdll.NtProtectVirtualMemory(self_process_handle, &addr, &size, flNewProtect, lpflOldProtect)) {
|
||||
switch (ntdll.NtProtectVirtualMemory(GetCurrentProcess(), &addr, &size, flNewProtect, lpflOldProtect)) {
|
||||
.SUCCESS => {},
|
||||
.INVALID_ADDRESS => return error.InvalidAddress,
|
||||
else => |st| return unexpectedStatus(st),
|
||||
|
|
@ -2018,7 +2089,7 @@ pub const LockFileError = error{
|
|||
pub fn LockFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?*IO_APC_ROUTINE,
|
||||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
ApcContext: ?*anyopaque,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
ByteOffset: *const LARGE_INTEGER,
|
||||
|
|
@ -2783,7 +2854,10 @@ pub fn unexpectedWSAError(err: ws2_32.WinsockError) UnexpectedError {
|
|||
/// and you get an unexpected status.
|
||||
pub fn unexpectedStatus(status: NTSTATUS) UnexpectedError {
|
||||
if (std.posix.unexpected_error_tracing) {
|
||||
std.debug.print("error.Unexpected NTSTATUS=0x{x}\n", .{@intFromEnum(status)});
|
||||
std.debug.print("error.Unexpected NTSTATUS=0x{x} ({s})\n", .{
|
||||
@intFromEnum(status),
|
||||
std.enums.tagName(NTSTATUS, status) orelse "<unnamed>",
|
||||
});
|
||||
std.debug.dumpCurrentStackTrace(.{ .first_address = @returnAddress() });
|
||||
}
|
||||
return error.Unexpected;
|
||||
|
|
@ -2791,14 +2865,20 @@ pub fn unexpectedStatus(status: NTSTATUS) UnexpectedError {
|
|||
|
||||
pub fn statusBug(status: NTSTATUS) UnexpectedError {
|
||||
switch (builtin.mode) {
|
||||
.Debug => std.debug.panic("programmer bug caused syscall status: {t}", .{status}),
|
||||
.Debug => std.debug.panic("programmer bug caused syscall status: 0x{x} ({s})", .{
|
||||
@intFromEnum(status),
|
||||
std.enums.tagName(NTSTATUS, status) orelse "<unnamed>",
|
||||
}),
|
||||
else => return error.Unexpected,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn errorBug(err: Win32Error) UnexpectedError {
|
||||
switch (builtin.mode) {
|
||||
.Debug => std.debug.panic("programmer bug caused syscall status: {t}", .{err}),
|
||||
.Debug => std.debug.panic("programmer bug caused syscall error: 0x{x} ({s})", .{
|
||||
@intFromEnum(err),
|
||||
std.enums.tagName(Win32Error, err) orelse "<unnamed>",
|
||||
}),
|
||||
else => return error.Unexpected,
|
||||
}
|
||||
}
|
||||
|
|
@ -2885,112 +2965,162 @@ pub const PCTSTR = @compileError("Deprecated: choose between `PCSTR` or `PCWSTR`
|
|||
pub const TRUE = 1;
|
||||
pub const FALSE = 0;
|
||||
|
||||
pub const DEVICE_TYPE = ULONG;
|
||||
pub const FILE_DEVICE_BEEP: DEVICE_TYPE = 0x0001;
|
||||
pub const FILE_DEVICE_CD_ROM: DEVICE_TYPE = 0x0002;
|
||||
pub const FILE_DEVICE_CD_ROM_FILE_SYSTEM: DEVICE_TYPE = 0x0003;
|
||||
pub const FILE_DEVICE_CONTROLLER: DEVICE_TYPE = 0x0004;
|
||||
pub const FILE_DEVICE_DATALINK: DEVICE_TYPE = 0x0005;
|
||||
pub const FILE_DEVICE_DFS: DEVICE_TYPE = 0x0006;
|
||||
pub const FILE_DEVICE_DISK: DEVICE_TYPE = 0x0007;
|
||||
pub const FILE_DEVICE_DISK_FILE_SYSTEM: DEVICE_TYPE = 0x0008;
|
||||
pub const FILE_DEVICE_FILE_SYSTEM: DEVICE_TYPE = 0x0009;
|
||||
pub const FILE_DEVICE_INPORT_PORT: DEVICE_TYPE = 0x000a;
|
||||
pub const FILE_DEVICE_KEYBOARD: DEVICE_TYPE = 0x000b;
|
||||
pub const FILE_DEVICE_MAILSLOT: DEVICE_TYPE = 0x000c;
|
||||
pub const FILE_DEVICE_MIDI_IN: DEVICE_TYPE = 0x000d;
|
||||
pub const FILE_DEVICE_MIDI_OUT: DEVICE_TYPE = 0x000e;
|
||||
pub const FILE_DEVICE_MOUSE: DEVICE_TYPE = 0x000f;
|
||||
pub const FILE_DEVICE_MULTI_UNC_PROVIDER: DEVICE_TYPE = 0x0010;
|
||||
pub const FILE_DEVICE_NAMED_PIPE: DEVICE_TYPE = 0x0011;
|
||||
pub const FILE_DEVICE_NETWORK: DEVICE_TYPE = 0x0012;
|
||||
pub const FILE_DEVICE_NETWORK_BROWSER: DEVICE_TYPE = 0x0013;
|
||||
pub const FILE_DEVICE_NETWORK_FILE_SYSTEM: DEVICE_TYPE = 0x0014;
|
||||
pub const FILE_DEVICE_NULL: DEVICE_TYPE = 0x0015;
|
||||
pub const FILE_DEVICE_PARALLEL_PORT: DEVICE_TYPE = 0x0016;
|
||||
pub const FILE_DEVICE_PHYSICAL_NETCARD: DEVICE_TYPE = 0x0017;
|
||||
pub const FILE_DEVICE_PRINTER: DEVICE_TYPE = 0x0018;
|
||||
pub const FILE_DEVICE_SCANNER: DEVICE_TYPE = 0x0019;
|
||||
pub const FILE_DEVICE_SERIAL_MOUSE_PORT: DEVICE_TYPE = 0x001a;
|
||||
pub const FILE_DEVICE_SERIAL_PORT: DEVICE_TYPE = 0x001b;
|
||||
pub const FILE_DEVICE_SCREEN: DEVICE_TYPE = 0x001c;
|
||||
pub const FILE_DEVICE_SOUND: DEVICE_TYPE = 0x001d;
|
||||
pub const FILE_DEVICE_STREAMS: DEVICE_TYPE = 0x001e;
|
||||
pub const FILE_DEVICE_TAPE: DEVICE_TYPE = 0x001f;
|
||||
pub const FILE_DEVICE_TAPE_FILE_SYSTEM: DEVICE_TYPE = 0x0020;
|
||||
pub const FILE_DEVICE_TRANSPORT: DEVICE_TYPE = 0x0021;
|
||||
pub const FILE_DEVICE_UNKNOWN: DEVICE_TYPE = 0x0022;
|
||||
pub const FILE_DEVICE_VIDEO: DEVICE_TYPE = 0x0023;
|
||||
pub const FILE_DEVICE_VIRTUAL_DISK: DEVICE_TYPE = 0x0024;
|
||||
pub const FILE_DEVICE_WAVE_IN: DEVICE_TYPE = 0x0025;
|
||||
pub const FILE_DEVICE_WAVE_OUT: DEVICE_TYPE = 0x0026;
|
||||
pub const FILE_DEVICE_8042_PORT: DEVICE_TYPE = 0x0027;
|
||||
pub const FILE_DEVICE_NETWORK_REDIRECTOR: DEVICE_TYPE = 0x0028;
|
||||
pub const FILE_DEVICE_BATTERY: DEVICE_TYPE = 0x0029;
|
||||
pub const FILE_DEVICE_BUS_EXTENDER: DEVICE_TYPE = 0x002a;
|
||||
pub const FILE_DEVICE_MODEM: DEVICE_TYPE = 0x002b;
|
||||
pub const FILE_DEVICE_VDM: DEVICE_TYPE = 0x002c;
|
||||
pub const FILE_DEVICE_MASS_STORAGE: DEVICE_TYPE = 0x002d;
|
||||
pub const FILE_DEVICE_SMB: DEVICE_TYPE = 0x002e;
|
||||
pub const FILE_DEVICE_KS: DEVICE_TYPE = 0x002f;
|
||||
pub const FILE_DEVICE_CHANGER: DEVICE_TYPE = 0x0030;
|
||||
pub const FILE_DEVICE_SMARTCARD: DEVICE_TYPE = 0x0031;
|
||||
pub const FILE_DEVICE_ACPI: DEVICE_TYPE = 0x0032;
|
||||
pub const FILE_DEVICE_DVD: DEVICE_TYPE = 0x0033;
|
||||
pub const FILE_DEVICE_FULLSCREEN_VIDEO: DEVICE_TYPE = 0x0034;
|
||||
pub const FILE_DEVICE_DFS_FILE_SYSTEM: DEVICE_TYPE = 0x0035;
|
||||
pub const FILE_DEVICE_DFS_VOLUME: DEVICE_TYPE = 0x0036;
|
||||
pub const FILE_DEVICE_SERENUM: DEVICE_TYPE = 0x0037;
|
||||
pub const FILE_DEVICE_TERMSRV: DEVICE_TYPE = 0x0038;
|
||||
pub const FILE_DEVICE_KSEC: DEVICE_TYPE = 0x0039;
|
||||
pub const FILE_DEVICE_FIPS: DEVICE_TYPE = 0x003a;
|
||||
pub const FILE_DEVICE_INFINIBAND: DEVICE_TYPE = 0x003b;
|
||||
// TODO: missing values?
|
||||
pub const FILE_DEVICE_VMBUS: DEVICE_TYPE = 0x003e;
|
||||
pub const FILE_DEVICE_CRYPT_PROVIDER: DEVICE_TYPE = 0x003f;
|
||||
pub const FILE_DEVICE_WPD: DEVICE_TYPE = 0x0040;
|
||||
pub const FILE_DEVICE_BLUETOOTH: DEVICE_TYPE = 0x0041;
|
||||
pub const FILE_DEVICE_MT_COMPOSITE: DEVICE_TYPE = 0x0042;
|
||||
pub const FILE_DEVICE_MT_TRANSPORT: DEVICE_TYPE = 0x0043;
|
||||
pub const FILE_DEVICE_BIOMETRIC: DEVICE_TYPE = 0x0044;
|
||||
pub const FILE_DEVICE_PMI: DEVICE_TYPE = 0x0045;
|
||||
pub const FILE_DEVICE_EHSTOR: DEVICE_TYPE = 0x0046;
|
||||
pub const FILE_DEVICE_DEVAPI: DEVICE_TYPE = 0x0047;
|
||||
pub const FILE_DEVICE_GPIO: DEVICE_TYPE = 0x0048;
|
||||
pub const FILE_DEVICE_USBEX: DEVICE_TYPE = 0x0049;
|
||||
pub const FILE_DEVICE_CONSOLE: DEVICE_TYPE = 0x0050;
|
||||
pub const FILE_DEVICE_NFP: DEVICE_TYPE = 0x0051;
|
||||
pub const FILE_DEVICE_SYSENV: DEVICE_TYPE = 0x0052;
|
||||
pub const FILE_DEVICE_VIRTUAL_BLOCK: DEVICE_TYPE = 0x0053;
|
||||
pub const FILE_DEVICE_POINT_OF_SERVICE: DEVICE_TYPE = 0x0054;
|
||||
pub const FILE_DEVICE_STORAGE_REPLICATION: DEVICE_TYPE = 0x0055;
|
||||
pub const FILE_DEVICE_TRUST_ENV: DEVICE_TYPE = 0x0056;
|
||||
pub const FILE_DEVICE_UCM: DEVICE_TYPE = 0x0057;
|
||||
pub const FILE_DEVICE_UCMTCPCI: DEVICE_TYPE = 0x0058;
|
||||
pub const FILE_DEVICE_PERSISTENT_MEMORY: DEVICE_TYPE = 0x0059;
|
||||
pub const FILE_DEVICE_NVDIMM: DEVICE_TYPE = 0x005a;
|
||||
pub const FILE_DEVICE_HOLOGRAPHIC: DEVICE_TYPE = 0x005b;
|
||||
pub const FILE_DEVICE_SDFXHCI: DEVICE_TYPE = 0x005c;
|
||||
pub const CTL_CODE = packed struct(ULONG) {
|
||||
Method: METHOD,
|
||||
Function: u12,
|
||||
Access: FILE_ACCESS,
|
||||
DeviceType: FILE_DEVICE,
|
||||
|
||||
/// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/buffer-descriptions-for-i-o-control-codes
|
||||
pub const TransferType = enum(u2) {
|
||||
METHOD_BUFFERED = 0,
|
||||
METHOD_IN_DIRECT = 1,
|
||||
METHOD_OUT_DIRECT = 2,
|
||||
METHOD_NEITHER = 3,
|
||||
pub const METHOD = enum(u2) {
|
||||
BUFFERED = 0,
|
||||
IN_DIRECT = 1,
|
||||
OUT_DIRECT = 2,
|
||||
NEITHER = 3,
|
||||
};
|
||||
|
||||
pub const FILE_ACCESS = packed struct(u2) {
|
||||
READ: bool = false,
|
||||
WRITE: bool = false,
|
||||
|
||||
pub const ANY: FILE_ACCESS = .{ .READ = false, .WRITE = false };
|
||||
pub const SPECIAL = ANY;
|
||||
};
|
||||
|
||||
pub const FILE_DEVICE = enum(u16) {
|
||||
BEEP = 0x00000001,
|
||||
CD_ROM = 0x00000002,
|
||||
CD_ROM_FILE_SYSTEM = 0x00000003,
|
||||
CONTROLLER = 0x00000004,
|
||||
DATALINK = 0x00000005,
|
||||
DFS = 0x00000006,
|
||||
DISK = 0x00000007,
|
||||
DISK_FILE_SYSTEM = 0x00000008,
|
||||
FILE_SYSTEM = 0x00000009,
|
||||
INPORT_PORT = 0x0000000a,
|
||||
KEYBOARD = 0x0000000b,
|
||||
MAILSLOT = 0x0000000c,
|
||||
MIDI_IN = 0x0000000d,
|
||||
MIDI_OUT = 0x0000000e,
|
||||
MOUSE = 0x0000000f,
|
||||
MULTI_UNC_PROVIDER = 0x00000010,
|
||||
NAMED_PIPE = 0x00000011,
|
||||
NETWORK = 0x00000012,
|
||||
NETWORK_BROWSER = 0x00000013,
|
||||
NETWORK_FILE_SYSTEM = 0x00000014,
|
||||
NULL = 0x00000015,
|
||||
PARALLEL_PORT = 0x00000016,
|
||||
PHYSICAL_NETCARD = 0x00000017,
|
||||
PRINTER = 0x00000018,
|
||||
SCANNER = 0x00000019,
|
||||
SERIAL_MOUSE_PORT = 0x0000001a,
|
||||
SERIAL_PORT = 0x0000001b,
|
||||
SCREEN = 0x0000001c,
|
||||
SOUND = 0x0000001d,
|
||||
STREAMS = 0x0000001e,
|
||||
TAPE = 0x0000001f,
|
||||
TAPE_FILE_SYSTEM = 0x00000020,
|
||||
TRANSPORT = 0x00000021,
|
||||
UNKNOWN = 0x00000022,
|
||||
VIDEO = 0x00000023,
|
||||
VIRTUAL_DISK = 0x00000024,
|
||||
WAVE_IN = 0x00000025,
|
||||
WAVE_OUT = 0x00000026,
|
||||
@"8042_PORT" = 0x00000027,
|
||||
NETWORK_REDIRECTOR = 0x00000028,
|
||||
BATTERY = 0x00000029,
|
||||
BUS_EXTENDER = 0x0000002a,
|
||||
MODEM = 0x0000002b,
|
||||
VDM = 0x0000002c,
|
||||
MASS_STORAGE = 0x0000002d,
|
||||
SMB = 0x0000002e,
|
||||
KS = 0x0000002f,
|
||||
CHANGER = 0x00000030,
|
||||
SMARTCARD = 0x00000031,
|
||||
ACPI = 0x00000032,
|
||||
DVD = 0x00000033,
|
||||
FULLSCREEN_VIDEO = 0x00000034,
|
||||
DFS_FILE_SYSTEM = 0x00000035,
|
||||
DFS_VOLUME = 0x00000036,
|
||||
SERENUM = 0x00000037,
|
||||
TERMSRV = 0x00000038,
|
||||
KSEC = 0x00000039,
|
||||
FIPS = 0x0000003A,
|
||||
INFINIBAND = 0x0000003B,
|
||||
VMBUS = 0x0000003E,
|
||||
CRYPT_PROVIDER = 0x0000003F,
|
||||
WPD = 0x00000040,
|
||||
BLUETOOTH = 0x00000041,
|
||||
MT_COMPOSITE = 0x00000042,
|
||||
MT_TRANSPORT = 0x00000043,
|
||||
BIOMETRIC = 0x00000044,
|
||||
PMI = 0x00000045,
|
||||
EHSTOR = 0x00000046,
|
||||
DEVAPI = 0x00000047,
|
||||
GPIO = 0x00000048,
|
||||
USBEX = 0x00000049,
|
||||
CONSOLE = 0x00000050,
|
||||
NFP = 0x00000051,
|
||||
SYSENV = 0x00000052,
|
||||
VIRTUAL_BLOCK = 0x00000053,
|
||||
POINT_OF_SERVICE = 0x00000054,
|
||||
STORAGE_REPLICATION = 0x00000055,
|
||||
TRUST_ENV = 0x00000056,
|
||||
UCM = 0x00000057,
|
||||
UCMTCPCI = 0x00000058,
|
||||
PERSISTENT_MEMORY = 0x00000059,
|
||||
NVDIMM = 0x0000005a,
|
||||
HOLOGRAPHIC = 0x0000005b,
|
||||
SDFXHCI = 0x0000005c,
|
||||
UCMUCSI = 0x0000005d,
|
||||
PRM = 0x0000005e,
|
||||
EVENT_COLLECTOR = 0x0000005f,
|
||||
USB4 = 0x00000060,
|
||||
SOUNDWIRE = 0x00000061,
|
||||
|
||||
MOUNTMGRCONTROLTYPE = 'm',
|
||||
|
||||
_,
|
||||
};
|
||||
};
|
||||
pub const IOCTL = struct {
|
||||
pub const MOUNTMGR = struct {
|
||||
pub const QUERY_POINTS: CTL_CODE = .{ .DeviceType = .MOUNTMGRCONTROLTYPE, .Function = 2, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const QUERY_DOS_VOLUME_PATH: CTL_CODE = .{ .DeviceType = .MOUNTMGRCONTROLTYPE, .Function = 12, .Method = .BUFFERED, .Access = .ANY };
|
||||
};
|
||||
};
|
||||
pub const FSCTL = struct {
|
||||
pub const SET_REPARSE_POINT: CTL_CODE = .{ .DeviceType = .FILE_SYSTEM, .Function = 41, .Method = .BUFFERED, .Access = .SPECIAL };
|
||||
pub const GET_REPARSE_POINT: CTL_CODE = .{ .DeviceType = .FILE_SYSTEM, .Function = 42, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const PIPE = struct {
|
||||
pub const ASSIGN_EVENT: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 0, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const DISCONNECT: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 1, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const LISTEN: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 2, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const PEEK: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 3, .Method = .BUFFERED, .Access = .{ .READ = true } };
|
||||
pub const QUERY_EVENT: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 4, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const TRANSCEIVE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 5, .Method = .NEITHER, .Access = .{ .READ = true, .WRITE = true } };
|
||||
pub const WAIT: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 6, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const IMPERSONATE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 7, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const SET_CLIENT_PROCESS: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 8, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const QUERY_CLIENT_PROCESS: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 9, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const GET_PIPE_ATTRIBUTE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 10, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const SET_PIPE_ATTRIBUTE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 11, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const GET_CONNECTION_ATTRIBUTE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 12, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const SET_CONNECTION_ATTRIBUTE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 13, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const GET_HANDLE_ATTRIBUTE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 14, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const SET_HANDLE_ATTRIBUTE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 15, .Method = .BUFFERED, .Access = .ANY };
|
||||
pub const FLUSH: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 16, .Method = .BUFFERED, .Access = .{ .WRITE = true } };
|
||||
|
||||
pub const INTERNAL_READ: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 2045, .Method = .BUFFERED, .Access = .{ .READ = true } };
|
||||
pub const INTERNAL_WRITE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 2046, .Method = .BUFFERED, .Access = .{ .WRITE = true } };
|
||||
pub const INTERNAL_TRANSCEIVE: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 2047, .Method = .NEITHER, .Access = .{ .READ = true, .WRITE = true } };
|
||||
pub const INTERNAL_READ_OVFLOW: CTL_CODE = .{ .DeviceType = .NAMED_PIPE, .Function = 2048, .Method = .BUFFERED, .Access = .{ .READ = true } };
|
||||
};
|
||||
};
|
||||
|
||||
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) |
|
||||
@intFromEnum(method);
|
||||
}
|
||||
pub const DEVICE_TYPE = packed struct(ULONG) {
|
||||
FileDevice: CTL_CODE.FILE_DEVICE,
|
||||
unused: u16 = 0,
|
||||
};
|
||||
|
||||
pub const INVALID_HANDLE_VALUE = @as(HANDLE, @ptrFromInt(maxInt(usize)));
|
||||
|
||||
|
|
@ -4466,14 +4596,14 @@ pub const EXCEPTION_DISPOSITION = i32;
|
|||
pub const EXCEPTION_ROUTINE = *const fn (
|
||||
ExceptionRecord: ?*EXCEPTION_RECORD,
|
||||
EstablisherFrame: PVOID,
|
||||
ContextRecord: *(Self.CONTEXT),
|
||||
ContextRecord: *(CONTEXT),
|
||||
DispatcherContext: PVOID,
|
||||
) callconv(.winapi) EXCEPTION_DISPOSITION;
|
||||
|
||||
pub const UNWIND_HISTORY_TABLE_SIZE = 12;
|
||||
pub const UNWIND_HISTORY_TABLE_ENTRY = extern struct {
|
||||
ImageBase: ULONG64,
|
||||
FunctionEntry: *Self.RUNTIME_FUNCTION,
|
||||
FunctionEntry: *RUNTIME_FUNCTION,
|
||||
};
|
||||
|
||||
pub const UNWIND_HISTORY_TABLE = extern struct {
|
||||
|
|
@ -4905,7 +5035,7 @@ pub fn FileInformationIterator(comptime FileInformationType: type) type {
|
|||
};
|
||||
}
|
||||
|
||||
pub const IO_APC_ROUTINE = *const fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.winapi) void;
|
||||
pub const IO_APC_ROUTINE = *const fn (?*anyopaque, *IO_STATUS_BLOCK, ULONG) callconv(.winapi) void;
|
||||
|
||||
pub const CURDIR = extern struct {
|
||||
DosPath: UNICODE_STRING,
|
||||
|
|
@ -5050,8 +5180,6 @@ pub const MOUNT_POINT_REPARSE_BUFFER = extern struct {
|
|||
PathBuffer: [1]WCHAR,
|
||||
};
|
||||
pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: ULONG = 16 * 1024;
|
||||
pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
|
||||
pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
|
||||
pub const IO_REPARSE_TAG_SYMLINK: ULONG = 0xa000000c;
|
||||
pub const IO_REPARSE_TAG_MOUNT_POINT: ULONG = 0xa0000003;
|
||||
pub const SYMLINK_FLAG_RELATIVE: ULONG = 0x1;
|
||||
|
|
@ -5059,8 +5187,6 @@ pub const SYMLINK_FLAG_RELATIVE: ULONG = 0x1;
|
|||
pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 0x1;
|
||||
pub const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD = 0x2;
|
||||
|
||||
pub const MOUNTMGRCONTROLTYPE = 0x0000006D;
|
||||
|
||||
pub const MOUNTMGR_MOUNT_POINT = extern struct {
|
||||
SymbolicLinkNameOffset: ULONG,
|
||||
SymbolicLinkNameLength: USHORT,
|
||||
|
|
@ -5077,7 +5203,6 @@ pub const MOUNTMGR_MOUNT_POINTS = extern struct {
|
|||
NumberOfMountPoints: ULONG,
|
||||
MountPoints: [1]MOUNTMGR_MOUNT_POINT,
|
||||
};
|
||||
pub const IOCTL_MOUNTMGR_QUERY_POINTS = CTL_CODE(MOUNTMGRCONTROLTYPE, 2, .METHOD_BUFFERED, FILE_ANY_ACCESS);
|
||||
|
||||
pub const MOUNTMGR_TARGET_NAME = extern struct {
|
||||
DeviceNameLength: USHORT,
|
||||
|
|
@ -5087,7 +5212,6 @@ pub const MOUNTMGR_VOLUME_PATHS = extern struct {
|
|||
MultiSzLength: ULONG,
|
||||
MultiSz: [1]WCHAR,
|
||||
};
|
||||
pub const IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH = CTL_CODE(MOUNTMGRCONTROLTYPE, 12, .METHOD_BUFFERED, FILE_ANY_ACCESS);
|
||||
|
||||
pub const OBJECT_INFORMATION_CLASS = enum(c_int) {
|
||||
ObjectBasicInformation = 0,
|
||||
|
|
|
|||
|
|
@ -1,136 +1,90 @@
|
|||
const std = @import("../../std.zig");
|
||||
const windows = std.os.windows;
|
||||
|
||||
const ACCESS_MASK = windows.ACCESS_MASK;
|
||||
const BOOL = windows.BOOL;
|
||||
const BOOLEAN = windows.BOOLEAN;
|
||||
const CONDITION_VARIABLE = windows.CONDITION_VARIABLE;
|
||||
const CONTEXT = windows.CONTEXT;
|
||||
const CRITICAL_SECTION = windows.CRITICAL_SECTION;
|
||||
const CTL_CODE = windows.CTL_CODE;
|
||||
const CURDIR = windows.CURDIR;
|
||||
const DWORD = windows.DWORD;
|
||||
const DWORD64 = windows.DWORD64;
|
||||
const ULONG = windows.ULONG;
|
||||
const ULONG_PTR = windows.ULONG_PTR;
|
||||
const NTSTATUS = windows.NTSTATUS;
|
||||
const WORD = windows.WORD;
|
||||
const HANDLE = windows.HANDLE;
|
||||
const ACCESS_MASK = windows.ACCESS_MASK;
|
||||
const IO_APC_ROUTINE = windows.IO_APC_ROUTINE;
|
||||
const BOOLEAN = windows.BOOLEAN;
|
||||
const OBJECT_ATTRIBUTES = windows.OBJECT_ATTRIBUTES;
|
||||
const PVOID = windows.PVOID;
|
||||
const IO_STATUS_BLOCK = windows.IO_STATUS_BLOCK;
|
||||
const LARGE_INTEGER = windows.LARGE_INTEGER;
|
||||
const OBJECT_INFORMATION_CLASS = windows.OBJECT_INFORMATION_CLASS;
|
||||
const EVENT_TYPE = windows.EVENT_TYPE;
|
||||
const EXCEPTION_ROUTINE = windows.EXCEPTION_ROUTINE;
|
||||
const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;
|
||||
const FILE_INFORMATION_CLASS = windows.FILE_INFORMATION_CLASS;
|
||||
const FS_INFORMATION_CLASS = windows.FS_INFORMATION_CLASS;
|
||||
const UNICODE_STRING = windows.UNICODE_STRING;
|
||||
const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;
|
||||
const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;
|
||||
const SIZE_T = windows.SIZE_T;
|
||||
const CURDIR = windows.CURDIR;
|
||||
const PCWSTR = windows.PCWSTR;
|
||||
const RTL_QUERY_REGISTRY_TABLE = windows.RTL_QUERY_REGISTRY_TABLE;
|
||||
const CONTEXT = windows.CONTEXT;
|
||||
const UNWIND_HISTORY_TABLE = windows.UNWIND_HISTORY_TABLE;
|
||||
const RUNTIME_FUNCTION = windows.RUNTIME_FUNCTION;
|
||||
const HANDLE = windows.HANDLE;
|
||||
const IO_APC_ROUTINE = windows.IO_APC_ROUTINE;
|
||||
const IO_STATUS_BLOCK = windows.IO_STATUS_BLOCK;
|
||||
const KNONVOLATILE_CONTEXT_POINTERS = windows.KNONVOLATILE_CONTEXT_POINTERS;
|
||||
const EXCEPTION_ROUTINE = windows.EXCEPTION_ROUTINE;
|
||||
const LARGE_INTEGER = windows.LARGE_INTEGER;
|
||||
const LONG = windows.LONG;
|
||||
const LPCVOID = windows.LPCVOID;
|
||||
const LPVOID = windows.LPVOID;
|
||||
const NTSTATUS = windows.NTSTATUS;
|
||||
const OBJECT_ATTRIBUTES = windows.OBJECT_ATTRIBUTES;
|
||||
const OBJECT_INFORMATION_CLASS = windows.OBJECT_INFORMATION_CLASS;
|
||||
const PCWSTR = windows.PCWSTR;
|
||||
const PROCESSINFOCLASS = windows.PROCESSINFOCLASS;
|
||||
const PVOID = windows.PVOID;
|
||||
const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;
|
||||
const RTL_QUERY_REGISTRY_TABLE = windows.RTL_QUERY_REGISTRY_TABLE;
|
||||
const RUNTIME_FUNCTION = windows.RUNTIME_FUNCTION;
|
||||
const SECTION_INHERIT = windows.SECTION_INHERIT;
|
||||
const SIZE_T = windows.SIZE_T;
|
||||
const SRWLOCK = windows.SRWLOCK;
|
||||
const SYSTEM_INFORMATION_CLASS = windows.SYSTEM_INFORMATION_CLASS;
|
||||
const THREADINFOCLASS = windows.THREADINFOCLASS;
|
||||
const PROCESSINFOCLASS = windows.PROCESSINFOCLASS;
|
||||
const LPVOID = windows.LPVOID;
|
||||
const LPCVOID = windows.LPCVOID;
|
||||
const SECTION_INHERIT = windows.SECTION_INHERIT;
|
||||
const ULONG = windows.ULONG;
|
||||
const ULONG_PTR = windows.ULONG_PTR;
|
||||
const UNICODE_STRING = windows.UNICODE_STRING;
|
||||
const UNWIND_HISTORY_TABLE = windows.UNWIND_HISTORY_TABLE;
|
||||
const VECTORED_EXCEPTION_HANDLER = windows.VECTORED_EXCEPTION_HANDLER;
|
||||
const CRITICAL_SECTION = windows.CRITICAL_SECTION;
|
||||
const SRWLOCK = windows.SRWLOCK;
|
||||
const CONDITION_VARIABLE = windows.CONDITION_VARIABLE;
|
||||
const WORD = windows.WORD;
|
||||
|
||||
// ddk/ntddk.h
|
||||
pub extern "ntdll" fn NtQueryInformationProcess(
|
||||
ProcessHandle: HANDLE,
|
||||
ProcessInformationClass: PROCESSINFOCLASS,
|
||||
ProcessInformation: *anyopaque,
|
||||
ProcessInformation: ?*anyopaque,
|
||||
ProcessInformationLength: ULONG,
|
||||
ReturnLength: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtQueryInformationThread(
|
||||
ThreadHandle: HANDLE,
|
||||
ThreadInformationClass: THREADINFOCLASS,
|
||||
ThreadInformation: *anyopaque,
|
||||
ThreadInformationLength: ULONG,
|
||||
ReturnLength: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtQuerySystemInformation(
|
||||
SystemInformationClass: SYSTEM_INFORMATION_CLASS,
|
||||
SystemInformation: PVOID,
|
||||
SystemInformationLength: ULONG,
|
||||
ReturnLength: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtSetInformationThread(
|
||||
ThreadHandle: HANDLE,
|
||||
ThreadInformationClass: THREADINFOCLASS,
|
||||
ThreadInformation: *const anyopaque,
|
||||
ThreadInformationLength: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlGetVersion(
|
||||
lpVersionInformation: *RTL_OSVERSIONINFOW,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn RtlCaptureStackBackTrace(
|
||||
FramesToSkip: DWORD,
|
||||
FramesToCapture: DWORD,
|
||||
BackTrace: **anyopaque,
|
||||
BackTraceHash: ?*DWORD,
|
||||
) callconv(.winapi) WORD;
|
||||
pub extern "ntdll" fn RtlCaptureContext(ContextRecord: *CONTEXT) callconv(.winapi) void;
|
||||
pub extern "ntdll" fn RtlLookupFunctionEntry(
|
||||
ControlPc: DWORD64,
|
||||
ImageBase: *DWORD64,
|
||||
HistoryTable: *UNWIND_HISTORY_TABLE,
|
||||
) callconv(.winapi) ?*RUNTIME_FUNCTION;
|
||||
pub extern "ntdll" fn RtlVirtualUnwind(
|
||||
HandlerType: DWORD,
|
||||
ImageBase: DWORD64,
|
||||
ControlPc: DWORD64,
|
||||
FunctionEntry: *RUNTIME_FUNCTION,
|
||||
|
||||
// ddk/ntifs.h
|
||||
pub extern "ntdll" fn RtlAllocateHeap(
|
||||
HeapHandle: HANDLE,
|
||||
Flags: ULONG,
|
||||
Size: SIZE_T,
|
||||
) callconv(.winapi) ?PVOID;
|
||||
pub extern "ntdll" fn RtlCaptureContext(
|
||||
ContextRecord: *CONTEXT,
|
||||
HandlerData: *?PVOID,
|
||||
EstablisherFrame: *DWORD64,
|
||||
ContextPointers: ?*KNONVOLATILE_CONTEXT_POINTERS,
|
||||
) callconv(.winapi) *EXCEPTION_ROUTINE;
|
||||
pub extern "ntdll" fn RtlGetSystemTimePrecise() callconv(.winapi) LARGE_INTEGER;
|
||||
pub extern "ntdll" fn NtQueryInformationFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FileInformation: *anyopaque,
|
||||
Length: ULONG,
|
||||
FileInformationClass: FILE_INFORMATION_CLASS,
|
||||
) callconv(.winapi) void;
|
||||
pub extern "ntdll" fn RtlCaptureStackBackTrace(
|
||||
FramesToSkip: ULONG,
|
||||
FramesToCapture: ULONG,
|
||||
BackTrace: **anyopaque,
|
||||
BackTraceHash: ?*ULONG,
|
||||
) callconv(.winapi) WORD;
|
||||
pub extern "ntdll" fn NtQueryObject(
|
||||
Handle: HANDLE,
|
||||
ObjectInformationClass: OBJECT_INFORMATION_CLASS,
|
||||
ObjectInformation: ?PVOID,
|
||||
ObjectInformationLength: ULONG,
|
||||
ReturnLength: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtSetInformationFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FileInformation: PVOID,
|
||||
Length: ULONG,
|
||||
FileInformationClass: FILE_INFORMATION_CLASS,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtQueryAttributesFile(
|
||||
ObjectAttributes: *OBJECT_ATTRIBUTES,
|
||||
FileAttributes: *FILE_BASIC_INFORMATION,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlQueryPerformanceCounter(PerformanceCounter: *LARGE_INTEGER) callconv(.winapi) BOOL;
|
||||
pub extern "ntdll" fn RtlQueryPerformanceFrequency(PerformanceFrequency: *LARGE_INTEGER) callconv(.winapi) BOOL;
|
||||
pub extern "ntdll" fn NtQueryPerformanceCounter(
|
||||
PerformanceCounter: *LARGE_INTEGER,
|
||||
PerformanceFrequency: ?*LARGE_INTEGER,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtCreateFile(
|
||||
FileHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: *OBJECT_ATTRIBUTES,
|
||||
ObjectAttributes: *const OBJECT_ATTRIBUTES,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
AllocationSize: ?*LARGE_INTEGER,
|
||||
AllocationSize: ?*const LARGE_INTEGER,
|
||||
FileAttributes: ULONG,
|
||||
ShareAccess: ULONG,
|
||||
CreateDisposition: ULONG,
|
||||
|
|
@ -138,38 +92,13 @@ pub extern "ntdll" fn NtCreateFile(
|
|||
EaBuffer: ?*anyopaque,
|
||||
EaLength: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtCreateSection(
|
||||
SectionHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: ?*OBJECT_ATTRIBUTES,
|
||||
MaximumSize: ?*LARGE_INTEGER,
|
||||
SectionPageProtection: ULONG,
|
||||
AllocationAttributes: ULONG,
|
||||
FileHandle: ?HANDLE,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtMapViewOfSection(
|
||||
SectionHandle: HANDLE,
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: *PVOID,
|
||||
ZeroBits: ?*ULONG,
|
||||
CommitSize: SIZE_T,
|
||||
SectionOffset: ?*LARGE_INTEGER,
|
||||
ViewSize: *SIZE_T,
|
||||
InheritDispostion: SECTION_INHERIT,
|
||||
AllocationType: ULONG,
|
||||
Win32Protect: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtUnmapViewOfSection(
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: PVOID,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtDeviceIoControlFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
ApcContext: ?*anyopaque,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
IoControlCode: ULONG,
|
||||
IoControlCode: CTL_CODE,
|
||||
InputBuffer: ?*const anyopaque,
|
||||
InputBufferLength: ULONG,
|
||||
OutputBuffer: ?PVOID,
|
||||
|
|
@ -181,31 +110,32 @@ pub extern "ntdll" fn NtFsControlFile(
|
|||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
ApcContext: ?*anyopaque,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FsControlCode: ULONG,
|
||||
FsControlCode: CTL_CODE,
|
||||
InputBuffer: ?*const anyopaque,
|
||||
InputBufferLength: ULONG,
|
||||
OutputBuffer: ?PVOID,
|
||||
OutputBufferLength: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtClose(Handle: HANDLE) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn RtlDosPathNameToNtPathName_U(
|
||||
DosPathName: [*:0]const u16,
|
||||
NtPathName: *UNICODE_STRING,
|
||||
NtFileNamePart: ?*?[*:0]const u16,
|
||||
DirectoryInfo: ?*CURDIR,
|
||||
) callconv(.winapi) BOOL;
|
||||
pub extern "ntdll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(.winapi) void;
|
||||
|
||||
/// Returns the number of bytes written to `Buffer`.
|
||||
/// If the returned count is larger than `BufferByteLength`, the buffer was too small.
|
||||
/// If the returned count is zero, an error occurred.
|
||||
pub extern "ntdll" fn RtlGetFullPathName_U(
|
||||
FileName: [*:0]const u16,
|
||||
BufferByteLength: ULONG,
|
||||
Buffer: [*]u16,
|
||||
ShortName: ?*[*:0]const u16,
|
||||
) callconv(.winapi) windows.ULONG;
|
||||
|
||||
pub extern "ntdll" fn NtLockFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
ApcContext: ?*anyopaque,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
ByteOffset: *const LARGE_INTEGER,
|
||||
Length: *const LARGE_INTEGER,
|
||||
Key: ?*const ULONG,
|
||||
FailImmediately: BOOLEAN,
|
||||
ExclusiveLock: BOOLEAN,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtOpenFile(
|
||||
FileHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: *const OBJECT_ATTRIBUTES,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
ShareAccess: ULONG,
|
||||
OpenOptions: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtQueryDirectoryFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
|
|
@ -216,24 +146,224 @@ pub extern "ntdll" fn NtQueryDirectoryFile(
|
|||
Length: ULONG,
|
||||
FileInformationClass: FILE_INFORMATION_CLASS,
|
||||
ReturnSingleEntry: BOOLEAN,
|
||||
FileName: ?*UNICODE_STRING,
|
||||
FileName: ?*const UNICODE_STRING,
|
||||
RestartScan: BOOLEAN,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtQueryInformationFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FileInformation: *anyopaque,
|
||||
Length: ULONG,
|
||||
FileInformationClass: FILE_INFORMATION_CLASS,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtQueryVolumeInformationFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FsInformation: *anyopaque,
|
||||
Length: ULONG,
|
||||
FsInformationClass: FS_INFORMATION_CLASS,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtReadFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
ApcContext: ?*anyopaque,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
Buffer: *anyopaque,
|
||||
Length: ULONG,
|
||||
ByteOffset: ?*const LARGE_INTEGER,
|
||||
Key: ?*const ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtSetInformationFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FileInformation: *const anyopaque,
|
||||
Length: ULONG,
|
||||
FileInformationClass: FILE_INFORMATION_CLASS,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtWriteFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
ApcContext: ?*anyopaque,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
Buffer: *const anyopaque,
|
||||
Length: ULONG,
|
||||
ByteOffset: ?*const LARGE_INTEGER,
|
||||
Key: ?*const ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtUnlockFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
ByteOffset: *const LARGE_INTEGER,
|
||||
Length: *const LARGE_INTEGER,
|
||||
Key: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtClose(
|
||||
Handle: HANDLE,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtAllocateVirtualMemory(
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: *PVOID,
|
||||
ZeroBits: ULONG_PTR,
|
||||
RegionSize: *SIZE_T,
|
||||
AllocationType: ULONG,
|
||||
PageProtection: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtFreeVirtualMemory(
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: *PVOID,
|
||||
RegionSize: *SIZE_T,
|
||||
FreeType: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtSetInformationThread(
|
||||
ThreadHandle: HANDLE,
|
||||
ThreadInformationClass: THREADINFOCLASS,
|
||||
ThreadInformation: *const anyopaque,
|
||||
ThreadInformationLength: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtCreateSection(
|
||||
SectionHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: ?*const OBJECT_ATTRIBUTES,
|
||||
MaximumSize: ?*const LARGE_INTEGER,
|
||||
SectionPageProtection: ULONG,
|
||||
AllocationAttributes: ULONG,
|
||||
FileHandle: ?HANDLE,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
// ddk/wdm.h
|
||||
pub extern "ntdll" fn RtlFreeUnicodeString(
|
||||
UnicodeString: *UNICODE_STRING,
|
||||
) callconv(.winapi) void;
|
||||
pub extern "ntdll" fn RtlEqualUnicodeString(
|
||||
String1: *const UNICODE_STRING,
|
||||
String2: *const UNICODE_STRING,
|
||||
CaseInSensitive: BOOLEAN,
|
||||
) callconv(.winapi) BOOLEAN;
|
||||
pub extern "ntdll" fn RtlQueryRegistryValues(
|
||||
RelativeTo: ULONG,
|
||||
Path: PCWSTR,
|
||||
QueryTable: [*]RTL_QUERY_REGISTRY_TABLE,
|
||||
Context: ?*const anyopaque,
|
||||
Environment: ?*const anyopaque,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn RtlUpcaseUnicodeChar(
|
||||
SourceCharacter: u16,
|
||||
) callconv(.winapi) u16;
|
||||
|
||||
// winnt.h
|
||||
pub extern "ntdll" fn RtlLookupFunctionEntry(
|
||||
ControlPc: usize,
|
||||
ImageBase: *usize,
|
||||
HistoryTable: *UNWIND_HISTORY_TABLE,
|
||||
) callconv(.winapi) ?*RUNTIME_FUNCTION;
|
||||
pub extern "ntdll" fn RtlVirtualUnwind(
|
||||
HandlerType: DWORD,
|
||||
ImageBase: usize,
|
||||
ControlPc: usize,
|
||||
FunctionEntry: *RUNTIME_FUNCTION,
|
||||
ContextRecord: *CONTEXT,
|
||||
HandlerData: *?PVOID,
|
||||
EstablisherFrame: *usize,
|
||||
ContextPointers: ?*KNONVOLATILE_CONTEXT_POINTERS,
|
||||
) callconv(.winapi) *EXCEPTION_ROUTINE;
|
||||
|
||||
// winternl.h
|
||||
pub extern "ntdll" fn NtWaitForSingleObject(
|
||||
Handle: HANDLE,
|
||||
Alertable: BOOLEAN,
|
||||
Timeout: ?*const LARGE_INTEGER,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtQueryInformationThread(
|
||||
ThreadHandle: HANDLE,
|
||||
ThreadInformationClass: THREADINFOCLASS,
|
||||
ThreadInformation: *anyopaque,
|
||||
ThreadInformationLength: ULONG,
|
||||
ReturnLength: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtQuerySystemInformation(
|
||||
SystemInformationClass: SYSTEM_INFORMATION_CLASS,
|
||||
SystemInformation: PVOID,
|
||||
SystemInformationLength: ULONG,
|
||||
ReturnLength: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn RtlDosPathNameToNtPathName_U(
|
||||
DosPathName: [*:0]const u16,
|
||||
NtPathName: *UNICODE_STRING,
|
||||
NtFileNamePart: ?*?[*:0]const u16,
|
||||
DirectoryInfo: ?*CURDIR,
|
||||
) callconv(.winapi) BOOL;
|
||||
|
||||
pub extern "ntdll" fn RtlGetSystemTimePrecise() callconv(.winapi) LARGE_INTEGER;
|
||||
|
||||
pub extern "ntdll" fn NtQueryAttributesFile(
|
||||
ObjectAttributes: *const OBJECT_ATTRIBUTES,
|
||||
FileAttributes: *FILE_BASIC_INFORMATION,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlQueryPerformanceCounter(
|
||||
PerformanceCounter: *LARGE_INTEGER,
|
||||
) callconv(.winapi) BOOL;
|
||||
pub extern "ntdll" fn RtlQueryPerformanceFrequency(
|
||||
PerformanceFrequency: *LARGE_INTEGER,
|
||||
) callconv(.winapi) BOOL;
|
||||
pub extern "ntdll" fn NtQueryPerformanceCounter(
|
||||
PerformanceCounter: *LARGE_INTEGER,
|
||||
PerformanceFrequency: ?*LARGE_INTEGER,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtMapViewOfSection(
|
||||
SectionHandle: HANDLE,
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: ?*PVOID,
|
||||
ZeroBits: ?*const ULONG,
|
||||
CommitSize: SIZE_T,
|
||||
SectionOffset: ?*LARGE_INTEGER,
|
||||
ViewSize: *SIZE_T,
|
||||
InheritDispostion: SECTION_INHERIT,
|
||||
AllocationType: ULONG,
|
||||
Win32Protect: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtUnmapViewOfSection(
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: PVOID,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
/// Returns the number of bytes written to `Buffer`.
|
||||
/// If the returned count is larger than `BufferByteLength`, the buffer was too small.
|
||||
/// If the returned count is zero, an error occurred.
|
||||
pub extern "ntdll" fn RtlGetFullPathName_U(
|
||||
FileName: [*:0]const u16,
|
||||
BufferByteLength: ULONG,
|
||||
Buffer: [*]u16,
|
||||
ShortName: ?*[*:0]const u16,
|
||||
) callconv(.winapi) ULONG;
|
||||
|
||||
pub extern "ntdll" fn NtCreateEvent(
|
||||
EventHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: ?*const OBJECT_ATTRIBUTES,
|
||||
EventType: EVENT_TYPE,
|
||||
InitialState: BOOLEAN,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
pub extern "ntdll" fn NtSetEvent(
|
||||
EventHandle: HANDLE,
|
||||
PreviousState: ?*LONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtCreateKeyedEvent(
|
||||
KeyedEventHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: ?PVOID,
|
||||
ObjectAttributes: ?*const OBJECT_ATTRIBUTES,
|
||||
Flags: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtReleaseKeyedEvent(
|
||||
EventHandle: ?HANDLE,
|
||||
Key: ?*const anyopaque,
|
||||
Alertable: BOOLEAN,
|
||||
Timeout: ?*const LARGE_INTEGER,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtWaitForKeyedEvent(
|
||||
EventHandle: ?HANDLE,
|
||||
Key: ?*const anyopaque,
|
||||
|
|
@ -243,22 +373,6 @@ pub extern "ntdll" fn NtWaitForKeyedEvent(
|
|||
|
||||
pub extern "ntdll" fn RtlSetCurrentDirectory_U(PathName: *UNICODE_STRING) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtQueryObject(
|
||||
Handle: HANDLE,
|
||||
ObjectInformationClass: OBJECT_INFORMATION_CLASS,
|
||||
ObjectInformation: PVOID,
|
||||
ObjectInformationLength: ULONG,
|
||||
ReturnLength: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtQueryVolumeInformationFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FsInformation: *anyopaque,
|
||||
Length: ULONG,
|
||||
FsInformationClass: FS_INFORMATION_CLASS,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlWakeAddressAll(
|
||||
Address: ?*const anyopaque,
|
||||
) callconv(.winapi) void;
|
||||
|
|
@ -274,49 +388,10 @@ pub extern "ntdll" fn RtlWaitOnAddress(
|
|||
Timeout: ?*const LARGE_INTEGER,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlEqualUnicodeString(
|
||||
String1: *const UNICODE_STRING,
|
||||
String2: *const UNICODE_STRING,
|
||||
CaseInSensitive: BOOLEAN,
|
||||
) callconv(.winapi) BOOLEAN;
|
||||
|
||||
pub extern "ntdll" fn RtlUpcaseUnicodeChar(
|
||||
SourceCharacter: u16,
|
||||
) callconv(.winapi) u16;
|
||||
|
||||
pub extern "ntdll" fn NtLockFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?*IO_APC_ROUTINE,
|
||||
ApcContext: ?*anyopaque,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
ByteOffset: *const LARGE_INTEGER,
|
||||
Length: *const LARGE_INTEGER,
|
||||
Key: ?*ULONG,
|
||||
FailImmediately: BOOLEAN,
|
||||
ExclusiveLock: BOOLEAN,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtUnlockFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
ByteOffset: *const LARGE_INTEGER,
|
||||
Length: *const LARGE_INTEGER,
|
||||
Key: ?*ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtOpenKey(
|
||||
KeyHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: OBJECT_ATTRIBUTES,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlQueryRegistryValues(
|
||||
RelativeTo: ULONG,
|
||||
Path: PCWSTR,
|
||||
QueryTable: [*]RTL_QUERY_REGISTRY_TABLE,
|
||||
Context: ?*anyopaque,
|
||||
Environment: ?*anyopaque,
|
||||
ObjectAttributes: *const OBJECT_ATTRIBUTES,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtReadVirtualMemory(
|
||||
|
|
@ -350,7 +425,7 @@ pub extern "ntdll" fn RtlExitUserProcess(
|
|||
pub extern "ntdll" fn NtCreateNamedPipeFile(
|
||||
FileHandle: *HANDLE,
|
||||
DesiredAccess: ULONG,
|
||||
ObjectAttributes: *OBJECT_ATTRIBUTES,
|
||||
ObjectAttributes: *const OBJECT_ATTRIBUTES,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
ShareAccess: ULONG,
|
||||
CreateDisposition: ULONG,
|
||||
|
|
@ -361,23 +436,7 @@ pub extern "ntdll" fn NtCreateNamedPipeFile(
|
|||
MaximumInstances: ULONG,
|
||||
InboundQuota: ULONG,
|
||||
OutboundQuota: ULONG,
|
||||
DefaultTimeout: *LARGE_INTEGER,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtAllocateVirtualMemory(
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: ?*PVOID,
|
||||
ZeroBits: ULONG_PTR,
|
||||
RegionSize: ?*SIZE_T,
|
||||
AllocationType: ULONG,
|
||||
PageProtection: ULONG,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtFreeVirtualMemory(
|
||||
ProcessHandle: HANDLE,
|
||||
BaseAddress: ?*PVOID,
|
||||
RegionSize: *SIZE_T,
|
||||
FreeType: ULONG,
|
||||
DefaultTimeout: ?*const LARGE_INTEGER,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlAddVectoredExceptionHandler(
|
||||
|
|
@ -424,8 +483,11 @@ pub extern "ntdll" fn RtlReAllocateHeap(
|
|||
BaseAddress: PVOID,
|
||||
Size: SIZE_T,
|
||||
) callconv(.winapi) ?PVOID;
|
||||
pub extern "ntdll" fn RtlAllocateHeap(
|
||||
HeapHandle: HANDLE,
|
||||
Flags: ULONG,
|
||||
Size: SIZE_T,
|
||||
) callconv(.winapi) ?PVOID;
|
||||
|
||||
pub extern "ntdll" fn NtQueueApcThread(
|
||||
ThreadHandle: HANDLE,
|
||||
ApcRoutine: IO_APC_ROUTINE,
|
||||
ApcArgument1: ?*anyopaque,
|
||||
ApcArgument2: ?*anyopaque,
|
||||
ApcArgument3: ?*anyopaque,
|
||||
) callconv(.winapi) NTSTATUS;
|
||||
|
|
|
|||
|
|
@ -264,6 +264,99 @@ pub const LOG = struct {
|
|||
pub const DEBUG = 7;
|
||||
};
|
||||
|
||||
pub const key_t = switch (native_os) {
|
||||
.linux, .illumos => enum(c_int) {
|
||||
IPC_PRIVATE = 0,
|
||||
_,
|
||||
},
|
||||
.freebsd, .netbsd, .openbsd, .dragonfly => enum(c_long) {
|
||||
IPC_PRIVATE = 0,
|
||||
_,
|
||||
},
|
||||
.haiku,
|
||||
.driverkit,
|
||||
.ios,
|
||||
.maccatalyst,
|
||||
.macos,
|
||||
.tvos,
|
||||
.visionos,
|
||||
.watchos,
|
||||
=> enum(i32) {
|
||||
IPC_PRIVATE = 0,
|
||||
_,
|
||||
},
|
||||
else => unreachable,
|
||||
};
|
||||
pub const SETVAL = switch (native_os) {
|
||||
.linux => 16,
|
||||
|
||||
.illumos,
|
||||
.haiku,
|
||||
|
||||
.freebsd,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
.dragonfly,
|
||||
|
||||
.driverkit,
|
||||
.ios,
|
||||
.maccatalyst,
|
||||
.macos,
|
||||
.tvos,
|
||||
.visionos,
|
||||
.watchos,
|
||||
=> 8,
|
||||
|
||||
else => unreachable,
|
||||
};
|
||||
pub const SEM_UNDO = switch (native_os) {
|
||||
.linux,
|
||||
.illumos,
|
||||
|
||||
.freebsd,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
.dragonfly,
|
||||
|
||||
.driverkit,
|
||||
.ios,
|
||||
.maccatalyst,
|
||||
.macos,
|
||||
.tvos,
|
||||
.visionos,
|
||||
.watchos,
|
||||
=> 0x1000,
|
||||
|
||||
.haiku => 10,
|
||||
|
||||
else => unreachable,
|
||||
};
|
||||
pub const sembuf = switch (native_os) {
|
||||
.linux,
|
||||
.illumos,
|
||||
.haiku,
|
||||
|
||||
.freebsd,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
.dragonfly,
|
||||
|
||||
.driverkit,
|
||||
.ios,
|
||||
.maccatalyst,
|
||||
.macos,
|
||||
.tvos,
|
||||
.visionos,
|
||||
.watchos,
|
||||
=> extern struct {
|
||||
sem_num: c_ushort,
|
||||
sem_op: c_short,
|
||||
sem_flg: c_short,
|
||||
},
|
||||
|
||||
else => unreachable,
|
||||
};
|
||||
|
||||
pub const socket_t = if (native_os == .windows) windows.ws2_32.SOCKET else fd_t;
|
||||
|
||||
/// Obtains errno from the return value of a system function call.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue