From 5f42c7d7cba0325207fa617c5eac215adb1f2794 Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Fri, 3 Jul 2020 21:11:34 +0200 Subject: [PATCH] Windows: stop storage service during write The moment we write the block containing the partition table Windows services will start accessing the SD card and write data to "System volume information" folder. If others are writing to disk concurrently this may or may not affect our ability to eject the drive. Stop StorSvc temporarily between us writing the partition table (saved for last) and ejecting the SD card, just in case. Ref #75 --- downloadthread.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/downloadthread.cpp b/downloadthread.cpp index 903657e..0498f18 100644 --- a/downloadthread.cpp +++ b/downloadthread.cpp @@ -585,6 +585,14 @@ void DownloadThread::_writeComplete() emit finalizing(); +#ifdef Q_OS_WIN + // Temporarily stop storage services to prevent \[System Volume Information]\WPSettings.dat being created + QProcess p1; + QStringList args = {"stop", "StorSvc"}; + qDebug() << "Stopping storage services"; + p1.execute("net", args); +#endif + if (_firstBlock) { qDebug() << "Writing first block (which we skipped at first)"; @@ -610,6 +618,13 @@ void DownloadThread::_writeComplete() #endif eject_disk(_filename.constData()); +#ifdef Q_OS_WIN + QStringList args = {"start", "StorSvc"}; + QProcess *p2 = new QProcess(this); + qDebug() << "Restarting storage services"; + p2->startDetached("net", args); +#endif + emit success(); }