1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[ui] add new dialog to display MD5 & SHA-1

This commit is contained in:
Pete Batard 2015-07-04 22:48:11 +01:00
parent 485b016f17
commit 957bb9c495
4 changed files with 76 additions and 15 deletions

View file

@ -29,9 +29,13 @@
#include "msapi_utf8.h"
#include "rufus.h"
#include "resource.h"
#include "localization.h"
#undef BIG_ENDIAN_HOST
/* Globals */
char sha1str[41], md5str[33];
#if defined(__GNUC__)
#define ALIGNED(m) __attribute__ ((__aligned__(m)))
#elif defined(_MSC_VER)
@ -514,13 +518,44 @@ static void md5_final(MD5_CONTEXT *ctx)
#undef X
}
/*
* Checksum dialog callback
*/
INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HFONT hFont;
switch (message) {
case WM_INITDIALOG:
apply_localization(IDD_CHECKSUM, hDlg);
// Create the font and brush for the Info edit box
hFont = CreateFontA(-MulDiv(9, GetDeviceCaps(GetDC(hDlg), LOGPIXELSY), 72),
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
0, 0, PROOF_QUALITY, 0, "Courier New");
SendDlgItemMessageA(hDlg, IDC_MD5, WM_SETFONT, (WPARAM)hFont, TRUE);
SendDlgItemMessageA(hDlg, IDC_SHA1, WM_SETFONT, (WPARAM)hFont, TRUE);
SetWindowTextA(GetDlgItem(hDlg, IDC_MD5), md5str);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA1), sha1str);
CenterDialog(hDlg);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
reset_localization(IDD_CHECKSUM);
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
}
return (INT_PTR)FALSE;
}
DWORD WINAPI SumThread(void* param)
{
HANDLE h = INVALID_HANDLE_VALUE;
DWORD rSize = 0, LastRefresh = 0;
uint64_t rb;
char buffer[4096];
char str[41];
SHA1_CONTEXT sha1_ctx;
MD5_CONTEXT md5_ctx;
int i, r = -1;
@ -565,15 +600,17 @@ DWORD WINAPI SumThread(void* param)
md5_final(&md5_ctx);
for (i = 0; i < 16; i++)
safe_sprintf(&str[2 * i], sizeof(str) - 2 * i, "%02x", md5_ctx.buf[i]);
uprintf(" MD5:\t%s", str);
safe_sprintf(&md5str[2 * i], sizeof(md5str) - 2 * i, "%02x", md5_ctx.buf[i]);
uprintf(" MD5:\t%s", md5str);
for (i = 0; i < 20; i++)
safe_sprintf(&str[2*i], sizeof(str) - 2*i, "%02x", sha1_ctx.buf[i]);
uprintf(" SHA1:\t%s", str);
safe_sprintf(&sha1str[2*i], sizeof(sha1str) - 2*i, "%02x", sha1_ctx.buf[i]);
uprintf(" SHA1:\t%s", sha1str);
r = 0;
out:
safe_closehandle(h);
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
if (r == 0)
MyDialogBox(hMainInstance, IDD_CHECKSUM, hMainDialog, ChecksumCallback);
ExitThread(r);
}

View file

@ -34,6 +34,7 @@ const loc_control_id control_id[] = {
LOC_CTRL(IDD_LOG),
LOC_CTRL(IDD_UPDATE_POLICY),
LOC_CTRL(IDD_NEW_VERSION),
LOC_CTRL(IDD_CHECKSUM),
LOC_CTRL(IDC_DEVICE),
LOC_CTRL(IDC_FILESYSTEM),
LOC_CTRL(IDC_START),
@ -56,6 +57,7 @@ const loc_control_id control_id[] = {
LOC_CTRL(IDC_DISK_ID),
LOC_CTRL(IDC_EXTRA_PARTITION),
LOC_CTRL(IDC_ENABLE_FIXED_DISKS),
LOC_CTRL(IDC_HASH),
LOC_CTRL(IDC_ABOUT_LICENSE),
LOC_CTRL(IDC_ABOUT_ICON),
LOC_CTRL(IDC_ABOUT_UPDATES),
@ -84,6 +86,8 @@ const loc_control_id control_id[] = {
LOC_CTRL(IDC_YOUR_VERSION),
LOC_CTRL(IDC_LATEST_VERSION),
LOC_CTRL(IDC_DOWNLOAD_URL),
LOC_CTRL(IDC_MD5),
LOC_CTRL(IDC_SHA1),
LOC_CTRL(IDS_DEVICE_TXT),
LOC_CTRL(IDS_PARTITION_TYPE_TXT),
LOC_CTRL(IDS_FILESYSTEM_TXT),
@ -398,4 +402,5 @@ loc_dlg_list loc_dlg[] = {
LOC_DLG(IDD_LOG),
LOC_DLG(IDD_UPDATE_POLICY),
LOC_DLG(IDD_NEW_VERSION),
LOC_DLG(IDD_CHECKSUM),
};

View file

@ -9,6 +9,7 @@
#define IDD_LOG 105
#define IDD_UPDATE_POLICY 106
#define IDD_NEW_VERSION 107
#define IDD_CHECKSUM 108
#define IDI_ICON 110
#define IDI_UP 111
#define IDI_DOWN 112
@ -123,6 +124,8 @@
#define IDC_YOUR_VERSION 1068
#define IDC_LATEST_VERSION 1069
#define IDC_DOWNLOAD_URL 1070
#define IDC_MD5 1071
#define IDC_SHA1 1072
#define IDS_DEVICE_TXT 2000
#define IDS_PARTITION_TYPE_TXT 2001
#define IDS_FILESYSTEM_TXT 2002
@ -425,7 +428,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 505
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1071
#define _APS_NEXT_CONTROL_VALUE 1073
#define _APS_NEXT_SYMED_VALUE 4000
#endif
#endif

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 2.3.690"
CAPTION "Rufus 2.3.691"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -79,13 +79,25 @@ CAPTION "About Rufus"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20
CONTROL "",IDC_ABOUT_BLURB,"RichEdit20W",ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY,45,7,268,107
CONTROL "",IDC_ABOUT_COPYRIGHTS,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_TABSTOP,46,115,267,91,WS_EX_STATICEDGE
CONTROL "",IDC_ABOUT_BLURB,"RichEdit20W",0x884,45,7,268,107
CONTROL "",IDC_ABOUT_COPYRIGHTS,"RichEdit20W",WS_VSCROLL | WS_TABSTOP | 0x804,46,115,267,91,WS_EX_STATICEDGE
PUSHBUTTON "License",IDC_ABOUT_LICENSE,46,215,50,14,WS_GROUP
PUSHBUTTON "Updates",IDC_ABOUT_UPDATES,100,215,50,14,NOT WS_VISIBLE | WS_GROUP
DEFPUSHBUTTON "OK",IDOK,251,215,50,14,WS_GROUP
END
IDD_CHECKSUM DIALOGEX 0, 0, 301, 69
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Checksums"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,244,49,50,14,WS_GROUP
EDITTEXT IDC_SHA1,40,31,197,12,ES_LOWERCASE | ES_AUTOHSCROLL | ES_READONLY
EDITTEXT IDC_MD5,40,15,197,12,ES_LOWERCASE | ES_AUTOHSCROLL | ES_READONLY
LTEXT "MD5:",IDC_STATIC,13,16,18,8
LTEXT "SHA-1:",IDC_STATIC,13,32,22,8
END
IDD_LICENSE DIALOGEX 0, 0, 335, 205
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus License"
@ -127,7 +139,7 @@ FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20
DEFPUSHBUTTON "Close",IDCANCEL,221,172,50,14,WS_GROUP
CONTROL "",IDC_POLICY,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_TABSTOP,46,8,235,130,WS_EX_STATICEDGE
CONTROL "",IDC_POLICY,"RichEdit20W",WS_VSCROLL | WS_TABSTOP | 0x804,46,8,235,130,WS_EX_STATICEDGE
GROUPBOX "Settings",IDS_UPDATE_SETTINGS_GRP,45,145,165,46
LTEXT "Check for updates",IDS_UPDATE_FREQUENCY_TXT,51,159,76,11
COMBOBOX IDC_UPDATE_FREQUENCY,133,155,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
@ -143,7 +155,7 @@ CAPTION "Check For Updates - Rufus"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
PUSHBUTTON "Close",IDCANCEL,167,244,50,14,WS_GROUP
CONTROL "",IDC_RELEASE_NOTES,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_VSCROLL,15,77,352,88,WS_EX_STATICEDGE
CONTROL "",IDC_RELEASE_NOTES,"RichEdit20W",WS_VSCROLL | 0x804,15,77,352,88,WS_EX_STATICEDGE
DEFPUSHBUTTON "Download",IDC_DOWNLOAD,293,211,74,14,WS_GROUP
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,15,212,270,11
GROUPBOX "Release Notes",IDS_NEW_VERSION_NOTES_GRP,8,63,367,111
@ -253,6 +265,10 @@ BEGIN
BEGIN
END
IDD_CHECKSUM, DIALOG
BEGIN
END
IDD_LICENSE, DIALOG
BEGIN
END
@ -282,8 +298,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,3,690,0
PRODUCTVERSION 2,3,690,0
FILEVERSION 2,3,691,0
PRODUCTVERSION 2,3,691,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -300,13 +316,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.3.690"
VALUE "FileVersion", "2.3.691"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.3.690"
VALUE "ProductVersion", "2.3.691"
END
END
BLOCK "VarFileInfo"