diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-27 10:54:25 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-27 11:44:15 +0100 |
commit | 2ee3a99690d5e795309cd5199a9a3ca62221b14d (patch) | |
tree | abf2547387ca77a23caf0c11d93aad7cd39e08b1 /README.md | |
parent | Kill some more Camels (diff) | |
download | wintun-2ee3a99690d5e795309cd5199a9a3ca62221b14d.tar.xz wintun-2ee3a99690d5e795309cd5199a9a3ca62221b14d.zip |
Add basic usage info
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -29,3 +29,47 @@ If you possess an EV certificate for kernel mode code signing you should switch Modify the `<CrossCertificateFile>` to contain the full path to the cross-signing certificate of CA that issued your certificate. You should be able to find its `.crt` file in `C:\Program Files (x86)\Windows Kits\10\CrossCertificates`. Note that the `$(WDKContentRoot)` expands to `C:\Program Files (x86)\Windows Kits\10\`. If you already have `wintun.vcxproj.user` file, just add the `<PropertyGroup>` section. + +## Usage + +After loading the driver and creating a network interface the typical way using [SetupAPI](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/setupapi), open `\\.\Device\WINTUN%d` as Local System, where `%d` is the [LUID](https://docs.microsoft.com/en-us/windows/desktop/api/ifdef/ns-ifdef-_net_luid_lh) of the network device. You may then [`ReadFile`](https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-readfile) and [`WriteFile`](https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-writefile) bundles of packets of the following format: + +``` ++------------------------------+ +| size_0 | +| 4 bytes, native endian | ++------------------------------+ +| | +| padding | +| 12 bytes, all zero | +| | ++------------------------------+ +| | +| packet_0 | +| size_0 bytes | +| | +~ ~ +| | ++------------------------------+ +| padding | +| 16-((4+size_0)&15) bytes, | +| all zero | ++------------------------------+ +| size_1 | +| 4 bytes, native endian | ++------------------------------+ +| | +| padding | +| 12 bytes, all zero | +| | ++------------------------------+ +| | +| packet_1 | +| size_1 bytes | +| | +~ ~ +``` + +Each packet segment should contain a layer 3 IPv4 or IPv6 packet. Up to 256 packets may be read or written during each call to `ReadFile` or `WriteFile`. + +It is advisable to use [overlapped I/O](https://docs.microsoft.com/en-us/windows/desktop/sync/synchronization-and-overlapped-input-and-output) for this. If using blocking I/O instead, it may be desirable to open separate handles for reading and writing. |