|
| 1 | +# Introduction |
| 2 | + |
| 3 | +This library is derived from https://github.com/not-matthias/kernel-driver-with-rust. |
| 4 | +You can also check https://not-matthias.github.io/kernel-driver-with-rust/. |
| 5 | + |
| 6 | +I am not a rust expert nor I am a windows kernel expert, don't expect high quality. |
| 7 | +This is just a toy project. |
| 8 | + |
| 9 | +# Packages |
| 10 | + |
| 11 | +- `windows-kernel-common-sys` library is providing kernel types (`ntifs.h` and its transitive dependencies). |
| 12 | +- `windows-kernel-ntoskrnl-sys` is providing (a lot of) kernel functions (`ntfis.h` and its transitive dependencies). |
| 13 | +- `windows-kernel-cng-sys` is providing [BCrypt](https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/) bindings. |
| 14 | +- `windows-kernel-netio-sys` is providing [Winsock](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/) bindings. |
| 15 | +- `windows-kernel-winsock` is a high level wrapper of [Winsock], providing rust abstractions over the raw api. |
| 16 | + |
| 17 | +- `windows-kernel-winsock-example` is a kernel driver that use the `winsock` library to call [httpbin](http://httpbin.org/#/Dynamic_data/get_range__numbytes_). |
| 18 | + |
| 19 | +# Building and running the winsock example |
| 20 | + |
| 21 | +## Prerequisite |
| 22 | + |
| 23 | +Every package should be available through with the `Visual Studio Installer` |
| 24 | + |
| 25 | +- Microsoft Visual Studio |
| 26 | +- [Windows Driver Kit](https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) |
| 27 | +- LLVM (clang) |
| 28 | +- cargo (and [cargo-make](https://github.com/sagiegurari/cargo-make#installation)) |
| 29 | + |
| 30 | +## Compiling |
| 31 | + |
| 32 | +- `cd windows-kernel-winsock-example` |
| 33 | +- `cargo make sign` |
| 34 | + |
| 35 | +The command should generate a signed driver, located under `target\x86_64-pc-windows-msvc\debug\windows_kernel_winsock_example.sys`. |
| 36 | + |
| 37 | +## Running |
| 38 | + |
| 39 | +Go in your win10 VM. |
| 40 | +Open [Dbgview](https://docs.microsoft.com/en-us/sysinternals/downloads/debugview) and enable kernel logging. |
| 41 | +Open a terminal as admin. |
| 42 | + |
| 43 | +- *if not already existing* `sc create windows_kernel_winsock_example binPath="absolute path to windows_kernel_winsock_example.sys" type=kernel` |
| 44 | +- `sc start windows_kernel_winsock_example` |
| 45 | +- `sc stop windows_kernel_winsock_example` |
| 46 | + |
| 47 | +The driver should produce something like: |
| 48 | + |
| 49 | + |
| 50 | + |
0 commit comments