Skip to main content

azathoth_core/os/windows/nt/
structs.rs

1#![allow(non_snake_case, non_camel_case_types)]
2
3use core::ptr::null_mut;
4use crate::os::windows::types::HANDLE;
5use crate::os::windows::peb::structs::UNICODE_STRING;
6
7/// Windows `OBJECT_ATTRIBUTES` - passed to NT APIs to name objects and set security.
8#[repr(C)]
9pub struct ObjectAttributes {
10    pub length: u32,
11    pub root_directory: HANDLE,
12    pub object_name: *mut UNICODE_STRING,
13    pub attributes: u32,
14    pub security_descriptor: HANDLE,
15    pub security_quality_of_service: HANDLE,
16}
17
18impl ObjectAttributes {
19    pub fn empty() -> Self {
20        Self {
21            length: size_of::<Self>() as u32,
22            root_directory: null_mut(),
23            object_name: null_mut(),
24            attributes: 0,
25            security_descriptor: null_mut(),
26            security_quality_of_service: null_mut(),
27        }
28    }
29
30    pub fn with_attributes(attributes: u32, object_name: *mut UNICODE_STRING) -> Self {
31        Self {
32            length: size_of::<Self>() as u32,
33            root_directory: null_mut(),
34            object_name,
35            attributes,
36            security_descriptor: null_mut(),
37            security_quality_of_service: null_mut(),
38        }
39    }
40}
41
42/// Windows `IO_STATUS_BLOCK` - returned by NT I/O functions.
43#[repr(C)]
44pub struct IoStatusBlock {
45    pub status: i32,
46    pub information: usize,
47}
48
49impl IoStatusBlock {
50    pub fn empty() -> Self {
51        Self { status: 0, information: 0 }
52    }
53}
54
55/// Windows `LARGE_INTEGER` - 64-bit signed integer as two 32-bit halves.
56#[repr(C)]
57pub struct LargeInteger {
58    pub low: u32,
59    pub high: i32,
60}
61
62
63#[repr(C)]
64pub struct ClientId {
65    pub unique_process: usize,
66    pub unique_thread: usize,
67}
68
69impl ClientId {
70    pub fn for_pid(pid: u32) -> Self {
71        Self {
72            unique_process: pid as usize,
73            unique_thread: 0,
74        }
75    }
76}