blob: 5c44e5d3e6f1983d597b89664bfddc58df15ff67 (
plain) (
blame)
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
|
## Windows Kernel-Mode Drivers written in Rust
This library is just a proof-of-concept of the windows kernel-mode drivers, which can be written in Rust programming language.
It contains the types, constants and bindings for the [Windows Driver Kit](https://en.wikipedia.org/wiki/Windows_Driver_Kit)
with target OS starting from Windows XP (x86/x64).
### Getting started
To compile you need the following:
* Nightly Rust with MSVC ABI starting from 2016-04-12 (?), which supports "[is-like-msvc](https://github.com/rust-lang/rust/pull/32823)" target flavor.
* MSVC itself, either VS 2015 or just MSVC Build Tools.
* Rust environment for the Windows drivers: [kmd-env-rs](https://github.com/pravic/kmd-env-rs).
As workaround you can compile drivers as `#[crate_type="staticlib"]` and link them manually (see *examples/03.urandom/build.cmd*).
Setting up:
```
git clone https://github.com/pravic/kmd-env-rs .
git submodule init
git submodule update --recursive
```
[Set](https://github.com/rust-lang-nursery/multirust-rs#directory-overrides) the nightly-msvc Rust toolchain for this repository:
`rustup override add nightly-i686-msvc`
Try to compile example:
```
cd km\examples\01.minimal\
cargo build --release
```
By default, it compiles to x86 mode.
If you need x64, either change `kmd-env-rs/.cargo/config` as following:
```
[build]
target = "x86_64-sys-windows-msvc"
...
```
or use [RUST_TARGET_PATH](https://github.com/rust-lang/rfcs/blob/master/text/0131-target-specification.md):
```
set RUST_TARGET_PATH=C:/path/to/kmd-env-rs/.cargo`
cargo build --release --target i686-sys-windows-msvc
cargo build --release --target x86_64-sys-windows-msvc
```
If linker fails with error "*cannot open input file 'ntoskrnl.lib'*",
open `kmd-env-rs/.cargo/config` file and replace `../../../` with the full path to the "*kmd-env-rs*" directory.
### Examples
See [examples](https://github.com/pravic/winapi-kmd-rs/tree/master/examples) folder with a driver samples and screenshots.
### [Reference documentation](http://pravic.github.io/winapi-kmd-rs/).
#### Acknowledges
In memory of [Four-F](https://web.archive.org/web/20130530073702/http://www.freewebs.com/four-f/) - the author of tutorials about kernel mode drivers
development in assembly language (2002-2005).
|