Dokan Library const and methods. More...

Modules

 Dokan Notify
 Dokan User FS file-change notification.
 

Macros

#define DOKAN_VERSION   140
 
#define DOKAN_MINIMUM_COMPATIBLE_VERSION   110
 
#define DOKAN_DRIVER_NAME   L"dokan" DOKAN_MAJOR_API_VERSION L".sys"
 
#define DOKAN_NP_NAME   L"Dokan" DOKAN_MAJOR_API_VERSION
 

Functions

int DokanMain (PDOKAN_OPTIONS DokanOptions, PDOKAN_OPERATIONS DokanOperations)
 Mount a new Dokan Volume. More...
 
BOOL DokanUnmount (WCHAR DriveLetter)
 Unmount a Dokan device from a driver letter. More...
 
BOOL DokanRemoveMountPoint (LPCWSTR MountPoint)
 Unmount a Dokan device from a mount point. More...
 
BOOL DokanIsNameInExpression (LPCWSTR Expression, LPCWSTR Name, BOOL IgnoreCase)
 Checks whether Name matches Expression. More...
 
ULONG DokanVersion ()
 Get the version of Dokan. The returned ULONG is the version number without the dots. More...
 
ULONG DokanDriverVersion ()
 Get the version of the Dokan driver. The returned ULONG is the version number without the dots. More...
 
BOOL DokanResetTimeout (ULONG Timeout, PDOKAN_FILE_INFO DokanFileInfo)
 Extends the timeout of the current IO operation in driver. More...
 
HANDLE DokanOpenRequestorToken (PDOKAN_FILE_INFO DokanFileInfo)
 Get the handle to Access Token. More...
 
PDOKAN_CONTROL DokanGetMountPointList (BOOL uncOnly, PULONG nbRead)
 Get active Dokan mount points. More...
 
VOID DokanReleaseMountPointList (PDOKAN_CONTROL list)
 Release Mount point list resources from DokanGetMountPointList. More...
 
void DokanMapKernelToUserCreateFileFlags (ACCESS_MASK DesiredAccess, ULONG FileAttributes, ULONG CreateOptions, ULONG CreateDisposition, ACCESS_MASK *outDesiredAccess, DWORD *outFileAttributesAndFlags, DWORD *outCreationDisposition)
 Convert DOKAN_OPERATIONS::ZwCreateFile parameters to CreateFile parameters. More...
 
NTSTATUS DokanNtStatusFromWin32 (DWORD Error)
 Convert WIN32 error to NTSTATUS. More...
 

Detailed Description

Dokan Library const and methods.

Macro Definition Documentation

#define DOKAN_DRIVER_NAME   L"dokan" DOKAN_MAJOR_API_VERSION L".sys"

Driver file name including the DOKAN_MAJOR_API_VERSION

#define DOKAN_MINIMUM_COMPATIBLE_VERSION   110

Minimum Dokan version (ver 1.1.0) accepted.

#define DOKAN_NP_NAME   L"Dokan" DOKAN_MAJOR_API_VERSION

Network provider name including the DOKAN_MAJOR_API_VERSION

#define DOKAN_VERSION   140

The current Dokan version (140 means ver 1.4.0). DOKAN_OPTIONS::Version

Function Documentation

ULONG DokanDriverVersion ( )

Get the version of the Dokan driver. The returned ULONG is the version number without the dots.

Returns
The version of Dokan driver.
PDOKAN_CONTROL DokanGetMountPointList ( BOOL  uncOnly,
PULONG  nbRead 
)

Get active Dokan mount points.

Returned array need to be released by calling DokanReleaseMountPointList

Parameters
uncOnlyGet only instances that have UNC Name.
nbReadNumber of instances successfully retrieved.
Returns
Allocate array of DOKAN_CONTROL.
BOOL DokanIsNameInExpression ( LPCWSTR  Expression,
LPCWSTR  Name,
BOOL  IgnoreCase 
)

Checks whether Name matches Expression.

Behave like FsRtlIsNameInExpression routine from Microsoft
* (asterisk) Matches zero or more characters.
? (question mark) Matches a single character.
DOS_DOT (" quotation mark) Matches either a period or zero characters beyond the name string.
DOS_QM (> greater than) Matches any single character or, upon encountering a period or end of name string, advances the expression to the end of the set of contiguous DOS_QMs.
DOS_STAR (< less than) Matches zero or more characters until encountering and matching the final . in the name.

Parameters
ExpressionExpression can contain any of the above characters.
NameName to check
IgnoreCaseCase sensitive or not
Returns
result if name matches the expression
int DokanMain ( PDOKAN_OPTIONS  DokanOptions,
PDOKAN_OPERATIONS  DokanOperations 
)

Mount a new Dokan Volume.

This function block until the device is unmounted. If the mount fails, it will directly return a DokanMainResult error.

Parameters
DokanOptionsa DOKAN_OPTIONS that describe the mount.
DokanOperationsInstance of DOKAN_OPERATIONS that will be called for each request made by the kernel.
Returns
DokanMainResult status.
void DokanMapKernelToUserCreateFileFlags ( ACCESS_MASK  DesiredAccess,
ULONG  FileAttributes,
ULONG  CreateOptions,
ULONG  CreateDisposition,
ACCESS_MASK *  outDesiredAccess,
DWORD *  outFileAttributesAndFlags,
DWORD *  outCreationDisposition 
)

Convert DOKAN_OPERATIONS::ZwCreateFile parameters to CreateFile parameters.

Dokan Kernel forward the DesiredAccess directly from the IRP_MJ_CREATE. This DesiredAccess has been converted from generic rights (user CreateFile request) to standard rights and will be converted back here. https://msdn.microsoft.com/windows/hardware/drivers/ifs/access-mask

Parameters
DesiredAccessDesiredAccess from DOKAN_OPERATIONS::ZwCreateFile.
FileAttributesFileAttributes from DOKAN_OPERATIONS::ZwCreateFile.
CreateOptionsCreateOptions from DOKAN_OPERATIONS::ZwCreateFile.
CreateDispositionCreateDisposition from DOKAN_OPERATIONS::ZwCreateFile.
outDesiredAccessNew CreateFile dwDesiredAccess.
outFileAttributesAndFlagsNew CreateFile dwFlagsAndAttributes.
outCreationDispositionNew CreateFile dwCreationDisposition.
See also
CreateFile function (MSDN)
NTSTATUS DokanNtStatusFromWin32 ( DWORD  Error)

Convert WIN32 error to NTSTATUS.

https://support.microsoft.com/en-us/kb/113996

Parameters
ErrorWin32 Error to convert
Returns
NTSTATUS associate to the ERROR.
HANDLE DokanOpenRequestorToken ( PDOKAN_FILE_INFO  DokanFileInfo)

Get the handle to Access Token.

This method needs be called in CreateFile callback. The caller must call CloseHandle for the returned handle.

Parameters
DokanFileInfoDOKAN_FILE_INFO of the operation to extend.
Returns
A handle to the account token for the user on whose behalf the code is running.
VOID DokanReleaseMountPointList ( PDOKAN_CONTROL  list)

Release Mount point list resources from DokanGetMountPointList.

After DokanGetMountPointList call you will receive a dynamically allocated array of DOKAN_CONTROL. This array needs to be released when no longer needed by calling this function.

Parameters
listAllocated array of DOKAN_CONTROL from DokanGetMountPointList.
Returns
Nothing.
BOOL DokanRemoveMountPoint ( LPCWSTR  MountPoint)

Unmount a Dokan device from a mount point.

Parameters
MountPointMount point to unmount ("Z", "Z:", "Z:\", "Z:\MyMountPoint").
Returns
TRUE if device was unmounted or FALSE in case of failure or device not found.
BOOL DokanResetTimeout ( ULONG  Timeout,
PDOKAN_FILE_INFO  DokanFileInfo 
)

Extends the timeout of the current IO operation in driver.

Parameters
TimeoutExtended time in milliseconds requested.
DokanFileInfoDOKAN_FILE_INFO of the operation to extend.
Returns
If the operation was successful.
BOOL DokanUnmount ( WCHAR  DriveLetter)

Unmount a Dokan device from a driver letter.

Parameters
DriveLetterDokan driver letter to unmount.
Returns
TRUE if device was unmounted or FALSE in case of failure or device not found.
ULONG DokanVersion ( )

Get the version of Dokan. The returned ULONG is the version number without the dots.

Returns
The version of Dokan