Skip to content

Commit

Permalink
QueryObjectName: Add error union
Browse files Browse the repository at this point in the history
  • Loading branch information
The-King-of-Toasters committed Apr 20, 2024
1 parent dddddcf commit 9d7b040
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/std/os/windows.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,14 @@ pub fn SetFilePointerEx_CURRENT_get(handle: HANDLE) SetFilePointerError!u64 {
return @as(u64, @bitCast(result));
}

pub fn QueryObjectName(handle: HANDLE, out_buffer: []u16) ![]u16 {
pub const QueryObjectNameError = error{
AccessDenied,
InvalidHandle,
NameTooLong,
Unexpected,
};

pub fn QueryObjectName(handle: HANDLE, out_buffer: []u16) QueryObjectNameError![]u16 {
const out_buffer_aligned = mem.alignInSlice(out_buffer, @alignOf(OBJECT_NAME_INFORMATION)) orelse return error.NameTooLong;

const info = @as(*OBJECT_NAME_INFORMATION, @ptrCast(out_buffer_aligned));
Expand Down

0 comments on commit 9d7b040

Please sign in to comment.