Skip to content

How to Debug Dokan

Liryna edited this page Feb 25, 2016 · 16 revisions

MirrorFS

You can use /d /s options to enable debug output to stderr.

mirror.exe /d /s /r C:\Users /l m

Dokan Driver

Enable logs

Debug output are only enable in debug build. You will need to install the debug version of dokan.

After we will need to enable DbgPrint Output into Windows and dokan sys.

Windows

As explain on OSROnline, open (or add, if it's not already there) the key "HKLM\SYSTEM\CCS\Control\Session Manager\Debug Print Filter". Under this key, create a value with the name "IHVDRIVER" Set the value of this key equal to the DWORD value d.

Then run this command to enable debug mode: bcdedit -debug on

You must reboot for these changes to take effect.

Dokan sys

You need to run this command at launch of Dokan (or Windows boot).

dokanctl.exe /d 9

Get logs

Download DbgView. Enable kernel output with CTRL + K.

You should now be able to see DokanFS output!

Crash Report (BSOD)

After a BSOD, a crash dump is going to be created. This file hold all the information of the crash and is very helpful for debugging the driver. To get the crash report, you need to open the report (C:\Windows\memory.dmp or C:\Windows\Minidump\LATEST.dmp) with WinDbg and run the command !analyze -v.

Live Kernel Debugging

Live kernel debugging has numerous advantages but a second computer is recommended. Bellow the step for kernel debugging a Virtual Machine where Dokan is running.

On the Virtual Machine:

  • Run bcdedit /dbgsettings serial debugport:1 baudrate:115200. Shutdown the VM.
  • Add a Serial Port to the machine. For VirtualBox:
  • Go to Machine Settings => Serials Ports => Port 1
  • Check Enable Serial Port
  • Keep Port Number to COM1 and set Port Mode to Host Device.
  • Check Create Pipe
  • Enter the following Port Path: \\.\pipe\dokandbg.
  • Save changes and power on the VM.

On WinDbg:

  • Configure the symbols, File => Symbol File Path (CTRL + S) and enter the following value: srv*C:\symbols\ms*http://msdl.microsoft.com/download/symbols. Confirm. It is also recommended to use Checked versions of the operating system to have more information.
  • File => Kernel Debug (CTRL + K)
  • Select COM tab
  • Keep Baud Rate to 115200 and enter the following Port again: \\.\pipe\dokandbg
  • Check Pipe and Reconnect.
  • Confirm. After a while you should be connected to the VM and can now debug it remotely.