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
|
use std::os::windows::io::AsRawHandle;
use winioctl::{ioctl_none, ioctl_read, ioctl_write, DeviceType, Error};
const IOCTL_PRINT_VALUE: u32 = 0x800;
const IOCTL_READ_VALUE: u32 = 0x801;
const IOCTL_WRITE_VALUE: u32 = 0x802;
ioctl_none!(ioctl_print_value, DeviceType::Unknown, IOCTL_PRINT_VALUE);
ioctl_read!(ioctl_read_value, DeviceType::Unknown, IOCTL_READ_VALUE, i32);
ioctl_write!(
ioctl_write_value,
DeviceType::Unknown,
IOCTL_WRITE_VALUE,
i32
);
fn main() -> Result<(), Error> {
let file = std::fs::OpenOptions::new()
.read(true)
.write(true)
.create(false)
.open("\\??\\Example")?;
let mut value = 0;
unsafe {
ioctl_read_value(file.as_raw_handle(), &mut value)?;
}
value += 1;
unsafe {
ioctl_write_value(file.as_raw_handle(), &value)?;
}
unsafe {
ioctl_print_value(file.as_raw_handle())?;
}
Ok(())
}
|