├── .gitignore ├── Changelog.txt ├── Delphi ├── DiskImager.pas ├── DiskWriterDemo.dpr ├── DiskWriterDemo.dproj ├── FDemo.dfm └── FDemo.pas ├── GPL-2 ├── LGPL-2.1 ├── License.txt ├── README.txt ├── TODO.txt ├── Win32DiskImager.sln ├── Win32SysInfo ├── Win32SysInfo.pro ├── Win32SysInfo.pro.user ├── w32si-main.cpp ├── w32si-mw.cpp ├── w32si.h └── win32sysinfo.ui ├── clean.bat ├── cli ├── Win32DiskImagerCLI.vcxproj ├── Win32DiskImagerCLI.vcxproj.filters └── Win32DiskImagerCLI.vcxproj.user ├── compile.bat ├── mkzip.bat ├── setup.iss └── src ├── CMakeLists.txt ├── DiskImager.manifest ├── DiskImager.pro ├── DiskImager.rc ├── Win32DiskImagerDLL.cpp ├── Win32DiskImagerDLL.h ├── cli_main.cpp ├── deviceinfo.cpp ├── deviceinfo.h ├── disk.cpp ├── disk.h ├── diskimager_cn.ts ├── diskimager_de_de.ts ├── diskimager_en.ts ├── diskimager_fr.ts ├── diskimager_it.ts ├── diskimager_pl.ts ├── diskwriter.cpp ├── diskwriter.h ├── dll_main.cpp ├── droppablelineedit.cpp ├── droppablelineedit.h ├── elapsedtimer.cpp ├── elapsedtimer.h ├── gui_icons.qrc ├── images ├── Win32DiskImager.ico ├── Win32DiskImager.png ├── browse.png ├── reload.png └── setup.ico ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── md5.h ├── resource.h ├── ui_helper.cpp └── ui_helper.h /.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | Release/ 3 | *.exe 4 | *.pro.user* 5 | *dll 6 | -------------------------------------------------------------------------------- /Changelog.txt: -------------------------------------------------------------------------------- 1 | Release 0.9.5 2 | ============= 3 | Update copyright headers, bump for point release 4 | Fixed broken translation (caused build error). 5 | Converted build environment to QT 5.2/Mingw 4.8 6 | Added Italian translation (LP#1270388) 7 | Added translations. 8 | Start work on installer with Innosetup. 9 | 10 | 11 | Release 0.9 12 | =========== 13 | Added custom file dialog window. 14 | 15 | Bug fixes: 16 | LP:1118217 - can not select SD card to write image to. 17 | LP:1191156 - File-open dialog does not accept non-existing *.img files as targets. 18 | 19 | 20 | Release 0.8 21 | =========== 22 | Added drag and drop - Drag a file from Windows Explorer and drop it in the 23 | text window. 24 | Added DiskImagesDir environment variable for default images directory. 25 | Improved startup Downloads directory search. 26 | Add copy button for MD5. 27 | 28 | Bug fixes: 29 | LP:1080880 Add a copy button for MD5. 30 | LP:1157849 - Partial sectors not written. 31 | LP:1117840 Initial startup can take a long time (+20s) due to the "Downloads" find routine. 32 | LP:1118349 Application does not start. 33 | LP:1157849 Partial sectors not written. 34 | SF:1 Application doesn't start. No window appears. 35 | SF:3 No support of russian characters in image file path 36 | SF:5 Very long app opening time 37 | 38 | 39 | Release 0.7 40 | =========== 41 | Added default directory path pointing to the user's download directory. 42 | Fixed permission settings to require administrator privileges in Vista/7 43 | Reinstated DiskImager.rc rc file (qmake method lost too many options - may revisit later). 44 | Make MD5Sum selectable for copying. Fixes LP:1080880. 45 | Add version info to the main window. 46 | Cleanup, move winver resources to project file. 47 | Renamed base translation for English. 48 | More translation updates, minor cleanup. 49 | Added translation capabilities. Cleaned up some code formatting (broke up long lines). 50 | Testing changes for UTF16 support. 51 | Clean up mixed indentation types, some minor code cleanup. no functional changes. 52 | Updating the 'driveLabel' stuff to use QString rather than char * on a suggestion from Roland Rudenauer 53 | 54 | Bug fixes: 55 | Fixed LP:1100228 "An error occured while accessing the device. Error1: Incorrect function" 56 | Fixed LP:1102608 "Cannot load images from network shares" 57 | Fixed LP:1095038 "Error message encoding is messed up" 58 | Fixed LP:984510 "Cannot select Device" 59 | Fixed LP:923719 "An error occured while accessing the device. Error1: Incorrect function" 60 | Fixed LP:985080 "C: with windows 7 partition erased with all data" (NOT FULLY VERIFIED) 61 | fixing memory leak 62 | -------------------------------------------------------------------------------- /Delphi/DiskImager.pas: -------------------------------------------------------------------------------- 1 | unit DiskImager; 2 | 3 | interface 4 | 5 | function DiskImager_HasError(): Boolean; stdcall; external 'win32diskimager.dll' name 'DiskImager_HasError'; 6 | 7 | function DiskImager_GetError(): PWideChar; stdcall; external 'win32diskimager.dll' name 'DiskImager_GetError'; 8 | 9 | function DiskImager_GetAvailableDrives(): PWideChar; stdcall; external 'win32diskimager.dll' name 'DiskImager_GetAvailableDrives'; 10 | 11 | function DiskImager_WriteToDisk(const DriveLetter: WideChar; const Filename: PWideChar): Boolean; stdcall; external 'win32diskimager.dll' name 'DiskImager_WriteToDisk'; 12 | 13 | procedure DiskImager_Fini(); stdcall; external 'win32diskimager.dll' name 'DiskImager_Fini'; 14 | 15 | implementation 16 | 17 | end. 18 | -------------------------------------------------------------------------------- /Delphi/DiskWriterDemo.dpr: -------------------------------------------------------------------------------- 1 | program DiskWriterDemo; 2 | 3 | uses 4 | Vcl.Forms, 5 | DiskImager in 'DiskImager.pas', 6 | FDemo in 'FDemo.pas' {frmDiskWriterDemo}; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | Application.Initialize; 12 | Application.MainFormOnTaskbar := True; 13 | Application.CreateForm(TfrmDiskWriterDemo, frmDiskWriterDemo); 14 | Application.Run; 15 | end. 16 | -------------------------------------------------------------------------------- /Delphi/DiskWriterDemo.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {3DD66002-047E-4EFE-B70E-21BD14E6F4EC} 4 | 15.4 5 | VCL 6 | DiskWriterDemo.dpr 7 | True 8 | Debug 9 | Win32 10 | 1 11 | Application 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Cfg_1 34 | true 35 | true 36 | 37 | 38 | true 39 | Base 40 | true 41 | 42 | 43 | DiskWriterDemo 44 | System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) 45 | $(BDS)\bin\delphi_PROJECTICON.ico 46 | .\$(Platform)\$(Config) 47 | .\$(Platform)\$(Config) 48 | false 49 | false 50 | false 51 | false 52 | false 53 | 54 | 55 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 56 | 1033 57 | true 58 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 59 | cxSchedulerTreeBrowserRS20;JvGlobus;dxSkinOffice2007SilverRS20;cxGridRS20;dxFireDACServerModeRS20;dxPSdxLCLnkRS20;ipstudiowindataset;dxPScxExtCommonRS20;JvManagedThreads;JvMM;FlexCel_Core;cxPageControlRS20;dxPSdxSpreadSheetLnkRS20;FireDACPgDriver;JvCrypt;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;IntegratedUnitTest_DXE6;JvNet;dxSkinsdxBarPainterRS20;officeXPrt;dxSkinSharpRS20;JvDotNetCtrls;DbxCommonDriver;dxLayoutControlRS20;vclimg;VCL_FlexCel_Components;dxSkinsdxNavBarPainterRS20;dbxcds;dxSkinSilverRS20;DatasnapConnectorsFreePascal;JvXPCtrls;dxPSCoreRS20;dxSkinOffice2013LightGrayRS20;vcldb;dxPSTeeChartRS20;dxSkinOffice2013WhiteRS20;dxSkinMcSkinRS20;CustomIPTransport;dsnap;IndyIPServer;dxSkinCoffeeRS20;dxSkinGlassOceansRS20;IndyCore;dxSkinOffice2010SilverRS20;dxComnRS20;CloudService;dxFlowChartRS20;FMX_FlexCel_Core;FmxTeeUI;FireDACIBDriver;dxDBXServerModeRS20;cxTreeListdxBarPopupMenuRS20;dclcxStatusKeeperPackageRS20;dxSkinOffice2007PinkRS20;dxSkinOffice2013DarkGrayRS20;dxPsPrVwAdvRS20;dxSkinSpringTimeRS20;dxPScxGridLnkRS20;dxSkiniMaginaryRS20;ipstudiowinwordxp;dxSkinDevExpressDarkStyleRS20;JvDB;cxSchedulerGridRS20;dxtrmdRS20;JvRuntimeDesign;dsnapxml;dxSpreadSheetRS20;FireDACDb2Driver;dxSkinMoneyTwinsRS20;JclDeveloperTools;QRDBASE_DXE6;dxSkinOffice2007GreenRS20;dxPScxTLLnkRS20;cxPivotGridOLAPRS20;dxPSdxFCLnkRS20;cetoolspkgdXE6;bindcompfmx;vcldbx;FireDACODBCDriver;RESTBackendComponents;dbrtl;FireDACCommon;bindcomp;inetdb;qrdBDE_DXE6;JvPluginSystem;DBXOdbcDriver;JvCmp;vclFireDAC;madDisAsm_;cxSpreadSheetRS20;xmlrtl;JvTimeFramework;dxPScxSSLnkRS20;dxSkinOffice2007BlackRS20;FireDACCommonDriver;bindengine;vclactnband;soaprtl;FMXTee;FlexCel_Pdf;dxGDIPlusRS20;bindcompvcl;AgTMSDXE6;vclie;Jcl;cxVerticalGridRS20;madExcept_;cxSchedulerRS20;aurelius;dxSkinBlackRS20;FireDACMSSQLDriver;DBXInformixDriver;dxSkinSummer2008RS20;Intraweb;cxBarEditItemRS20;DataSnapServerMidas;ipstudiowinclient;dsnapcon;DBXFirebirdDriver;inet;dxBarRS20;cxDataRS20;dxSkinDarkSideRS20;JvPascalInterpreter;FireDACMySQLDriver;soapmidas;vclx;dxPScxVGridLnkRS20;dxSkinLondonLiquidSkyRS20;QRD_DXE6;dxCoreRS20;DBXSybaseASADriver;RESTComponents;dxPSPrVwRibbonRS20;FlexCel_XlsAdapter;dbexpress;dxPSLnksRS20;IndyIPClient;JvBDE;dxSpellCheckerRS20;dxBarExtItemsRS20;dxdbtrRS20;FireDACSqliteDriver;FireDACDSDriver;cxSchedulerRibbonStyleEventEditorRS20;DBXSqliteDriver;fmx;dxSkinVS2010RS20;dxPScxPCProdRS20;IndySystem;dxSkinXmas2008BlueRS20;TeeDB;tethering;cxStatusKeeperPackageRS20;JvDlgs;inetdbbde;dxTabbedMDIRS20;DataSnapClient;dxmdsRS20;DataSnapProviderClient;VCL_FlexCel_Components_DESIGN;DBXSybaseASEDriver;dxdborRS20;dxPSdxDBTVLnkRS20;dxlibXE6;DcsvclXE6;MetropolisUILiveTile;dxPScxSchedulerLnkRS20;dxSkinCaramelRS20;dxSkinLiquidSkyRS20;vcldsnap;dxGaugeControlRS20;dxSkinDevExpressStyleRS20;fmxFireDAC;cxPivotGridChartRS20;DBXDb2Driver;DBXOracleDriver;dxSkinOffice2010BlueRS20;JvCore;dcldxSkinsCoreRS20;vclribbon;cxExportRS20;dxServerModeRS20;dxSkinscxSchedulerPainterRS20;dxSkinMetropolisDarkRS20;fmxase;vcl;DBXMSSQLDriver;IndyIPCommon;dxSkinBlueRS20;dxSkinsdxDLPainterRS20;DataSnapFireDAC;FireDACDBXDriver;dxBarExtDBItemsRS20;dxSkinOffice2010BlackRS20;soapserver;dxPSDBTeeChartRS20;JvAppFrm;inetdbxpress;dxADOServerModeRS20;dxSkinBlueprintRS20;dxSkinFoggyRS20;dxSkinSharpPlusRS20;FireDACInfxDriver;cxPivotGridRS20;JvDocking;adortl;clInetSuitedXE6;JvWizards;dxRibbonRS20;madBasic_;FireDACASADriver;dxSkinHighContrastRS20;MMSRuntime;JvHMI;dxSkinTheAsphaltWorldRS20;JvBands;CoolTrayIcon_DXE6;dxBarDBNavRS20;dxSkinscxPCPainterRS20;QR506RunDXE6;rtl;DbxClientDriver;dxSkinMetropolisRS20;dxNavBarRS20;dxDockingRS20;Tee;dxSkinOffice2007BlueRS20;JclContainers;dxSkinsdxRibbonPainterRS20;FlexCel_Render;dxSkinValentineRS20;JvSystem;DataSnapNativeClient;svnui;JvControls;IndyProtocols;DBXMySQLDriver;dxPScxCommonRS20;dxSkinSevenClassicRS20;dxSkinPumpkinRS20;bindcompdbx;TeeUI;JvJans;VCL_FlexCel_Core;ipstudiowin;JvPageComps;JvStdCtrls;JvCustom;JvPrintPreview;dxSkinDarkRoomRS20;FireDACADSDriver;vcltouch;dxSkinStardustRS20;cxEditorsRS20;dxorgcRS20;dxPSdxDBOCLnkRS20;VclSmp;FireDAC;VCLRESTComponents;dxSkinsCoreRS20;DataSnapConnectors;dxSkinSevenRS20;cxLibraryRS20;fmxobj;dxMapControlRS20;JclVcl;svn;dxWizardControlRS20;dxSkinLilianRS20;FireDACOracleDriver;fmxdae;dxPScxPivotGridLnkRS20;dxSkinWhiteprintRS20;bdertl;dxThemeRS20;dxPSdxOCLnkRS20;cxTreeListRS20;dxTileControlRS20;FireDACMSAccDriver;DataSnapIndy10ServerTransport;$(DCC_UsePackage) 60 | $(BDS)\bin\default_app.manifest 61 | 62 | 63 | cxSchedulerTreeBrowserRS20;dxSkinOffice2007SilverRS20;cxGridRS20;dxFireDACServerModeRS20;dxPSdxLCLnkRS20;dxPScxExtCommonRS20;FlexCel_Core;cxPageControlRS20;dxPSdxSpreadSheetLnkRS20;FireDACPgDriver;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;dxSkinsdxBarPainterRS20;officeXPrt;dxSkinSharpRS20;DbxCommonDriver;dxLayoutControlRS20;vclimg;VCL_FlexCel_Components;dxSkinsdxNavBarPainterRS20;dbxcds;dxSkinSilverRS20;DatasnapConnectorsFreePascal;dxPSCoreRS20;dxSkinOffice2013LightGrayRS20;vcldb;dxPSTeeChartRS20;dxSkinOffice2013WhiteRS20;dxSkinMcSkinRS20;CustomIPTransport;dsnap;IndyIPServer;dxSkinCoffeeRS20;dxSkinGlassOceansRS20;IndyCore;dxSkinOffice2010SilverRS20;dxComnRS20;CloudService;dxFlowChartRS20;FMX_FlexCel_Core;FmxTeeUI;FireDACIBDriver;dxDBXServerModeRS20;cxTreeListdxBarPopupMenuRS20;dxSkinOffice2007PinkRS20;dxSkinOffice2013DarkGrayRS20;dxPsPrVwAdvRS20;dxSkinSpringTimeRS20;dxPScxGridLnkRS20;dxSkiniMaginaryRS20;dxSkinDevExpressDarkStyleRS20;cxSchedulerGridRS20;dxtrmdRS20;dsnapxml;dxSpreadSheetRS20;FireDACDb2Driver;dxSkinMoneyTwinsRS20;dxSkinOffice2007GreenRS20;dxPScxTLLnkRS20;cxPivotGridOLAPRS20;dxPSdxFCLnkRS20;bindcompfmx;FireDACODBCDriver;RESTBackendComponents;dbrtl;FireDACCommon;bindcomp;inetdb;DBXOdbcDriver;vclFireDAC;cxSpreadSheetRS20;xmlrtl;dxPScxSSLnkRS20;dxSkinOffice2007BlackRS20;FireDACCommonDriver;bindengine;vclactnband;soaprtl;FMXTee;FlexCel_Pdf;dxGDIPlusRS20;bindcompvcl;vclie;cxVerticalGridRS20;cxSchedulerRS20;aurelius;dxSkinBlackRS20;FireDACMSSQLDriver;DBXInformixDriver;dxSkinSummer2008RS20;Intraweb;cxBarEditItemRS20;DataSnapServerMidas;ipstudiowinclient;dsnapcon;DBXFirebirdDriver;inet;dxBarRS20;cxDataRS20;dxSkinDarkSideRS20;FireDACMySQLDriver;soapmidas;vclx;dxPScxVGridLnkRS20;dxSkinLondonLiquidSkyRS20;dxCoreRS20;DBXSybaseASADriver;RESTComponents;dxPSPrVwRibbonRS20;FlexCel_XlsAdapter;dbexpress;dxPSLnksRS20;IndyIPClient;dxSpellCheckerRS20;dxBarExtItemsRS20;dxdbtrRS20;FireDACSqliteDriver;FireDACDSDriver;cxSchedulerRibbonStyleEventEditorRS20;DBXSqliteDriver;fmx;dxSkinVS2010RS20;dxPScxPCProdRS20;IndySystem;dxSkinXmas2008BlueRS20;TeeDB;tethering;dxTabbedMDIRS20;DataSnapClient;dxmdsRS20;DataSnapProviderClient;VCL_FlexCel_Components_DESIGN;DBXSybaseASEDriver;dxdborRS20;dxPSdxDBTVLnkRS20;MetropolisUILiveTile;dxPScxSchedulerLnkRS20;dxSkinCaramelRS20;dxSkinLiquidSkyRS20;vcldsnap;dxGaugeControlRS20;dxSkinDevExpressStyleRS20;fmxFireDAC;cxPivotGridChartRS20;DBXDb2Driver;DBXOracleDriver;dxSkinOffice2010BlueRS20;dcldxSkinsCoreRS20;vclribbon;cxExportRS20;dxServerModeRS20;dxSkinscxSchedulerPainterRS20;dxSkinMetropolisDarkRS20;fmxase;vcl;DBXMSSQLDriver;IndyIPCommon;dxSkinBlueRS20;dxSkinsdxDLPainterRS20;DataSnapFireDAC;FireDACDBXDriver;dxBarExtDBItemsRS20;dxSkinOffice2010BlackRS20;soapserver;dxPSDBTeeChartRS20;inetdbxpress;dxADOServerModeRS20;dxSkinBlueprintRS20;dxSkinFoggyRS20;dxSkinSharpPlusRS20;FireDACInfxDriver;cxPivotGridRS20;adortl;dxRibbonRS20;FireDACASADriver;dxSkinHighContrastRS20;dxSkinTheAsphaltWorldRS20;dxBarDBNavRS20;dxSkinscxPCPainterRS20;rtl;DbxClientDriver;dxSkinMetropolisRS20;dxNavBarRS20;dxDockingRS20;Tee;dxSkinOffice2007BlueRS20;dxSkinsdxRibbonPainterRS20;FlexCel_Render;dxSkinValentineRS20;DataSnapNativeClient;IndyProtocols;DBXMySQLDriver;dxPScxCommonRS20;dxSkinSevenClassicRS20;dxSkinPumpkinRS20;bindcompdbx;TeeUI;VCL_FlexCel_Core;ipstudiowin;dxSkinDarkRoomRS20;FireDACADSDriver;vcltouch;dxSkinStardustRS20;cxEditorsRS20;dxorgcRS20;dxPSdxDBOCLnkRS20;VclSmp;FireDAC;VCLRESTComponents;dxSkinsCoreRS20;DataSnapConnectors;dxSkinSevenRS20;cxLibraryRS20;fmxobj;dxMapControlRS20;dxWizardControlRS20;dxSkinLilianRS20;FireDACOracleDriver;fmxdae;dxPScxPivotGridLnkRS20;dxSkinWhiteprintRS20;dxThemeRS20;dxPSdxOCLnkRS20;cxTreeListRS20;dxTileControlRS20;FireDACMSAccDriver;DataSnapIndy10ServerTransport;$(DCC_UsePackage) 64 | 65 | 66 | DEBUG;$(DCC_Define) 67 | true 68 | false 69 | true 70 | true 71 | true 72 | 73 | 74 | false 75 | 76 | 77 | false 78 | RELEASE;$(DCC_Define) 79 | 0 80 | 0 81 | 82 | 83 | 84 | MainSource 85 | 86 | 87 | 88 |
frmDiskWriterDemo
89 | dfm 90 |
91 | 92 | Cfg_2 93 | Base 94 | 95 | 96 | Base 97 | 98 | 99 | Cfg_1 100 | Base 101 | 102 |
103 | 104 | Delphi.Personality.12 105 | 106 | 107 | 108 | 109 | DiskWriterDemo.dpr 110 | 111 | 112 | 113 | 114 | True 115 | False 116 | 117 | 118 | 12 119 | 120 | 121 | 122 |
123 | -------------------------------------------------------------------------------- /Delphi/FDemo.dfm: -------------------------------------------------------------------------------- 1 | object frmDiskWriterDemo: TfrmDiskWriterDemo 2 | Left = 0 3 | Top = 0 4 | Caption = 'Test DiskWriter' 5 | ClientHeight = 112 6 | ClientWidth = 338 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'Tahoma' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | OnCreate = FormCreate 15 | PixelsPerInch = 96 16 | TextHeight = 13 17 | object cbbDrives: TComboBox 18 | Left = 8 19 | Top = 8 20 | Width = 81 21 | Height = 21 22 | Style = csDropDownList 23 | TabOrder = 0 24 | end 25 | object btnStart: TButton 26 | Left = 8 27 | Top = 80 28 | Width = 89 29 | Height = 25 30 | Caption = 'Write to disk' 31 | TabOrder = 1 32 | OnClick = btnStartClick 33 | end 34 | object edtFilename: TEdit 35 | Left = 8 36 | Top = 40 37 | Width = 321 38 | Height = 21 39 | TabOrder = 2 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /Delphi/FDemo.pas: -------------------------------------------------------------------------------- 1 | unit FDemo; 2 | 3 | interface 4 | 5 | uses 6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 7 | Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, DiskImager; 8 | 9 | type 10 | TfrmDiskWriterDemo = class(TForm) 11 | cbbDrives: TComboBox; 12 | btnStart: TButton; 13 | edtFilename: TEdit; 14 | procedure FormCreate(Sender: TObject); 15 | procedure btnStartClick(Sender: TObject); 16 | private 17 | { Private declarations } 18 | public 19 | { Public declarations } 20 | end; 21 | 22 | var 23 | frmDiskWriterDemo: TfrmDiskWriterDemo; 24 | 25 | implementation 26 | 27 | {$R *.dfm} 28 | 29 | procedure TfrmDiskWriterDemo.btnStartClick(Sender: TObject); 30 | begin 31 | if cbbDrives.Text = '' then 32 | begin 33 | ShowMessage('No drive selected'); 34 | Exit; 35 | end; 36 | 37 | if not DiskImager_WriteToDisk(cbbDrives.Text[1], PChar(edtFilename.Text)) then 38 | begin 39 | while DiskImager_HasError() do 40 | begin 41 | ShowMessage(DiskImager_GetError()); 42 | end; 43 | end; 44 | end; 45 | 46 | procedure TfrmDiskWriterDemo.FormCreate(Sender: TObject); 47 | var 48 | drives: string; 49 | I: integer; 50 | begin 51 | drives := DiskImager_GetAvailableDrives(); 52 | for I := 1 to Length(drives) do 53 | begin 54 | cbbDrives.Items.Add(drives[I]); 55 | end; 56 | 57 | while DiskImager_HasError() do 58 | begin 59 | ShowMessage(DiskImager_GetError()); 60 | end; 61 | end; 62 | 63 | end. 64 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | 2 | This fork contains changes and added code for a DLL and a CLI version of the project. 3 | 4 | DLL API: https://github.com/GDKsoftware/win32diskimager/blob/master/src/Win32DiskImagerDLL.h 5 | 6 | = 7 | 8 | Image Writer for Microsoft Windows 9 | Release 0.9.5 - Unnamed Edition 2: The oddly released sequel 10 | ====== 11 | About: 12 | ====== 13 | This utility is used to write img files to SD and USB memory devices. 14 | Simply run the utility, point it at your img, and then select the 15 | removable device to write to. 16 | 17 | This utility can not write CD-ROMs. 18 | 19 | Future releases and source code are available on our Sourceforge project: 20 | http://sourceforge.net/projects/win32diskimager/ 21 | 22 | This program is Beta , and has no warranty. It may eat your files, 23 | call you names, or explode in a massive shower of code. The authors take 24 | no responsibility for these possible events. 25 | 26 | =================== 27 | Build Instructions: 28 | =================== 29 | Requirements: 30 | 1. Now using QT 5.2.1/MinGW 4.8. Snapshot available in the Build Tools directory at 31 | https://sourceforge.net/projects/win32diskimager/files/Build%20Tools/ 32 | 33 | Short Version: 34 | 1. Install the Qt Full SDK and use QT Creator to build. Included batch files 35 | no longer updated and may be deleted in the future. 36 | 37 | ============= 38 | New Features: 39 | ============= 40 | Add user defined file types capability. 41 | Some additional language translations. 42 | 43 | ============= 44 | Known Issues: 45 | ============= 46 | 47 | * Lack of reformat capabilities. 48 | * Lack of file compression support 49 | * Does not work with USB Floppy drives. 50 | 51 | These are being looked into for future releases. 52 | 53 | ====== 54 | Legal: 55 | ====== 56 | Image Writer for Windows is licensed under the General Public 57 | License v2. The full text of this license is available in 58 | GPL-2. 59 | 60 | This project uses and includes binaries of the MinGW runtime library, 61 | which is available at http://www.mingw.org 62 | 63 | This project uses and includes binaries of the Qt library, licensed under the 64 | "Library General Public License" and is available at 65 | http://www.qt-project.org/. 66 | 67 | The license text is available in LGPL-2.1 68 | 69 | Original version developed by Justin Davis 70 | Maintained by the ImageWriter developers (http://sourceforge.net/projects/win32diskimager). 71 | 72 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | +1.0 Work list: 2 | 3 | 4 | Bug fixes: 5 | Drag & Drop in Windows 7 6 | USB Floppy (support or specifically remove from device list) 7 | Issue with default directory still? Need to test. 8 | 9 | Features: 10 | Compression support 11 | Write verification 12 | Reformat device 13 | -------------------------------------------------------------------------------- /Win32DiskImager.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win32DiskImagerCLI", "cli\Win32DiskImagerCLI.vcxproj", "{2BA7EF24-5197-4A6E-9440-4447257EDFB0}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win32DiskImagerDLL", "dll\Win32DiskImagerDLL.vcxproj", "{97D84C5D-BA70-42B2-B699-ADFAA95FB4F4}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2BA7EF24-5197-4A6E-9440-4447257EDFB0}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {2BA7EF24-5197-4A6E-9440-4447257EDFB0}.Debug|Win32.Build.0 = Debug|Win32 18 | {2BA7EF24-5197-4A6E-9440-4447257EDFB0}.Release|Win32.ActiveCfg = Release|Win32 19 | {2BA7EF24-5197-4A6E-9440-4447257EDFB0}.Release|Win32.Build.0 = Release|Win32 20 | {97D84C5D-BA70-42B2-B699-ADFAA95FB4F4}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {97D84C5D-BA70-42B2-B699-ADFAA95FB4F4}.Debug|Win32.Build.0 = Debug|Win32 22 | {97D84C5D-BA70-42B2-B699-ADFAA95FB4F4}.Release|Win32.ActiveCfg = Release|Win32 23 | {97D84C5D-BA70-42B2-B699-ADFAA95FB4F4}.Release|Win32.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Win32SysInfo/Win32SysInfo.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-02-19T09:50:29 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = ../../Win32SysInfo 12 | TEMPLATE = app 13 | 14 | 15 | SOURCES += \ 16 | w32si-main.cpp \ 17 | w32si-mw.cpp 18 | 19 | HEADERS += \ 20 | w32si.h 21 | 22 | FORMS += \ 23 | win32sysinfo.ui 24 | -------------------------------------------------------------------------------- /Win32SysInfo/Win32SysInfo.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ProjectExplorer.Project.ActiveTarget 7 | 0 8 | 9 | 10 | ProjectExplorer.Project.EditorSettings 11 | 12 | true 13 | false 14 | true 15 | 16 | Cpp 17 | 18 | CppGlobal 19 | 20 | 21 | 22 | QmlJS 23 | 24 | QmlJSGlobal 25 | 26 | 27 | 2 28 | UTF-8 29 | false 30 | 4 31 | false 32 | true 33 | 1 34 | true 35 | 0 36 | true 37 | 0 38 | 8 39 | true 40 | 1 41 | true 42 | true 43 | true 44 | false 45 | 46 | 47 | 48 | ProjectExplorer.Project.PluginSettings 49 | 50 | 51 | 52 | ProjectExplorer.Project.Target.0 53 | 54 | Unnamed 55 | 4.8.4 56 | {a470cd7c-e37f-4b71-89f1-9364d417dfe6} 57 | 1 58 | 0 59 | 0 60 | 61 | 62 | 63 | true 64 | qmake 65 | 66 | QtProjectManager.QMakeBuildStep 67 | false 68 | true 69 | 70 | false 71 | 72 | 73 | true 74 | Make 75 | 76 | Qt4ProjectManager.MakeStep 77 | false 78 | 79 | 80 | 81 | 2 82 | Build 83 | 84 | ProjectExplorer.BuildSteps.Build 85 | 86 | 87 | 88 | true 89 | Make 90 | 91 | Qt4ProjectManager.MakeStep 92 | true 93 | clean 94 | 95 | 96 | 1 97 | Clean 98 | 99 | ProjectExplorer.BuildSteps.Clean 100 | 101 | 2 102 | false 103 | 104 | Debug 105 | 106 | Qt4ProjectManager.Qt4BuildConfiguration 107 | 2 108 | C:/Win32DiskImager/code/Debug 109 | true 110 | 111 | 112 | 113 | 114 | true 115 | qmake 116 | 117 | QtProjectManager.QMakeBuildStep 118 | false 119 | true 120 | 121 | false 122 | 123 | 124 | true 125 | Make 126 | 127 | Qt4ProjectManager.MakeStep 128 | false 129 | 130 | 131 | 132 | 2 133 | Build 134 | 135 | ProjectExplorer.BuildSteps.Build 136 | 137 | 138 | 139 | true 140 | Make 141 | 142 | Qt4ProjectManager.MakeStep 143 | true 144 | clean 145 | 146 | 147 | 1 148 | Clean 149 | 150 | ProjectExplorer.BuildSteps.Clean 151 | 152 | 2 153 | false 154 | 155 | Release 156 | 157 | Qt4ProjectManager.Qt4BuildConfiguration 158 | 0 159 | C:/Win32DiskImager/code/Release 160 | true 161 | 162 | 2 163 | 164 | 165 | 0 166 | Deploy 167 | 168 | ProjectExplorer.BuildSteps.Deploy 169 | 170 | 1 171 | Deploy locally 172 | 173 | ProjectExplorer.DefaultDeployConfiguration 174 | 175 | 1 176 | 177 | true 178 | 179 | false 180 | false 181 | false 182 | false 183 | true 184 | 0.01 185 | 10 186 | true 187 | 25 188 | 189 | true 190 | valgrind 191 | 192 | 0 193 | 1 194 | 2 195 | 3 196 | 4 197 | 5 198 | 6 199 | 7 200 | 8 201 | 9 202 | 10 203 | 11 204 | 12 205 | 13 206 | 14 207 | 208 | Win32SysInfo 209 | 210 | Qt4ProjectManager.Qt4RunConfiguration:C:/Win32DiskImager/code/Win32SysInfo/Win32SysInfo.pro 211 | 2 212 | 213 | Win32SysInfo.pro 214 | false 215 | false 216 | 217 | 218 | 3768 219 | true 220 | false 221 | false 222 | true 223 | 224 | 1 225 | 226 | 227 | 228 | ProjectExplorer.Project.TargetCount 229 | 1 230 | 231 | 232 | ProjectExplorer.Project.Updater.EnvironmentId 233 | {1f6db6d4-ddf4-44ab-bb75-53aebd158640} 234 | 235 | 236 | ProjectExplorer.Project.Updater.FileVersion 237 | 12 238 | 239 | 240 | -------------------------------------------------------------------------------- /Win32SysInfo/w32si-main.cpp: -------------------------------------------------------------------------------- 1 | #include "w32si.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Win32SysInfo/w32si-mw.cpp: -------------------------------------------------------------------------------- 1 | #include "w32si.h" 2 | 3 | MainWindow::MainWindow(QWidget *parent) : 4 | QMainWindow(parent), 5 | ui(new Ui::MainWindow) 6 | { 7 | ui->setupUi(this); 8 | } 9 | 10 | MainWindow::~MainWindow() 11 | { 12 | delete ui; 13 | } 14 | -------------------------------------------------------------------------------- /Win32SysInfo/w32si.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include "ui_win32sysinfo.h" 6 | 7 | namespace Ui { 8 | class MainWindow; 9 | } 10 | 11 | class MainWindow : public QMainWindow 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MainWindow(QWidget *parent = 0); 17 | ~MainWindow(); 18 | 19 | private: 20 | Ui::MainWindow *ui; 21 | }; 22 | 23 | #endif // MAINWINDOW_H 24 | -------------------------------------------------------------------------------- /Win32SysInfo/win32sysinfo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 362 10 | 160 11 | 12 | 13 | 14 | Win32 SysInfo 15 | 16 | 17 | 18 | ../src/images/Win32DiskImager.ico../src/images/Win32DiskImager.ico 19 | 20 | 21 | 22 | 23 | 24 | 0 25 | 10 26 | 361 27 | 121 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Start 38 | 39 | 40 | 41 | 42 | 43 | 44 | View 45 | 46 | 47 | 48 | 49 | 50 | 51 | Upload 52 | 53 | 54 | 55 | 56 | 57 | 58 | Exit 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | TopToolBarArea 68 | 69 | 70 | false 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd src 3 | C:\MinGW\bin\mingw32-make.exe release-distclean debug-distclean 4 | cd .. 5 | pause 6 | @echo on 7 | -------------------------------------------------------------------------------- /cli/Win32DiskImagerCLI.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {2BA7EF24-5197-4A6E-9440-4447257EDFB0} 15 | Win32Proj 16 | Win32DiskImagerCLI 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /cli/Win32DiskImagerCLI.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | -------------------------------------------------------------------------------- /cli/Win32DiskImagerCLI.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | F "Z:\VS2012_PRO_enu.iso" 5 | WindowsLocalDebugger 6 | 7 | -------------------------------------------------------------------------------- /compile.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd src 3 | qmake.exe 4 | mingw32-make.exe 5 | cd .. 6 | pause 7 | @echo on 8 | -------------------------------------------------------------------------------- /mkzip.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | PATH C:\Program Files\WinZip;c:\Program Files\Bazaar;%PATH% 3 | bzr export win32diskimager-source.zip 4 | wzzip win32diskimager-binary.zip mingwm10.dll Win32DiskImager.exe QtGui4.dll QtCore4.dll GPL-2 LGPL-2.1 README.txt libgcc_s_dw2-1.dll libstdc++-6.dll 5 | @echo on 6 | -------------------------------------------------------------------------------- /setup.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppExeName "Win32DiskImager.exe" 5 | #define MyAppName GetStringFileInfo(MyAppExeName,ORIGINAL_FILENAME) 6 | #define MyAppVersion GetStringFileInfo(MyAppExeName,PRODUCT_VERSION) 7 | #define MyAppPublisher "ImageWriter Developers" 8 | #define MyAppURL "http://win32diskimager.sourceforge.net" 9 | 10 | 11 | [Setup] 12 | ; NOTE: The value of AppId uniquely identifies this application. 13 | ; Do not use the same AppId value in installers for other applications. 14 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 15 | AppId={{D074CE74-912A-4AD3-A0BF-3937D9D01F17} 16 | AppName={#MyAppName} 17 | AppVersion={#MyAppVersion} 18 | ;AppVerName={#MyAppName} {#MyAppVersion} 19 | AppPublisher={#MyAppPublisher} 20 | AppPublisherURL={#MyAppURL} 21 | AppSupportURL={#MyAppURL} 22 | AppUpdatesURL={#MyAppURL} 23 | DefaultDirName={pf32}\ImageWriter 24 | DefaultGroupName=Image Writer 25 | LicenseFile=License.txt 26 | OutputBaseFilename={#MyAppName}-setup-{#MyAppVersion} 27 | SetupIconFile=setup.ico 28 | Compression=lzma2 29 | SolidCompression=yes 30 | PrivilegesRequired=admin 31 | 32 | [Languages] 33 | Name: "english"; MessagesFile: "compiler:Default.isl" 34 | 35 | [Tasks] 36 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 37 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 38 | 39 | [Files] 40 | Source: "Win32DiskImager.exe"; DestDir: "{app}"; Flags: ignoreversion 41 | Source: "Changelog.txt"; DestDir: "{app}"; Flags: ignoreversion 42 | Source: "GPL-2"; DestDir: "{app}"; Flags: ignoreversion 43 | Source: "LGPL-2.1"; DestDir: "{app}"; Flags: ignoreversion 44 | Source: "*.dll"; DestDir: "{app}"; Flags: ignoreversion 45 | Source: "platforms\*.dll"; DestDir: "{app}\platforms"; Flags: ignoreversion 46 | Source: "*.qm"; DestDir: "{app}"; Flags: ignoreversion 47 | Source: "README.txt"; DestDir: "{app}"; Flags: ignoreversion isreadme 48 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 49 | 50 | [Icons] 51 | Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 52 | Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" 53 | Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" 54 | Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 55 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon 56 | 57 | [Run] 58 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent runascurrentuser 59 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | 3 | project(win32diskimager) 4 | 5 | add_definitions(-std=c++11) 6 | 7 | add_definitions(-DUNICODE -D_UNICODE) 8 | add_definitions(-DCONSOLE -D_CONSOLE) 9 | 10 | set(cli_SOURCES 11 | disk.cpp 12 | deviceinfo.cpp 13 | diskwriter.cpp 14 | ui_helper.cpp 15 | cli_main.cpp) 16 | 17 | add_executable(win32diskimager ${cli_SOURCES}) 18 | 19 | 20 | remove_definitions(-DCONSOLE -D_CONSOLE) 21 | add_definitions(-DWIN) 22 | add_definitions(-DWIN32) 23 | add_definitions(-D_WINDOWS) 24 | add_definitions(-D_WINDLL) 25 | add_definitions(-D_USRDLL) 26 | add_definitions(-DWIN32DISKIMAGERDLL_EXPORTS) 27 | 28 | set(dll_SOURCES 29 | disk.cpp 30 | deviceinfo.cpp 31 | diskwriter.cpp 32 | ui_helper.cpp 33 | Win32DiskImagerDLL.cpp 34 | dll_main.cpp) 35 | 36 | SET (LIB_TYPE SHARED) 37 | add_library(win32diskimagerdll ${LIB_TYPE} ${dll_SOURCES}) 38 | -------------------------------------------------------------------------------- /src/DiskImager.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/DiskImager.pro: -------------------------------------------------------------------------------- 1 | ################################################################### 2 | # This program is free software; you can redistribute it and/or 3 | # modify it under the terms of the GNU General Public License 4 | # as published by the Free Software Foundation; either version 2 5 | # of the License, or (at your option) any later version. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, see http://gnu.org/licenses/ 14 | # 15 | # 16 | # Copyright (C) 2009, Justin Davis 17 | # Copyright (C) 2009-2014 ImageWriter developers 18 | # https://launchpad.net/~image-writer-devs 19 | ################################################################### 20 | TEMPLATE = app 21 | TARGET = ../../Win32DiskImager 22 | DEPENDPATH += . 23 | INCLUDEPATH += . 24 | #CONFIG += release 25 | DEFINES -= UNICODE 26 | QT += widgets 27 | #DEFINES += QT_NO_CAST_FROM_ASCII 28 | VERSION = 0.9.5 29 | VERSTR = '\\"$${VERSION}\\"' 30 | DEFINES += VER=\"$${VERSTR}\" 31 | DEFINES += WINVER=0x0601 32 | DEFINES += _WIN32_WINNT=0x0601 33 | QMAKE_TARGET_PRODUCT = "Win32 Image Writer" 34 | QMAKE_TARGET_DESCRIPTION = "Image Writer for Windows to write USB and SD images" 35 | QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2009-2014 Windows ImageWriter Team" 36 | 37 | # Input 38 | HEADERS += disk.h\ 39 | mainwindow.h\ 40 | droppablelineedit.h \ 41 | elapsedtimer.h 42 | 43 | FORMS += mainwindow.ui 44 | 45 | SOURCES += disk.cpp\ 46 | main.cpp\ 47 | mainwindow.cpp\ 48 | droppablelineedit.cpp \ 49 | elapsedtimer.cpp 50 | 51 | RESOURCES += gui_icons.qrc 52 | 53 | RC_FILE = DiskImager.rc 54 | 55 | TRANSLATIONS = diskimager_en.ts\ 56 | diskimager_cn.ts\ 57 | diskimager_it.ts\ 58 | diskimager_pl.ts 59 | -------------------------------------------------------------------------------- /src/DiskImager.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (U.S.) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | #pragma code_page(1252) 22 | #endif //_WIN32 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // RT_MANIFEST 27 | // 28 | 29 | 1 RT_MANIFEST "DiskImager.manifest" 30 | 31 | #ifdef APSTUDIO_INVOKED 32 | ///////////////////////////////////////////////////////////////////////////// 33 | // 34 | // TEXTINCLUDE 35 | // 36 | 37 | 1 TEXTINCLUDE 38 | BEGIN 39 | "resource.\0" 40 | END 41 | 42 | 3 TEXTINCLUDE 43 | BEGIN 44 | "\r\0" 45 | END 46 | 47 | #endif // APSTUDIO_INVOKED 48 | 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | // 52 | // Version 53 | // 54 | 55 | VS_VERSION_INFO VERSIONINFO 56 | FILEVERSION 0,9,5,0 57 | PRODUCTVERSION 0,9,5,0 58 | FILEFLAGSMASK 0x17L 59 | #ifdef _DEBUG 60 | FILEFLAGS 0x1L 61 | #else 62 | FILEFLAGS 0x0L 63 | #endif 64 | FILEOS 0x4L 65 | FILETYPE 0x0L 66 | FILESUBTYPE 0x0L 67 | BEGIN 68 | BLOCK "StringFileInfo" 69 | BEGIN 70 | BLOCK "040904b0" 71 | BEGIN 72 | VALUE "Comments", "Image Writer for Windows to write USB and SD images" 73 | VALUE "FileDescription", "DiskImager" 74 | VALUE "FileVersion", "0.9.5" 75 | VALUE "InternalName", "win32-image-writer" 76 | VALUE "LegalCopyright", "Copyright (C) 2009-2014 Windows ImageWriter Team" 77 | VALUE "OriginalFilename", "Win32DiskImager" 78 | VALUE "ProductName", "Win32 Image Writer" 79 | VALUE "ProductVersion", "0.9.5" 80 | END 81 | END 82 | BLOCK "VarFileInfo" 83 | BEGIN 84 | VALUE "Translation", 0x409, 1200 85 | END 86 | END 87 | 88 | 89 | ///////////////////////////////////////////////////////////////////////////// 90 | // 91 | // Icon 92 | // 93 | 94 | // Icon with lowest ID value placed first to ensure application icon 95 | // remains consistent on all systems. 96 | IDI_ICON1 ICON "images\\Win32DiskImager.ico" 97 | #endif // English (U.S.) resources 98 | ///////////////////////////////////////////////////////////////////////////// 99 | 100 | 101 | 102 | #ifndef APSTUDIO_INVOKED 103 | ///////////////////////////////////////////////////////////////////////////// 104 | // 105 | // Generated from the TEXTINCLUDE 3 resource. 106 | // 107 | 108 | 109 | ///////////////////////////////////////////////////////////////////////////// 110 | #endif // not APSTUDIO_INVOKED 111 | 112 | -------------------------------------------------------------------------------- /src/Win32DiskImagerDLL.cpp: -------------------------------------------------------------------------------- 1 | // Win32DiskImagerDLL.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "Win32DiskImagerDLL.h" 5 | 6 | #include "ui_helper.h" 7 | #include "deviceinfo.h" 8 | #include "diskwriter.h" 9 | 10 | wchar_t *lasterrormsg = nullptr; 11 | wchar_t *availabledrives = nullptr; 12 | 13 | bool __stdcall DiskImager_HasError() { 14 | return CUIHelper::GetInstance()->hasErrors(); 15 | } 16 | 17 | wchar_t * __stdcall DiskImager_GetError() { 18 | if (lasterrormsg != nullptr) { 19 | delete lasterrormsg; 20 | lasterrormsg = nullptr; 21 | } 22 | 23 | auto errormsg = CUIHelper::GetInstance()->popErrorMessage(); 24 | 25 | lasterrormsg = new wchar_t[errormsg.length() + 1]; 26 | lasterrormsg[errormsg.length()] = 0x00; 27 | 28 | memcpy(lasterrormsg, errormsg.c_str(), errormsg.length() * sizeof(wchar_t)); 29 | 30 | return lasterrormsg; 31 | } 32 | 33 | wchar_t * __stdcall DiskImager_GetAvailableDrives() { 34 | if (availabledrives != nullptr) { 35 | delete availabledrives; 36 | availabledrives = nullptr; 37 | } 38 | 39 | CDeviceInfo devinfo; 40 | std::vector> v; 41 | 42 | devinfo.getLogicalDrives(&v); 43 | 44 | availabledrives = new wchar_t[v.size() + 1]; 45 | availabledrives[v.size()] = 0x00; 46 | 47 | size_t idxChar = 0; 48 | for (auto p : v) 49 | { 50 | availabledrives[idxChar] = p.first; 51 | ++idxChar; 52 | } 53 | 54 | return availabledrives; 55 | } 56 | 57 | bool __stdcall DiskImager_WriteToDisk(const wchar_t driveletter, const wchar_t *filename) { 58 | CDiskWriter writer; 59 | CDeviceInfo devinfo; 60 | std::vector> v; 61 | 62 | devinfo.getLogicalDrives(&v); 63 | 64 | int volume = 0; 65 | int disk = 0; 66 | bool found = false; 67 | for (auto p : v) 68 | { 69 | if (p.first == driveletter) { 70 | disk = p.second; 71 | volume = p.first - 'A'; 72 | found = true; 73 | } 74 | } 75 | 76 | if (found) { 77 | return writer.WriteImageToDisk(filename, disk, volume); 78 | } 79 | else 80 | { 81 | CUIHelper::critical(L"Selected disk not supported"); 82 | 83 | return false; 84 | } 85 | } 86 | 87 | void __stdcall DiskImager_Fini() { 88 | if (lasterrormsg != nullptr) { 89 | delete lasterrormsg; 90 | lasterrormsg = nullptr; 91 | } 92 | 93 | if (availabledrives != nullptr) { 94 | delete availabledrives; 95 | availabledrives = nullptr; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/Win32DiskImagerDLL.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | #ifdef WIN32DISKIMAGERDLL_EXPORTS 6 | #define WIN32DISKIMAGERDLL_API __declspec(dllexport) 7 | #else 8 | #define WIN32DISKIMAGERDLL_API __declspec(dllimport) 9 | #endif 10 | 11 | WIN32DISKIMAGERDLL_API bool __stdcall DiskImager_HasError(); 12 | 13 | WIN32DISKIMAGERDLL_API wchar_t * __stdcall DiskImager_GetError(); 14 | 15 | WIN32DISKIMAGERDLL_API wchar_t * __stdcall DiskImager_GetAvailableDrives(); 16 | 17 | WIN32DISKIMAGERDLL_API bool __stdcall DiskImager_WriteToDisk(const wchar_t driveletter, const wchar_t *filename); 18 | 19 | WIN32DISKIMAGERDLL_API void __stdcall DiskImager_Fini(); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /src/cli_main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "deviceinfo.h" 3 | #include "diskwriter.h" 4 | #include "ui_helper.h" 5 | 6 | #include 7 | #include 8 | 9 | // http://stackoverflow.com/questions/13871617/winmain-and-main-in-c-extended 10 | 11 | extern int wmain(int, wchar_t**); 12 | 13 | #include // GetCommandLine, CommandLineToArgvW, LocalFree 14 | 15 | int main() 16 | { 17 | struct Args 18 | { 19 | int n; 20 | wchar_t** p; 21 | 22 | ~Args() { if (p != 0) { ::LocalFree(p); } } 23 | Args() : p(::CommandLineToArgvW(::GetCommandLine(), &n)) {} 24 | }; 25 | 26 | Args args; 27 | 28 | if (args.p == 0) 29 | { 30 | return EXIT_FAILURE; 31 | } 32 | return wmain(args.n, args.p); 33 | } 34 | 35 | 36 | int wmain(int argc, wchar_t *argv[]) { 37 | std::locale::global(std::locale("")); 38 | 39 | CDiskWriter writer; 40 | CDeviceInfo devinfo; 41 | std::vector> v; 42 | 43 | try { 44 | devinfo.getLogicalDrives(&v); 45 | 46 | std::wstring driveletter, filename; 47 | if (argc == 3) { 48 | driveletter = argv[1]; 49 | filename = argv[2]; 50 | 51 | int volume = 0; 52 | int disk = 0; 53 | bool found = false; 54 | for (auto p : v) 55 | { 56 | if (p.first == driveletter[0]) { 57 | disk = p.second; 58 | volume = p.first - 'A'; 59 | found = true; 60 | } 61 | } 62 | 63 | if (found) { 64 | writer.WriteImageToDisk(filename, disk, volume); 65 | } 66 | else 67 | { 68 | CUIHelper::critical(L"Selected disk not supported"); 69 | 70 | return 1; 71 | } 72 | } 73 | else 74 | { 75 | CUIHelper::critical(L"Usage: Win32DiskImagerCLI.exe "); 76 | 77 | return 1; 78 | } 79 | 80 | } 81 | catch (std::exception e) 82 | { 83 | CUIHelper::critical(e.what()); 84 | 85 | return 1; 86 | } 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /src/deviceinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "deviceinfo.h" 2 | 3 | #include 4 | #include "disk.h" 5 | 6 | CDeviceInfo::CDeviceInfo() 7 | { 8 | } 9 | 10 | 11 | CDeviceInfo::~CDeviceInfo() 12 | { 13 | } 14 | 15 | // getLogicalDrives sets cBoxDevice with any logical drives found, as long 16 | // as they indicate that they're either removable, or fixed and on USB bus 17 | void CDeviceInfo::getLogicalDrives(std::vector> *vDrives) 18 | { 19 | // GetLogicalDrives returns 0 on failure, or a bitmask representing 20 | // the drives available on the system (bit 0 = A:, bit 1 = B:, etc) 21 | unsigned long driveMask = ::GetLogicalDrives(); 22 | int i = 0; 23 | ULONG pID; 24 | 25 | while (driveMask != 0) 26 | { 27 | if (driveMask & 1) 28 | { 29 | // the "A" in drivename will get incremented by the # of bits 30 | // we've shifted 31 | std::wstring drivename = L"\\\\.\\A:\\"; 32 | drivename[4] += i; 33 | 34 | if (::checkDriveType(drivename, &pID)) 35 | { 36 | std::pair drive; 37 | drive = std::make_pair(drivename[4], pID); 38 | vDrives->push_back(drive); 39 | } 40 | } 41 | driveMask >>= 1; 42 | ++i; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/deviceinfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CDeviceInfo 7 | { 8 | public: 9 | CDeviceInfo(); 10 | virtual ~CDeviceInfo(); 11 | 12 | void getLogicalDrives(std::vector> *vDrives); 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /src/disk.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * This program is free software; you can redistribute it and/or * 3 | * modify it under the terms of the GNU General Public License * 4 | * as published by the Free Software Foundation; either version 2 * 5 | * of the License, or (at your option) any later version. * 6 | * * 7 | * This program is distributed in the hope that it will be useful, * 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 | * GNU General Public License for more details. * 11 | * * 12 | * You should have received a copy of the GNU General Public License * 13 | * along with this program; if not, see http://gnu.org/licenses/ 14 | * --- * 15 | * Copyright (C) 2009, Justin Davis * 16 | * Copyright (C) 2009-2014 ImageWriter developers * 17 | * https://launchpad.net/~image-writer-devs * 18 | **********************************************************************/ 19 | 20 | #ifndef WINVER 21 | #define WINVER 0x0601 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "disk.h" 30 | 31 | #include "ui_helper.h" 32 | 33 | HANDLE getHandleOnFile(LPCWSTR filelocation, DWORD access) 34 | { 35 | HANDLE hFile; 36 | hFile = CreateFileW(filelocation, access, (access == GENERIC_READ) ? FILE_SHARE_READ : 0, NULL, (access == GENERIC_READ) ? OPEN_EXISTING:CREATE_ALWAYS, 0, NULL); 37 | if (hFile == INVALID_HANDLE_VALUE) 38 | { 39 | CUIHelper::criticalWithCurrentError(L"File Error", L"An error occurred when attempting to get a handle on the file."); 40 | } 41 | return hFile; 42 | } 43 | 44 | HANDLE getHandleOnDevice(int device, DWORD access) 45 | { 46 | HANDLE hDevice; 47 | std::wstring devicename(L"\\\\.\\PhysicalDrive"); 48 | devicename = devicename + std::to_wstring(device); 49 | 50 | hDevice = CreateFile(devicename.c_str(), access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 51 | if (hDevice == INVALID_HANDLE_VALUE) 52 | { 53 | CUIHelper::criticalWithCurrentError(L"Device Error", L"An error occurred when attempting to get a handle on the device."); 54 | } 55 | return hDevice; 56 | } 57 | 58 | HANDLE getHandleOnVolume(int volume, DWORD access) 59 | { 60 | HANDLE hVolume; 61 | wchar_t volumename[] = L"\\\\.\\A:"; 62 | volumename[4] += volume; 63 | hVolume = CreateFile(volumename, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 64 | if (hVolume == INVALID_HANDLE_VALUE) 65 | { 66 | CUIHelper::criticalWithCurrentError(L"Volume Error", L"An error occurred when attempting to get a handle on the volume."); 67 | } 68 | return hVolume; 69 | } 70 | 71 | bool getLockOnVolume(HANDLE handle) 72 | { 73 | DWORD bytesreturned; 74 | BOOL bResult; 75 | bResult = DeviceIoControl(handle, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &bytesreturned, NULL); 76 | if (!bResult) 77 | { 78 | CUIHelper::criticalWithCurrentError(L"Lock Error", L"An error occurred when attempting to lock the volume."); 79 | } 80 | return (bResult); 81 | } 82 | 83 | bool removeLockOnVolume(HANDLE handle) 84 | { 85 | DWORD junk; 86 | BOOL bResult; 87 | bResult = DeviceIoControl(handle, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &junk, NULL); 88 | if (!bResult) 89 | { 90 | CUIHelper::criticalWithCurrentError(L"Unlock Error", L"An error occurred when attempting to unlock the volume."); 91 | } 92 | return (bResult); 93 | } 94 | 95 | bool unmountVolume(HANDLE handle) 96 | { 97 | DWORD junk; 98 | BOOL bResult; 99 | bResult = DeviceIoControl(handle, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &junk, NULL); 100 | if (!bResult) 101 | { 102 | CUIHelper::criticalWithCurrentError(L"Dismount Error", L"An error occurred when attempting to dismount the volume."); 103 | } 104 | return (bResult); 105 | } 106 | 107 | bool isVolumeUnmounted(HANDLE handle) 108 | { 109 | DWORD junk; 110 | BOOL bResult; 111 | bResult = DeviceIoControl(handle, FSCTL_IS_VOLUME_MOUNTED, NULL, 0, NULL, 0, &junk, NULL); 112 | return (!bResult); 113 | } 114 | 115 | char *readSectorDataFromHandle(HANDLE handle, unsigned long long startsector, unsigned long long numsectors, unsigned long long sectorsize) 116 | { 117 | unsigned long bytesread; 118 | char *data = new char[sectorsize * numsectors]; 119 | LARGE_INTEGER li; 120 | li.QuadPart = startsector * sectorsize; 121 | SetFilePointer(handle, li.LowPart, &li.HighPart, FILE_BEGIN); 122 | if (!ReadFile(handle, data, sectorsize * numsectors, &bytesread, NULL)) 123 | { 124 | CUIHelper::criticalWithCurrentError(L"Read Error", L"An error occurred when attempting to read data from handle."); 125 | 126 | delete[] data; 127 | data = NULL; 128 | } 129 | if (bytesread < (sectorsize * numsectors)) 130 | { 131 | memset(data + bytesread,0,(sectorsize * numsectors) - bytesread); 132 | } 133 | return data; 134 | } 135 | 136 | bool writeSectorDataToHandle(HANDLE handle, char *data, unsigned long long startsector, unsigned long long numsectors, unsigned long long sectorsize) 137 | { 138 | unsigned long byteswritten; 139 | BOOL bResult; 140 | LARGE_INTEGER li; 141 | li.QuadPart = startsector * sectorsize; 142 | SetFilePointer(handle, li.LowPart, &li.HighPart, FILE_BEGIN); 143 | bResult = WriteFile(handle, data, sectorsize * numsectors, &byteswritten, NULL); 144 | if (!bResult) 145 | { 146 | CUIHelper::criticalWithCurrentError(L"Write Error", L"An error occurred when attempting to write data from handle."); 147 | } 148 | return (bResult); 149 | } 150 | 151 | unsigned long long getNumberOfSectors(HANDLE handle, unsigned long long *sectorsize) 152 | { 153 | DWORD junk; 154 | DISK_GEOMETRY_EX diskgeometry; 155 | BOOL bResult; 156 | bResult = DeviceIoControl(handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &diskgeometry, sizeof(diskgeometry), &junk, NULL); 157 | if (!bResult) 158 | { 159 | CUIHelper::criticalWithCurrentError(L"Device Error", L"An error occurred when attempting to get the device's geometry."); 160 | 161 | return 0; 162 | } 163 | if (sectorsize != NULL) 164 | { 165 | *sectorsize = (unsigned long long)diskgeometry.Geometry.BytesPerSector; 166 | } 167 | return (unsigned long long)diskgeometry.DiskSize.QuadPart / (unsigned long long)diskgeometry.Geometry.BytesPerSector; 168 | } 169 | 170 | unsigned long long getFileSizeInSectors(HANDLE handle, unsigned long long sectorsize) 171 | { 172 | unsigned long long retVal = 0; 173 | LARGE_INTEGER filesize; 174 | if(GetFileSizeEx(handle, &filesize) == 0) 175 | { 176 | CUIHelper::criticalWithCurrentError(L"File Error", L"An error occurred while getting the file size."); 177 | 178 | retVal = 0; 179 | } 180 | else 181 | { 182 | retVal = ((unsigned long long)filesize.QuadPart / sectorsize ) + (((unsigned long long)filesize.QuadPart % sectorsize )?1:0); 183 | } 184 | return(retVal); 185 | } 186 | 187 | bool spaceAvailable(const wchar_t *location, unsigned long long spaceneeded) 188 | { 189 | ULARGE_INTEGER freespace; 190 | BOOL bResult; 191 | bResult = GetDiskFreeSpaceEx(location, NULL, NULL, &freespace); 192 | if (!bResult) 193 | { 194 | std::wstring errormessage(L"Failed to get the free space on drive "); 195 | errormessage = errormessage + location + std::wstring(L". Checking of free space will be skipped."); 196 | 197 | CUIHelper::criticalWithCurrentError(L"File Error", errormessage.c_str()); 198 | 199 | return true; 200 | } 201 | return (spaceneeded <= freespace.QuadPart); 202 | } 203 | 204 | // given a drive letter (ending in a slash), return the label for that drive 205 | // TODO make this more robust by adding input verification 206 | UIString getDriveLabel(const wchar_t *drv) 207 | { 208 | UIString retVal; 209 | int szNameBuf = MAX_PATH + 1; 210 | wchar_t *nameBuf = NULL; 211 | if ((nameBuf = (wchar_t *)calloc(szNameBuf, sizeof(char))) != 0) 212 | { 213 | ::GetVolumeInformationW(drv, nameBuf, szNameBuf, NULL, 214 | NULL, NULL, NULL, 0); 215 | } 216 | 217 | // if malloc fails, nameBuf will be NULL. 218 | // if GetVolumeInfo fails, nameBuf will contain empty string 219 | // if all succeeds, nameBuf will contain label 220 | if(nameBuf == NULL) 221 | { 222 | retVal = UIString(L""); 223 | } 224 | else 225 | { 226 | retVal = UIString(nameBuf); 227 | free(nameBuf); 228 | } 229 | 230 | return(retVal); 231 | } 232 | 233 | BOOL GetDisksProperty(HANDLE hDevice, PSTORAGE_DEVICE_DESCRIPTOR pDevDesc, 234 | DEVICE_NUMBER *devInfo) 235 | { 236 | STORAGE_PROPERTY_QUERY Query; // input param for query 237 | DWORD dwOutBytes; // IOCTL output length 238 | BOOL bResult; // IOCTL return val 239 | BOOL retVal = true; 240 | DWORD cbBytesReturned; 241 | 242 | // specify the query type 243 | Query.PropertyId = StorageDeviceProperty; 244 | Query.QueryType = PropertyStandardQuery; 245 | Query.AdditionalParameters[0] = 0; 246 | 247 | // Query using IOCTL_STORAGE_QUERY_PROPERTY 248 | bResult = ::DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY, 249 | &Query, sizeof(STORAGE_PROPERTY_QUERY), pDevDesc, 250 | pDevDesc->Size, &dwOutBytes, (LPOVERLAPPED)NULL); 251 | if (bResult) 252 | { 253 | bResult = ::DeviceIoControl(hDevice, IOCTL_STORAGE_GET_DEVICE_NUMBER, 254 | NULL, 0, devInfo, sizeof(DEVICE_NUMBER), &dwOutBytes, 255 | (LPOVERLAPPED)NULL); 256 | if (!bResult) 257 | { 258 | retVal = false; 259 | 260 | CUIHelper::criticalWithCurrentError(L"File Error", 261 | L"An error occurred while getting the device number.\n" 262 | L"This usually means something is currently accessing the device;" 263 | L"please close all applications and try again.\n"); 264 | } 265 | } 266 | else 267 | { 268 | if (DeviceIoControl(hDevice, IOCTL_STORAGE_CHECK_VERIFY2, NULL, 0, NULL, 0, &cbBytesReturned, 269 | (LPOVERLAPPED) NULL)) 270 | { 271 | CUIHelper::criticalWithCurrentError(L"File Error", 272 | L"An error occurred while querying the properties.\n" 273 | L"This usually means something is currently accessing the device;" 274 | L"please close all applications and try again.\n"); 275 | } 276 | 277 | retVal = false; 278 | } 279 | 280 | return(retVal); 281 | } 282 | 283 | // for some reason my MingW compilter/toolchain doesn't know how to resolve these? easier to just do this than trying to figure out what's wrong 284 | typedef enum _StorageType { 285 | SBusTypeUsb = 0x07, 286 | SBusTypeSata = 0x0B, 287 | SBusTypeSd = 0x0C, 288 | SBusTypeMmc = 0x0D 289 | } StorageType; 290 | 291 | bool checkDriveType(const std::wstring name, ULONG *pid) 292 | { 293 | HANDLE hDevice; 294 | PSTORAGE_DEVICE_DESCRIPTOR pDevDesc; 295 | DEVICE_NUMBER deviceInfo; 296 | bool retVal = false; 297 | std::wstring nameWithSlash = name; 298 | std::wstring nameNoSlash = name; 299 | int driveType; 300 | DWORD cbBytesReturned; 301 | 302 | if (name.at(name.length() - 1) != '\\') { 303 | nameWithSlash.append(L"\\"); 304 | } else { 305 | nameNoSlash.resize(name.length() - 1); 306 | } 307 | 308 | driveType = GetDriveType(nameWithSlash.c_str()); 309 | switch( driveType ) 310 | { 311 | case DRIVE_REMOVABLE: // The media can be removed from the drive. 312 | case DRIVE_FIXED: // The media cannot be removed from the drive. 313 | hDevice = CreateFile(nameNoSlash.c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 314 | if (hDevice == INVALID_HANDLE_VALUE) 315 | { 316 | std::wstring errormessage = L"An error occurred when attempting to get a handle on "; 317 | errormessage += nameWithSlash; 318 | errormessage += L".\n"; 319 | CUIHelper::criticalWithCurrentError(L"Volume Error", errormessage.c_str()); 320 | } 321 | else 322 | { 323 | int arrSz = sizeof(STORAGE_DEVICE_DESCRIPTOR) + 512 - 1; 324 | pDevDesc = (PSTORAGE_DEVICE_DESCRIPTOR)new BYTE[arrSz]; 325 | pDevDesc->Size = arrSz; 326 | 327 | if (GetDisksProperty(hDevice, pDevDesc, &deviceInfo)) 328 | { 329 | // get the device number if the drive is 330 | // removable or (fixed AND on the usb bus, SD, or MMC (undefined in XP/mingw)) 331 | if ( 332 | (((driveType == DRIVE_REMOVABLE) && (pDevDesc->BusType != SBusTypeSata)) 333 | || ((driveType == DRIVE_FIXED) && ((pDevDesc->BusType == SBusTypeUsb) 334 | || (pDevDesc->BusType == SBusTypeSd) || (pDevDesc->BusType == SBusTypeMmc))))) 335 | { 336 | // ensure that the drive is actually accessible 337 | // multi-card hubs were reporting "removable" even when empty 338 | if (DeviceIoControl(hDevice, IOCTL_STORAGE_CHECK_VERIFY2, NULL, 0, NULL, 0, &cbBytesReturned, (LPOVERLAPPED)NULL)) 339 | { 340 | *pid = deviceInfo.DeviceNumber; 341 | retVal = true; 342 | } 343 | else 344 | // IOCTL_STORAGE_CHECK_VERIFY2 fails on some devices under XP/Vista, try the other (slower) method, just in case. 345 | { 346 | CloseHandle(hDevice); 347 | hDevice = CreateFile(nameNoSlash.c_str(), FILE_READ_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 348 | if (DeviceIoControl(hDevice, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, NULL, 0, &cbBytesReturned, (LPOVERLAPPED)NULL)) 349 | { 350 | *pid = deviceInfo.DeviceNumber; 351 | retVal = true; 352 | } 353 | } 354 | } 355 | 356 | } 357 | 358 | delete[] pDevDesc; 359 | CloseHandle(hDevice); 360 | } 361 | 362 | break; 363 | default: 364 | retVal = false; 365 | } 366 | 367 | return(retVal); 368 | } 369 | -------------------------------------------------------------------------------- /src/disk.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * This program is free software; you can redistribute it and/or * 3 | * modify it under the terms of the GNU General Public License * 4 | * as published by the Free Software Foundation; either version 2 * 5 | * of the License, or (at your option) any later version. * 6 | * * 7 | * This program is distributed in the hope that it will be useful, * 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 | * GNU General Public License for more details. * 11 | * * 12 | * You should have received a copy of the GNU General Public License * 13 | * along with this program; if not, see http://gnu.org/licenses/ 14 | * --- * 15 | * Copyright (C) 2009, Justin Davis * 16 | * Copyright (C) 2009-2014 ImageWriter developers * 17 | * https://launchpad.net/~image-writer-devs * 18 | **********************************************************************/ 19 | 20 | #ifndef DISK_H 21 | #define DISK_H 22 | 23 | #ifndef WINVER 24 | #define WINVER 0x0601 25 | #endif 26 | 27 | #include "ui_helper.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #ifndef FSCTL_IS_VOLUME_MOUNTED 34 | #define FSCTL_IS_VOLUME_MOUNTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS) 35 | #endif // FSCTL_IS_VOLUME_MOUNTED 36 | 37 | typedef struct _DEVICE_NUMBER 38 | { 39 | DEVICE_TYPE DeviceType; 40 | ULONG DeviceNumber; 41 | ULONG PartitionNumber; 42 | } DEVICE_NUMBER, *PDEVICE_NUMBER; 43 | 44 | // IOCTL control code 45 | #define IOCTL_STORAGE_QUERY_PROPERTY CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS) 46 | 47 | HANDLE getHandleOnFile(LPCWSTR filelocation, DWORD access); 48 | HANDLE getHandleOnDevice(int device, DWORD access); 49 | HANDLE getHandleOnVolume(int volume, DWORD access); 50 | UIString getDriveLabel(const char *drv); 51 | bool getLockOnVolume(HANDLE handle); 52 | bool removeLockOnVolume(HANDLE handle); 53 | bool unmountVolume(HANDLE handle); 54 | bool isVolumeUnmounted(HANDLE handle); 55 | char *readSectorDataFromHandle(HANDLE handle, unsigned long long startsector, unsigned long long numsectors, unsigned long long sectorsize); 56 | bool writeSectorDataToHandle(HANDLE handle, char *data, unsigned long long startsector, unsigned long long numsectors, unsigned long long sectorsize); 57 | unsigned long long getNumberOfSectors(HANDLE handle, unsigned long long *sectorsize); 58 | unsigned long long getFileSizeInSectors(HANDLE handle, unsigned long long sectorsize); 59 | bool spaceAvailable(char *location, unsigned long long spaceneeded); 60 | bool checkDriveType(const std::wstring name, ULONG *pid); 61 | 62 | #endif // DISK_H 63 | -------------------------------------------------------------------------------- /src/diskimager_cn.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Win32 磁盘映像工具 9 | 10 | 11 | 12 | 13 | 映像文件 14 | 15 | 16 | 17 | 18 | ... 19 | 20 | 21 | 22 | 23 | 设备 24 | 25 | 26 | 27 | 28 | 选中则为映像文件产生MD5 Hash 29 | 30 | 31 | 32 | 33 | MD5 Hash: 34 | 35 | 36 | 37 | 38 | 任务进度条 39 | 40 | 41 | 42 | 43 | %p% 44 | 45 | 46 | 47 | 48 | 取消任务 49 | 50 | 51 | 52 | 53 | 取消 54 | 55 | 56 | 57 | 58 | 閱讀從“設備”的數據並寫入'文件' 59 | 60 | 61 | 62 | 63 | 读取 64 | 65 | 66 | 67 | 68 | 写入数据 '映像文件' 到 '设备' 69 | 70 | 71 | 72 | 73 | 写入 74 | 75 | 76 | 77 | 78 | Exit Win32 Disk Imager 79 | 80 | 81 | 82 | 83 | 退出 84 | 85 | 86 | 87 | 88 | 89 | 退出? 90 | 91 | 92 | 93 | 94 | 现在退出映像文件将不完整. 95 | 仍然退出? 96 | 97 | 98 | 99 | 100 | 现在退出将造成磁盘文件不完整. 101 | 仍然退出? 102 | 103 | 104 | 105 | 106 | 选择一个磁盘映像 107 | 108 | 109 | 110 | 111 | 生成中... 112 | 113 | 114 | 115 | 116 | 取消? 117 | 118 | 119 | 120 | 121 | 现在取消会造成目的文件不完整. 122 | 仍然取消? 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 写入出错 131 | 132 | 133 | 134 | 135 | 136 | 在目标设备上找不到映像文件. 137 | 138 | 139 | 140 | 141 | 确认覆盖 142 | 143 | 144 | 145 | 146 | 写入物理设备可能会造成该设备不可使用. 147 | (设备: %1 "%2") 148 | 是否继续? 149 | 150 | 151 | 152 | 153 | 该磁盘空间不够: 容量: %1 sectors 可以使用: %2 sectors Sector size: %3 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 文件错误 162 | 163 | 164 | 165 | 166 | 文件不存在. 167 | 168 | 169 | 170 | 171 | 没有读取该文件的权限. 172 | 173 | 174 | 175 | 176 | 该文件为空文件. 177 | 178 | 179 | 180 | 181 | 完成. 182 | 183 | 184 | 185 | 186 | 187 | 完成 188 | 189 | 190 | 191 | 192 | 写入成功. 193 | 194 | 195 | 196 | 197 | 请选中要使用的影响文件. 198 | 199 | 200 | 201 | 202 | 文件已存在 203 | 204 | 205 | 206 | 207 | 缺人覆盖已存在的文件? 208 | 209 | 210 | 211 | 212 | 硬盘空间不够. 213 | 214 | 215 | 216 | 217 | 读取成功. 218 | 219 | 220 | 221 | 222 | 文件信息 223 | 224 | 225 | 226 | 227 | 请选择要保存的文件路径. 228 | 229 | 230 | 231 | 232 | QObject 233 | 234 | 235 | 236 | 237 | 238 | 文件错误 239 | 240 | 241 | 242 | 243 | 获取文件句柄失败. 244 | 错误 %1: %2 245 | 246 | 247 | 248 | 249 | 250 | 错误设备 251 | 252 | 253 | 254 | 255 | 获取设备句柄失败. 256 | 错误 %1: %2 257 | 258 | 259 | 260 | 261 | 262 | 卷错误 263 | 264 | 265 | 266 | 267 | 获取卷句柄失败 268 | 错误 %1: %2 269 | 270 | 271 | 272 | 273 | 锁错误 274 | 275 | 276 | 277 | 278 | 锁该卷时发生错误. 279 | 错误 %1: %2 280 | 281 | 282 | 283 | 284 | 解锁失败 285 | 286 | 287 | 288 | 289 | 解锁改卷时失败. 290 | 错误 %1: %2 291 | 292 | 293 | 294 | 295 | 卸载失败 296 | 297 | 298 | 299 | 300 | 卸载卷时发生错误 . 301 | 错误 %1: %2 302 | 303 | 304 | 305 | 306 | 读取失败 307 | 308 | 309 | 310 | 311 | 从该句柄中读取数据发生错误. 312 | 错误 %1: %2 313 | 314 | 315 | 316 | 317 | 写入失败 318 | 319 | 320 | 321 | 322 | 向该句柄写入数据时发生错误. 323 | 错误 %1: %2 324 | 325 | 326 | 327 | 328 | 无法获取设备's geometry. 329 | 错误 %1: %2 330 | 331 | 332 | 333 | 334 | 无法获取文件大小. 335 | 错误 %1: %2 336 | 337 | 338 | 339 | 340 | 剩余空间 341 | 342 | 343 | 344 | 345 | 无法得到驱动器剩余空间 %1. 346 | 错误 %2: %3 347 | 已忽略剩余空间检查. 348 | 349 | 350 | 351 | 352 | 获取设备号失败. 353 | 通常发生该错误是由于其他程序正在访问该设备;请关闭相关程序重试. 354 | 355 | 错误 %1: %2 356 | 357 | 358 | 359 | 360 | 获取属性信息失败. 361 | 通常发生该错误是由于其他程序正在访问该设备;请关闭相关程序重试. 362 | 363 | 错误 %1: %2 364 | 365 | 366 | 367 | 368 | 获取句柄时发生错误 %3. 369 | 错误 %1: %2 370 | 371 | 372 | 373 | 374 | -------------------------------------------------------------------------------- /src/diskimager_de_de.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Win32 Disk Imager 9 | Win32 Disk Imager 10 | 11 | 12 | 13 | Image File 14 | Image-Datei 15 | 16 | 17 | 18 | ... 19 | ... 20 | 21 | 22 | 23 | Device 24 | Datenträger 25 | 26 | 27 | 28 | If checked, will generate the MD5 hash for the image file 29 | Wenn aktiviert, wird der MD5-Hash für die Image-Datei generieren. 30 | 31 | 32 | 33 | MD5 Hash: 34 | MD5-Hash: 35 | 36 | 37 | 38 | Progress 39 | Fortschritt 40 | 41 | 42 | 43 | %p% 44 | %p% 45 | 46 | 47 | 48 | Cancel current process. 49 | Aktuellen Vorgang abbrechen. 50 | 51 | 52 | 53 | Cancel 54 | Abbrechen 55 | 56 | 57 | 58 | Read data from 'Device' to 'Image File' 59 | Vom Datenträger lesen und als Image-Datei schreiben 60 | 61 | 62 | 63 | Read 64 | Lesen 65 | 66 | 67 | 68 | Write data from 'Image File' to 'Device' 69 | Schreibe Image Datei auf den Datenträger 70 | 71 | 72 | 73 | Write 74 | Schreiben 75 | 76 | 77 | 78 | Exit Win32 Disk Imager 79 | Win32 Disk Imager beenden 80 | 81 | 82 | 83 | Exit 84 | Beenden 85 | 86 | 87 | 88 | 89 | Exit? 90 | Beenden? 91 | 92 | 93 | 94 | Exiting now will result in a corrupt image file. 95 | Are you sure you want to exit? 96 | Wenn Sie jetzt das Programm beenden, führt das zu einer beschädigte Image-Datei. Sind Sie sicher, dass Sie beenden möchten? 97 | 98 | 99 | 100 | Exiting now will result in a corrupt disk. 101 | Are you sure you want to exit? 102 | Wenn Sie jetzt das Programm beenden, führt das zu einem beschädigten Datenträger. Sind Sie sicher, dass Sie beenden möchten? 103 | 104 | 105 | 106 | Select a disk image 107 | Wählen Sie eine Image-Datei 108 | 109 | 110 | 111 | Generating... 112 | Erstellen... 113 | 114 | 115 | 116 | Cancel? 117 | Abbrechen? 118 | 119 | 120 | 121 | Canceling now will result in a corrupt destination. 122 | Are you sure you want to cancel? 123 | Wenn Sie jetzt abbrechen, führt das zu einem beschädigtem Ziel. Sind Sie sicher, dass Sie jetzt abbrechen möchten? 124 | 125 | 126 | 127 | 128 | 129 | 130 | Write Error 131 | Fehler beim Schreiben 132 | 133 | 134 | 135 | 136 | Image file cannot be located on the target device. 137 | Image-Datei kann nicht auf dem Zielgerät gefunden werden. 138 | 139 | 140 | 141 | Confirm overwrite 142 | Überschreiben bestätigen 143 | 144 | 145 | 146 | Writing to a physical device can corrupt the device. 147 | (Target Device: %1 "%2") 148 | Are you sure you want to continue? 149 | Auf ein physikalisches Gerät schreiben, kann dieses beschädigen. (Zielgerät: %1 „%2“) Sind Sie sicher, dass sie fortfahren möchten? 150 | 151 | 152 | 153 | Not enough space on disk: Size: %1 sectors Available: %2 sectors Sector size: %3 154 | Nicht genügend Speicherplatz auf dem Datenträger: Größe: %1 Sektoren Verfügbar: %2 Sektoren Sektorgröße: %3 155 | 156 | 157 | 158 | 159 | 160 | 161 | File Error 162 | Dateifehler 163 | 164 | 165 | 166 | The selected file does not exist. 167 | Die ausgewählte Datei ist nicht vorhanden. 168 | 169 | 170 | 171 | You do not have permision to read the selected file. 172 | Sie haben keine Erlaubnis, die ausgewählte Datei zu lesen. 173 | 174 | 175 | 176 | The specified file contains no data. 177 | Die angegebene Datei enthält keine Daten. 178 | 179 | 180 | 181 | Done. 182 | Erledigt. 183 | 184 | 185 | 186 | 187 | Complete 188 | Abschließen 189 | 190 | 191 | 192 | Write Successful. 193 | Schreiben war erfolgreich. 194 | 195 | 196 | 197 | Please specify an image file to use. 198 | Bitte geben Sie eine Image-Datei an, die Sie verwenden wollen. 199 | 200 | 201 | 202 | Confirm Overwrite 203 | Überschreiben bestätigen 204 | 205 | 206 | 207 | Are you sure you want to overwrite the specified file? 208 | Sind Sie sicher, dass die angegebene Datei überschrieben werden soll? 209 | 210 | 211 | 212 | Disk is not large enough for the specified image. 213 | Der Datenträger ist nicht groß genug für die angegebene Image-Date. 214 | 215 | 216 | 217 | Read Successful. 218 | Lesen war erfolgreich. 219 | 220 | 221 | 222 | File Info 223 | Datei-Info 224 | 225 | 226 | 227 | Please specify a file to save data to. 228 | Bitte geben Sie eine Datei an zum Speichern der Daten. 229 | 230 | 231 | 232 | QObject 233 | 234 | 235 | 236 | 237 | 238 | File Error 239 | Dateifehler 240 | 241 | 242 | 243 | An error occurred when attempting to get a handle on the file. 244 | Error %1: %2 245 | Fehler beim Versuch, ein Handle auf die Datei zu erhalten. Fehler %1: %2 246 | 247 | 248 | 249 | 250 | Device Error 251 | Gerätefehler 252 | 253 | 254 | 255 | An error occurred when attempting to get a handle on the device. 256 | Error %1: %2 257 | Fehler beim Versuch, ein Handle auf das Gerät zu erhalten. Fehler %1: %2 258 | 259 | 260 | 261 | 262 | Volume Error 263 | Volumenfehler 264 | 265 | 266 | 267 | An error occurred when attempting to get a handle on the volume. 268 | Error %1: %2 269 | Fehler beim Versuch, ein Handle auf das Volumen zu erhalten. Fehler %1: %2 270 | 271 | 272 | 273 | Lock Error 274 | Sperrfehler 275 | 276 | 277 | 278 | An error occurred when attempting to lock the volume. 279 | Error %1: %2 280 | Fehler beim Versuch, das Volumen zu sperren. Fehler %1: %2 281 | 282 | 283 | 284 | Unlock Error 285 | Entsperrfehler 286 | 287 | 288 | 289 | An error occurred when attempting to unlock the volume. 290 | Error %1: %2 291 | Fehler beim Versuch, das Volumen zu entsperren. Fehler %1: %2 292 | 293 | 294 | 295 | Dismount Error 296 | Aushängen Fehler 297 | 298 | 299 | 300 | An error occurred when attempting to dismount the volume. 301 | Error %1: %2 302 | Fehler beim Versuch, das Volumen auszuhängen. Fehler %1: %2 303 | 304 | 305 | 306 | Read Error 307 | Lesefehler 308 | 309 | 310 | 311 | An error occurred when attempting to read data from handle. 312 | Error %1: %2 313 | Fehler beim Versuch, Daten zu lesen. Fehler %1: %2 314 | 315 | 316 | 317 | Write Error 318 | Fehler beim Schreiben 319 | 320 | 321 | 322 | An error occurred when attempting to write data to handle. 323 | Error %1: %2 324 | Fehler beim Versuch, Daten zu schreiben. Fehler %1: %2 325 | 326 | 327 | 328 | An error occurred when attempting to get the device's geometry. 329 | Error %1: %2 330 | Fehler beim Versuch, die Gerätegeometrie abzufragen. Fehler %1: %2 331 | 332 | 333 | 334 | An error occurred while getting the file size. 335 | Error %1: %2 336 | Fehler beim Versuch, die Dateigröße abzufragen. Fehler %1: %2 337 | 338 | 339 | 340 | Free Space Error 341 | Fehler des freier Speicherplatz 342 | 343 | 344 | 345 | Failed to get the free space on drive %1. 346 | Error %2: %3 347 | Checking of free space will be skipped. 348 | Fehler beim Abrufen den freien Speicherplatz auf Laufwerk %1. Fehler %2: %3 Überprüfung des freien Speicherplatzes wird übersprungen. 349 | 350 | 351 | 352 | An error occurred while getting the device number. 353 | This usually means something is currently accessing the device;please close all applications and try again. 354 | 355 | Error %1: %2 356 | Fehler beim Abrufen der Gerätenummer. Dies bedeutet in der Regel, dass derzeit etwas Zugriff auf das Gerät hat, bitte schließen Sie alle Anwendungen und versuchen Sie es erneut. Fehler %1: %2 357 | 358 | 359 | 360 | An error occurred while querying the properties. 361 | This usually means something is currently accessing the device; please close all applications and try again. 362 | 363 | Error %1: %2 364 | Fehler beim Abfragen der Eigenschaften. Dies bedeutet in der Regel, dass derzeit etwas Zugriff auf das Gerät hat, bitte schließen Sie alle Anwendungen und versuchen Sie es erneut. Fehler %1: %2 365 | 366 | 367 | 368 | An error occurred when attempting to get a handle on %3. 369 | Error %1: %2 370 | Fehler beim Versuch, ein Handle auf %3. Fehler %1: %2 371 | 372 | 373 | 374 | -------------------------------------------------------------------------------- /src/diskimager_en.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Win32 Disk Imager 9 | 10 | 11 | 12 | 13 | Image File 14 | 15 | 16 | 17 | 18 | ... 19 | 20 | 21 | 22 | 23 | Device 24 | 25 | 26 | 27 | 28 | If checked, will generate the MD5 hash for the image file 29 | 30 | 31 | 32 | 33 | MD5 Hash: 34 | 35 | 36 | 37 | 38 | Progress 39 | 40 | 41 | 42 | 43 | %p% 44 | 45 | 46 | 47 | 48 | Cancel current process. 49 | 50 | 51 | 52 | 53 | Cancel 54 | 55 | 56 | 57 | 58 | Read data from 'Device' to 'Image File' 59 | 60 | 61 | 62 | 63 | Read 64 | 65 | 66 | 67 | 68 | Write data from 'Image File' to 'Device' 69 | 70 | 71 | 72 | 73 | Write 74 | 75 | 76 | 77 | 78 | Exit Win32 Disk Imager 79 | 80 | 81 | 82 | 83 | Exit 84 | 85 | 86 | 87 | 88 | 89 | Exit? 90 | 91 | 92 | 93 | 94 | Exiting now will result in a corrupt image file. 95 | Are you sure you want to exit? 96 | 97 | 98 | 99 | 100 | Exiting now will result in a corrupt disk. 101 | Are you sure you want to exit? 102 | 103 | 104 | 105 | 106 | Select a disk image 107 | 108 | 109 | 110 | 111 | Generating... 112 | 113 | 114 | 115 | 116 | Cancel? 117 | 118 | 119 | 120 | 121 | Canceling now will result in a corrupt destination. 122 | Are you sure you want to cancel? 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | Write Error 131 | 132 | 133 | 134 | 135 | 136 | Image file cannot be located on the target device. 137 | 138 | 139 | 140 | 141 | Confirm overwrite 142 | 143 | 144 | 145 | 146 | Writing to a physical device can corrupt the device. 147 | (Target Device: %1 "%2") 148 | Are you sure you want to continue? 149 | 150 | 151 | 152 | 153 | Not enough space on disk: Size: %1 sectors Available: %2 sectors Sector size: %3 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | File Error 162 | 163 | 164 | 165 | 166 | The selected file does not exist. 167 | 168 | 169 | 170 | 171 | You do not have permision to read the selected file. 172 | 173 | 174 | 175 | 176 | The specified file contains no data. 177 | 178 | 179 | 180 | 181 | Done. 182 | 183 | 184 | 185 | 186 | 187 | Complete 188 | 189 | 190 | 191 | 192 | Write Successful. 193 | 194 | 195 | 196 | 197 | Please specify an image file to use. 198 | 199 | 200 | 201 | 202 | Confirm Overwrite 203 | 204 | 205 | 206 | 207 | Are you sure you want to overwrite the specified file? 208 | 209 | 210 | 211 | 212 | Disk is not large enough for the specified image. 213 | 214 | 215 | 216 | 217 | Read Successful. 218 | 219 | 220 | 221 | 222 | File Info 223 | 224 | 225 | 226 | 227 | Please specify a file to save data to. 228 | 229 | 230 | 231 | 232 | QObject 233 | 234 | 235 | 236 | 237 | 238 | File Error 239 | 240 | 241 | 242 | 243 | An error occurred when attempting to get a handle on the file. 244 | Error %1: %2 245 | 246 | 247 | 248 | 249 | 250 | Device Error 251 | 252 | 253 | 254 | 255 | An error occurred when attempting to get a handle on the device. 256 | Error %1: %2 257 | 258 | 259 | 260 | 261 | 262 | Volume Error 263 | 264 | 265 | 266 | 267 | An error occurred when attempting to get a handle on the volume. 268 | Error %1: %2 269 | 270 | 271 | 272 | 273 | Lock Error 274 | 275 | 276 | 277 | 278 | An error occurred when attempting to lock the volume. 279 | Error %1: %2 280 | 281 | 282 | 283 | 284 | Unlock Error 285 | 286 | 287 | 288 | 289 | An error occurred when attempting to unlock the volume. 290 | Error %1: %2 291 | 292 | 293 | 294 | 295 | Dismount Error 296 | 297 | 298 | 299 | 300 | An error occurred when attempting to dismount the volume. 301 | Error %1: %2 302 | 303 | 304 | 305 | 306 | Read Error 307 | 308 | 309 | 310 | 311 | An error occurred when attempting to read data from handle. 312 | Error %1: %2 313 | 314 | 315 | 316 | 317 | Write Error 318 | 319 | 320 | 321 | 322 | An error occurred when attempting to write data to handle. 323 | Error %1: %2 324 | 325 | 326 | 327 | 328 | An error occurred when attempting to get the device's geometry. 329 | Error %1: %2 330 | 331 | 332 | 333 | 334 | An error occurred while getting the file size. 335 | Error %1: %2 336 | 337 | 338 | 339 | 340 | Free Space Error 341 | 342 | 343 | 344 | 345 | Failed to get the free space on drive %1. 346 | Error %2: %3 347 | Checking of free space will be skipped. 348 | 349 | 350 | 351 | 352 | An error occurred while getting the device number. 353 | This usually means something is currently accessing the device;please close all applications and try again. 354 | 355 | Error %1: %2 356 | 357 | 358 | 359 | 360 | An error occurred while querying the properties. 361 | This usually means something is currently accessing the device; please close all applications and try again. 362 | 363 | Error %1: %2 364 | 365 | 366 | 367 | 368 | An error occurred when attempting to get a handle on %3. 369 | Error %1: %2 370 | 371 | 372 | 373 | 374 | -------------------------------------------------------------------------------- /src/diskimager_fr.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Win32 Disk Imager 9 | Win32 Disk Imager 10 | 11 | 12 | 13 | Image File 14 | Fichier image 15 | 16 | 17 | 18 | ... 19 | 20 | 21 | 22 | 23 | Device 24 | Périphérique 25 | 26 | 27 | 28 | If checked, will generate the MD5 hash for the image file 29 | Si coché, va générer le hash MD5 du fichier image 30 | 31 | 32 | 33 | MD5 Hash: 34 | Hash MD5: 35 | 36 | 37 | 38 | Progress 39 | Progression 40 | 41 | 42 | 43 | %p% 44 | %p% 45 | 46 | 47 | 48 | Cancel current process. 49 | Annuler la tâche en cours. 50 | 51 | 52 | 53 | Cancel 54 | Annuler 55 | 56 | 57 | 58 | Read data from 'Device' to 'Image File' 59 | Lire les données depuis 'Périphérique' vers le fichier image 60 | 61 | 62 | 63 | Read 64 | Lire 65 | 66 | 67 | 68 | Write data from 'Image File' to 'Device' 69 | Ecrire les données du 'fichier image' sur le 'Périphérique' 70 | 71 | 72 | 73 | Write 74 | Ecrire 75 | 76 | 77 | 78 | Exit Win32 Disk Imager 79 | Fermer Win32 Disk Imager 80 | 81 | 82 | 83 | Exit 84 | Fermer 85 | 86 | 87 | 88 | 89 | Exit? 90 | Fermer? 91 | 92 | 93 | 94 | Exiting now will result in a corrupt image file. 95 | Are you sure you want to exit? 96 | Quitter maintenant vous donnera un fichier image corrompu. Etes-vous sûr de vouloir quitter? 97 | 98 | 99 | 100 | Exiting now will result in a corrupt disk. 101 | Are you sure you want to exit? 102 | Quitter maintenant résultera en un disque corrompu. Etes-vous sûr de vouloir quitter? 103 | 104 | 105 | 106 | Select a disk image 107 | Sélectionner une image disque 108 | 109 | 110 | 111 | Generating... 112 | Génération... 113 | 114 | 115 | 116 | Cancel? 117 | Annuler? 118 | 119 | 120 | 121 | Canceling now will result in a corrupt destination. 122 | Are you sure you want to cancel? 123 | Annuler maintenant corrompera la destination. Etes-vous sûr de vouloir annuler? 124 | 125 | 126 | 127 | 128 | 129 | 130 | Write Error 131 | Erreur d'écriture 132 | 133 | 134 | 135 | 136 | Image file cannot be located on the target device. 137 | Le fichier image n'a pas été trouvé sur le périphérique cible. 138 | 139 | 140 | 141 | Confirm overwrite 142 | Confirmer l'écrasement 143 | 144 | 145 | 146 | Writing to a physical device can corrupt the device. 147 | (Target Device: %1 "%2") 148 | Are you sure you want to continue? 149 | Ecrire sur un périphérique physique peut le corrompre. 150 | (Périphérique cible: %1 "%2") 151 | Etes-vous sûr de vouloir continuer? 152 | 153 | 154 | 155 | Not enough space on disk: Size: %1 sectors Available: %2 sectors Sector size: %3 156 | Pas assez d'espace disponible sur le disque: Taille: %1 secteurs Disponible: %2 secteurs Taille d'un secteur: %3 157 | 158 | 159 | 160 | 161 | 162 | 163 | File Error 164 | Erreur de fichier 165 | 166 | 167 | 168 | The selected file does not exist. 169 | Le fichier sélectionné n'existe pas. 170 | 171 | 172 | 173 | You do not have permision to read the selected file. 174 | Vous n'avez pas la permission de lire le fichier sélectionné. 175 | 176 | 177 | 178 | The specified file contains no data. 179 | Le fichier spécifié ne contient aucune donnée. 180 | 181 | 182 | 183 | Done. 184 | Effectué. 185 | 186 | 187 | 188 | 189 | Complete 190 | Terminé 191 | 192 | 193 | 194 | Write Successful. 195 | Ecriture réussie. 196 | 197 | 198 | 199 | Please specify an image file to use. 200 | Merci de spécifier le fichier image à utiliser. 201 | 202 | 203 | 204 | Confirm Overwrite 205 | Confirmer l'écrasement 206 | 207 | 208 | 209 | Are you sure you want to overwrite the specified file? 210 | Etes-vous sur de vouloir écraser le fichier spécifié? 211 | 212 | 213 | 214 | Disk is not large enough for the specified image. 215 | Le disque n'est pas assez grand pour contenir l'image spécifiée. 216 | 217 | 218 | 219 | Read Successful. 220 | Lecture effectuée avec succès. 221 | 222 | 223 | 224 | File Info 225 | Infos sur le fichier 226 | 227 | 228 | 229 | Please specify a file to save data to. 230 | Merci de spécifier un fichier dans lequel sauvegarder les données 231 | 232 | 233 | 234 | QObject 235 | 236 | 237 | 238 | 239 | 240 | File Error 241 | Erreur fichier 242 | 243 | 244 | 245 | An error occurred when attempting to get a handle on the file. 246 | Error %1: %2 247 | Une erreur est apparue lors de la tentative d'accès au fichier. 248 | Erreur %1: %2 249 | 250 | 251 | 252 | 253 | Device Error 254 | Erreur du périphérique 255 | 256 | 257 | 258 | An error occurred when attempting to get a handle on the device. 259 | Error %1: %2 260 | Une erreur est apparue lors de la tentative d'accès au périphérique. 261 | Erreur %1: %2 262 | 263 | 264 | 265 | 266 | Volume Error 267 | Erreur du volume 268 | 269 | 270 | 271 | An error occurred when attempting to get a handle on the volume. 272 | Error %1: %2 273 | Une erreur est apparue lors de la tentative d'accès au volume. 274 | Erreur %1: %2 275 | 276 | 277 | 278 | Lock Error 279 | Erreur de verrouillage 280 | 281 | 282 | 283 | An error occurred when attempting to lock the volume. 284 | Error %1: %2 285 | Une erreur est apparue lors de la tentative de verrouillage du volume. 286 | Erreur %1: %2 287 | 288 | 289 | 290 | Unlock Error 291 | Erreur de déverrouillage 292 | 293 | 294 | 295 | An error occurred when attempting to unlock the volume. 296 | Error %1: %2 297 | Une erreur est apparue lors de la tentative de déverrouillage du volume. 298 | Erreur %1: %2 299 | 300 | 301 | 302 | Dismount Error 303 | Erreur de démontage 304 | 305 | 306 | 307 | An error occurred when attempting to dismount the volume. 308 | Error %1: %2 309 | Une erreur est apparue lors de la tentative de démonter le volume. 310 | Erreur %1: %2 311 | 312 | 313 | 314 | Read Error 315 | Erreur de lecture 316 | 317 | 318 | 319 | An error occurred when attempting to read data from handle. 320 | Error %1: %2 321 | Une erreur est apparue lors de la tentative de lecture des données. 322 | Erreur %1: %2 323 | 324 | 325 | 326 | Write Error 327 | Erreur d'écriture 328 | 329 | 330 | 331 | An error occurred when attempting to write data to handle. 332 | Error %1: %2 333 | Une erreur est apparue lors de la tentative d'écriture des données. 334 | Erreur %1: %2 335 | 336 | 337 | 338 | An error occurred when attempting to get the device's geometry. 339 | Error %1: %2 340 | Une erreur est apparue lors de la tentative d'obtention de la géométrie du périphérique. 341 | Erreur %1: %2 342 | 343 | 344 | 345 | An error occurred while getting the file size. 346 | Error %1: %2 347 | Une erreur s'est produite lors de l'obtention de la taille du fichier. 348 | Erreur %1: %2 349 | 350 | 351 | 352 | Free Space Error 353 | Erreur d'espace libre 354 | 355 | 356 | 357 | Failed to get the free space on drive %1. 358 | Error %2: %3 359 | Checking of free space will be skipped. 360 | Echec d'obtention de l'espace libre sur le disque %1. 361 | Erreur %2: %3 362 | La vérification de l'espace libre ne sera pas effectuée. 363 | 364 | 365 | 366 | An error occurred while getting the device number. 367 | This usually means something is currently accessing the device;please close all applications and try again. 368 | 369 | Error %1: %2 370 | Une erreur s'est produite lors de la récupération du numéro du périphérique. 371 | Cela signifie généralement que quelque chose est en train d'accéder au dispositif, s'il vous plaît fermez toutes les applications et essayez à nouveau. 372 | 373 | Erreur %1: %2 374 | 375 | 376 | 377 | An error occurred while querying the properties. 378 | This usually means something is currently accessing the device; please close all applications and try again. 379 | 380 | Error %1: %2 381 | Une erreur s'est produite lors de l'interrogation des propriétés. 382 | Cela signifie généralement que quelque chose est en train d'accéder au dispositif; s'il vous plaît fermez toutes les applications et essayez à nouveau. 383 | 384 | Erreur %1: %2 385 | 386 | 387 | 388 | An error occurred when attempting to get a handle on %3. 389 | Error %1: %2 390 | Une erreur s'est produite lors de la tentative d'accès su r%3. 391 | Erreur %1: %2 392 | 393 | 394 | 395 | -------------------------------------------------------------------------------- /src/diskimager_pl.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Win32 Disk Imager 9 | Win32 Disk Imager 10 | 11 | 12 | 13 | Image File 14 | Plik Obrazu 15 | 16 | 17 | 18 | ... 19 | ... 20 | 21 | 22 | 23 | Device 24 | Urządzenie 25 | 26 | 27 | 28 | If checked, will generate the MD5 hash for the image file 29 | Jeśli zaznaczone, wygeneruje hash MD5 dla pliku obrazu 30 | 31 | 32 | 33 | MD5 Hash: 34 | Hash MD5: 35 | 36 | 37 | 38 | Progress 39 | Postęp 40 | 41 | 42 | 43 | %p% 44 | %p% 45 | 46 | 47 | 48 | Cancel current process. 49 | Anuluj obecny proces. 50 | 51 | 52 | 53 | Cancel 54 | Anuluj 55 | 56 | 57 | 58 | Read data from 'Device' to 'Image File' 59 | Czytaj dane z 'Urządzenie' do 'Plik Obrazu' 60 | 61 | 62 | 63 | Read 64 | Czytaj 65 | 66 | 67 | 68 | Write data from 'Image File' to 'Device' 69 | prawdopodobnie oryginał zepsuty, EDIT(31.08.13): chyba jednak codziło tylko o nazwę pola. 70 | Zapisz dane w "Plik Obrazu' do "Urządzenie' 71 | 72 | 73 | 74 | Write 75 | Zapisz 76 | 77 | 78 | 79 | Exit Win32 Disk Imager 80 | Wyjdź z Win32 Disk Imager 81 | 82 | 83 | 84 | Exit 85 | Wyjdź 86 | 87 | 88 | 89 | 90 | Exit? 91 | Wyjść? 92 | 93 | 94 | 95 | Exiting now will result in a corrupt image file. 96 | Are you sure you want to exit? 97 | Wyjście teraz spowoduje uszkodzenie pliku obrazu. Czy na pewno chcesz wyjść? 98 | 99 | 100 | 101 | Exiting now will result in a corrupt disk. 102 | Are you sure you want to exit? 103 | Wyjście teraz spowoduje uszkodzenie dysku. Czy na pewno chcesz wyjść? 104 | 105 | 106 | 107 | Select a disk image 108 | Wybierz obraz dysku 109 | 110 | 111 | 112 | Generating... 113 | Generowanie... 114 | 115 | 116 | 117 | Cancel? 118 | Anulować? 119 | 120 | 121 | 122 | Canceling now will result in a corrupt destination. 123 | Are you sure you want to cancel? 124 | Anulowanie teraz spowoduje uszkodzenie celu. Czy na pewno chcesz wyjść? 125 | 126 | 127 | 128 | 129 | 130 | 131 | Write Error 132 | Błąd Zapisu 133 | 134 | 135 | 136 | 137 | Image file cannot be located on the target device. 138 | Plik obrazu nie może zostać umieszczony na urządzeniu docelowym. 139 | 140 | 141 | 142 | Confirm overwrite 143 | Potwierdź Nadpisanie 144 | 145 | 146 | 147 | Writing to a physical device can corrupt the device. 148 | (Target Device: %1 "%2") 149 | Are you sure you want to continue? 150 | Zapis na urządzeniu fizycznym może uszkodzić urządzenie. 151 | (Urządzenie docelowe: %1 "%2") 152 | Czy chcesz kontynuować? 153 | 154 | 155 | 156 | Not enough space on disk: Size: %1 sectors Available: %2 sectors Sector size: %3 157 | Niewystarczająca ilość miejsca na dysku: Rozmiar: %1 sektorów Dostępne: %2 sektorów Rozmiar sektora: %3 158 | 159 | 160 | 161 | 162 | 163 | 164 | File Error 165 | Błąd Pliku 166 | 167 | 168 | 169 | The selected file does not exist. 170 | Wybrany plik nie istnieje. 171 | 172 | 173 | 174 | You do not have permision to read the selected file. 175 | Nie masz uprawnień aby odczytać wybrany plik. 176 | 177 | 178 | 179 | The specified file contains no data. 180 | Wybrany plik nie zawiera danych. 181 | 182 | 183 | 184 | Done. 185 | Zrobione. 186 | 187 | 188 | 189 | 190 | Complete 191 | Gotowe 192 | 193 | 194 | 195 | Write Successful. 196 | Zapis Pomyślny. 197 | 198 | 199 | 200 | Please specify an image file to use. 201 | Proszę wybrać plik obrazu do użycia. 202 | 203 | 204 | 205 | Confirm Overwrite 206 | Potwierdź Nadpisanie 207 | 208 | 209 | 210 | Are you sure you want to overwrite the specified file? 211 | Czy jesteś pewien że chcesz nadpisać wybrany plik? 212 | 213 | 214 | 215 | Disk is not large enough for the specified image. 216 | Dysk nie jest odpowiednio wielki dla wybranego obrazu. 217 | 218 | 219 | 220 | Read Successful. 221 | Odczyt Pomyślny. 222 | 223 | 224 | 225 | File Info 226 | Info Pliku 227 | 228 | 229 | 230 | Please specify a file to save data to. 231 | Proszę wybrać plik do którego zapisać dane. 232 | 233 | 234 | 235 | QObject 236 | 237 | 238 | 239 | 240 | 241 | File Error 242 | Błąd Pliku 243 | 244 | 245 | 246 | An error occurred when attempting to get a handle on the file. 247 | Error %1: %2 248 | Wystąpił błąd podczas próby obsługi pliku. 249 | Błąd %1: %2 250 | 251 | 252 | 253 | 254 | Device Error 255 | Błąd Urządzenia 256 | 257 | 258 | 259 | An error occurred when attempting to get a handle on the device. 260 | Error %1: %2 261 | Wystąpił błąd podczas próby obsługi urządzenia. 262 | Błąd %1: %2 263 | 264 | 265 | 266 | 267 | Volume Error 268 | Błąd Woluminu 269 | 270 | 271 | 272 | An error occurred when attempting to get a handle on the volume. 273 | Error %1: %2 274 | Wystąpił błąd podczas próby obsługi woluminu. 275 | Błąd %1: %2 276 | 277 | 278 | 279 | Lock Error 280 | Błąd Blokowania 281 | 282 | 283 | 284 | An error occurred when attempting to lock the volume. 285 | Error %1: %2 286 | Wystąpił błąd podczas próby zablokowania woluminu. 287 | Błąd %1: %2 288 | 289 | 290 | 291 | Unlock Error 292 | Błąd Odblokowywania 293 | 294 | 295 | 296 | An error occurred when attempting to unlock the volume. 297 | Error %1: %2 298 | Wystąpił błąd podczas próby odblokowania woluminu. 299 | Błąd %1: %2 300 | 301 | 302 | 303 | Dismount Error 304 | Błąd Odmontowywania 305 | 306 | 307 | 308 | An error occurred when attempting to dismount the volume. 309 | Error %1: %2 310 | Wystąpił błąd podczas próby odmontowania woluminu. 311 | Błąd %1: %2 312 | 313 | 314 | 315 | Read Error 316 | Błąd Odczytu 317 | 318 | 319 | 320 | An error occurred when attempting to read data from handle. 321 | Error %1: %2 322 | o co kaman? Do obsługiwanego miejsca? Albo do kontroli? Miejmy nadzieję ze to nie wyskoczy podczas użytkowania :) 323 | An error occurred when attempting to read data from handle. 324 | Error %1: %2 325 | 326 | 327 | 328 | Write Error 329 | Błąd Zapisu 330 | 331 | 332 | 333 | An error occurred when attempting to write data to handle. 334 | Error %1: %2 335 | o co kaman? Do obsługiwanego miejsca? Albo do kontroli? Miejmy nadzieję ze to nie wyskoczy podczas użytkowania :) 336 | An error occurred when attempting to write data to handle. 337 | Error %1: %2 338 | 339 | 340 | 341 | An error occurred when attempting to get the device's geometry. 342 | Error %1: %2 343 | Wystąpił błąd podczas próby otrzymania geometrii urządzenia. 344 | Błąd %1: %2 345 | 346 | 347 | 348 | An error occurred while getting the file size. 349 | Error %1: %2 350 | Wystąpił błąd podczas otrzymywania rozmiaru pliku. Błąd %1: %2 351 | 352 | 353 | 354 | Free Space Error 355 | Błąd Wolnej Przestrzeni 356 | 357 | 358 | 359 | Failed to get the free space on drive %1. 360 | Error %2: %3 361 | Checking of free space will be skipped. 362 | Niepowodzenie uzyskania wolnego miejsca na dysku %1. 363 | Błąd %2: %3 364 | Sprawdzanie wolnej pamięci zostanie pominięte. 365 | 366 | 367 | 368 | An error occurred while getting the device number. 369 | This usually means something is currently accessing the device;please close all applications and try again. 370 | 371 | Error %1: %2 372 | Wystąpił błąd podczas otrzymywania numeru urządzenia. 373 | To zazwyczaj oznacza że obecnie coś ma dostęp do urządzenia; proszę zamknąć wszystkie aplikacje i spróbować ponownie. 374 | 375 | Błąd %1: %2 376 | 377 | 378 | 379 | An error occurred while querying the properties. 380 | This usually means something is currently accessing the device; please close all applications and try again. 381 | 382 | Error %1: %2 383 | Wystąpił błąd podczas odpytywania właściwości. 384 | To zazwyczaj oznacza że obecnie coś ma dostęp do urządzenia; proszę zamknąć wszystkie aplikacje i spróbować ponownie. 385 | 386 | Błąd %1: %2 387 | 388 | 389 | 390 | An error occurred when attempting to get a handle on %3. 391 | Error %1: %2 392 | Wystąpił błąd podczas próby otrzymania kontroli na %3. 393 | Błąd %1: %2 394 | 395 | 396 | 397 | -------------------------------------------------------------------------------- /src/diskwriter.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "diskwriter.h" 3 | #include 4 | #include "disk.h" 5 | #include 6 | 7 | void CProgressBar::setRange(INT64 iPos, INT64 iMax) { 8 | Max = iMax; 9 | Pos = iPos; 10 | } 11 | 12 | void CProgressBar::setValue(INT64 iPos) { 13 | Pos = iPos; 14 | } 15 | 16 | 17 | CDiskWriter::CDiskWriter() { 18 | hVolume = INVALID_HANDLE_VALUE; 19 | hFile = INVALID_HANDLE_VALUE; 20 | hRawDisk = INVALID_HANDLE_VALUE; 21 | sectorData = NULL; 22 | sectorsize = 0ul; 23 | } 24 | 25 | CDiskWriter::~CDiskWriter() { 26 | if (hRawDisk != INVALID_HANDLE_VALUE) 27 | { 28 | CloseHandle(hRawDisk); 29 | hRawDisk = INVALID_HANDLE_VALUE; 30 | } 31 | if (hFile != INVALID_HANDLE_VALUE) 32 | { 33 | CloseHandle(hFile); 34 | hFile = INVALID_HANDLE_VALUE; 35 | } 36 | if (hVolume != INVALID_HANDLE_VALUE) 37 | { 38 | CloseHandle(hVolume); 39 | hVolume = INVALID_HANDLE_VALUE; 40 | } 41 | if (sectorData != NULL) 42 | { 43 | delete[] sectorData; 44 | sectorData = NULL; 45 | } 46 | } 47 | 48 | bool CDiskWriter::FileExists(const std::wstring sFilename) { 49 | FILE *fp = _wfopen(sFilename.c_str(), L"rb"); 50 | if (fp != 0) { 51 | fclose(fp); 52 | 53 | return true; 54 | } 55 | 56 | return false; 57 | } 58 | 59 | bool CDiskWriter::WriteImageToDisk(const std::wstring sFilename, int iDeviceID, int iVolumeID) { 60 | if (!this->FileExists(sFilename)) { 61 | status = STATUS_IDLE; 62 | CUIHelper::critical(L"File doesn't exist"); 63 | return false; 64 | } 65 | 66 | status = STATUS_WRITING; 67 | 68 | hVolume = getHandleOnVolume(iVolumeID, GENERIC_WRITE); 69 | if (hVolume == INVALID_HANDLE_VALUE) 70 | { 71 | status = STATUS_IDLE; 72 | return false; 73 | } 74 | if (!getLockOnVolume(hVolume)) 75 | { 76 | CloseHandle(hVolume); 77 | status = STATUS_IDLE; 78 | hVolume = INVALID_HANDLE_VALUE; 79 | return false; 80 | } 81 | if (!unmountVolume(hVolume)) 82 | { 83 | removeLockOnVolume(hVolume); 84 | CloseHandle(hVolume); 85 | status = STATUS_IDLE; 86 | hVolume = INVALID_HANDLE_VALUE; 87 | return false; 88 | } 89 | hFile = getHandleOnFile(sFilename.c_str(), GENERIC_READ); 90 | if (hFile == INVALID_HANDLE_VALUE) 91 | { 92 | removeLockOnVolume(hVolume); 93 | CloseHandle(hVolume); 94 | status = STATUS_IDLE; 95 | hVolume = INVALID_HANDLE_VALUE; 96 | return false; 97 | } 98 | hRawDisk = getHandleOnDevice(iDeviceID, GENERIC_WRITE); 99 | if (hRawDisk == INVALID_HANDLE_VALUE) 100 | { 101 | removeLockOnVolume(hVolume); 102 | CloseHandle(hFile); 103 | CloseHandle(hVolume); 104 | status = STATUS_IDLE; 105 | hVolume = INVALID_HANDLE_VALUE; 106 | hFile = INVALID_HANDLE_VALUE; 107 | return false; 108 | } 109 | 110 | unsigned long long i, availablesectors, numsectors; 111 | 112 | availablesectors = getNumberOfSectors(hRawDisk, §orsize); 113 | numsectors = getFileSizeInSectors(hFile, sectorsize); 114 | if (numsectors > availablesectors) 115 | { 116 | CUIHelper::critical(L"Not enough available space!"); 117 | return false; 118 | } 119 | 120 | ProgressBar.setRange(0, (numsectors == 0ul) ? 100 : (int)numsectors); 121 | for (i = 0ul; i < numsectors && status == STATUS_WRITING; i += 1024ul) 122 | { 123 | sectorData = readSectorDataFromHandle(hFile, i, (numsectors - i >= 1024ul) ? 1024ul : (numsectors - i), sectorsize); 124 | if (sectorData == NULL) 125 | { 126 | removeLockOnVolume(hVolume); 127 | CloseHandle(hRawDisk); 128 | CloseHandle(hFile); 129 | CloseHandle(hVolume); 130 | status = STATUS_IDLE; 131 | hRawDisk = INVALID_HANDLE_VALUE; 132 | hFile = INVALID_HANDLE_VALUE; 133 | hVolume = INVALID_HANDLE_VALUE; 134 | return false; 135 | } 136 | if (!writeSectorDataToHandle(hRawDisk, sectorData, i, (numsectors - i >= 1024ul) ? 1024ul : (numsectors - i), sectorsize)) 137 | { 138 | delete[] sectorData; 139 | removeLockOnVolume(hVolume); 140 | CloseHandle(hRawDisk); 141 | CloseHandle(hFile); 142 | CloseHandle(hVolume); 143 | status = STATUS_IDLE; 144 | sectorData = NULL; 145 | hRawDisk = INVALID_HANDLE_VALUE; 146 | hFile = INVALID_HANDLE_VALUE; 147 | hVolume = INVALID_HANDLE_VALUE; 148 | return false; 149 | } 150 | delete[] sectorData; 151 | sectorData = NULL; 152 | 153 | ProgressBar.setValue(i); 154 | 155 | ::Sleep(1); 156 | } 157 | removeLockOnVolume(hVolume); 158 | CloseHandle(hRawDisk); 159 | CloseHandle(hFile); 160 | CloseHandle(hVolume); 161 | hRawDisk = INVALID_HANDLE_VALUE; 162 | hFile = INVALID_HANDLE_VALUE; 163 | hVolume = INVALID_HANDLE_VALUE; 164 | 165 | return true; 166 | } 167 | -------------------------------------------------------------------------------- /src/diskwriter.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | class CProgressBar { 6 | protected: 7 | INT64 Pos, Max; 8 | public: 9 | void setRange(INT64 iPos, INT64 iMax); 10 | void setValue(INT64 iPos); 11 | }; 12 | 13 | class CDiskWriter { 14 | protected: 15 | enum Status { STATUS_IDLE = 0, STATUS_READING, STATUS_WRITING, STATUS_EXIT, STATUS_CANCELED }; 16 | 17 | HANDLE hVolume; 18 | HANDLE hFile; 19 | HANDLE hRawDisk; 20 | char *sectorData; 21 | unsigned long long sectorsize; 22 | 23 | bool FileExists(const std::wstring sFilename); 24 | public: 25 | int status; 26 | CProgressBar ProgressBar; 27 | 28 | CDiskWriter(); 29 | virtual ~CDiskWriter(); 30 | 31 | bool WriteImageToDisk(const std::wstring sFilename, int iDeviceID, int iVolumeID); 32 | }; 33 | -------------------------------------------------------------------------------- /src/dll_main.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | 3 | #include 4 | 5 | BOOL APIENTRY DllMain( HMODULE hModule, 6 | DWORD ul_reason_for_call, 7 | LPVOID lpReserved 8 | ) 9 | { 10 | switch (ul_reason_for_call) 11 | { 12 | case DLL_PROCESS_ATTACH: 13 | case DLL_THREAD_ATTACH: 14 | case DLL_THREAD_DETACH: 15 | case DLL_PROCESS_DETACH: 16 | break; 17 | } 18 | return TRUE; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/droppablelineedit.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * This program is free software; you can redistribute it and/or * 3 | * modify it under the terms of the GNU General Public License * 4 | * as published by the Free Software Foundation; either version 2 * 5 | * of the License, or (at your option) any later version. * 6 | * * 7 | * This program is distributed in the hope that it will be useful, * 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 | * GNU General Public License for more details. * 11 | * * 12 | * You should have received a copy of the GNU General Public License * 13 | * along with this program; if not, see http://gnu.org/licenses/ 14 | * --- * 15 | * Copyright (C) 2009, Justin Davis * 16 | * Copyright (C) 2009-2014 ImageWriter developers * 17 | * https://launchpad.net/~image-writer-devs * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include "droppablelineedit.h" 22 | 23 | DroppableLineEdit::DroppableLineEdit(QWidget *parent) 24 | : QLineEdit(parent) 25 | { 26 | setAcceptDrops(true); 27 | } 28 | 29 | void DroppableLineEdit::dragEnterEvent(QDragEnterEvent *event) 30 | { 31 | // accept just text/uri-list and text/plain mime formats 32 | if ( (event->mimeData()->hasFormat("text/uri-list")) || 33 | (event->mimeData()->hasFormat("text/plain")) ) 34 | { 35 | event->acceptProposedAction(); 36 | } 37 | } 38 | 39 | void DroppableLineEdit::dropEvent(QDropEvent *event) 40 | { 41 | QList urlList; 42 | QString fName; 43 | QFileInfo info; 44 | const QMimeData *data = event->mimeData(); 45 | 46 | if (data->hasUrls()) 47 | { 48 | urlList = data->urls(); // returns list of QUrls 49 | // if just text was dropped, urlList is empty (size == 0) 50 | 51 | if ( urlList.size() > 0) // if at least one QUrl is present in list 52 | { 53 | fName = urlList[0].toLocalFile(); // convert first QUrl to local path 54 | info.setFile( fName ); // information about file 55 | if ( info.isFile() ) 56 | { 57 | setText( fName ); // if is file, setText 58 | event->acceptProposedAction(); 59 | } else { 60 | // setText("has url but Cannot drop"); 61 | event->ignore(); 62 | } 63 | } 64 | } 65 | else if (data->hasText()) 66 | { 67 | setText(data->text()); 68 | event->acceptProposedAction(); 69 | } else { 70 | event->ignore(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/droppablelineedit.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * This program is free software; you can redistribute it and/or * 3 | * modify it under the terms of the GNU General Public License * 4 | * as published by the Free Software Foundation; either version 2 * 5 | * of the License, or (at your option) any later version. * 6 | * * 7 | * This program is distributed in the hope that it will be useful, * 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 | * GNU General Public License for more details. * 11 | * * 12 | * You should have received a copy of the GNU General Public License * 13 | * along with this program; if not, see http://gnu.org/licenses/ 14 | * --- * 15 | * Copyright (C) 2009, Justin Davis * 16 | * Copyright (C) 2009-2014 ImageWriter developers * 17 | * https://launchpad.net/~image-writer-devs * 18 | **********************************************************************/ 19 | 20 | #ifndef DROPPABLELINEEDIT_H 21 | #define DROPPABLELINEEDIT_H 22 | 23 | #include 24 | #include 25 | 26 | class DroppableLineEdit : public QLineEdit 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | DroppableLineEdit(QWidget *parent = 0); 32 | 33 | void dragEnterEvent(QDragEnterEvent *event); 34 | void dropEvent(QDropEvent *event); 35 | 36 | private: 37 | 38 | }; 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/elapsedtimer.cpp: -------------------------------------------------------------------------------- 1 | #include "elapsedtimer.h" 2 | 3 | ElapsedTimer::ElapsedTimer(QWidget *parent) 4 | : QLabel(parent) 5 | { 6 | timer = new QTime(); 7 | setTextFormat(Qt::PlainText); 8 | setTextInteractionFlags(Qt::NoTextInteraction); 9 | setText(QString("0:00/0:00")); 10 | setVisible(false); 11 | } 12 | 13 | ElapsedTimer::~ElapsedTimer() 14 | { 15 | delete timer; 16 | } 17 | 18 | int ElapsedTimer::ms() 19 | { 20 | return(timer->elapsed()); 21 | } 22 | 23 | void ElapsedTimer::update(unsigned long long progress, unsigned long long total) 24 | { 25 | unsigned short eSec = 0, eMin = 0, eHour = 0; 26 | unsigned short tSec = 0, tMin = 0, tHour = 0; 27 | 28 | unsigned int baseSecs = timer->elapsed() / MS_PER_SEC; 29 | eSec = baseSecs % SECS_PER_MIN; 30 | if (baseSecs >= SECS_PER_MIN) 31 | { 32 | eMin = baseSecs / SECS_PER_MIN; 33 | if (baseSecs >= SECS_PER_HOUR) 34 | { 35 | eHour = baseSecs / SECS_PER_HOUR; 36 | } 37 | } 38 | 39 | unsigned int totalSecs = (unsigned int)((float)baseSecs * ( (float)total/(float)progress )); 40 | unsigned int totalMin = 0; 41 | tSec = totalSecs % SECS_PER_MIN; 42 | if (totalSecs >= SECS_PER_MIN) 43 | { 44 | totalMin = totalSecs / SECS_PER_MIN; 45 | tMin = totalMin % MINS_PER_HOUR; 46 | if (totalMin > MINS_PER_HOUR) 47 | { 48 | tHour = totalMin / MINS_PER_HOUR; 49 | } 50 | } 51 | 52 | const QChar & fillChar = QLatin1Char( '0' ); 53 | QString qs = QString("%1:%2/").arg(eMin, 2, 10, fillChar).arg(eSec, 2, 10, fillChar); 54 | if (eHour > 0) 55 | { 56 | qs.prepend(QString("%1:").arg(eHour, 2, 10, fillChar)); 57 | } 58 | if (tHour > 0) 59 | { 60 | qs += (QString("%1:").arg(tHour, 2, 10, fillChar)); 61 | } 62 | qs += (QString("%1:%2 ").arg(tMin, 2, 10, fillChar).arg(tSec, 2, 10, fillChar)); 63 | // added a space following the times to separate the text slightly from the right edge of the status bar... 64 | // there's probably a more "QT-correct" way to do that (like, margins or something), 65 | // but this was simple and effective. 66 | setText(qs); 67 | } 68 | 69 | void ElapsedTimer::start() 70 | { 71 | setVisible(true); 72 | timer->start(); 73 | } 74 | 75 | void ElapsedTimer::stop() 76 | { 77 | setVisible(false); 78 | setText(QString("0:00/0:00")); 79 | } 80 | -------------------------------------------------------------------------------- /src/elapsedtimer.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * This program is free software; you can redistribute it and/or * 3 | * modify it under the terms of the GNU General Public License * 4 | * as published by the Free Software Foundation; either version 2 * 5 | * of the License, or (at your option) any later version. * 6 | * * 7 | * This program is distributed in the hope that it will be useful, * 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 | * GNU General Public License for more details. * 11 | * * 12 | * You should have received a copy of the GNU General Public License * 13 | * along with this program; if not, see http://gnu.org/licenses/ 14 | * --- * 15 | * Copyright (C) 2009, Justin Davis * 16 | * Copyright (C) 2009-2014 ImageWriter developers * 17 | * https://launchpad.net/~image-writer-devs * 18 | **********************************************************************/ 19 | 20 | #ifndef ELAPSEDTIMER_H 21 | #define ELAPSEDTIMER_H 22 | 23 | #ifndef WINVER 24 | #define WINVER 0x0601 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | //#include 32 | //#include 33 | //#include 34 | //#include 35 | 36 | class ElapsedTimer : public QLabel 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | ElapsedTimer(QWidget *parent = 0); 42 | ~ElapsedTimer(); 43 | int ms(); 44 | void update(unsigned long long progress, unsigned long long total); 45 | void start(); 46 | void stop(); 47 | 48 | private: 49 | // QLabel *lDisplay; 50 | QTime *timer; 51 | static const unsigned short MS_PER_SEC = 1000; 52 | static const unsigned short SECS_PER_MIN = 60; 53 | static const unsigned short MINS_PER_HOUR = 60; 54 | static const unsigned short SECS_PER_HOUR = (SECS_PER_MIN * MINS_PER_HOUR); 55 | }; 56 | 57 | #endif // ELAPSEDTIMER_H 58 | -------------------------------------------------------------------------------- /src/gui_icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/browse.png 4 | images/reload.png 5 | images/Win32DiskImager.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/images/Win32DiskImager.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GDKsoftware/win32diskimager/0982891607a3498a6fe49cd9a0a83cdb5a1ef145/src/images/Win32DiskImager.ico -------------------------------------------------------------------------------- /src/images/Win32DiskImager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GDKsoftware/win32diskimager/0982891607a3498a6fe49cd9a0a83cdb5a1ef145/src/images/Win32DiskImager.png -------------------------------------------------------------------------------- /src/images/browse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GDKsoftware/win32diskimager/0982891607a3498a6fe49cd9a0a83cdb5a1ef145/src/images/browse.png -------------------------------------------------------------------------------- /src/images/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GDKsoftware/win32diskimager/0982891607a3498a6fe49cd9a0a83cdb5a1ef145/src/images/reload.png -------------------------------------------------------------------------------- /src/images/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GDKsoftware/win32diskimager/0982891607a3498a6fe49cd9a0a83cdb5a1ef145/src/images/setup.ico -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * This program is free software; you can redistribute it and/or * 3 | * modify it under the terms of the GNU General Public License * 4 | * as published by the Free Software Foundation; either version 2 * 5 | * of the License, or (at your option) any later version. * 6 | * * 7 | * This program is distributed in the hope that it will be useful, * 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 | * GNU General Public License for more details. * 11 | * * 12 | * You should have received a copy of the GNU General Public License * 13 | * along with this program; if not, see http://gnu.org/licenses/ 14 | * --- * 15 | * Copyright (C) 2009, Justin Davis * 16 | * Copyright (C) 2009-2014 ImageWriter developers * 17 | * https://launchpad.net/~image-writer-devs * 18 | **********************************************************************/ 19 | 20 | #ifndef WINVER 21 | #define WINVER 0x0601 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "disk.h" 30 | #include "mainwindow.h" 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | QApplication app(argc, argv); 35 | app.setApplicationDisplayName(VER); 36 | 37 | QString locale = QLocale::system().name(); 38 | QTranslator translator; 39 | translator.load(QString("diskimager_")+ locale); 40 | app.installTranslator(&translator); 41 | 42 | MainWindow mainwindow; 43 | mainwindow.show(); 44 | return app.exec(); 45 | } 46 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * This program is free software; you can redistribute it and/or * 3 | * modify it under the terms of the GNU General Public License * 4 | * as published by the Free Software Foundation; either version 2 * 5 | * of the License, or (at your option) any later version. * 6 | * * 7 | * This program is distributed in the hope that it will be useful, * 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 | * GNU General Public License for more details. * 11 | * * 12 | * You should have received a copy of the GNU General Public License * 13 | * along with this program; if not, see http://gnu.org/licenses/ 14 | * --- * 15 | * Copyright (C) 2009, Justin Davis * 16 | * Copyright (C) 2009-2014 ImageWriter developers * 17 | * http://launchpad.net/~image-writer-devs * 18 | **********************************************************************/ 19 | 20 | #ifndef MAINWINDOW_H 21 | #define MAINWINDOW_H 22 | 23 | #ifndef WINVER 24 | #define WINVER 0x0601 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "ui_mainwindow.h" 34 | #include "disk.h" 35 | #include "elapsedtimer.h" 36 | 37 | class MainWindow : public QMainWindow, public Ui::MainWindow 38 | { 39 | Q_OBJECT 40 | public: 41 | MainWindow(QWidget *parent=0); 42 | ~MainWindow(); 43 | void closeEvent(QCloseEvent *event); 44 | enum Status {STATUS_IDLE=0, STATUS_READING, STATUS_WRITING, STATUS_EXIT, STATUS_CANCELED}; 45 | bool nativeEvent(const QByteArray &type, void *vMsg, long *result); 46 | protected slots: 47 | void on_tbBrowse_clicked(); 48 | void on_bCancel_clicked(); 49 | void on_bWrite_clicked(); 50 | void on_bRead_clicked(); 51 | void on_leFile_textChanged(); 52 | void on_leFile_editingFinished(); 53 | void on_md5CheckBox_stateChanged(); 54 | void on_bMd5Copy_clicked(); 55 | private: 56 | // find attached devices 57 | void getLogicalDrives(); 58 | void setReadWriteButtonState(); 59 | 60 | HANDLE hVolume; 61 | HANDLE hFile; 62 | HANDLE hRawDisk; 63 | static const unsigned short ONE_SEC_IN_MS = 1000; 64 | unsigned long long sectorsize; 65 | int status; 66 | char *sectorData; 67 | QTime update_timer; 68 | ElapsedTimer *elapsed_timer = NULL; 69 | QClipboard *clipboard; 70 | void generateMd5(char *filename); 71 | QString myHomeDir; 72 | void updateMd5CopyButton(); 73 | }; 74 | 75 | #endif // MAINWINDOW_H 76 | -------------------------------------------------------------------------------- /src/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 405 10 | 211 11 | 12 | 13 | 14 | true 15 | 16 | 17 | Win32 Disk Imager 18 | 19 | 20 | 21 | :/images/images/Win32DiskImager.png:/images/images/Win32DiskImager.png 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Image File 31 | 32 | 33 | 34 | 3 35 | 36 | 37 | 0 38 | 39 | 40 | 0 41 | 42 | 43 | 0 44 | 45 | 46 | 0 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | ... 55 | 56 | 57 | 58 | :/images/images/browse.png:/images/images/browse.png 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Device 69 | 70 | 71 | 72 | 0 73 | 74 | 75 | 0 76 | 77 | 78 | 0 79 | 80 | 81 | 0 82 | 83 | 84 | 0 85 | 86 | 87 | 88 | 89 | 90 | 0 91 | 0 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 4 105 | 106 | 107 | 108 | 109 | 110 | 0 111 | 0 112 | 113 | 114 | 115 | 116 | 35 117 | 16777215 118 | 119 | 120 | 121 | Copy MD5 to clipboard 122 | 123 | 124 | Copy 125 | 126 | 127 | 128 | 129 | 130 | 131 | Qt::Horizontal 132 | 133 | 134 | QSizePolicy::Fixed 135 | 136 | 137 | 138 | 13 139 | 20 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 0 149 | 0 150 | 151 | 152 | 153 | 154 | 20 155 | 0 156 | 157 | 158 | 159 | If checked, will generate the MD5 hash for the image file 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | false 170 | 171 | 172 | 173 | 0 174 | 0 175 | 176 | 177 | 178 | MD5 Hash: 179 | 180 | 181 | 182 | 183 | 184 | 185 | false 186 | 187 | 188 | 189 | 190 | 191 | Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 5 201 | 202 | 203 | 204 | 205 | Read Only Allocated Partitions 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | Progress 215 | 216 | 217 | 218 | 0 219 | 220 | 221 | 0 222 | 223 | 224 | 0 225 | 226 | 227 | 0 228 | 229 | 230 | 0 231 | 232 | 233 | 234 | 235 | 0 236 | 237 | 238 | true 239 | 240 | 241 | %p% 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | Qt::Horizontal 254 | 255 | 256 | 257 | 40 258 | 20 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | false 267 | 268 | 269 | 270 | 0 271 | 0 272 | 273 | 274 | 275 | Cancel current process. 276 | 277 | 278 | Cancel 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 0 287 | 0 288 | 289 | 290 | 291 | 292 | 293 | 294 | Read data from 'Device' to 'Image File' 295 | 296 | 297 | Read 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 0 306 | 0 307 | 308 | 309 | 310 | Write data from 'Image File' to 'Device' 311 | 312 | 313 | Write 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 0 322 | 0 323 | 324 | 325 | 326 | Exit Win32 Disk Imager 327 | 328 | 329 | Exit 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | DroppableLineEdit 342 | QLineEdit 343 |
droppablelineedit.h
344 |
345 |
346 | 347 | 348 | 349 | 350 | 351 | bExit 352 | clicked() 353 | MainWindow 354 | close() 355 | 356 | 357 | 270 358 | 98 359 | 360 | 361 | 154 362 | 68 363 | 364 | 365 | 366 | 367 |
368 | -------------------------------------------------------------------------------- /src/md5.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 2 | // rights reserved. 3 | 4 | // License to copy and use this software is granted provided that it 5 | // is identified as the "RSA Data Security, Inc. MD5 Message-Digest 6 | // Algorithm" in all material mentioning or referencing this software 7 | // or this function. 8 | // 9 | // License is also granted to make and use derivative works provided 10 | // that such works are identified as "derived from the RSA Data 11 | // Security, Inc. MD5 Message-Digest Algorithm" in all material 12 | // mentioning or referencing the derived work. 13 | // 14 | // RSA Data Security, Inc. makes no representations concerning either 15 | // the merchantability of this software or the suitability of this 16 | // software for any particular purpose. It is provided "as is" 17 | // without express or implied warranty of any kind. 18 | // 19 | // These notices must be retained in any copies of any part of this 20 | // documentation and/or software. 21 | 22 | // The original md5 implementation avoids external libraries. 23 | // This version has dependency on stdio.h for file input and 24 | // string.h for memcpy. 25 | #ifndef MD5_H 26 | #define MD5_H 27 | 28 | #include 29 | #include 30 | 31 | // Constants for MD5Transform routine. 32 | #define S11 7 33 | #define S12 12 34 | #define S13 17 35 | #define S14 22 36 | #define S21 5 37 | #define S22 9 38 | #define S23 14 39 | #define S24 20 40 | #define S31 4 41 | #define S32 11 42 | #define S33 16 43 | #define S34 23 44 | #define S41 6 45 | #define S42 10 46 | #define S43 15 47 | #define S44 21 48 | 49 | static unsigned char PADDING[64] = { 50 | 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 53 | }; 54 | 55 | // F, G, H and I are basic MD5 functions. 56 | #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) 57 | #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) 58 | #define H(x, y, z) ((x) ^ (y) ^ (z)) 59 | #define I(x, y, z) ((y) ^ ((x) | (~z))) 60 | 61 | // ROTATE_LEFT rotates x left n bits. 62 | #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) 63 | 64 | // FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. 65 | // Rotation is separate from addition to prevent recomputation. 66 | #define FF(a, b, c, d, x, s, ac) { \ 67 | (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ 68 | (a) = ROTATE_LEFT ((a), (s)); \ 69 | (a) += (b); \ 70 | } 71 | #define GG(a, b, c, d, x, s, ac) { \ 72 | (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ 73 | (a) = ROTATE_LEFT ((a), (s)); \ 74 | (a) += (b); \ 75 | } 76 | #define HH(a, b, c, d, x, s, ac) { \ 77 | (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ 78 | (a) = ROTATE_LEFT ((a), (s)); \ 79 | (a) += (b); \ 80 | } 81 | #define II(a, b, c, d, x, s, ac) { \ 82 | (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ 83 | (a) = ROTATE_LEFT ((a), (s)); \ 84 | (a) += (b); \ 85 | } 86 | 87 | typedef unsigned char BYTE; 88 | 89 | // POINTER defines a generic pointer type 90 | typedef unsigned char *POINTER; 91 | 92 | // UINT2 defines a two byte word 93 | typedef unsigned short int UINT2; 94 | 95 | // UINT4 defines a four byte word 96 | typedef unsigned long int UINT4; 97 | 98 | // convenient object that wraps 99 | // the C-functions for use in C++ only 100 | class MD5 101 | { 102 | private: 103 | struct __context_t { 104 | UINT4 state[4]; /* state (ABCD) */ 105 | UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ 106 | unsigned char buffer[64]; /* input buffer */ 107 | } context ; 108 | 109 | // The core of the MD5 algorithm is here. 110 | // MD5 basic transformation. Transforms state based on block. 111 | static void MD5Transform( UINT4 state[4], unsigned char block[64] ) 112 | { 113 | UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; 114 | 115 | Decode (x, block, 64); 116 | 117 | /* Round 1 */ 118 | FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ 119 | FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ 120 | FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ 121 | FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ 122 | FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ 123 | FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ 124 | FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ 125 | FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ 126 | FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ 127 | FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ 128 | FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ 129 | FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ 130 | FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ 131 | FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ 132 | FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ 133 | FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ 134 | 135 | /* Round 2 */ 136 | GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ 137 | GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ 138 | GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ 139 | GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ 140 | GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ 141 | GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ 142 | GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ 143 | GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ 144 | GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ 145 | GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ 146 | GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ 147 | GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ 148 | GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ 149 | GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ 150 | GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ 151 | GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ 152 | 153 | /* Round 3 */ 154 | HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ 155 | HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ 156 | HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ 157 | HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ 158 | HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ 159 | HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ 160 | HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ 161 | HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ 162 | HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ 163 | HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ 164 | HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ 165 | HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ 166 | HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ 167 | HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ 168 | HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ 169 | HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ 170 | 171 | /* Round 4 */ 172 | II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ 173 | II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ 174 | II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ 175 | II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ 176 | II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ 177 | II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ 178 | II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ 179 | II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ 180 | II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ 181 | II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ 182 | II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ 183 | II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ 184 | II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ 185 | II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ 186 | II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ 187 | II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ 188 | 189 | state[0] += a; 190 | state[1] += b; 191 | state[2] += c; 192 | state[3] += d; 193 | 194 | // Zeroize sensitive information. 195 | memset((POINTER)x, 0, sizeof (x)); 196 | } 197 | 198 | // Encodes input (UINT4) into output (unsigned char). Assumes len is 199 | // a multiple of 4. 200 | static void Encode( unsigned char *output, UINT4 *input, unsigned int len ) 201 | { 202 | unsigned int i, j; 203 | 204 | for (i = 0, j = 0; j < len; i++, j += 4) 205 | { 206 | output[j] = (unsigned char)(input[i] & 0xff); 207 | output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); 208 | output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); 209 | output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); 210 | } 211 | } 212 | 213 | // Decodes input (unsigned char) into output (UINT4). Assumes len is 214 | // a multiple of 4. 215 | static void Decode( UINT4 *output, unsigned char *input, unsigned int len ) 216 | { 217 | unsigned int i, j; 218 | 219 | for (i = 0, j = 0; j < len; i++, j += 4) 220 | { 221 | output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | 222 | (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); 223 | } 224 | } 225 | 226 | public: 227 | // MAIN FUNCTIONS 228 | MD5() 229 | { 230 | Init(); 231 | } 232 | 233 | // MD5 initialization. Begins an MD5 operation, writing a new context. 234 | void Init() 235 | { 236 | context.count[0] = context.count[1] = 0; 237 | 238 | // Load magic initialization constants. 239 | context.state[0] = 0x67452301; 240 | context.state[1] = 0xefcdab89; 241 | context.state[2] = 0x98badcfe; 242 | context.state[3] = 0x10325476; 243 | } 244 | 245 | // MD5 block update operation. Continues an MD5 message-digest 246 | // operation, processing another message block, and updating the 247 | // context. 248 | void Update( 249 | unsigned char *input, // input block 250 | unsigned int inputLen ) // length of input block 251 | { 252 | unsigned int i, index, partLen; 253 | 254 | // Compute number of bytes mod 64 255 | index = (unsigned int)((context.count[0] >> 3) & 0x3F); 256 | 257 | // Update number of bits 258 | if ((context.count[0] += ((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3)) 259 | { 260 | context.count[1]++; 261 | } 262 | context.count[1] += ((UINT4)inputLen >> 29); 263 | 264 | partLen = 64 - index; 265 | 266 | // Transform as many times as possible. 267 | if (inputLen >= partLen) 268 | { 269 | memcpy((POINTER)&context.buffer[index], (POINTER)input, partLen); 270 | MD5Transform (context.state, context.buffer); 271 | 272 | for (i = partLen; i + 63 < inputLen; i += 64) 273 | { 274 | MD5Transform (context.state, &input[i]); 275 | } 276 | 277 | index = 0; 278 | } 279 | else 280 | { 281 | i = 0; 282 | } 283 | 284 | /* Buffer remaining input */ 285 | memcpy((POINTER)&context.buffer[index], (POINTER)&input[i], inputLen-i); 286 | } 287 | 288 | // MD5 finalization. Ends an MD5 message-digest operation, writing the 289 | // the message digest and zeroizing the context. 290 | // Writes to digestRaw 291 | void Final() 292 | { 293 | unsigned char bits[8]; 294 | unsigned int index, padLen; 295 | 296 | // Save number of bits 297 | Encode( bits, context.count, 8 ); 298 | 299 | // Pad out to 56 mod 64. 300 | index = (unsigned int)((context.count[0] >> 3) & 0x3f); 301 | padLen = (index < 56) ? (56 - index) : (120 - index); 302 | Update( PADDING, padLen ); 303 | 304 | // Append length (before padding) 305 | Update( bits, 8 ); 306 | 307 | // Store state in digest 308 | Encode( digestRaw, context.state, 16); 309 | 310 | // Zeroize sensitive information. 311 | memset((POINTER)&context, 0, sizeof (context)); 312 | 313 | writeToString(); 314 | } 315 | 316 | /// Buffer must be 32+1 (nul) = 33 chars long at least 317 | void writeToString() 318 | { 319 | int pos; 320 | 321 | for( pos = 0 ; pos < 16 ; pos++ ) 322 | { 323 | sprintf( digestChars+(pos*2), "%02x", digestRaw[pos] ); 324 | } 325 | } 326 | 327 | public: 328 | // an MD5 digest is a 16-byte number (32 hex digits) 329 | BYTE digestRaw[ 16 ] ; 330 | 331 | // This version of the digest is actually 332 | // a "printf'd" version of the digest. 333 | char digestChars[ 33 ] ; 334 | 335 | // Load a file from disk and digest it 336 | // Digests a file and returns the result. 337 | char* digestFile( char *filename ) 338 | { 339 | Init() ; 340 | 341 | FILE *file; 342 | 343 | int len; 344 | unsigned char buffer[1024]; 345 | 346 | if( (file = fopen (filename, "rb")) == NULL ) 347 | { 348 | printf( "%s can't be opened\n", filename ); 349 | } 350 | else 351 | { 352 | while( (len = fread( buffer, 1, 1024, file )) ) 353 | { 354 | Update( buffer, len ); 355 | } 356 | Final(); 357 | 358 | fclose( file ); 359 | } 360 | 361 | return digestChars; 362 | } 363 | 364 | // Digests a byte-array already in memory 365 | char* digestMemory( BYTE *memchunk, int len ) 366 | { 367 | Init(); 368 | Update( memchunk, len ); 369 | Final(); 370 | 371 | return digestChars; 372 | } 373 | 374 | // Digests a string and prints the result. 375 | char* digestString( char *string ) 376 | { 377 | Init(); 378 | Update( (unsigned char*)string, strlen(string) ); 379 | Final(); 380 | 381 | return digestChars; 382 | } 383 | }; 384 | 385 | #endif 386 | 387 | -------------------------------------------------------------------------------- /src/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by DiskImager.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 101 11 | #define _APS_NEXT_COMMAND_VALUE 40001 12 | #define _APS_NEXT_CONTROL_VALUE 1000 13 | #define _APS_NEXT_SYMED_VALUE 101 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /src/ui_helper.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "ui_helper.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | CUIHelper helperinstance; 10 | 11 | std::wstring CUIHelper::popErrorMessage() { 12 | if (errormessages.size() != 0) { 13 | auto msg = errormessages[0]; 14 | errormessages.erase(errormessages.begin()); 15 | return msg; 16 | } 17 | 18 | return nullptr; 19 | } 20 | 21 | void CUIHelper::pushErrorMessage(std::wstring message) { 22 | errormessages.push_back(message); 23 | } 24 | 25 | bool CUIHelper::hasErrors() { 26 | return (errormessages.size() != 0); 27 | } 28 | 29 | CUIHelper *CUIHelper::GetInstance() { 30 | return &helperinstance; 31 | } 32 | 33 | void CUIHelper::critical(const wchar_t *message) { 34 | #ifdef _CONSOLE 35 | std::wcerr << message; 36 | #else 37 | helperinstance.pushErrorMessage(message); 38 | #endif 39 | } 40 | 41 | std::wstring string2wstring(std::string s) { 42 | std::wstring returnstr; 43 | 44 | size_t convertedChars = 0; 45 | size_t strlength = s.length(); 46 | unsigned int iNewLen = strlength * sizeof(wchar_t); 47 | wchar_t *newstr = static_cast(malloc(iNewLen + 4)); 48 | convertedChars = mbstowcs(newstr, s.c_str(), strlength); 49 | returnstr.append(newstr); 50 | free(newstr); 51 | 52 | return returnstr; 53 | } 54 | 55 | void CUIHelper::critical(const char *message) { 56 | #ifdef _CONSOLE 57 | std::cerr << message; 58 | #else 59 | helperinstance.pushErrorMessage(string2wstring(message)); 60 | #endif 61 | } 62 | 63 | void CUIHelper::criticalWithCurrentError(const wchar_t *title, const wchar_t *message) { 64 | wchar_t *errormessage = NULL; 65 | ::FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, GetLastError(), 0, 66 | (LPWSTR)&errormessage, 0, NULL); 67 | 68 | #ifdef _CONSOLE 69 | std::wcerr << title << L" - " << message << std::endl 70 | << L"Error " << std::to_wstring((int)GetLastError()).c_str() << L": " << errormessage; 71 | #else 72 | std::wstring errmsg = errormessage; 73 | 74 | std::wstring s = title; 75 | s.append(L" - "); 76 | s.append(message); 77 | s.append(L"\n"); 78 | s.append(L"Error "); 79 | s.append(std::to_wstring((int)GetLastError())); 80 | s.append(L": "); 81 | s.append(errmsg); 82 | 83 | helperinstance.pushErrorMessage(s); 84 | #endif 85 | 86 | delete errormessage; 87 | } 88 | 89 | void CUIHelper::criticalWithCurrentError(const wchar_t *title, const std::wstring message) { 90 | #ifdef _CONSOLE 91 | criticalWithCurrentError(title, message.c_str()); 92 | #endif 93 | } 94 | -------------------------------------------------------------------------------- /src/ui_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef UI_HELPER_H 2 | #define UI_HELPER_H 3 | 4 | #ifdef _CONSOLE 5 | #include 6 | 7 | #define UIString std::wstring 8 | #else 9 | #ifdef _WINDLL 10 | #include 11 | 12 | #define UIString std::wstring 13 | #else 14 | #include 15 | #include 16 | 17 | #define UIString QString 18 | #endif 19 | #endif 20 | 21 | #include 22 | 23 | class CUIHelper { 24 | protected: 25 | std::vector errormessages; 26 | public: 27 | std::wstring popErrorMessage(); 28 | void pushErrorMessage(std::wstring message); 29 | bool hasErrors(); 30 | 31 | static CUIHelper *GetInstance(); 32 | 33 | static void critical(const wchar_t *message); 34 | static void critical(const char *message); 35 | static void criticalWithCurrentError(const wchar_t *title, const wchar_t *message); 36 | static void criticalWithCurrentError(const wchar_t *title, const std::wstring message); 37 | }; 38 | 39 | #endif //UI_HELPER_H 40 | --------------------------------------------------------------------------------