Skip to content

Commit fbd19f7

Browse files
author
Pawel Rojek
committed
Added ignored_drives.cfg support
1 parent 4c18359 commit fbd19f7

File tree

9 files changed

+211
-73
lines changed

9 files changed

+211
-73
lines changed

Changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Release 1.0.1 Beyond
2+
=============
3+
Added ignored_drives.cfg config file to skip/ignore/blacklist drives (subst, virtual, network)
4+
[Workaround for bugs #41 and #47]
5+
6+
17
Release 1.0.0
28
=============
39
Add Verify Image function
@@ -24,6 +30,7 @@ SF: 39 - Miswrote to SSD
2430
SF: 40 - Disk Imager scans whole %USERPROFILE% on start
2531
SF: 45 - Translation files adustment
2632

33+
2734
Release 0.9.5
2835
=============
2936
Update copyright headers, bump for point release

README-1.0.0.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Image Writer for Microsoft Windows
2+
Release 1.0.0 - The "Holy cow, we made a 1.0 Release" release.
3+
======
4+
About:
5+
======
6+
This utility is used to read and write raw image files to SD and USB memory devices.
7+
Simply run the utility, point it at your raw image, and then select the
8+
removable device to write to.
9+
10+
This utility can not write CD-ROMs. USB Floppy is NOT supported at this time.
11+
12+
Future releases and source code are available on our Sourceforge project:
13+
http://sourceforge.net/projects/win32diskimager/
14+
15+
This program is Beta, and has no warranty. It may eat your files,
16+
call you names, or explode in a massive shower of code. The authors take
17+
no responsibility for these possible events.
18+
19+
===================
20+
Build Instructions:
21+
===================
22+
Requirements:
23+
1. Now using QT 5.7/MinGW 5.3.
24+
25+
Short Version:
26+
1. Install the Qt Full SDK and use QT Creator to build.
27+
See DEVEL.txt for details
28+
29+
=============
30+
New Features:
31+
=============
32+
Verify Image - Now you can verify an image file with a device. This compares
33+
the image file to the device, not the device to the image file (i.e. if you
34+
write a 2G image file to an 8G device, it will only read 2G of the device for
35+
comparison).
36+
Additional checksums - Added SHA1 and SHA256 checksums.
37+
Read Only Allocated Partitions - Option to read only to the end of the defined partition(s). Ex: Write a 2G image to a 32G device, reading it to a new file will only read to the end of
38+
the defined partition (2G).
39+
Save last opened folder - The program will now store the last used folder in
40+
the Windows registry and default to it on next execution.
41+
Additional language translations (thanks to devoted users for contributing).
42+
43+
=============
44+
Bugs Fixed
45+
=============
46+
https://bugs.launchpad.net/win32-image-writer
47+
LP: 1285238 - Need to check filename text box for valid filename (not just a directory).
48+
LP: 1323876 - Installer doesn't create the correct permissions on install
49+
LP: 1330125 - Multi-partition SD card only partly copied
50+
https://sourceforge.net/p/win32diskimager/tickets/
51+
SF: 7 - Windows 8 x64 USB floppy access denied. Possibly imaging C drive
52+
SF: 8 - Browse Dialog doesnt open then crashes application
53+
SF: 9 - Cannot Read SD Card
54+
SF: 13 - 0.9.5 version refuses to open read-only image
55+
SF: 15 - Open a image for write, bring window in the background
56+
SF: 27 - Error1: Incorrect function
57+
SF: 35 - Mismatch between allocating and deleting memory buffer
58+
SF: 39 - Miswrote to SSD
59+
SF: 40 - Disk Imager scans whole %USERPROFILE% on start
60+
SF: 45 - Translation files adustment
61+
62+
63+
64+
=============
65+
Known Issues:
66+
=============
67+
* Lack of reformat capabilities.
68+
* Lack of file compression support
69+
70+
These are being looked into for future releases.
71+
72+
======
73+
Legal:
74+
======
75+
Image Writer for Windows is licensed under the General Public
76+
License v2. The full text of this license is available in
77+
GPL-2.
78+
79+
This project uses and includes binaries of the MinGW runtime library,
80+
which is available at http://www.mingw.org
81+
82+
This project uses and includes binaries of the Qt library, licensed under the
83+
"Library General Public License" and is available at
84+
http://www.qt-project.org/.
85+
86+
The license text is available in LGPL-2.1
87+
88+
Original version developed by Justin Davis <[email protected]>
89+
Maintained by the ImageWriter developers (http://sourceforge.net/projects/win32diskimager).
90+

README.txt

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,35 @@
11
Image Writer for Microsoft Windows
2-
Release 1.0.0 - The "Holy cow, we made a 1.0 Release" release.
2+
Release 1.0.1 Beyond [2019-08-15]
33
======
4-
About:
5-
======
6-
This utility is used to read and write raw image files to SD and USB memory devices.
7-
Simply run the utility, point it at your raw image, and then select the
8-
removable device to write to.
9-
10-
This utility can not write CD-ROMs. USB Floppy is NOT supported at this time.
11-
12-
Future releases and source code are available on our Sourceforge project:
13-
http://sourceforge.net/projects/win32diskimager/
4+
This fork (based on 1.0.0) adds ignored_drives.cfg config file to skip/ignore/blacklist drives.
145

15-
This program is Beta, and has no warranty. It may eat your files,
16-
call you names, or explode in a massive shower of code. The authors take
17-
no responsibility for these possible events.
6+
This allows to workaround issues with virtual drives, mapped network drives and subst drives.
7+
But also speeds up startup and can protect you from accidental deletion of important drives/files.
8+
See ignored_drives.cfg for details.
189

19-
===================
20-
Build Instructions:
21-
===================
22-
Requirements:
23-
1. Now using QT 5.7/MinGW 5.3.
10+
URL: https://github.com/pawelrojek/win32diskimagerbeyond
2411

25-
Short Version:
26-
1. Install the Qt Full SDK and use QT Creator to build.
27-
See DEVEL.txt for details
2812

29-
=============
30-
New Features:
31-
=============
32-
Verify Image - Now you can verify an image file with a device. This compares
33-
the image file to the device, not the device to the image file (i.e. if you
34-
write a 2G image file to an 8G device, it will only read 2G of the device for
35-
comparison).
36-
Additional checksums - Added SHA1 and SHA256 checksums.
37-
Read Only Allocated Partitions - Option to read only to the end of the defined partition(s). Ex: Write a 2G image to a 32G device, reading it to a new file will only read to the end of
38-
the defined partition (2G).
39-
Save last opened folder - The program will now store the last used folder in
40-
the Windows registry and default to it on next execution.
41-
Additional language translations (thanks to devoted users for contributing).
4213

43-
=============
44-
Bugs Fixed
45-
=============
46-
https://bugs.launchpad.net/win32-image-writer
47-
LP: 1285238 - Need to check filename text box for valid filename (not just a directory).
48-
LP: 1323876 - Installer doesn't create the correct permissions on install
49-
LP: 1330125 - Multi-partition SD card only partly copied
50-
https://sourceforge.net/p/win32diskimager/tickets/
51-
SF: 7 - Windows 8 x64 USB floppy access denied. Possibly imaging C drive
52-
SF: 8 - Browse Dialog doesnt open then crashes application
53-
SF: 9 - Cannot Read SD Card
54-
SF: 13 - 0.9.5 version refuses to open read-only image
55-
SF: 15 - Open a image for write, bring window in the background
56-
SF: 27 - Error1: Incorrect function
57-
SF: 35 - Mismatch between allocating and deleting memory buffer
58-
SF: 39 - Miswrote to SSD
59-
SF: 40 - Disk Imager scans whole %USERPROFILE% on start
60-
SF: 45 - Translation files adustment
6114

6215

6316

64-
=============
65-
Known Issues:
66-
=============
67-
* Lack of reformat capabilities.
68-
* Lack of file compression support
69-
70-
These are being looked into for future releases.
71-
7217
======
7318
Legal:
7419
======
7520
Image Writer for Windows is licensed under the General Public
76-
License v2. The full text of this license is available in
21+
License v2. The full text of this license is available in
7722
GPL-2.
7823

7924
This project uses and includes binaries of the MinGW runtime library,
8025
which is available at http://www.mingw.org
8126

82-
This project uses and includes binaries of the Qt library, licensed under the
83-
"Library General Public License" and is available at
27+
This project uses and includes binaries of the Qt library, licensed under the
28+
"Library General Public License" and is available at
8429
http://www.qt-project.org/.
8530

8631
The license text is available in LGPL-2.1
8732

8833
Original version developed by Justin Davis <[email protected]>
8934
Maintained by the ImageWriter developers (http://sourceforge.net/projects/win32diskimager).
90-
35+
Beyond fork by Pawel Rojek (https://github.com/pawelrojek/win32diskimagerbeyond).

ignored_drives.cfg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Uncomment/add drives you want to ignore/blacklist
2+
# (examples below)
3+
4+
# External USB drives:
5+
#k:\
6+
#l:\
7+
#m:\
8+
#n:\
9+
10+
# PCloud p:\
11+
#p:\
12+
13+
# Subst drive
14+
#z:\

src/DiskImager.pro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# Copyright (C) 2009, Justin Davis <[email protected]>
1717
# Copyright (C) 2009-2017 ImageWriter developers
1818
# https://sourceforge.net/projects/win32diskimager/
19+
# Copyright (C) 2019, Pawel Rojek (the "Beyond" mod)
20+
1921
###################################################################
2022
TEMPLATE = app
2123
TARGET = ../../Win32DiskImager
@@ -24,14 +26,14 @@ INCLUDEPATH += .
2426
#CONFIG += release
2527
DEFINES -= UNICODE
2628
QT += widgets
27-
VERSION = 1.0
29+
VERSION = 1.0.1
2830
VERSTR = '\\"$${VERSION}\\"'
2931
DEFINES += VER=\"$${VERSTR}\"
3032
DEFINES += WINVER=0x0601
3133
DEFINES += _WIN32_WINNT=0x0601
3234
QMAKE_TARGET_PRODUCT = "Win32 Image Writer"
3335
QMAKE_TARGET_DESCRIPTION = "Image Writer for Windows to write USB and SD images"
34-
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2009-2017 Windows ImageWriter Team"
36+
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2009-2019 Windows ImageWriter Team"
3537

3638
# Input
3739
HEADERS += disk.h\

src/disk.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ DWORD getDeviceID(HANDLE hVolume)
6464
return sd.Extents[0].DiskNumber;
6565
}
6666

67+
void DebugToFile(QString txt)
68+
{
69+
QString appDir = qApp->applicationDirPath() + "\\";
70+
QFile f(appDir + "debug.log");
71+
if (f.open(QIODevice::WriteOnly | QIODevice::Append))
72+
{
73+
QTextStream stream(&f);
74+
stream << txt << endl;
75+
}
76+
}
77+
78+
6779
HANDLE getHandleOnDevice(int device, DWORD access)
6880
{
6981
HANDLE hDevice;
@@ -308,6 +320,8 @@ QString getDriveLabel(const char *drv)
308320
return(retVal);
309321
}
310322

323+
324+
311325
BOOL GetDisksProperty(HANDLE hDevice, PSTORAGE_DEVICE_DESCRIPTOR pDevDesc,
312326
DEVICE_NUMBER *devInfo)
313327
{
@@ -440,6 +454,7 @@ bool checkDriveType(char *name, ULONG *pid)
440454
switch( driveType )
441455
{
442456
case DRIVE_REMOVABLE: // The media can be removed from the drive.
457+
//or Virtual [e.g. PCloud] [TODO]
443458
case DRIVE_FIXED: // The media cannot be removed from the drive. Some USB drives report as this.
444459
hDevice = CreateFile(nameNoSlash, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
445460
if (hDevice == INVALID_HANDLE_VALUE)
@@ -500,3 +515,52 @@ bool checkDriveType(char *name, ULONG *pid)
500515

501516
return(retVal);
502517
}
518+
519+
bool isDriveVirtual(QString drive)
520+
{
521+
//[todo] placeholder to fix some bugs the other way
522+
return false;
523+
}
524+
525+
bool isDriveIgnored(char drive)
526+
{
527+
// DebugToFile(QString("Comparing %1").arg(drive));
528+
if (ignoredDrives.indexOf(drive) > -1) return true;
529+
return false;
530+
}
531+
532+
void loadDriveIgnoreList()
533+
{
534+
ignoredDrives = "";
535+
/*
536+
[todo] add more paths to look for the config file
537+
or this could also be moved to the registry
538+
but it will be harder to edit
539+
so I'm sticking with config file for now
540+
*/
541+
QString appDir = qApp->applicationDirPath() + "\\";
542+
QString fileName = appDir + "ignored_drives.cfg";
543+
544+
if (!QFileInfo(fileName).exists()) return;
545+
546+
QFile inputFile(fileName);
547+
if (inputFile.open(QIODevice::ReadOnly))
548+
{
549+
QTextStream in(&inputFile);
550+
while (!in.atEnd())
551+
{
552+
QString line = in.readLine();
553+
line = line.trimmed();
554+
if (line=="") continue; //empty line
555+
QString firstChar = line.left(1);
556+
if ( (firstChar=="#") || (firstChar==";") ) continue; //comments
557+
558+
if (firstChar.at(0).isLetter()) //otherwise it's probably a drive letter
559+
{
560+
ignoredDrives += firstChar.toUpper(); //duplicates aren't important
561+
}
562+
}
563+
inputFile.close();
564+
}
565+
// DebugToFile("Drive ignore list: " + ignoredDrives);
566+
}

src/disk.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ unsigned long long getFileSizeInSectors(HANDLE handle, unsigned long long sector
6060
bool spaceAvailable(char *location, unsigned long long spaceneeded);
6161
bool checkDriveType(char *name, ULONG *pid);
6262

63+
void DebugToFile(QString txt); //helper function saves string to debug.log
64+
65+
void loadDriveIgnoreList();
66+
bool isDriveIgnored(char drive);
67+
static QString ignoredDrives;
68+
6369
#endif // DISK_H

src/ignored_drives.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
o:\
2+
i:\

0 commit comments

Comments
 (0)