Skip to content

Commit

Permalink
Added ignored_drives.cfg support
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Rojek committed Aug 15, 2019
1 parent 4c18359 commit fbd19f7
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 73 deletions.
7 changes: 7 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Release 1.0.1 Beyond
=============
Added ignored_drives.cfg config file to skip/ignore/blacklist drives (subst, virtual, network)
[Workaround for bugs #41 and #47]


Release 1.0.0
=============
Add Verify Image function
Expand All @@ -24,6 +30,7 @@ SF: 39 - Miswrote to SSD
SF: 40 - Disk Imager scans whole %USERPROFILE% on start
SF: 45 - Translation files adustment


Release 0.9.5
=============
Update copyright headers, bump for point release
Expand Down
90 changes: 90 additions & 0 deletions README-1.0.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Image Writer for Microsoft Windows
Release 1.0.0 - The "Holy cow, we made a 1.0 Release" release.
======
About:
======
This utility is used to read and write raw image files to SD and USB memory devices.
Simply run the utility, point it at your raw image, and then select the
removable device to write to.

This utility can not write CD-ROMs. USB Floppy is NOT supported at this time.

Future releases and source code are available on our Sourceforge project:
http://sourceforge.net/projects/win32diskimager/

This program is Beta, and has no warranty. It may eat your files,
call you names, or explode in a massive shower of code. The authors take
no responsibility for these possible events.

===================
Build Instructions:
===================
Requirements:
1. Now using QT 5.7/MinGW 5.3.

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

=============
New Features:
=============
Verify Image - Now you can verify an image file with a device. This compares
the image file to the device, not the device to the image file (i.e. if you
write a 2G image file to an 8G device, it will only read 2G of the device for
comparison).
Additional checksums - Added SHA1 and SHA256 checksums.
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
the defined partition (2G).
Save last opened folder - The program will now store the last used folder in
the Windows registry and default to it on next execution.
Additional language translations (thanks to devoted users for contributing).

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



=============
Known Issues:
=============
* Lack of reformat capabilities.
* Lack of file compression support

These are being looked into for future releases.

======
Legal:
======
Image Writer for Windows is licensed under the General Public
License v2. The full text of this license is available in
GPL-2.

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

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

The license text is available in LGPL-2.1

Original version developed by Justin Davis <[email protected]>
Maintained by the ImageWriter developers (http://sourceforge.net/projects/win32diskimager).

75 changes: 10 additions & 65 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,90 +1,35 @@
Image Writer for Microsoft Windows
Release 1.0.0 - The "Holy cow, we made a 1.0 Release" release.
Release 1.0.1 Beyond [2019-08-15]
======
About:
======
This utility is used to read and write raw image files to SD and USB memory devices.
Simply run the utility, point it at your raw image, and then select the
removable device to write to.

This utility can not write CD-ROMs. USB Floppy is NOT supported at this time.

Future releases and source code are available on our Sourceforge project:
http://sourceforge.net/projects/win32diskimager/
This fork (based on 1.0.0) adds ignored_drives.cfg config file to skip/ignore/blacklist drives.

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

===================
Build Instructions:
===================
Requirements:
1. Now using QT 5.7/MinGW 5.3.
URL: https://github.com/pawelrojek/win32diskimagerbeyond

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

=============
New Features:
=============
Verify Image - Now you can verify an image file with a device. This compares
the image file to the device, not the device to the image file (i.e. if you
write a 2G image file to an 8G device, it will only read 2G of the device for
comparison).
Additional checksums - Added SHA1 and SHA256 checksums.
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
the defined partition (2G).
Save last opened folder - The program will now store the last used folder in
the Windows registry and default to it on next execution.
Additional language translations (thanks to devoted users for contributing).

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



=============
Known Issues:
=============
* Lack of reformat capabilities.
* Lack of file compression support

These are being looked into for future releases.

======
Legal:
======
Image Writer for Windows is licensed under the General Public
License v2. The full text of this license is available in
License v2. The full text of this license is available in
GPL-2.

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

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

The license text is available in LGPL-2.1

Original version developed by Justin Davis <[email protected]>
Maintained by the ImageWriter developers (http://sourceforge.net/projects/win32diskimager).

Beyond fork by Pawel Rojek (https://github.com/pawelrojek/win32diskimagerbeyond).
14 changes: 14 additions & 0 deletions ignored_drives.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Uncomment/add drives you want to ignore/blacklist
# (examples below)

# External USB drives:
#k:\
#l:\
#m:\
#n:\

# PCloud p:\
#p:\

# Subst drive
#z:\
6 changes: 4 additions & 2 deletions src/DiskImager.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# Copyright (C) 2009, Justin Davis <[email protected]>
# Copyright (C) 2009-2017 ImageWriter developers
# https://sourceforge.net/projects/win32diskimager/
# Copyright (C) 2019, Pawel Rojek (the "Beyond" mod)
# <[email protected]>
###################################################################
TEMPLATE = app
TARGET = ../../Win32DiskImager
Expand All @@ -24,14 +26,14 @@ INCLUDEPATH += .
#CONFIG += release
DEFINES -= UNICODE
QT += widgets
VERSION = 1.0
VERSION = 1.0.1
VERSTR = '\\"$${VERSION}\\"'
DEFINES += VER=\"$${VERSTR}\"
DEFINES += WINVER=0x0601
DEFINES += _WIN32_WINNT=0x0601
QMAKE_TARGET_PRODUCT = "Win32 Image Writer"
QMAKE_TARGET_DESCRIPTION = "Image Writer for Windows to write USB and SD images"
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2009-2017 Windows ImageWriter Team"
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2009-2019 Windows ImageWriter Team"

# Input
HEADERS += disk.h\
Expand Down
64 changes: 64 additions & 0 deletions src/disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ DWORD getDeviceID(HANDLE hVolume)
return sd.Extents[0].DiskNumber;
}

void DebugToFile(QString txt)
{
QString appDir = qApp->applicationDirPath() + "\\";
QFile f(appDir + "debug.log");
if (f.open(QIODevice::WriteOnly | QIODevice::Append))
{
QTextStream stream(&f);
stream << txt << endl;
}
}


HANDLE getHandleOnDevice(int device, DWORD access)
{
HANDLE hDevice;
Expand Down Expand Up @@ -308,6 +320,8 @@ QString getDriveLabel(const char *drv)
return(retVal);
}



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

return(retVal);
}

bool isDriveVirtual(QString drive)
{
//[todo] placeholder to fix some bugs the other way
return false;
}

bool isDriveIgnored(char drive)
{
// DebugToFile(QString("Comparing %1").arg(drive));
if (ignoredDrives.indexOf(drive) > -1) return true;
return false;
}

void loadDriveIgnoreList()
{
ignoredDrives = "";
/*
[todo] add more paths to look for the config file
or this could also be moved to the registry
but it will be harder to edit
so I'm sticking with config file for now
*/
QString appDir = qApp->applicationDirPath() + "\\";
QString fileName = appDir + "ignored_drives.cfg";

if (!QFileInfo(fileName).exists()) return;

QFile inputFile(fileName);
if (inputFile.open(QIODevice::ReadOnly))
{
QTextStream in(&inputFile);
while (!in.atEnd())
{
QString line = in.readLine();
line = line.trimmed();
if (line=="") continue; //empty line
QString firstChar = line.left(1);
if ( (firstChar=="#") || (firstChar==";") ) continue; //comments

if (firstChar.at(0).isLetter()) //otherwise it's probably a drive letter
{
ignoredDrives += firstChar.toUpper(); //duplicates aren't important
}
}
inputFile.close();
}
// DebugToFile("Drive ignore list: " + ignoredDrives);
}
6 changes: 6 additions & 0 deletions src/disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ unsigned long long getFileSizeInSectors(HANDLE handle, unsigned long long sector
bool spaceAvailable(char *location, unsigned long long spaceneeded);
bool checkDriveType(char *name, ULONG *pid);

void DebugToFile(QString txt); //helper function saves string to debug.log

void loadDriveIgnoreList();
bool isDriveIgnored(char drive);
static QString ignoredDrives;

#endif // DISK_H
2 changes: 2 additions & 0 deletions src/ignored_drives.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
o:\
i:\
Loading

0 comments on commit fbd19f7

Please sign in to comment.