Skip to content

Commit

Permalink
upgrade to Dokan 2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
KoltesDigital committed Sep 1, 2022
1 parent bcfee7b commit 8d6a099
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 139 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ install:
- ps: $Env:PATH = "$Env:PATH;C:\Users\appveyor\.cargo\bin"
- ps: |
if ($Env:USE_INSTALLED_LIB -eq $true) {
$Env:DokanLibrary1_LibraryPath_x64 = "C:\Program Files\Dokan\Dokan Library-1.5.0\lib\"
$Env:DokanLibrary1_LibraryPath_x86 = "C:\Program Files\Dokan\Dokan Library-1.5.0\x86\lib\"
$Env:DokanLibrary1_LibraryPath_x64 = "C:\Program Files\Dokan\DokanLibrary-2.0.5\lib\"
$Env:DokanLibrary1_LibraryPath_x86 = "C:\Program Files\Dokan\DokanLibrary-2.0.5\x86\lib\"
} else {
rm C:\Windows\System32\dokan1.dll
rm C:\Windows\SysWOW64\dokan1.dll
rm C:\Windows\System32\dokan2.dll
rm C:\Windows\SysWOW64\dokan2.dll
}
before_build:
Expand Down
2 changes: 1 addition & 1 deletion dokan-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dokan-sys"
version = "0.2.0+dokan150"
version = "0.3.0+dokan205"
authors = ["DDoSolitary <[email protected]>"]
description = "Raw FFI bindings for Dokan (user mode file system library for Windows)"
homepage = "https://dokan-dev.github.io"
Expand Down
2 changes: 1 addition & 1 deletion dokan-sys/src/dokany
Submodule dokany updated 84 files
+151 −0 CHANGELOG.md
+2 −2 Dokan.props
+17 −3 README.md
+25 −33 appveyor.yml
+1 −1 documentations/Doxyfile
+9 −11 documentations/mainpage.md
+10 −19 dokan/access.c
+15 −21 dokan/cleanup.c
+9 −25 dokan/close.c
+82 −98 dokan/create.c
+258 −248 dokan/directory.c
+900 −513 dokan/dokan.c
+7 −1 dokan/dokan.def
+164 −54 dokan/dokan.h
+4 −4 dokan/dokan.rc
+4 −0 dokan/dokan.vcxproj
+661 −0 dokan/dokan_pool.c
+75 −0 dokan/dokan_pool.h
+226 −0 dokan/dokan_vector.c
+72 −0 dokan/dokan_vector.h
+0 −9 dokan/dokanc.h
+139 −98 dokan/dokani.h
+172 −206 dokan/fileinfo.c
+15 −23 dokan/flush.c
+28 −33 dokan/lock.c
+53 −36 dokan/mount.c
+26 −27 dokan/read.c
+56 −58 dokan/security.c
+59 −52 dokan/setfile.c
+13 −72 dokan/timeout.c
+30 −45 dokan/volume.c
+85 −92 dokan/write.c
+8 −7 dokan_control/dokanctl.c
+3 −3 dokan_fuse/CMakeLists.txt
+5 −0 dokan_fuse/include/dokanfuse.h
+3 −1 dokan_fuse/include/fusemain.h
+1 −1 dokan_fuse/include/utils.h
+16 −6 dokan_fuse/src/dokanfuse.cpp
+2 −2 dokan_fuse/src/dokanfuse.def
+4 −4 dokan_fuse/src/dokanfuse.rc
+7 −4 dokan_fuse/src/fusemain.cpp
+30 −182 dokan_fuse/src/utils.cpp
+4 −4 dokan_np/dokan_np.rc
+38 −31 dokan_np/dokannp.c
+21 −21 dokan_wix/Dokan_x64.wxs
+13 −13 dokan_wix/Dokan_x86.wxs
+37 −17 dokan_wix/dokan.ddf
+9 −9 dokan_wix/version.xml
+9 −9 samples/dokan_memfs/filenode.cpp
+9 −5 samples/dokan_memfs/filenode.h
+25 −27 samples/dokan_memfs/filenodes.cpp
+5 −1 samples/dokan_memfs/filenodes.h
+31 −8 samples/dokan_memfs/main.cpp
+13 −10 samples/dokan_memfs/memfs.cpp
+9 −7 samples/dokan_memfs/memfs.h
+15 −6 samples/dokan_memfs/memfs_helper.h
+70 −40 samples/dokan_memfs/memfs_operations.cpp
+4 −3 samples/dokan_memfs/memfs_operations.h
+59 −51 samples/dokan_mirror/mirror.c
+1 −1 samples/memfs_test.ps1
+2 −7 samples/mirror_test.ps1
+1 −1 scripts/build_helper.ps1
+1 −1 sys/close.c
+25 −15 sys/create.c
+35 −108 sys/device.c
+5 −0 sys/directory.c
+7 −4 sys/dispatch.c
+2 −2 sys/dokan.c
+67 −31 sys/dokan.h
+3 −3 sys/dokan.inf
+4 −4 sys/dokan.rc
+298 −84 sys/event.c
+196 −186 sys/fileinfo.c
+164 −19 sys/fscontrol.c
+101 −53 sys/init.c
+35 −166 sys/notification.c
+64 −63 sys/public.h
+2 −33 sys/timeout.c
+178 −94 sys/util/fcb.c
+22 −7 sys/util/fcb.h
+3 −3 sys/util/irp_buffer_helper.h
+12 −30 sys/util/log.c
+17 −11 sys/util/log.h
+1 −1 sys/util/ntstatus_log.inc
85 changes: 57 additions & 28 deletions dokan-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use libc::c_int;
use winapi::shared::basetsd::ULONG64;
use winapi::shared::minwindef::{BOOL, DWORD, FILETIME, LPCVOID, LPDWORD, LPVOID, MAX_PATH};
use winapi::shared::ntdef::{
BOOLEAN, HANDLE, LONGLONG, LPCWSTR, LPWSTR, NTSTATUS, PULONG, PULONGLONG, PVOID64, UCHAR,
BOOLEAN, HANDLE, LONGLONG, LPCWSTR, LPWSTR, NTSTATUS, PULONG, PULONGLONG, PVOID, SCHAR, UCHAR,
ULONG, UNICODE_STRING, USHORT, WCHAR,
};
use winapi::um::fileapi::LPBY_HANDLE_FILE_INFORMATION;
Expand All @@ -30,33 +30,37 @@ pub mod win32;

include!(concat!(env!("OUT_DIR"), "/version.rs"));

pub const DOKAN_OPTION_DEBUG: ULONG = 1;
pub const DOKAN_OPTION_STDERR: ULONG = 2;
pub const DOKAN_OPTION_ALT_STREAM: ULONG = 4;
pub const DOKAN_OPTION_WRITE_PROTECT: ULONG = 8;
pub const DOKAN_OPTION_NETWORK: ULONG = 16;
pub const DOKAN_OPTION_REMOVABLE: ULONG = 32;
pub const DOKAN_OPTION_MOUNT_MANAGER: ULONG = 64;
pub const DOKAN_OPTION_CURRENT_SESSION: ULONG = 128;
pub const DOKAN_OPTION_FILELOCK_USER_MODE: ULONG = 256;
pub const DOKAN_OPTION_ENABLE_NOTIFICATION_API: ULONG = 512;
pub const DOKAN_OPTION_ENABLE_FCB_GARBAGE_COLLECTION: ULONG = 2048;
pub const DOKAN_OPTION_CASE_SENSITIVE: ULONG = 4096;
pub const DOKAN_OPTION_ENABLE_UNMOUNT_NETWORK_DRIVE: ULONG = 8192;
pub const DOKAN_OPTION_DISPATCH_DRIVER_LOGS: ULONG = 16384;
pub const DOKAN_OPTION_DEBUG: ULONG = 1 << 0;
pub const DOKAN_OPTION_STDERR: ULONG = 1 << 1;
pub const DOKAN_OPTION_ALT_STREAM: ULONG = 1 << 2;
pub const DOKAN_OPTION_WRITE_PROTECT: ULONG = 1 << 3;
pub const DOKAN_OPTION_NETWORK: ULONG = 1 << 4;
pub const DOKAN_OPTION_REMOVABLE: ULONG = 1 << 5;
pub const DOKAN_OPTION_MOUNT_MANAGER: ULONG = 1 << 6;
pub const DOKAN_OPTION_CURRENT_SESSION: ULONG = 1 << 7;
pub const DOKAN_OPTION_FILELOCK_USER_MODE: ULONG = 1 << 8;
pub const DOKAN_OPTION_CASE_SENSITIVE: ULONG = 1 << 9;
pub const DOKAN_OPTION_ENABLE_UNMOUNT_NETWORK_DRIVE: ULONG = 1 << 10;
pub const DOKAN_OPTION_DISPATCH_DRIVER_LOGS: ULONG = 1 << 11;
pub const DOKAN_OPTION_ALLOW_IPC_BATCHING: ULONG = 1 << 12;

pub type DOKAN_HANDLE = *mut libc::c_void;
pub type PDOKAN_HANDLE = *mut DOKAN_HANDLE;

#[repr(C)]
#[derive(Debug)]
pub struct DOKAN_OPTIONS {
pub Version: USHORT,
pub ThreadCount: USHORT,
pub SingleThread: BOOLEAN,
pub Options: ULONG,
pub GlobalContext: ULONG64,
pub MountPoint: LPCWSTR,
pub UNCName: LPCWSTR,
pub Timeout: ULONG,
pub AllocationUnitSize: ULONG,
pub SectorSize: ULONG,
pub VolumeSecurityDescriptorLength: ULONG,
pub VolumeSecurityDescriptor: [SCHAR; 1024 * 16],
}

pub type PDOKAN_OPTIONS = *mut DOKAN_OPTIONS;
Expand All @@ -67,6 +71,7 @@ pub struct DOKAN_FILE_INFO {
pub Context: ULONG64,
pub DokanContext: ULONG64,
pub DokanOptions: PDOKAN_OPTIONS,
pub ProcessingContext: PVOID,
pub ProcessId: ULONG,
pub IsDirectory: UCHAR,
pub DeleteOnClose: UCHAR,
Expand All @@ -79,8 +84,7 @@ pub struct DOKAN_FILE_INFO {
pub type PDOKAN_FILE_INFO = *mut DOKAN_FILE_INFO;

pub type PFillFindData = unsafe extern "stdcall" fn(PWIN32_FIND_DATAW, PDOKAN_FILE_INFO) -> c_int;
pub type PFillFindStreamData =
unsafe extern "stdcall" fn(PWIN32_FIND_STREAM_DATA, PDOKAN_FILE_INFO) -> c_int;
pub type PFillFindStreamData = unsafe extern "stdcall" fn(PWIN32_FIND_STREAM_DATA, PVOID) -> BOOL;

#[repr(C)]
pub struct DOKAN_ACCESS_STATE {
Expand Down Expand Up @@ -246,7 +250,9 @@ pub struct DOKAN_OPERATIONS {
DokanFileInfo: PDOKAN_FILE_INFO,
) -> NTSTATUS,
>,
pub Mounted: Option<extern "stdcall" fn(DokanFileInfo: PDOKAN_FILE_INFO) -> NTSTATUS>,
pub Mounted: Option<
extern "stdcall" fn(MountPoint: LPCWSTR, DokanFileInfo: PDOKAN_FILE_INFO) -> NTSTATUS,
>,
pub Unmounted: Option<extern "stdcall" fn(DokanFileInfo: PDOKAN_FILE_INFO) -> NTSTATUS>,
pub GetFileSecurity: Option<
extern "stdcall" fn(
Expand All @@ -271,6 +277,7 @@ pub struct DOKAN_OPERATIONS {
extern "stdcall" fn(
FileName: LPCWSTR,
FillFindStreamData: PFillFindStreamData,
FindStreamContext: PVOID,
DokanFileInfo: PDOKAN_FILE_INFO,
) -> NTSTATUS,
>,
Expand All @@ -288,28 +295,41 @@ pub const DOKAN_MOUNT_POINT_ERROR: c_int = -6;
pub const DOKAN_VERSION_ERROR: c_int = -7;

#[repr(C)]
pub struct DOKAN_CONTROL {
pub struct DOKAN_MOUNT_POINT_INFO {
pub Type: ULONG,
pub MountPoint: [WCHAR; MAX_PATH],
pub UNCName: [WCHAR; 64],
pub DeviceName: [WCHAR; 64],
pub VolumeDeviceObject: PVOID64,
pub SessionId: ULONG,
pub MountOptions: ULONG,
}

pub type PDOKAN_CONTROL = *mut DOKAN_CONTROL;
pub type PDOKAN_MOUNT_POINT_INFO = *mut DOKAN_MOUNT_POINT_INFO;

extern "stdcall" {
pub fn DokanInit();
pub fn DokanShutdown();
pub fn DokanMain(DokanOptions: PDOKAN_OPTIONS, DokanOperations: PDOKAN_OPERATIONS) -> c_int;
pub fn DokanCreateFileSystem(
DokanOptions: PDOKAN_OPTIONS,
DokanOperations: PDOKAN_OPERATIONS,
DokanInstance: *mut DOKAN_HANDLE,
) -> c_int;
pub fn DokanIsFileSystemRunning(DokanInstance: DOKAN_HANDLE) -> BOOL;
pub fn DokanWaitForFileSystemClosed(
DokanInstance: DOKAN_HANDLE,
dwMilliseconds: DWORD,
) -> DWORD;
pub fn DokanCloseHandle(DokanInstance: DOKAN_HANDLE);
pub fn DokanUnmount(DriveLetter: WCHAR) -> BOOL;
pub fn DokanRemoveMountPoint(MountPoint: LPCWSTR) -> BOOL;
pub fn DokanIsNameInExpression(Expression: LPCWSTR, Name: LPCWSTR, IgnoreCase: BOOL) -> BOOL;
pub fn DokanVersion() -> ULONG;
pub fn DokanDriverVersion() -> ULONG;
pub fn DokanResetTimeout(Timeout: ULONG, DokanFileInfo: PDOKAN_FILE_INFO) -> BOOL;
pub fn DokanOpenRequestorToken(DokanFileInfo: PDOKAN_FILE_INFO) -> HANDLE;
pub fn DokanGetMountPointList(uncOnly: BOOL, nbRead: PULONG) -> PDOKAN_CONTROL;
pub fn DokanReleaseMountPointList(list: PDOKAN_CONTROL);
pub fn DokanGetMountPointList(uncOnly: BOOL, nbRead: PULONG) -> PDOKAN_MOUNT_POINT_INFO;
pub fn DokanReleaseMountPointList(list: PDOKAN_MOUNT_POINT_INFO);
pub fn DokanMapKernelToUserCreateFileFlags(
DesiredAccess: ACCESS_MASK,
FileAttributes: ULONG,
Expand All @@ -319,11 +339,20 @@ extern "stdcall" {
outFileAttributesAndFlags: *mut DWORD,
outCreationDisposition: *mut DWORD,
);
pub fn DokanNotifyCreate(FilePath: LPCWSTR, IsDirectory: BOOL) -> BOOL;
pub fn DokanNotifyDelete(FilePath: LPCWSTR, IsDirectory: BOOL) -> BOOL;
pub fn DokanNotifyUpdate(FilePath: LPCWSTR) -> BOOL;
pub fn DokanNotifyXAttrUpdate(FilePath: LPCWSTR) -> BOOL;
pub fn DokanNotifyCreate(
DokanInstance: DOKAN_HANDLE,
FilePath: LPCWSTR,
IsDirectory: BOOL,
) -> BOOL;
pub fn DokanNotifyDelete(
DokanInstance: DOKAN_HANDLE,
FilePath: LPCWSTR,
IsDirectory: BOOL,
) -> BOOL;
pub fn DokanNotifyUpdate(DokanInstance: DOKAN_HANDLE, FilePath: LPCWSTR) -> BOOL;
pub fn DokanNotifyXAttrUpdate(DokanInstance: DOKAN_HANDLE, FilePath: LPCWSTR) -> BOOL;
pub fn DokanNotifyRename(
DokanInstance: DOKAN_HANDLE,
OldPath: LPCWSTR,
NewPath: LPCWSTR,
IsDirectory: BOOL,
Expand Down
4 changes: 2 additions & 2 deletions dokan/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dokan"
version = "0.2.0+dokan150"
version = "0.3.0+dokan205"
authors = ["DDoSolitary <[email protected]>"]
description = "Rust-friendly wrapper for Dokan (user mode file system library for Windows)"
homepage = "https://dokan-dev.github.io"
Expand All @@ -16,7 +16,7 @@ edition = "2018"
appveyor = { repository = "Liryna/dokan-rust" }

[dependencies]
dokan-sys = { version = "= 0.2.0", path = "../dokan-sys" }
dokan-sys = { version = "= 0.3.0", path = "../dokan-sys" }
bitflags = "1.2.1"
widestring = "0.4.3"
winapi = { version = "0.3.9", features = ["std", "errhandlingapi", "handleapi", "heapapi", "ioapiset", "minwinbase", "minwindef", "ntdef", "ntstatus", "processthreadsapi", "sddl", "securitybaseapi", "synchapi", "winbase", "winerror", "winnt"] }
Expand Down
27 changes: 21 additions & 6 deletions dokan/examples/memfs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,18 @@ impl<'a, 'b: 'a> FileSystemHandler<'a, 'b> for MemFsHandler {
})
}

fn mounted(
&'b self,
_mount_point: &U16CStr,
_info: &OperationInfo<'a, 'b, Self>,
) -> Result<(), OperationError> {
Ok(())
}

fn unmounted(&'b self, _info: &OperationInfo<'a, 'b, Self>) -> Result<(), OperationError> {
Ok(())
}

fn get_file_security(
&'b self,
_file_name: &U16CStr,
Expand Down Expand Up @@ -1284,12 +1296,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.help("Mount point path."),
)
.arg(
Arg::with_name("thread_count")
Arg::with_name("single_thread")
.short("t")
.long("threads")
.takes_value(true)
.value_name("THREAD_COUNT")
.default_value("0")
.long("single-thread")
.help("Thread count. Use \"0\" to let Dokan choose it automatically."),
)
.arg(
Expand All @@ -1313,10 +1322,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if matches.is_present("removable") {
flags |= MountFlags::REMOVABLE;
}

init();

Drive::new()
.mount_point(&mount_point)
.thread_count(matches.value_of("thread_count").unwrap().parse()?)
.single_thread(matches.is_present("single_thread"))
.flags(flags)
.mount(&MemFsHandler::new())?;

shutdown();

Ok(())
}
Loading

0 comments on commit 8d6a099

Please sign in to comment.