Skip to content
Liryna edited this page Dec 30, 2021 · 25 revisions

Compling Dokany

User Snapshot

Compiling Dokany is only necessary, when doing your own changes to the source code. At each commit on the repository and for every pull request, AppVeyor is building a Dokan installer that can be used for testing. The installer can be found by clicking the "All" build configuration and then changing to the "Artifacts" tab on AppVeyor

The installer is self signed with certificates that you can find in cert folder. To run correctly the installer, you will need to install the Dokan self signed certificates and configure Windows to accept testsigned drivers. The following script will do these steps automatically:

cd dokany
Powershell.exe -executionpolicy remotesigned -File .\cert\dokan-import.ps1
//reboot computer before running dokan installer

Installing dependencies

In order to compile Dokan, the following software needs to be installed.

And optionally:

  • Wix (for the installer)
  • Cygwin 64-bit (for compiling Cygwin-versions of dokanfuse)
    • Additional packages: cmake make gcc-core gcc-g++ pkg-config
  • MSYS2 (for compiling MinGW-versions of dokanfuse)
    • Additional packages (run in MSYS2-bash): pacman -S mingw-w64-{x86_64,i686}-toolchain mingw-w64-{x86_64,i686}-cmake
  • Doxygen Doxygen (for generating documentation from source code)

Directory Structure

  • documentations: Doxygen documentation
  • dokan: dokan1.dll userspace library
  • dokan_control: userspace program dokanctl.exe, used for unmounting, listing mountpoints etc.
  • dokan_fuse: userspace wrapper library dokanfuse1.dll implementing the FUSE API known from POSIX-OSes (Linux, MacOS, BSD...)
  • dokan_np: userspace network provider dokannp1.dll, needed for mounting as network share or network drive
  • dokan_vsix: Visual Studio template
  • dokan_wix: Installer
  • samples: Mirror / Memfs example programs
  • scripts: useful scripts used for testing, continuous integration, environment setup
  • sys: dokan1.sys Windows Kernel driver

Compiling

Getting the code

Build the driver, libraries and tools

  • Clone git repository with git clone https://github.com/dokan-dev/dokany.git
  • Navigate to dokany folder and open dokan.sln solution file with Visual Studio.
  • If using VS Professional, on VS menu select BUILD => Batch Build... then check all Win32/x64 Release configuration and click on
  • Generate*. The batch-script build.bat will build for everything all platforms, except the installer and the documentation.
  • All drivers, libraries and tools will be compiled. You can install them.

Build the installer

  • Add the needed environment variables for installer signature (only needed for Release build)
  • SIGNTOOL - Signtool.exe path (ex: C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe)
  • SHA1_CERTTHUMBPRINT - SHA1 Sign certificat thumb print
  • SHA2_CERTTHUMBPRINT - SHA2 Sign certificat thumb print
  • EV_CERTTHUMBPRINT - EV Sign certificat thumb print
  • Navigate to dokany root folder and launch .\scripts\build_installer.ps1 in a powershell console.

2 Installers are going to be generated:

Version Name
Release DokanSetup.exe
Debug DokanSetupDbg.exe

Signing

Signing of user mode files is optional and can be done by any code-signing certificate. It is still recommended as few antivirus programs and company security policies will not allow unsigned file deployment.

Signing of kernel mode files (.sys driver files) became mandatory on recent Windows systems and must be done by a kernel code-signing certificate. On development machine, you can disable this driver signing verification by following this procedure. Or use the self signed test certificate generated by visual studio during the build.

CertMgr.exe /add x64\Win10Debug\dokan1.cer /s /r localMachine root
CertMgr.exe /add x64\Win10Debug\dokan1.cer /s /r localMachine trustedpublisher

Bcdedit.exe -set TESTSIGNING ON
//Reboot computer to enable the changes

If you don't want to purchase a kernel code-signing certificate, you can download and use released signed binaries version of Dokan.