Skip to content

Windows: flush shell notifications when dismounting with /q - #1852

Open
amail80 wants to merge 1 commit into
veracrypt:masterfrom
amail80:fix/ghost-drive-letter-quit
Open

Windows: flush shell notifications when dismounting with /q#1852
amail80 wants to merge 1 commit into
veracrypt:masterfrom
amail80:fix/ghost-drive-letter-quit

Conversation

@amail80

@amail80 amail80 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #1658. That fix gates the synchronous SHChangeNotify on Silent,
but the immediate process exit is caused by Quit, and the two are set by
different command line switches:

/s, /silent  ->  Silent = TRUE     (suppresses the user interface)
/q, /quit    ->  Quit   = TRUE     (exit after processing command line)

/q does not imply /s, so VeraCrypt /dismount X: /q never reaches the
SHCNF_FLUSH branch and the ghost drive letter reported in #337 and #1426 can
still appear. This is what the process actually terminates on
(src/Mount/Mount.c):

if (Quit)
{
    if (TaskBarIconMutex == NULL)
    {
        SignalExitCode (exitCode);
        exit (exitCode);
    }

Observable without hitting the race: the same Silent check also selects how
the unmount runs, so VeraCrypt /d X: /q displays the wait dialog, which only
happens when Silent is FALSE - confirming the flush branch is skipped on this
path. Whether a ghost letter then appears depends on Explorer processing the
asynchronous notification before the process exits, so it is timing dependent;
the missing flush is not.

Quit is defined in Mount.c only, while half of the fix lives in Dlgcode.c,
which is also linked into Format and ExpandVolume - and ExpandVolume defines its
own Quit, so the symbol cannot simply be moved. This adds a small shared flag
instead:

  • src/Common/Dlgcode.c/.h - BOOL ProcessExitsAfterCommand
  • src/Mount/Mount.c - set next to each Quit = TRUE; in ExtractCommandLine()
  • both guards become if (Silent || ProcessExitsAfterCommand)

Silent is kept in the condition, so existing behaviour is unchanged; the patch
is purely additive.

Also reported on SourceForge as ticket #629.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant