1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2026-07-06 04:58:01 -05:00

Windows: allow cancelling long mount operations

Add a root-driver abort IOCTL that bypasses the mount control mutex and sets cooperative KDF abort flags for the active mount.

Restrict abort requests to privileged callers or to the user that initiated the pending mount, and retry early wait-dialog cancel requests until the driver has registered the cancellable mount context.

Wire the wait dialog Cancel button to send the abort request through a fresh driver handle, and propagate ERR_USER_ABORT through header/cache processing.

Add a /cancelmount command-line switch that sends the same abort request without displaying UI, so users can cancel hidden-wait-dialog mount operations from another process.
This commit is contained in:
Mounir IDRASSI
2026-06-07 17:14:37 +09:00
parent 105425ebb0
commit 1871765a76
13 changed files with 437 additions and 23 deletions
+17
View File
@@ -26,6 +26,22 @@ typedef struct _THREAD_BLOCK_
MOUNT_STRUCT *mount;
} THREAD_BLOCK, *PTHREAD_BLOCK;
#ifndef SECURITY_MAX_SID_SIZE
#define SECURITY_MAX_SID_SIZE 68
#endif
typedef struct _MOUNT_CANCEL_CONTEXT_
{
LONG Active;
LONG UserAbortRequested;
LONG KeyDerivationAbort;
LONG UserSidValid;
LONG SequenceNumber;
int nDosDriveNo;
ULONG UserSidLength;
UCHAR UserSid[SECURITY_MAX_SID_SIZE];
} MOUNT_CANCEL_CONTEXT, *PMOUNT_CANCEL_CONTEXT;
/* This structure is allocated for non-root devices! WARNING: bRootDevice
must be the first member of the structure! */
@@ -43,6 +59,7 @@ typedef struct EXTENSION
BOOL bThreadShouldQuit; /* Instruct per device worker thread to quit */
PETHREAD peThread; /* Thread handle */
KEVENT keCreateEvent; /* Device creation event */
PMOUNT_CANCEL_CONTEXT MountCancelContext;
KSPIN_LOCK ListSpinLock; /* IRP spinlock */
LIST_ENTRY ListEntry; /* IRP listentry */
KSEMAPHORE RequestSemaphore; /* IRP list request Semaphore */