diff --git a/.gitignore b/.gitignore index b59ae1f..8e86698 100644 --- a/.gitignore +++ b/.gitignore @@ -9,10 +9,9 @@ /x64/Debug # Static Driver Verifier Output -/runsdvui.cmd /sdv -/SDV-default.xml -/sdv-user.sdv /smvbuild.log -/smvexecute-*.log /smvstats.txt + +# Driver Verification Log +/wintun.DVL.XML diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..66b04e2 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +# +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2018-2019 WireGuard LLC. All Rights Reserved. +# + +!IFNDEF CFG +CFG=Release +!ENDIF +!IFNDEF PLAT +PLAT=x64 +!ENDIF +!IF "$(PLAT)" == "Win32" +OUTPUT_DIR=$(CFG) +!ELSE +OUTPUT_DIR=$(PLAT)\$(CFG) +!ENDIF +MSBUILD_FLAGS=/p:Configuration="$(CFG)" /p:Platform="$(PLAT)" /m /v:minimal /nologo + +build :: + msbuild.exe "wintun.vcxproj" /t:Build $(MSBUILD_FLAGS) + +clean :: + msbuild.exe "wintun.vcxproj" /t:Clean $(MSBUILD_FLAGS) + +!IF "$(CFG)" == "Release" + +dvl :: "wintun.DVL.XML" + +clean :: + msbuild.exe "wintun.vcxproj" /t:sdv /p:Inputs="/clean" $(MSBUILD_FLAGS) + -if exist "wintun.DVL.XML" del /f /q "wintun.DVL.XML" + -if exist "smvstats.txt" del /f /q "smvstats.txt" + +"sdv\SDV.DVL.xml" "$(OUTPUT_DIR)\vc.nativecodeanalysis.all.xml" : + msbuild.exe "wintun.vcxproj" /t:sdv /p:Inputs="/check:*" $(MSBUILD_FLAGS) + +"wintun.DVL.XML" : "sdv\SDV.DVL.xml" "$(OUTPUT_DIR)\vc.nativecodeanalysis.all.xml" + msbuild.exe "wintun.vcxproj" /t:dvl $(MSBUILD_FLAGS) + +!ENDIF diff --git a/README.md b/README.md index fe9d0bc..88ce3c5 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,45 @@ Modify the `` to contain the full path to the cross-signin If you already have `wintun.vcxproj.user` file, just add the `` section. + +## Building from Command Line + +Open _Developer Command Prompt for VS 2017_ and use `nmake` command: + +``` +nmake [] [CFG=] [PLAT=] +``` + +### Targets + +`build` + Builds the driver. This is the default target. + +`clean` + Deletes all intermediate and output files. + +`dvl` + Runs Static Driver Verifier, which includes a clean driver build, and creates a Driver Verification Log in `wintun.DVL.XML` file. Release configurations only. When you are ready to test your driver using the Windows Hardware Certification Kit (HCK), you need to copy the `wintun.DVL.XML` file to the `%SystemDrive%\DVL` directory on the test computer. + +The driver output folder is: +| Platform and Configuration | Folder | +| -------------------------- | -------------------- | +| x86 Debug | `Debug\wintun` | +| x86 Release | `Release\wintun` | +| AMD64 Debug | `x64\Debug\wintun` | +| AMD64 Release | `x64\Release\wintun` | + +### Properties + +Properties may be defined as environment variables, or specified on the `nmake` command line. + +`CFG` + Specifies configuration to build or clean. May be `Debug` or `Release` (default). + +`PLAT` + Specifies driver platform to build. May be `Win32` or `x64` (default). + + ## 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) index (`NetLuidIndex` member) 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: diff --git a/wintun.vcxproj b/wintun.vcxproj index acafbc2..448d30d 100644 --- a/wintun.vcxproj +++ b/wintun.vcxproj @@ -85,21 +85,25 @@ true $(WDKContentRoot)CodeAnalysis\DriverMustFixRules.ruleset + $(ConfigurationName)\ $(ConfigurationName)\ true AllRules.ruleset + $(ConfigurationName)\ $(ConfigurationName)\ true $(WDKContentRoot)CodeAnalysis\DriverMustFixRules.ruleset + $(Platform)\$(ConfigurationName)\ $(Platform)\$(ConfigurationName)\ true AllRules.ruleset + $(Platform)\$(ConfigurationName)\ $(Platform)\$(ConfigurationName)\