Skip to content

A modern WPF application for managing Dokan file system mirrors with system tray support, single-instance mode, and intuitive UI

License

Notifications You must be signed in to change notification settings

player-alex/dokan-mirror-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

☁️ Dokan Mirror Manager

Platform .NET C# WPF License

A modern WPF application for managing Dokan file system mirrors with an intuitive user interface πŸš€

Features β€’ Installation β€’ Usage β€’ Building


✨ Features

  • πŸ—‚οΈ Multiple Mount Management - Create and manage multiple mirror mounts simultaneously
  • πŸ’Ύ Smart Drive Letter Selection - Automatically assigns available drive letters, prevents conflicts
  • πŸ€– Auto-Mount on Startup - Configure mounts to automatically mount when the application starts
  • πŸ”’ Read-Only Mode - Mount mirrors in read-only mode for data protection (enabled by default)
  • 🌍 Environment Variable Support - Use environment variables in paths (e.g., %USERPROFILE%\Desktop)
  • 🎯 System Tray Support - Minimize to system tray with notification support
  • ⚑ Single Instance - Only one application instance runs at a time; launching again restores the window
  • πŸ”„ Auto-Unmount - Automatically unmount drives on application exit with confirmation
  • πŸ’Ύ Persistent Configuration - Save and restore mount configurations between sessions
  • 🏷️ Dynamic Volume Labels - Automatically sets volume labels based on source (drive label or folder name)
  • 🎨 Modern UI - Built with MahApps.Metro for a clean, modern interface
  • πŸš€ Non-Blocking Operations - Async mount/unmount operations keep UI responsive
  • ⏱️ Smart Unmount - Progress tracking with timeout handling and background completion
  • πŸ”Œ IPC API - Query mount points from external applications via WM_COPYDATA and Named Pipes

πŸ“Έ Screenshots

Main Window

πŸ“‹ Requirements

  • πŸͺŸ Windows 10/11 (x64)
  • πŸ”· .NET 8.0 Runtime - Download
  • πŸ“¦ Dokan Driver - User mode file system library for Windows
  • πŸ”‘ Administrator privileges - Required for mount operations

πŸ“₯ Installation

  1. Download the latest release from the Releases page
  2. Install Dokan Driver if not already installed
  3. Extract the downloaded archive
  4. Run dokan-mirror-manager.exe as Administrator

⚠️ Important: The application must be run with Administrator privileges to perform mount operations.

πŸ“– Usage

βž• Adding a Mount

  1. Click the Add button
  2. Select a source directory or drive using the folder browser
  3. A drive letter is automatically assigned from available letters
  4. Optionally enable Auto Mount to automatically mount on application startup
  5. Read Only mode is enabled by default for safety
  6. Click the Mount πŸ“‚ button to mount the drive

πŸ”„ Mounting/Unmounting

  • Mount: Click the folder open icon (πŸ“‚) next to the mount item
  • Unmount: Click the folder remove icon (πŸ—‘οΈ) next to the mounted item
    • Shows elapsed time during unmount: "Unmounting Z:... (5s)"
    • If unmount takes longer than expected (>10s), displays timeout dialog with options
    • Can continue in background if needed

❌ Removing a Mount

  1. Select an unmounted item from the list
  2. Click the Remove button

πŸ’‘ Tip: You cannot remove a mounted drive. Unmount it first.

🎯 System Tray

  • Minimize: Close the window to minimize to system tray (shows notification)
  • Restore: Click the tray icon or launch the application again
  • Exit: Right-click tray icon β†’ Exit (prompts to unmount drives)

πŸ” Single Instance

The application runs as a single instance. If you try to launch it while already running:

  • If visible: Nothing happens (already running)
  • If in tray: Window automatically restores and comes to front

πŸ› οΈ Building from Source

Prerequisites

  • πŸ”§ Visual Studio 2022 or later (or VS Code with C# extension)
  • πŸ”· .NET 8.0 SDK - Download
  • πŸ“¦ Dokan Driver (for testing) - Download

Build Steps

# Clone the repository
git clone https://github.com/player-alex/dokan-mirror-manager.git
cd dokan-mirror-manager

# Restore dependencies
dotnet restore

# Build the project (Release configuration)
dotnet build -c Release

# Or build for x64 specifically
dotnet build -c Release --arch x64

Run from Source

# Run as Administrator (required for Dokan operations)
dotnet run --project dokan-mirror-manager/dokan-mirror-manager.csproj

⚠️ Note: Must be run as Administrator for Dokan operations.

βš™οΈ Configuration

Mount configurations are automatically saved to mounts.json in the application directory.

Configuration includes:

  • πŸ“ Source paths (supports environment variables)
  • πŸ’Ύ Destination drive letters
  • πŸ€– Auto-mount settings
  • πŸ”’ Read-only settings

The configuration file is created automatically on first mount and updated whenever changes are made.

Environment Variables

You can use Windows environment variables in source paths within mounts.json:

[
  {
    "SourcePath": "%USERPROFILE%\\Desktop",
    "DestinationLetter": "Z:\\",
    "AutoMount": true,
    "IsReadOnly": true
  }
]

Supported variables:

  • %USERPROFILE% - User's home directory
  • %APPDATA% - Application data folder
  • %LOCALAPPDATA% - Local application data folder
  • %ProgramFiles% - Program Files directory
  • %TEMP% - Temporary files directory
  • Any other Windows environment variables

Smart Drive Letter Management

The application automatically manages drive letters to prevent conflicts:

  • Auto-Assignment: Automatically assigns available drive letters when adding new mounts
  • Conflict Resolution: If a drive letter is already in use, automatically selects the next available one
  • Duplicate Handling: When loading from mounts.json, duplicates are automatically resolved
  • Dynamic Updates: Drive letter dropdowns update in real-time based on availability

πŸ”Œ IPC API

Dokan Mirror Manager provides an IPC (Inter-Process Communication) API that allows external applications to query mount point information.

API Overview

The API uses Windows messages (WM_COPYDATA) and Named Pipes for communication:

  1. Client finds the application window by title: "Dokan Mirror Manager"
  2. Client sends WM_COPYDATA message with a unique pipe name
  3. Server responds via the specified Named Pipe with JSON data

Protocol Details

Message: WM_COPYDATA (0x004A)

  • dwData: 0x8002 (WM_GET_MOUNT_POINTS)
  • lpData: UTF-16LE encoded pipe name (with null terminator)
  • cbData: Byte length of pipe name (including null terminator)

Response Format (JSON):

{
  "success": true,
  "mountPoints": [
    {
      "srcPath": "C:\\SourceFolder",
      "dstPath": "Z:\\",
      "driveName": "SourceFolder",
      "status": "Mounted",
      "isReadOnly": true,
      "autoMount": false,
      "errorMessage": ""
    }
  ],
  "timestamp": "2025-10-26T18:00:00.000Z",
  "version": "1.0"
}

Python Example

See Examples/MountPointQuery/Python/mount_point_query_client.py for a complete implementation:

import win32gui
from ctypes import *

# Find application window
hwnd = win32gui.FindWindow(None, "Dokan Mirror Manager")

# Create Named Pipe name
pipe_name = f"DokanMirrorManager_Query_{uuid.uuid4().hex}"

# Send WM_COPYDATA request
# ... (see example file for complete code)

# Receive response via Named Pipe
# Response contains JSON with mount point information

C# Example

See Examples/MountPointQuery/CSharp/TestSendCopyData/Program.cs for a complete C# implementation.

Status Values

Status Description
Unmounted Not currently mounted
Mounting Mount operation in progress
Mounted Successfully mounted
Unmounting Unmount operation in progress
Error Mount operation failed

Security Notes

  • UIPI (User Interface Privilege Isolation): The application uses ChangeWindowMessageFilterEx to allow WM_COPYDATA messages from processes with different privilege levels
  • Named Pipes: Each request uses a unique pipe name to prevent conflicts
  • Timeout: The server has a 10-second timeout for pipe connections

πŸ”§ Technologies Used

Technology Purpose Version
.NET Application framework 8.0
WPF UI framework -
Caliburn.Micro MVVM framework 5.0.258
MahApps.Metro Modern UI toolkit 2.4.11
DokanNet .NET wrapper for Dokan 2.3.0.1
Hardcodet.NotifyIcon.Wpf System tray support 2.0.1

πŸ› Troubleshooting

❌ Application crashes on mount
  • βœ… Ensure Dokan Driver is properly installed
  • βœ… Run the application as Administrator
  • βœ… Check mount_error.log in the application directory for details
  • βœ… Verify the source path exists and is accessible
πŸ’Ύ Drive letter not available
  • βœ… Make sure the drive letter is not already in use
  • βœ… Check Windows Disk Management for assigned letters
  • βœ… Try a different drive letter
🚫 Application won't start
  • βœ… Verify .NET 8.0 Runtime is installed
  • βœ… Check crash.log in the application directory
  • βœ… Ensure you're running as Administrator
  • βœ… Try running from command line to see error messages
⚠️ Already running message appears

This is normal behavior. The application uses single-instance mode:

  • If the window is hidden in tray, it will be restored automatically
  • If the window is already visible, the existing instance continues running
⏱️ Unmount is taking a long time

If unmount takes longer than expected:

  • βœ… Close any programs accessing files on the drive (Explorer, cmd, etc.)
  • βœ… Wait for the timeout dialog to show processes using the drive
  • βœ… Choose to continue waiting or let it complete in background
  • βœ… The drive will unmount automatically when all file handles are released

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


About

A modern WPF application for managing Dokan file system mirrors with system tray support, single-instance mode, and intuitive UI

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages