Building - tnodir/fort GitHub Wiki

Requirements

Visual Studio

  • latest Visual Studio Community Edition or just Build Tools for Visual Studio
  • latest Visual Studio SDK
  • Windows Driver Kit (WDK), same version as Visual Studio SDK

Qt (for UI)

  • latest Qt 6 and QtCreator

Qt 6 can be built from sources by <PATH-TO>\fort\deploy\qt-build.bat script.

Qt 6.1 for Windows 7

The Windows 7 build (build-win7, x86) needs a static Qt 6.1, which still runs on Windows 7. Only its qtbase module is needed.

Requirements:

  • the EWDK with WDK 10.0.20348 (VS 2019 tools), see "Driver with EWDK" below
  • CMake 3.20 (e.g. 3.20.6) with ninja.exe in its bin folder: Qt 6.1 needs CMake 3.16+, but not CMake 4
  • Perl

Sources:

  • clone the qtbase: git clone --branch 6.1 https://code.qt.io/qt/qtbase.git
  • check out its commit cb4026f636187b1378d39e46a90edf3fb9a7d785 (version 6.1.3)
  • in its src\CMakeLists.txt comment out the add_subdirectory(printsupport) line
  • the tests and examples folders aren't needed: they may be deleted; keep the coin folder: the install copies its coin\instructions\qmake\ensure_pro_file.cmake

Build:

  • Edit <PATH-TO>\fort\scripts\make\config.bat to correct the paths: EWDK_OLD, CMAKE_WIN7_HOME, PERL_HOME and QT_STATIC_WIN7 (the static folder of the Qt's build folder below)
  • Open a new Command Prompt and run call <PATH-TO>\fort\scripts\make\qt\qt-env-win7.bat to set up its environment (x86)
  • Create the Qt's build folder (e.g. qt-fort-win7) and change working directory to it
  • Run <PATH-TO>\qtbase\configure with the options of <PATH-TO>\fort\deploy\qt-build-win7.bat and -prefix "<PATH-TO>\qt-fort-win7\static"
  • Run cmake --build . --parallel && cmake --install .
  • The <PATH-TO>\qt-fort-win7\static will be created!

Run the qtbase\configure, not the top-level configure of the qt5 repository: the latter reads all the submodules, even skipped ones. To configure again with other sources' folder, delete the CMakeCache.txt and CMakeFiles of the build folder first.

GoogleTest (for unit tests)

  • clone the https://github.com/google/googletest somewhere
  • add Environment variable "GOOGLETEST_DIR" (upper case!) with value of cloned path (i.e. it should contain googlemock & googletest folders)

Inno Setup (for Installer)

Building

UI

  • Run the <PATH-TO>\fort\scripts\i18n\release_ts.bat to create src\ui\i18n\*.qm translation files
  • Open the <PATH-TO>\fort\src\FortFirewall.pro in QtCreator
  • Select "MSVC 64-bit Kit" and its "Release" configuration
  • Turn on the "Shadow build"
  • Change "Build directory" to <PATH-TO>\fort\build-win10 (the folder will be auto-created on building later)
  • Build it
  • The <PATH-TO>\fort\build-win10\ui_bin\FortFirewall.exe will be created!

Driver

  • Open Visual Studio 2022 Tools Command Prompt for targeting x64 ("x64 Native Tools Command Prompt for VS 2022" link)
  • Change working directory to driver sources by cd <PATH-TO>\fort\src\driver
  • Run msvcbuild-win10-64.bat
  • The <PATH-TO>\fort\build-driver-win10\x64\fortfw.sys will be created!

Driver with EWDK

Alternatively you can build the driver with EWDK.

EWDK installation:

EWDK Command Prompt for targeting x64 (instead of Visual Studio 2022 Tools Command Prompt):

  • run <EWDK_MOUNTED_DRIVE>:\LaunchBuildEnv.cmd amd64

All targets by scripts

The scripts in <PATH-TO>\fort\scripts\make build all the targets from a plain Command Prompt, they set up the compilers' environments themselves:

  • Edit scripts\make\config.bat to correct the paths: the EWDKs (EWDK_OLD for Windows 7: the EWDK with WDK 10.0.20348, EWDK_NEW for Windows 10: the latest EWDK), the folder of Visual Studio's vcvars*.bat, the static Qt builds, jom.exe, the driver payloads' key, the Inno Setup's folder (INNO_HOME), GnuPG's gpg.exe, the installers' signing key and the file of its passphrase
  • Run ui\make-all.bat to build the build-win7, build-win10 and build-win10-arm64 (or one of them by ui\build-win10.bat etc.; the arguments are passed to make, e.g. clean)
  • Run driver\make-all.bat to build the drivers in build-driver-win7 (Win32, x64) and build-driver-win10 (x64, ARM64)
  • Run driver-loader\make-all.bat to wrap the built drivers into the loaders of build-driver-loader-* by build-win10\driver_payload\DriverPayload.exe
  • Run deploy\make-all.bat to make the installers in deploy\out (or one of them by deploy\build-win10.bat etc.) by deploy\setup-deployment.bat and deploy\create-installer.bat, and their GnuPG signatures (*.exe.sig)

Each make-all.bat stops at the first error.

Deploy

Certificates

  • Driver is already test signed by default

Run as Administrator from command line the following commands to turn on/off Windows' Test Signing Mode and reboot computer.

Turn On the Test Signing Mode:

BcdEdit.exe -set loadoptions DISABLE_INTEGRITY_CHECKS
BcdEdit.exe -set NOINTEGRITYCHECKS ON
BcdEdit.exe -set TESTSIGNING ON

Turn Off the Test Signing Mode:

BcdEdit.exe -set loadoptions ENABLE_INTEGRITY_CHECKS
BcdEdit.exe -set NOINTEGRITYCHECKS OFF
BcdEdit.exe -set TESTSIGNING OFF

Installer

  • Set the INNO_HOME environment variable to the Inno Setup's folder, if it's not C:\Program Files\Inno Setup 7
  • Run <PATH-TO>\fort\deploy\setup-deployment-win10.bat to make the <PATH-TO>\fort\deploy\build
  • Run <PATH-TO>\fort\deploy\create-installer.bat
  • The <PATH-TO>\fort\deploy\out\FortFirewall-*.exe will be created!

Debugging

Running without Service and Admin rights

Add to registry: "HKLM/SOFTWARE/Fort Firewall”: “isDriverNonAdmin” (DWORD) = 1

⚠️ **GitHub.com Fallback** ⚠️