6.0 KiB
Build Instructions for Windows
Quick Start Guide
Follow these steps to build and run the DNS Packet Filter on Windows.
Prerequisites
- Windows 10/11 (64-bit)
- Visual Studio 2019 or later with C++ development tools
- Or MinGW-w64 with GCC 8.0+
- CMake 3.15 or later
- Download from: https://cmake.org/download/
Step 1: Setup WinDivert Library
IMPORTANT: You need to download WinDivert on a Windows machine.
-
Download WinDivert 2.2:
https://github.com/basil00/WinDivert/releases/download/v2.2.2/WinDivert-2.2.2-A.zip -
Extract the ZIP file
-
Copy the required files:
From
WinDivert-2.2.2-A/include/:Copy: windivert.h To: external/WinDivert/include/windivert.hFrom
WinDivert-2.2.2-A/x64/:Copy: WinDivert.dll To: external/WinDivert/lib/WinDivert.dll Copy: WinDivert64.sys To: external/WinDivert/lib/WinDivert64.sys Copy: WinDivert.lib To: external/WinDivert/lib/WinDivert.lib -
Verify the directory structure:
external/WinDivert/ ├── include/ │ └── windivert.h └── lib/ ├── WinDivert.dll ├── WinDivert64.sys └── WinDivert.lib
Step 2: Build with CMake
Option A: Using Visual Studio
-
Open Command Prompt or PowerShell
-
Navigate to the project directory:
cd C:\path\to\windows-filter -
Create build directory:
mkdir build cd build -
Generate Visual Studio project files:
cmake .. -G "Visual Studio 17 2022"For Visual Studio 2019, use:
cmake .. -G "Visual Studio 16 2019" -
Build the project:
cmake --build . --config Release -
Output files will be in
build/Release/
Option B: Using Visual Studio IDE
-
Generate project files:
mkdir build cd build cmake .. -G "Visual Studio 17 2022" -
Open
build/DNSPacketFilter.slnin Visual Studio -
Set build configuration to Release
-
Build → Build Solution (or press F7)
-
Output files will be in
build/Release/
Option C: Using MinGW
-
Ensure MinGW-w64 is in your PATH
-
Create build directory:
mkdir build cd build -
Generate Makefiles:
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -
Build:
mingw32-make -
Output files will be in
build/
Step 3: Verify Build Output
After successful build, check that these files exist in the output directory:
build/Release/ (or build/ for MinGW)
├── dns_filter.exe
├── WinDivert.dll
├── WinDivert64.sys
└── config/
└── rules.json
Step 4: Run the Application
IMPORTANT: Must run as Administrator!
-
Open Command Prompt as Administrator:
- Press Windows Key
- Type "cmd"
- Right-click "Command Prompt"
- Select "Run as administrator"
-
Navigate to the build output directory:
cd C:\path\to\windows-filter\build\Release -
Run the application:
dns_filter.exe -
You should see:
================================================== Windows DNS Packet Filter Powered by WinDivert ================================================== Configuration file: config/rules.json Loaded X filtering rules ... DNS Packet Filter is now active! -
Press
Ctrl+Cto stop
Troubleshooting
CMake Configuration Errors
Error: "Could not find WinDivert.lib"
Solution:
- Verify WinDivert files are in
external/WinDivert/lib/ - Re-run Step 1 to copy the files correctly
Error: "CMake version too old"
Solution:
- Download latest CMake from https://cmake.org/download/
- Or use
choco install cmake(if you have Chocolatey)
Build Errors
Error: "windivert.h: No such file or directory"
Solution:
- Verify
external/WinDivert/include/windivert.hexists - Re-run Step 1 to copy the header file
Error: "C++17 support required"
Solution:
- Update Visual Studio to 2017 or later
- Or update MinGW to GCC 8.0 or later
Runtime Errors
Error: "Access denied"
Solution:
- Run as Administrator (see Step 4)
Error: "WinDivert driver not found"
Solution:
- Ensure
WinDivert64.sysis in the same directory asdns_filter.exe - Check antivirus didn't quarantine the file
Error: "Failed to load configuration"
Solution:
- Verify
config/rules.jsonexists in the same directory - Check JSON syntax is valid
Testing the Build
-
Start the filter (as Administrator)
-
Open another Command Prompt and test DNS queries:
nslookup example.com nslookup google.com -
Check the log file:
type dns_filter.log -
You should see DNS queries being logged
Development Workflow
For development and testing:
-
Make code changes in
src/orinclude/ -
Rebuild:
cd build cmake --build . --config Release -
Test the changes:
cd Release dns_filter.exe
Clean Build
To perform a clean build:
# Remove build directory
rmdir /s /q build
# Create new build
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config Release
Advanced: Cross-Compilation
To build from Linux/macOS for Windows:
-
Install MinGW cross-compiler
-
Configure CMake with toolchain:
cmake .. -DCMAKE_TOOLCHAIN_FILE=mingw-w64-toolchain.cmake -
Build:
make
Note: You still need to copy WinDivert files on the target Windows machine.
Next Steps
After successful build:
- Read README.md for usage instructions
- Edit
config/rules.jsonto customize filtering rules - Review logs in
dns_filter.log
Getting Help
If you encounter issues:
- Check the Troubleshooting section above
- Verify all prerequisites are installed correctly
- Ensure WinDivert files are copied correctly
- Check build output for specific error messages
Happy filtering!