1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Kernel-Mode Types.

use ::KIRQL;


// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
// more optimization opportunities around it recognizing things like
// malloc/free.
#[repr(u8)]
#[doc(hidden)]
pub enum km_void {
    // Two dummy variants so the #[repr] attribute can be used.
    #[doc(hidden)]
    __variant1,
    #[doc(hidden)]
    __variant2,
}

pub type VOID = km_void;
pub type PVOID = *mut VOID;
pub type PCVOID = *const VOID;


pub type PETHREAD = PVOID;
pub type PIO_APC_ROUTINE = Option<extern "system" fn (ApcContext: PCVOID, IoStatusBlock: *const IO_STATUS_BLOCK, Reserved: u32)>;


extern "system"
{
	pub fn KeGetCurrentIrql() -> KIRQL;
	pub fn KeRaiseIrqlToDpcLevel() -> KIRQL;
	pub fn KfLowerIrql(NewIrql: KIRQL) -> KIRQL;
	pub fn KfRaiseIrql(NewIrql: KIRQL) -> KIRQL;
}


/// Doubly linked list structure.
#[repr(C)]
pub struct LIST_ENTRY
{
	pub next: *mut LIST_ENTRY,
	pub prev: *mut LIST_ENTRY,
}

/// Spin Lock.
#[repr(C)]
pub struct KSPIN_LOCK
{
	pub lock: usize,
}

/// Common dispatcher object header.
#[repr(C)]
pub struct DISPATCHER_HEADER
{
	pub Type: u8,
	pub Absolute: u8,
	pub Size: u8,
	pub Inserted: u8,
	pub SignalState: i32,
	pub WaitListHead: LIST_ENTRY,
}

/// An I/O status block.
#[repr(C)]
pub struct IO_STATUS_BLOCK
{
	pub Status: ::NTSTATUS,
	pub Information: usize,
}

pub type PIO_STATUS_BLOCK = *mut IO_STATUS_BLOCK;


/// Processor modes.
#[repr(C)]
pub enum KPROCESSOR_MODE
{
	KernelMode,
	UserMode,
}

/// I/O Request priority.
pub mod IO_PRIORITY {
	/// I/O Request priority type.
	pub type KPRIORITY_BOOST = u8;

	pub const IO_NO_INCREMENT: KPRIORITY_BOOST = 0;
	pub const IO_DISK_INCREMENT: KPRIORITY_BOOST = 1;
	pub const EVENT_INCREMENT: KPRIORITY_BOOST = 1;
}