mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] rename checksum.c to hash.c
This commit is contained in:
parent
3e81b38c2d
commit
090bfb9770
12 changed files with 173 additions and 164 deletions
|
@ -397,7 +397,7 @@
|
||||||
<ClCompile Include="..\src\process.c" />
|
<ClCompile Include="..\src\process.c" />
|
||||||
<ClCompile Include="..\src\re.c" />
|
<ClCompile Include="..\src\re.c" />
|
||||||
<ClCompile Include="..\src\rufus.c" />
|
<ClCompile Include="..\src\rufus.c" />
|
||||||
<ClCompile Include="..\src\checksum.c" />
|
<ClCompile Include="..\src\hash.c" />
|
||||||
<ClCompile Include="..\src\smart.c" />
|
<ClCompile Include="..\src\smart.c" />
|
||||||
<ClCompile Include="..\src\stdfn.c" />
|
<ClCompile Include="..\src\stdfn.c" />
|
||||||
<ClCompile Include="..\src\stdio.c" />
|
<ClCompile Include="..\src\stdio.c" />
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
<ClCompile Include="..\src\smart.c">
|
<ClCompile Include="..\src\smart.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\checksum.c">
|
<ClCompile Include="..\src\hash.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\pki.c">
|
<ClCompile Include="..\src\pki.c">
|
||||||
|
|
|
@ -14,7 +14,7 @@ AM_V_WINDRES = $(AM_V_WINDRES_$(V))
|
||||||
%_rc.o: %.rc ../res/loc/embedded.loc
|
%_rc.o: %.rc ../res/loc/embedded.loc
|
||||||
$(AM_V_WINDRES) $(AM_RCFLAGS) -i $< -o $@
|
$(AM_V_WINDRES) $(AM_RCFLAGS) -i $< -o $@
|
||||||
|
|
||||||
rufus_SOURCES = badblocks.c checksum.c cpu.c dev.c dos.c dos_locale.c drive.c format.c format_ext.c format_fat32.c icon.c iso.c \
|
rufus_SOURCES = badblocks.c cpu.c dev.c dos.c dos_locale.c drive.c format.c format_ext.c format_fat32.c hash.c icon.c iso.c \
|
||||||
localization.c net.c parser.c pki.c process.c re.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c ui.c vhd.c wue.c
|
localization.c net.c parser.c pki.c process.c re.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c ui.c vhd.c wue.c
|
||||||
rufus_CFLAGS = -I$(srcdir)/ms-sys/inc -I$(srcdir)/syslinux/libfat -I$(srcdir)/syslinux/libinstaller -I$(srcdir)/syslinux/win -I$(srcdir)/libcdio $(AM_CFLAGS) \
|
rufus_CFLAGS = -I$(srcdir)/ms-sys/inc -I$(srcdir)/syslinux/libfat -I$(srcdir)/syslinux/libinstaller -I$(srcdir)/syslinux/win -I$(srcdir)/libcdio $(AM_CFLAGS) \
|
||||||
-DEXT2_FLAT_INCLUDES=0 -DSOLUTION=rufus
|
-DEXT2_FLAT_INCLUDES=0 -DSOLUTION=rufus
|
||||||
|
|
|
@ -87,13 +87,14 @@ mkinstalldirs = $(install_sh) -d
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES =
|
||||||
CONFIG_CLEAN_VPATH_FILES =
|
CONFIG_CLEAN_VPATH_FILES =
|
||||||
PROGRAMS = $(noinst_PROGRAMS)
|
PROGRAMS = $(noinst_PROGRAMS)
|
||||||
am_rufus_OBJECTS = rufus-badblocks.$(OBJEXT) rufus-checksum.$(OBJEXT) \
|
am_rufus_OBJECTS = rufus-badblocks.$(OBJEXT) rufus-cpu.$(OBJEXT) \
|
||||||
rufus-cpu.$(OBJEXT) rufus-dev.$(OBJEXT) rufus-dos.$(OBJEXT) \
|
rufus-dev.$(OBJEXT) rufus-dos.$(OBJEXT) \
|
||||||
rufus-dos_locale.$(OBJEXT) rufus-drive.$(OBJEXT) \
|
rufus-dos_locale.$(OBJEXT) rufus-drive.$(OBJEXT) \
|
||||||
rufus-format.$(OBJEXT) rufus-format_ext.$(OBJEXT) \
|
rufus-format.$(OBJEXT) rufus-format_ext.$(OBJEXT) \
|
||||||
rufus-format_fat32.$(OBJEXT) rufus-icon.$(OBJEXT) \
|
rufus-format_fat32.$(OBJEXT) rufus-hash.$(OBJEXT) \
|
||||||
rufus-iso.$(OBJEXT) rufus-localization.$(OBJEXT) \
|
rufus-icon.$(OBJEXT) rufus-iso.$(OBJEXT) \
|
||||||
rufus-net.$(OBJEXT) rufus-parser.$(OBJEXT) rufus-pki.$(OBJEXT) \
|
rufus-localization.$(OBJEXT) rufus-net.$(OBJEXT) \
|
||||||
|
rufus-parser.$(OBJEXT) rufus-pki.$(OBJEXT) \
|
||||||
rufus-process.$(OBJEXT) rufus-re.$(OBJEXT) \
|
rufus-process.$(OBJEXT) rufus-re.$(OBJEXT) \
|
||||||
rufus-rufus.$(OBJEXT) rufus-smart.$(OBJEXT) \
|
rufus-rufus.$(OBJEXT) rufus-smart.$(OBJEXT) \
|
||||||
rufus-stdfn.$(OBJEXT) rufus-stdio.$(OBJEXT) \
|
rufus-stdfn.$(OBJEXT) rufus-stdio.$(OBJEXT) \
|
||||||
|
@ -281,7 +282,7 @@ AM_V_WINDRES_0 = @echo " RC $@";$(WINDRES)
|
||||||
AM_V_WINDRES_1 = $(WINDRES)
|
AM_V_WINDRES_1 = $(WINDRES)
|
||||||
AM_V_WINDRES_ = $(AM_V_WINDRES_$(AM_DEFAULT_VERBOSITY))
|
AM_V_WINDRES_ = $(AM_V_WINDRES_$(AM_DEFAULT_VERBOSITY))
|
||||||
AM_V_WINDRES = $(AM_V_WINDRES_$(V))
|
AM_V_WINDRES = $(AM_V_WINDRES_$(V))
|
||||||
rufus_SOURCES = badblocks.c checksum.c cpu.c dev.c dos.c dos_locale.c drive.c format.c format_ext.c format_fat32.c icon.c iso.c \
|
rufus_SOURCES = badblocks.c cpu.c dev.c dos.c dos_locale.c drive.c format.c format_ext.c format_fat32.c hash.c icon.c iso.c \
|
||||||
localization.c net.c parser.c pki.c process.c re.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c ui.c vhd.c wue.c
|
localization.c net.c parser.c pki.c process.c re.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c ui.c vhd.c wue.c
|
||||||
|
|
||||||
rufus_CFLAGS = -I$(srcdir)/ms-sys/inc -I$(srcdir)/syslinux/libfat -I$(srcdir)/syslinux/libinstaller -I$(srcdir)/syslinux/win -I$(srcdir)/libcdio $(AM_CFLAGS) \
|
rufus_CFLAGS = -I$(srcdir)/ms-sys/inc -I$(srcdir)/syslinux/libfat -I$(srcdir)/syslinux/libinstaller -I$(srcdir)/syslinux/win -I$(srcdir)/libcdio $(AM_CFLAGS) \
|
||||||
|
@ -351,12 +352,6 @@ rufus-badblocks.o: badblocks.c
|
||||||
rufus-badblocks.obj: badblocks.c
|
rufus-badblocks.obj: badblocks.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-badblocks.obj `if test -f 'badblocks.c'; then $(CYGPATH_W) 'badblocks.c'; else $(CYGPATH_W) '$(srcdir)/badblocks.c'; fi`
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-badblocks.obj `if test -f 'badblocks.c'; then $(CYGPATH_W) 'badblocks.c'; else $(CYGPATH_W) '$(srcdir)/badblocks.c'; fi`
|
||||||
|
|
||||||
rufus-checksum.o: checksum.c
|
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-checksum.o `test -f 'checksum.c' || echo '$(srcdir)/'`checksum.c
|
|
||||||
|
|
||||||
rufus-checksum.obj: checksum.c
|
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-checksum.obj `if test -f 'checksum.c'; then $(CYGPATH_W) 'checksum.c'; else $(CYGPATH_W) '$(srcdir)/checksum.c'; fi`
|
|
||||||
|
|
||||||
rufus-cpu.o: cpu.c
|
rufus-cpu.o: cpu.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-cpu.o `test -f 'cpu.c' || echo '$(srcdir)/'`cpu.c
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-cpu.o `test -f 'cpu.c' || echo '$(srcdir)/'`cpu.c
|
||||||
|
|
||||||
|
@ -405,6 +400,12 @@ rufus-format_fat32.o: format_fat32.c
|
||||||
rufus-format_fat32.obj: format_fat32.c
|
rufus-format_fat32.obj: format_fat32.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-format_fat32.obj `if test -f 'format_fat32.c'; then $(CYGPATH_W) 'format_fat32.c'; else $(CYGPATH_W) '$(srcdir)/format_fat32.c'; fi`
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-format_fat32.obj `if test -f 'format_fat32.c'; then $(CYGPATH_W) 'format_fat32.c'; else $(CYGPATH_W) '$(srcdir)/format_fat32.c'; fi`
|
||||||
|
|
||||||
|
rufus-hash.o: hash.c
|
||||||
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-hash.o `test -f 'hash.c' || echo '$(srcdir)/'`hash.c
|
||||||
|
|
||||||
|
rufus-hash.obj: hash.c
|
||||||
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-hash.obj `if test -f 'hash.c'; then $(CYGPATH_W) 'hash.c'; else $(CYGPATH_W) '$(srcdir)/hash.c'; fi`
|
||||||
|
|
||||||
rufus-icon.o: icon.c
|
rufus-icon.o: icon.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-icon.o `test -f 'icon.c' || echo '$(srcdir)/'`icon.c
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-icon.o `test -f 'icon.c' || echo '$(srcdir)/'`icon.c
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Copyright © 2004-2019 Tom St Denis
|
* Copyright © 2004-2019 Tom St Denis
|
||||||
* Copyright © 2004 g10 Code GmbH
|
* Copyright © 2004 g10 Code GmbH
|
||||||
* Copyright © 2002-2015 Wei Dai & Igor Pavlov
|
* Copyright © 2002-2015 Wei Dai & Igor Pavlov
|
||||||
* Copyright © 2015-2021 Pete Batard <pete@akeo.ie>
|
* Copyright © 2015-2023 Pete Batard <pete@akeo.ie>
|
||||||
* Copyright © 2022 Jeffrey Walton <noloader@gmail.com>
|
* Copyright © 2022 Jeffrey Walton <noloader@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -61,6 +61,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <windows.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
@ -112,9 +113,9 @@
|
||||||
// would modify the buffer being processed.
|
// would modify the buffer being processed.
|
||||||
|
|
||||||
/* Globals */
|
/* Globals */
|
||||||
char sum_str[CHECKSUM_MAX][150];
|
char hash_str[HASH_MAX][150];
|
||||||
uint32_t proc_bufnum, sum_count[CHECKSUM_MAX] = { MD5_HASHSIZE, SHA1_HASHSIZE, SHA256_HASHSIZE, SHA512_HASHSIZE };
|
uint32_t proc_bufnum, hash_count[HASH_MAX] = { MD5_HASHSIZE, SHA1_HASHSIZE, SHA256_HASHSIZE, SHA512_HASHSIZE };
|
||||||
HANDLE data_ready[CHECKSUM_MAX] = { 0 }, thread_ready[CHECKSUM_MAX] = { 0 };
|
HANDLE data_ready[HASH_MAX] = { 0 }, thread_ready[HASH_MAX] = { 0 };
|
||||||
DWORD read_size[NUM_BUFFERS];
|
DWORD read_size[NUM_BUFFERS];
|
||||||
BOOL enable_extra_hashes = FALSE;
|
BOOL enable_extra_hashes = FALSE;
|
||||||
uint8_t ALIGNED(64) buffer[NUM_BUFFERS][BUFFER_SIZE];
|
uint8_t ALIGNED(64) buffer[NUM_BUFFERS][BUFFER_SIZE];
|
||||||
|
@ -173,16 +174,16 @@ static const uint64_t K512[80] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For convenience, we use a common context for all the checksum algorithms,
|
* For convenience, we use a common context for all the hash algorithms,
|
||||||
* which means some elements may be unused...
|
* which means some elements may be unused...
|
||||||
*/
|
*/
|
||||||
typedef struct ALIGNED(64) {
|
typedef struct ALIGNED(64) {
|
||||||
uint8_t buf[MAX_BLOCKSIZE];
|
uint8_t buf[MAX_BLOCKSIZE];
|
||||||
uint64_t state[8];
|
uint64_t state[8];
|
||||||
uint64_t bytecount;
|
uint64_t bytecount;
|
||||||
} SUM_CONTEXT;
|
} HASH_CONTEXT;
|
||||||
|
|
||||||
static void md5_init(SUM_CONTEXT *ctx)
|
static void md5_init(HASH_CONTEXT *ctx)
|
||||||
{
|
{
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
ctx->state[0] = 0x67452301;
|
ctx->state[0] = 0x67452301;
|
||||||
|
@ -191,7 +192,7 @@ static void md5_init(SUM_CONTEXT *ctx)
|
||||||
ctx->state[3] = 0x10325476;
|
ctx->state[3] = 0x10325476;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sha1_init(SUM_CONTEXT *ctx)
|
static void sha1_init(HASH_CONTEXT *ctx)
|
||||||
{
|
{
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
ctx->state[0] = 0x67452301;
|
ctx->state[0] = 0x67452301;
|
||||||
|
@ -201,7 +202,7 @@ static void sha1_init(SUM_CONTEXT *ctx)
|
||||||
ctx->state[4] = 0xc3d2e1f0;
|
ctx->state[4] = 0xc3d2e1f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sha256_init(SUM_CONTEXT *ctx)
|
static void sha256_init(HASH_CONTEXT *ctx)
|
||||||
{
|
{
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
ctx->state[0] = 0x6a09e667;
|
ctx->state[0] = 0x6a09e667;
|
||||||
|
@ -214,7 +215,7 @@ static void sha256_init(SUM_CONTEXT *ctx)
|
||||||
ctx->state[7] = 0x5be0cd19;
|
ctx->state[7] = 0x5be0cd19;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sha512_init(SUM_CONTEXT* ctx)
|
static void sha512_init(HASH_CONTEXT* ctx)
|
||||||
{
|
{
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
ctx->state[0] = 0x6a09e667f3bcc908ULL;
|
ctx->state[0] = 0x6a09e667f3bcc908ULL;
|
||||||
|
@ -228,7 +229,7 @@ static void sha512_init(SUM_CONTEXT* ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transform the message X which consists of 16 32-bit-words (SHA-1) */
|
/* Transform the message X which consists of 16 32-bit-words (SHA-1) */
|
||||||
static void sha1_transform_cc(SUM_CONTEXT *ctx, const uint8_t *data)
|
static void sha1_transform_cc(HASH_CONTEXT *ctx, const uint8_t *data)
|
||||||
{
|
{
|
||||||
uint32_t a, b, c, d, e, tm, x[16];
|
uint32_t a, b, c, d, e, tm, x[16];
|
||||||
|
|
||||||
|
@ -572,7 +573,7 @@ static void sha1_transform_x86(uint64_t state64[5], const uint8_t *data, size_t
|
||||||
#endif /* CPU_X86_SHA1_ACCELERATION */
|
#endif /* CPU_X86_SHA1_ACCELERATION */
|
||||||
|
|
||||||
/* Transform the message X which consists of 16 32-bit-words (SHA-1) */
|
/* Transform the message X which consists of 16 32-bit-words (SHA-1) */
|
||||||
static void sha1_transform(SUM_CONTEXT *ctx, const uint8_t *data)
|
static void sha1_transform(HASH_CONTEXT *ctx, const uint8_t *data)
|
||||||
{
|
{
|
||||||
#ifdef CPU_X86_SHA1_ACCELERATION
|
#ifdef CPU_X86_SHA1_ACCELERATION
|
||||||
if (cpu_has_sha1_accel)
|
if (cpu_has_sha1_accel)
|
||||||
|
@ -589,7 +590,7 @@ static void sha1_transform(SUM_CONTEXT *ctx, const uint8_t *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transform the message X which consists of 16 32-bit-words (SHA-256) */
|
/* Transform the message X which consists of 16 32-bit-words (SHA-256) */
|
||||||
static __inline void sha256_transform_cc(SUM_CONTEXT *ctx, const uint8_t *data)
|
static __inline void sha256_transform_cc(HASH_CONTEXT *ctx, const uint8_t *data)
|
||||||
{
|
{
|
||||||
uint32_t a, b, c, d, e, f, g, h, j, x[16];
|
uint32_t a, b, c, d, e, f, g, h, j, x[16];
|
||||||
|
|
||||||
|
@ -883,7 +884,7 @@ static __inline void sha256_transform_x86(uint64_t state64[8], const uint8_t *da
|
||||||
}
|
}
|
||||||
#endif /* CPU_X86_SHA256_ACCELERATION */
|
#endif /* CPU_X86_SHA256_ACCELERATION */
|
||||||
|
|
||||||
static __inline void sha256_transform(SUM_CONTEXT *ctx, const uint8_t *data)
|
static __inline void sha256_transform(HASH_CONTEXT *ctx, const uint8_t *data)
|
||||||
{
|
{
|
||||||
#ifdef CPU_X86_SHA256_ACCELERATION
|
#ifdef CPU_X86_SHA256_ACCELERATION
|
||||||
if (cpu_has_sha256_accel)
|
if (cpu_has_sha256_accel)
|
||||||
|
@ -904,7 +905,7 @@ static __inline void sha256_transform(SUM_CONTEXT *ctx, const uint8_t *data)
|
||||||
* This is an algorithm that *REALLY* benefits from being executed as 64-bit
|
* This is an algorithm that *REALLY* benefits from being executed as 64-bit
|
||||||
* code rather than 32-bit, as it's more than twice as fast then...
|
* code rather than 32-bit, as it's more than twice as fast then...
|
||||||
*/
|
*/
|
||||||
static __inline void sha512_transform(SUM_CONTEXT* ctx, const uint8_t* data)
|
static __inline void sha512_transform(HASH_CONTEXT* ctx, const uint8_t* data)
|
||||||
{
|
{
|
||||||
uint64_t a, b, c, d, e, f, g, h, W[80];
|
uint64_t a, b, c, d, e, f, g, h, W[80];
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
@ -967,7 +968,7 @@ static __inline void sha512_transform(SUM_CONTEXT* ctx, const uint8_t* data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transform the message X which consists of 16 32-bit-words (MD5) */
|
/* Transform the message X which consists of 16 32-bit-words (MD5) */
|
||||||
static void md5_transform(SUM_CONTEXT *ctx, const uint8_t *data)
|
static void md5_transform(HASH_CONTEXT *ctx, const uint8_t *data)
|
||||||
{
|
{
|
||||||
uint32_t a, b, c, d, x[16];
|
uint32_t a, b, c, d, x[16];
|
||||||
|
|
||||||
|
@ -1080,7 +1081,7 @@ static void md5_transform(SUM_CONTEXT *ctx, const uint8_t *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the message digest with the contents of the buffer (SHA-1) */
|
/* Update the message digest with the contents of the buffer (SHA-1) */
|
||||||
static void sha1_write(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
static void sha1_write(HASH_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t num = ctx->bytecount & (SHA1_BLOCKSIZE - 1);
|
size_t num = ctx->bytecount & (SHA1_BLOCKSIZE - 1);
|
||||||
|
|
||||||
|
@ -1132,7 +1133,7 @@ static void sha1_write(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the message digest with the contents of the buffer (SHA-256) */
|
/* Update the message digest with the contents of the buffer (SHA-256) */
|
||||||
static void sha256_write(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
static void sha256_write(HASH_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t num = ctx->bytecount & (SHA256_BLOCKSIZE - 1);
|
size_t num = ctx->bytecount & (SHA256_BLOCKSIZE - 1);
|
||||||
|
|
||||||
|
@ -1184,7 +1185,7 @@ static void sha256_write(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the message digest with the contents of the buffer (SHA-512) */
|
/* Update the message digest with the contents of the buffer (SHA-512) */
|
||||||
static void sha512_write(SUM_CONTEXT* ctx, const uint8_t* buf, size_t len)
|
static void sha512_write(HASH_CONTEXT* ctx, const uint8_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t num = ctx->bytecount & (SHA512_BLOCKSIZE - 1);
|
size_t num = ctx->bytecount & (SHA512_BLOCKSIZE - 1);
|
||||||
|
|
||||||
|
@ -1219,7 +1220,7 @@ static void sha512_write(SUM_CONTEXT* ctx, const uint8_t* buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the message digest with the contents of the buffer (MD5) */
|
/* Update the message digest with the contents of the buffer (MD5) */
|
||||||
static void md5_write(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
static void md5_write(HASH_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t num = ctx->bytecount & (MD5_BLOCKSIZE - 1);
|
size_t num = ctx->bytecount & (MD5_BLOCKSIZE - 1);
|
||||||
|
|
||||||
|
@ -1254,7 +1255,7 @@ static void md5_write(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finalize the computation and write the digest in ctx->state[] (SHA-1) */
|
/* Finalize the computation and write the digest in ctx->state[] (SHA-1) */
|
||||||
static void sha1_final(SUM_CONTEXT *ctx)
|
static void sha1_final(HASH_CONTEXT *ctx)
|
||||||
{
|
{
|
||||||
size_t pos = ((size_t)ctx->bytecount) & (SHA1_BLOCKSIZE - 1);
|
size_t pos = ((size_t)ctx->bytecount) & (SHA1_BLOCKSIZE - 1);
|
||||||
uint64_t bitcount = ctx->bytecount << 3;
|
uint64_t bitcount = ctx->bytecount << 3;
|
||||||
|
@ -1297,7 +1298,7 @@ static void sha1_final(SUM_CONTEXT *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finalize the computation and write the digest in ctx->state[] (SHA-256) */
|
/* Finalize the computation and write the digest in ctx->state[] (SHA-256) */
|
||||||
static void sha256_final(SUM_CONTEXT *ctx)
|
static void sha256_final(HASH_CONTEXT *ctx)
|
||||||
{
|
{
|
||||||
size_t pos = ((size_t)ctx->bytecount) & (SHA256_BLOCKSIZE - 1);
|
size_t pos = ((size_t)ctx->bytecount) & (SHA256_BLOCKSIZE - 1);
|
||||||
uint64_t bitcount = ctx->bytecount << 3;
|
uint64_t bitcount = ctx->bytecount << 3;
|
||||||
|
@ -1343,7 +1344,7 @@ static void sha256_final(SUM_CONTEXT *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finalize the computation and write the digest in ctx->state[] (SHA-256) */
|
/* Finalize the computation and write the digest in ctx->state[] (SHA-256) */
|
||||||
static void sha512_final(SUM_CONTEXT* ctx)
|
static void sha512_final(HASH_CONTEXT* ctx)
|
||||||
{
|
{
|
||||||
size_t pos = ((size_t)ctx->bytecount) & (SHA512_BLOCKSIZE - 1);
|
size_t pos = ((size_t)ctx->bytecount) & (SHA512_BLOCKSIZE - 1);
|
||||||
/* 16 EB ought to be enough for everybody... */
|
/* 16 EB ought to be enough for everybody... */
|
||||||
|
@ -1400,7 +1401,7 @@ static void sha512_final(SUM_CONTEXT* ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finalize the computation and write the digest in ctx->state[] (MD5) */
|
/* Finalize the computation and write the digest in ctx->state[] (MD5) */
|
||||||
static void md5_final(SUM_CONTEXT *ctx)
|
static void md5_final(HASH_CONTEXT *ctx)
|
||||||
{
|
{
|
||||||
size_t count = ((size_t)ctx->bytecount) & (MD5_BLOCKSIZE - 1);
|
size_t count = ((size_t)ctx->bytecount) & (MD5_BLOCKSIZE - 1);
|
||||||
uint64_t bitcount = ctx->bytecount << 3;
|
uint64_t bitcount = ctx->bytecount << 3;
|
||||||
|
@ -1456,29 +1457,29 @@ static void md5_final(SUM_CONTEXT *ctx)
|
||||||
//#define NULL_TEST
|
//#define NULL_TEST
|
||||||
#ifdef NULL_TEST
|
#ifdef NULL_TEST
|
||||||
// These 'null' calls are useful for testing load balancing and individual algorithm speed
|
// These 'null' calls are useful for testing load balancing and individual algorithm speed
|
||||||
static void null_init(SUM_CONTEXT *ctx) { memset(ctx, 0, sizeof(*ctx)); }
|
static void null_init(HASH_CONTEXT *ctx) { memset(ctx, 0, sizeof(*ctx)); }
|
||||||
static void null_write(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len) { }
|
static void null_write(HASH_CONTEXT *ctx, const uint8_t *buf, size_t len) { }
|
||||||
static void null_final(SUM_CONTEXT *ctx) { }
|
static void null_final(HASH_CONTEXT *ctx) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void sum_init_t(SUM_CONTEXT *ctx);
|
typedef void hash_init_t(HASH_CONTEXT *ctx);
|
||||||
typedef void sum_write_t(SUM_CONTEXT *ctx, const uint8_t *buf, size_t len);
|
typedef void hash_write_t(HASH_CONTEXT *ctx, const uint8_t *buf, size_t len);
|
||||||
typedef void sum_final_t(SUM_CONTEXT *ctx);
|
typedef void hash_final_t(HASH_CONTEXT *ctx);
|
||||||
sum_init_t *sum_init[CHECKSUM_MAX] = { md5_init, sha1_init , sha256_init, sha512_init };
|
hash_init_t *hash_init[HASH_MAX] = { md5_init, sha1_init , sha256_init, sha512_init };
|
||||||
sum_write_t *sum_write[CHECKSUM_MAX] = { md5_write, sha1_write , sha256_write, sha512_write };
|
hash_write_t *hash_write[HASH_MAX] = { md5_write, sha1_write , sha256_write, sha512_write };
|
||||||
sum_final_t *sum_final[CHECKSUM_MAX] = { md5_final, sha1_final , sha256_final, sha512_final };
|
hash_final_t *hash_final[HASH_MAX] = { md5_final, sha1_final , sha256_final, sha512_final };
|
||||||
|
|
||||||
// Compute an individual checksum without threading or buffering, for a single file
|
// Compute an individual hash without threading or buffering, for a single file
|
||||||
BOOL HashFile(const unsigned type, const char* path, uint8_t* sum)
|
BOOL HashFile(const unsigned type, const char* path, uint8_t* hash)
|
||||||
{
|
{
|
||||||
BOOL r = FALSE;
|
BOOL r = FALSE;
|
||||||
SUM_CONTEXT sum_ctx = { {0} };
|
HASH_CONTEXT hash_ctx = { {0} };
|
||||||
HANDLE h = INVALID_HANDLE_VALUE;
|
HANDLE h = INVALID_HANDLE_VALUE;
|
||||||
DWORD rs = 0;
|
DWORD rs = 0;
|
||||||
uint64_t rb;
|
uint64_t rb;
|
||||||
uint8_t buf[4096];
|
uint8_t buf[4096];
|
||||||
|
|
||||||
if ((type >= CHECKSUM_MAX) || (path == NULL) || (sum == NULL))
|
if ((type >= HASH_MAX) || (path == NULL) || (hash == NULL))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
h = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
h = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
@ -1488,7 +1489,7 @@ BOOL HashFile(const unsigned type, const char* path, uint8_t* sum)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
sum_init[type](&sum_ctx);
|
hash_init[type](&hash_ctx);
|
||||||
for (rb = 0; ; rb += rs) {
|
for (rb = 0; ; rb += rs) {
|
||||||
CHECK_FOR_USER_CANCEL;
|
CHECK_FOR_USER_CANCEL;
|
||||||
if (!ReadFile(h, buf, sizeof(buf), &rs, NULL)) {
|
if (!ReadFile(h, buf, sizeof(buf), &rs, NULL)) {
|
||||||
|
@ -1498,11 +1499,11 @@ BOOL HashFile(const unsigned type, const char* path, uint8_t* sum)
|
||||||
}
|
}
|
||||||
if (rs == 0)
|
if (rs == 0)
|
||||||
break;
|
break;
|
||||||
sum_write[type](&sum_ctx, buf, (size_t)rs);
|
hash_write[type](&hash_ctx, buf, (size_t)rs);
|
||||||
}
|
}
|
||||||
sum_final[type](&sum_ctx);
|
hash_final[type](&hash_ctx);
|
||||||
|
|
||||||
memcpy(sum, sum_ctx.buf, sum_count[type]);
|
memcpy(hash, hash_ctx.buf, hash_count[type]);
|
||||||
r = TRUE;
|
r = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -1510,19 +1511,19 @@ out:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL HashBuffer(const unsigned type, const uint8_t* buf, const size_t len, uint8_t* sum)
|
BOOL HashBuffer(const unsigned type, const uint8_t* buf, const size_t len, uint8_t* hash)
|
||||||
{
|
{
|
||||||
BOOL r = FALSE;
|
BOOL r = FALSE;
|
||||||
SUM_CONTEXT sum_ctx = { {0} };
|
HASH_CONTEXT hash_ctx = { {0} };
|
||||||
|
|
||||||
if ((type >= CHECKSUM_MAX) || (sum == NULL))
|
if ((type >= HASH_MAX) || (hash == NULL))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
sum_init[type](&sum_ctx);
|
hash_init[type](&hash_ctx);
|
||||||
sum_write[type](&sum_ctx, buf, len);
|
hash_write[type](&hash_ctx, buf, len);
|
||||||
sum_final[type](&sum_ctx);
|
hash_final[type](&hash_ctx);
|
||||||
|
|
||||||
memcpy(sum, sum_ctx.buf, sum_count[type]);
|
memcpy(hash, hash_ctx.buf, hash_count[type]);
|
||||||
r = TRUE;
|
r = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -1530,9 +1531,9 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checksum dialog callback
|
* Hash dialog callback
|
||||||
*/
|
*/
|
||||||
INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK HashCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int i, dw, dh;
|
int i, dw, dh;
|
||||||
RECT rc;
|
RECT rc;
|
||||||
|
@ -1541,7 +1542,7 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
apply_localization(IDD_CHECKSUM, hDlg);
|
apply_localization(IDD_HASH, hDlg);
|
||||||
hDC = GetDC(hDlg);
|
hDC = GetDC(hDlg);
|
||||||
hFont = CreateFontA(-MulDiv(9, GetDeviceCaps(hDC, LOGPIXELSY), 72),
|
hFont = CreateFontA(-MulDiv(9, GetDeviceCaps(hDC, LOGPIXELSY), 72),
|
||||||
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
||||||
|
@ -1551,11 +1552,11 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
||||||
SendDlgItemMessageA(hDlg, IDC_SHA1, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendDlgItemMessageA(hDlg, IDC_SHA1, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
SendDlgItemMessageA(hDlg, IDC_SHA256, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendDlgItemMessageA(hDlg, IDC_SHA256, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
SendDlgItemMessageA(hDlg, IDC_SHA512, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendDlgItemMessageA(hDlg, IDC_SHA512, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
SetWindowTextA(GetDlgItem(hDlg, IDC_MD5), sum_str[0]);
|
SetWindowTextA(GetDlgItem(hDlg, IDC_MD5), hash_str[0]);
|
||||||
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA1), sum_str[1]);
|
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA1), hash_str[1]);
|
||||||
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA256), sum_str[2]);
|
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA256), hash_str[2]);
|
||||||
if (enable_extra_hashes)
|
if (enable_extra_hashes)
|
||||||
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA512), sum_str[3]);
|
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA512), hash_str[3]);
|
||||||
else
|
else
|
||||||
SetWindowTextU(GetDlgItem(hDlg, IDC_SHA512), lmprintf(MSG_311, "<Alt>-<H>"));
|
SetWindowTextU(GetDlgItem(hDlg, IDC_SHA512), lmprintf(MSG_311, "<Alt>-<H>"));
|
||||||
|
|
||||||
|
@ -1566,7 +1567,7 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
||||||
GetWindowRect(GetDlgItem(hDlg, IDC_MD5), &rc);
|
GetWindowRect(GetDlgItem(hDlg, IDC_MD5), &rc);
|
||||||
dw = rc.right - rc.left;
|
dw = rc.right - rc.left;
|
||||||
dh = rc.bottom - rc.top;
|
dh = rc.bottom - rc.top;
|
||||||
DrawTextU(hDC, sum_str[0], -1, &rc, DT_CALCRECT);
|
DrawTextU(hDC, hash_str[0], -1, &rc, DT_CALCRECT);
|
||||||
dw = rc.right - rc.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
|
dw = rc.right - rc.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
|
||||||
dh = rc.bottom - rc.top - dh + 6;
|
dh = rc.bottom - rc.top - dh + 6;
|
||||||
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA256), 0, 0, dw, dh, 1.0f);
|
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA256), 0, 0, dw, dh, 1.0f);
|
||||||
|
@ -1574,7 +1575,7 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
||||||
|
|
||||||
GetWindowRect(GetDlgItem(hDlg, IDC_SHA1), &rc);
|
GetWindowRect(GetDlgItem(hDlg, IDC_SHA1), &rc);
|
||||||
dw = rc.right - rc.left;
|
dw = rc.right - rc.left;
|
||||||
DrawTextU(hDC, sum_str[1], -1, &rc, DT_CALCRECT);
|
DrawTextU(hDC, hash_str[1], -1, &rc, DT_CALCRECT);
|
||||||
dw = rc.right - rc.left - dw + 12;
|
dw = rc.right - rc.left - dw + 12;
|
||||||
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MD5), 0, 0, dw, 0, 1.0f);
|
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MD5), 0, 0, dw, 0, 1.0f);
|
||||||
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA1), 0, 0, dw, 0, 1.0f);
|
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA1), 0, 0, dw, 0, 1.0f);
|
||||||
|
@ -1594,7 +1595,7 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
reset_localization(IDD_CHECKSUM);
|
reset_localization(IDD_HASH);
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1603,12 +1604,12 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
|
|
||||||
// Individual thread that computes one of MD5, SHA1, SHA256 or SHA512 in parallel
|
// Individual thread that computes one of MD5, SHA1, SHA256 or SHA512 in parallel
|
||||||
DWORD WINAPI IndividualSumThread(void* param)
|
DWORD WINAPI IndividualHashThread(void* param)
|
||||||
{
|
{
|
||||||
SUM_CONTEXT sum_ctx = { {0} }; // There's a memset in sum_init, but static analyzers still bug us
|
HASH_CONTEXT hash_ctx = { {0} }; // There's a memset in hash_init, but static analyzers still bug us
|
||||||
uint32_t i = (uint32_t)(uintptr_t)param, j;
|
uint32_t i = (uint32_t)(uintptr_t)param, j;
|
||||||
|
|
||||||
sum_init[i](&sum_ctx);
|
hash_init[i](&hash_ctx);
|
||||||
// Signal that we're ready to service requests
|
// Signal that we're ready to service requests
|
||||||
if (!SetEvent(thread_ready[i]))
|
if (!SetEvent(thread_ready[i]))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1616,45 +1617,45 @@ DWORD WINAPI IndividualSumThread(void* param)
|
||||||
// Wait for requests
|
// Wait for requests
|
||||||
while (1) {
|
while (1) {
|
||||||
if (WaitForSingleObject(data_ready[i], WAIT_TIME) != WAIT_OBJECT_0) {
|
if (WaitForSingleObject(data_ready[i], WAIT_TIME) != WAIT_OBJECT_0) {
|
||||||
uprintf("Failed to wait for event for checksum thread #%d: %s", i, WindowsErrorString());
|
uprintf("Failed to wait for event for hash thread #%d: %s", i, WindowsErrorString());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (read_size[proc_bufnum] != 0) {
|
if (read_size[proc_bufnum] != 0) {
|
||||||
sum_write[i](&sum_ctx, buffer[proc_bufnum], (size_t)read_size[proc_bufnum]);
|
hash_write[i](&hash_ctx, buffer[proc_bufnum], (size_t)read_size[proc_bufnum]);
|
||||||
if (!SetEvent(thread_ready[i]))
|
if (!SetEvent(thread_ready[i]))
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
sum_final[i](&sum_ctx);
|
hash_final[i](&hash_ctx);
|
||||||
memset(&sum_str[i], 0, ARRAYSIZE(sum_str[i]));
|
memset(&hash_str[i], 0, ARRAYSIZE(hash_str[i]));
|
||||||
for (j = 0; j < sum_count[i]; j++) {
|
for (j = 0; j < hash_count[i]; j++) {
|
||||||
sum_str[i][2 * j] = ((sum_ctx.buf[j] >> 4) < 10) ?
|
hash_str[i][2 * j] = ((hash_ctx.buf[j] >> 4) < 10) ?
|
||||||
((sum_ctx.buf[j] >> 4) + '0') : ((sum_ctx.buf[j] >> 4) - 0xa + 'a');
|
((hash_ctx.buf[j] >> 4) + '0') : ((hash_ctx.buf[j] >> 4) - 0xa + 'a');
|
||||||
sum_str[i][2 * j + 1] = ((sum_ctx.buf[j] & 15) < 10) ?
|
hash_str[i][2 * j + 1] = ((hash_ctx.buf[j] & 15) < 10) ?
|
||||||
((sum_ctx.buf[j] & 15) + '0') : ((sum_ctx.buf[j] & 15) - 0xa + 'a');
|
((hash_ctx.buf[j] & 15) + '0') : ((hash_ctx.buf[j] & 15) - 0xa + 'a');
|
||||||
}
|
}
|
||||||
sum_str[i][2 * j] = 0;
|
hash_str[i][2 * j] = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
uprintf("Failed to set event for checksum thread #%d: %s", i, WindowsErrorString());
|
uprintf("Failed to set event for hash thread #%d: %s", i, WindowsErrorString());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI SumThread(void* param)
|
DWORD WINAPI HashThread(void* param)
|
||||||
{
|
{
|
||||||
DWORD_PTR* thread_affinity = (DWORD_PTR*)param;
|
DWORD_PTR* thread_affinity = (DWORD_PTR*)param;
|
||||||
HANDLE sum_thread[CHECKSUM_MAX] = { NULL, NULL, NULL, NULL };
|
HANDLE hash_thread[HASH_MAX] = { NULL, NULL, NULL, NULL };
|
||||||
DWORD wr;
|
DWORD wr;
|
||||||
VOID* fd = NULL;
|
VOID* fd = NULL;
|
||||||
uint64_t processed_bytes;
|
uint64_t processed_bytes;
|
||||||
int i, read_bufnum, r = -1;
|
int i, read_bufnum, r = -1;
|
||||||
int num_checksums = CHECKSUM_MAX - (enable_extra_hashes ? 0 : 1);
|
int num_hashes = HASH_MAX - (enable_extra_hashes ? 0 : 1);
|
||||||
|
|
||||||
if ((image_path == NULL) || (thread_affinity == NULL))
|
if ((image_path == NULL) || (thread_affinity == NULL))
|
||||||
ExitThread(r);
|
ExitThread(r);
|
||||||
|
|
||||||
uprintf("\r\nComputing checksum for '%s'...", image_path);
|
uprintf("\r\nComputing hash for '%s'...", image_path);
|
||||||
|
|
||||||
if (thread_affinity[0] != 0)
|
if (thread_affinity[0] != 0)
|
||||||
// Use the first affinity mask, as our read thread is the least
|
// Use the first affinity mask, as our read thread is the least
|
||||||
|
@ -1663,24 +1664,24 @@ DWORD WINAPI SumThread(void* param)
|
||||||
// is usually in this first mask, for other tasks.
|
// is usually in this first mask, for other tasks.
|
||||||
SetThreadAffinityMask(GetCurrentThread(), thread_affinity[0]);
|
SetThreadAffinityMask(GetCurrentThread(), thread_affinity[0]);
|
||||||
|
|
||||||
for (i = 0; i < num_checksums; i++) {
|
for (i = 0; i < num_hashes; i++) {
|
||||||
// NB: Can't use a single manual-reset event for data_ready as we
|
// NB: Can't use a single manual-reset event for data_ready as we
|
||||||
// wouldn't be able to ensure the event is reset before the thread
|
// wouldn't be able to ensure the event is reset before the thread
|
||||||
// gets into its next wait loop
|
// gets into its next wait loop
|
||||||
data_ready[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
data_ready[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
thread_ready[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
thread_ready[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
if ((data_ready[i] == NULL) || (thread_ready[i] == NULL)) {
|
if ((data_ready[i] == NULL) || (thread_ready[i] == NULL)) {
|
||||||
uprintf("Unable to create checksum thread event: %s", WindowsErrorString());
|
uprintf("Unable to create hash thread event: %s", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
sum_thread[i] = CreateThread(NULL, 0, IndividualSumThread, (LPVOID)(uintptr_t)i, 0, NULL);
|
hash_thread[i] = CreateThread(NULL, 0, IndividualHashThread, (LPVOID)(uintptr_t)i, 0, NULL);
|
||||||
if (sum_thread[i] == NULL) {
|
if (hash_thread[i] == NULL) {
|
||||||
uprintf("Unable to start checksum thread #%d", i);
|
uprintf("Unable to start hash thread #%d", i);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
SetThreadPriority(sum_thread[i], default_thread_priority);
|
SetThreadPriority(hash_thread[i], default_thread_priority);
|
||||||
if (thread_affinity[i+1] != 0)
|
if (thread_affinity[i+1] != 0)
|
||||||
SetThreadAffinityMask(sum_thread[i], thread_affinity[i+1]);
|
SetThreadAffinityMask(hash_thread[i], thread_affinity[i+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = CreateFileAsync(image_path, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN);
|
fd = CreateFileAsync(image_path, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN);
|
||||||
|
@ -1717,12 +1718,12 @@ DWORD WINAPI SumThread(void* param)
|
||||||
// 3. Launch the next asynchronous read operation
|
// 3. Launch the next asynchronous read operation
|
||||||
ReadFileAsync(fd, buffer[read_bufnum], BUFFER_SIZE);
|
ReadFileAsync(fd, buffer[read_bufnum], BUFFER_SIZE);
|
||||||
|
|
||||||
// 4. Wait for all the sum threads to indicate that they are ready to process data
|
// 4. Wait for all the hash threads to indicate that they are ready to process data
|
||||||
wr = WaitForMultipleObjects(num_checksums, thread_ready, TRUE, WAIT_TIME);
|
wr = WaitForMultipleObjects(num_hashes, thread_ready, TRUE, WAIT_TIME);
|
||||||
if (wr != WAIT_OBJECT_0) {
|
if (wr != WAIT_OBJECT_0) {
|
||||||
if (wr == STATUS_TIMEOUT)
|
if (wr == STATUS_TIMEOUT)
|
||||||
SetLastError(ERROR_TIMEOUT);
|
SetLastError(ERROR_TIMEOUT);
|
||||||
uprintf("Checksum threads failed to signal: %s", WindowsErrorString());
|
uprintf("Hash threads failed to signal: %s", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1731,43 +1732,43 @@ DWORD WINAPI SumThread(void* param)
|
||||||
proc_bufnum = (read_bufnum + NUM_BUFFERS - 1) % NUM_BUFFERS;
|
proc_bufnum = (read_bufnum + NUM_BUFFERS - 1) % NUM_BUFFERS;
|
||||||
|
|
||||||
// 6. Signal the waiting threads that there is data available
|
// 6. Signal the waiting threads that there is data available
|
||||||
for (i = 0; i < num_checksums; i++) {
|
for (i = 0; i < num_hashes; i++) {
|
||||||
if (!SetEvent(data_ready[i])) {
|
if (!SetEvent(data_ready[i])) {
|
||||||
uprintf("Could not signal checksum thread %d: %s", i, WindowsErrorString());
|
uprintf("Could not signal hash thread %d: %s", i, WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our last event with read_size=0 signaled the threads to exit - wait for that to happen
|
// Our last event with read_size=0 signaled the threads to exit - wait for that to happen
|
||||||
if (WaitForMultipleObjects(num_checksums, sum_thread, TRUE, WAIT_TIME) != WAIT_OBJECT_0) {
|
if (WaitForMultipleObjects(num_hashes, hash_thread, TRUE, WAIT_TIME) != WAIT_OBJECT_0) {
|
||||||
uprintf("Checksum threads did not finalize: %s", WindowsErrorString());
|
uprintf("Hash threads did not finalize: %s", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
uprintf(" MD5: %s", sum_str[0]);
|
uprintf(" MD5: %s", hash_str[0]);
|
||||||
uprintf(" SHA1: %s", sum_str[1]);
|
uprintf(" SHA1: %s", hash_str[1]);
|
||||||
uprintf(" SHA256: %s", sum_str[2]);
|
uprintf(" SHA256: %s", hash_str[2]);
|
||||||
if (enable_extra_hashes) {
|
if (enable_extra_hashes) {
|
||||||
char c = sum_str[3][SHA512_HASHSIZE];
|
char c = hash_str[3][SHA512_HASHSIZE];
|
||||||
sum_str[3][SHA512_HASHSIZE] = 0;
|
hash_str[3][SHA512_HASHSIZE] = 0;
|
||||||
uprintf(" SHA512: %s", sum_str[3]);
|
uprintf(" SHA512: %s", hash_str[3]);
|
||||||
sum_str[3][SHA512_HASHSIZE] = c;
|
hash_str[3][SHA512_HASHSIZE] = c;
|
||||||
uprintf(" %s", &sum_str[3][SHA512_HASHSIZE]);
|
uprintf(" %s", &hash_str[3][SHA512_HASHSIZE]);
|
||||||
}
|
}
|
||||||
r = 0;
|
r = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
for (i = 0; i < num_checksums; i++) {
|
for (i = 0; i < num_hashes; i++) {
|
||||||
if (sum_thread[i] != NULL)
|
if (hash_thread[i] != NULL)
|
||||||
TerminateThread(sum_thread[i], 1);
|
TerminateThread(hash_thread[i], 1);
|
||||||
safe_closehandle(data_ready[i]);
|
safe_closehandle(data_ready[i]);
|
||||||
safe_closehandle(thread_ready[i]);
|
safe_closehandle(thread_ready[i]);
|
||||||
}
|
}
|
||||||
CloseFileAsync(fd);
|
CloseFileAsync(fd);
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
MyDialogBox(hMainInstance, IDD_CHECKSUM, hMainDialog, ChecksumCallback);
|
MyDialogBox(hMainInstance, IDD_HASH, hMainDialog, HashCallback);
|
||||||
ExitThread(r);
|
ExitThread(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1777,11 +1778,11 @@ out:
|
||||||
BOOL IsBufferInDB(const unsigned char* buf, const size_t len)
|
BOOL IsBufferInDB(const unsigned char* buf, const size_t len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint8_t sum[32];
|
uint8_t hash[32];
|
||||||
if (!HashBuffer(CHECKSUM_SHA256, buf, len, sum))
|
if (!HashBuffer(HASH_SHA256, buf, len, hash))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for (i = 0; i < ARRAYSIZE(sha256db); i += 32)
|
for (i = 0; i < ARRAYSIZE(sha256db); i += 32)
|
||||||
if (memcmp(sum, &sha256db[i], 32) == 0)
|
if (memcmp(hash, &sha256db[i], 32) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1789,11 +1790,11 @@ BOOL IsBufferInDB(const unsigned char* buf, const size_t len)
|
||||||
BOOL IsFileInDB(const char* path)
|
BOOL IsFileInDB(const char* path)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint8_t sum[32];
|
uint8_t hash[32];
|
||||||
if (!HashFile(CHECKSUM_SHA256, path, sum))
|
if (!HashFile(HASH_SHA256, path, hash))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for (i = 0; i < ARRAYSIZE(sha256db); i += 32)
|
for (i = 0; i < ARRAYSIZE(sha256db); i += 32)
|
||||||
if (memcmp(sum, &sha256db[i], 32) == 0)
|
if (memcmp(hash, &sha256db[i], 32) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1838,7 +1839,7 @@ const char test_msg[] = "Did you ever hear the tragedy of Darth Plagueis The Wis
|
||||||
* Much rather copy paste from md5sum/sha#sum output from Linux and just
|
* Much rather copy paste from md5sum/sha#sum output from Linux and just
|
||||||
* convert the string.
|
* convert the string.
|
||||||
*/
|
*/
|
||||||
const char* test_hash[CHECKSUM_MAX][4] = {
|
const char* test_hash[HASH_MAX][4] = {
|
||||||
{
|
{
|
||||||
"d41d8cd98f00b204e9800998ecf8427e",
|
"d41d8cd98f00b204e9800998ecf8427e",
|
||||||
"74cac558072300385f7ab4dff7465e3c",
|
"74cac558072300385f7ab4dff7465e3c",
|
||||||
|
@ -1863,12 +1864,12 @@ const char* test_hash[CHECKSUM_MAX][4] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Tests the message digest algorithms */
|
/* Tests the message digest algorithms */
|
||||||
int TestChecksum(void)
|
int TestHashes(void)
|
||||||
{
|
{
|
||||||
const uint32_t blocksize[CHECKSUM_MAX] = { MD5_BLOCKSIZE, SHA1_BLOCKSIZE, SHA256_BLOCKSIZE, SHA512_BLOCKSIZE };
|
const uint32_t blocksize[HASH_MAX] = { MD5_BLOCKSIZE, SHA1_BLOCKSIZE, SHA256_BLOCKSIZE, SHA512_BLOCKSIZE };
|
||||||
const char* hash_name[4] = { "MD5 ", "SHA1 ", "SHA256", "SHA512" };
|
const char* hash_name[4] = { "MD5 ", "SHA1 ", "SHA256", "SHA512" };
|
||||||
int i, j, errors = 0;
|
int i, j, errors = 0;
|
||||||
uint8_t sum[MAX_HASHSIZE], *sum_expected;
|
uint8_t hash[MAX_HASHSIZE], *hash_expected;
|
||||||
size_t full_msg_len = strlen(test_msg);
|
size_t full_msg_len = strlen(test_msg);
|
||||||
char* msg = malloc(full_msg_len + 1);
|
char* msg = malloc(full_msg_len + 1);
|
||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
|
@ -1878,7 +1879,7 @@ int TestChecksum(void)
|
||||||
uprintf("SHA1 acceleration: %s", (cpu_has_sha1_accel ? "TRUE" : "FALSE"));
|
uprintf("SHA1 acceleration: %s", (cpu_has_sha1_accel ? "TRUE" : "FALSE"));
|
||||||
uprintf("SHA256 acceleration: %s", (cpu_has_sha256_accel ? "TRUE" : "FALSE"));
|
uprintf("SHA256 acceleration: %s", (cpu_has_sha256_accel ? "TRUE" : "FALSE"));
|
||||||
|
|
||||||
for (j = 0; j < CHECKSUM_MAX; j++) {
|
for (j = 0; j < HASH_MAX; j++) {
|
||||||
size_t copy_msg_len[4];
|
size_t copy_msg_len[4];
|
||||||
copy_msg_len[0] = 0;
|
copy_msg_len[0] = 0;
|
||||||
copy_msg_len[1] = 3;
|
copy_msg_len[1] = 3;
|
||||||
|
@ -1890,15 +1891,15 @@ int TestChecksum(void)
|
||||||
memset(msg, 0, full_msg_len + 1);
|
memset(msg, 0, full_msg_len + 1);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
memcpy(msg, test_msg, copy_msg_len[i]);
|
memcpy(msg, test_msg, copy_msg_len[i]);
|
||||||
HashBuffer(j, msg, copy_msg_len[i], sum);
|
HashBuffer(j, msg, copy_msg_len[i], hash);
|
||||||
sum_expected = to_bin(test_hash[j][i]);
|
hash_expected = to_bin(test_hash[j][i]);
|
||||||
if (memcmp(sum, sum_expected, sum_count[j]) != 0) {
|
if (memcmp(hash, hash_expected, hash_count[j]) != 0) {
|
||||||
uprintf("Test %s %d: FAIL", hash_name[j], i);
|
uprintf("Test %s %d: FAIL", hash_name[j], i);
|
||||||
errors++;
|
errors++;
|
||||||
} else {
|
} else {
|
||||||
uprintf("Test %s %d: PASS", hash_name[j], i);
|
uprintf("Test %s %d: PASS", hash_name[j], i);
|
||||||
}
|
}
|
||||||
free(sum_expected);
|
free(hash_expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,7 +664,7 @@ static void update_md5sum(void)
|
||||||
size = read_file(modified_path.String[i], &buf);
|
size = read_file(modified_path.String[i], &buf);
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
continue;
|
continue;
|
||||||
HashBuffer(CHECKSUM_MD5, buf, size, sum);
|
HashBuffer(HASH_MD5, buf, size, sum);
|
||||||
free(buf);
|
free(buf);
|
||||||
while ((pos > 0) && (md5_data[pos - 1] != '\n'))
|
while ((pos > 0) && (md5_data[pos - 1] != '\n'))
|
||||||
pos--;
|
pos--;
|
||||||
|
|
|
@ -114,18 +114,22 @@ const char* additional_copyrights =
|
||||||
"https://kolibrios.org/\\line\n"
|
"https://kolibrios.org/\\line\n"
|
||||||
"GNU General Public License (GPL) v2 or later\\line\n"
|
"GNU General Public License (GPL) v2 or later\\line\n"
|
||||||
"\\line\n"
|
"\\line\n"
|
||||||
"MD5 checksum by Ron Rivest, Colin Plumb et al.\\line\n"
|
"MD5 hash by Ron Rivest, Colin Plumb et al.\\line\n"
|
||||||
"Public Domain\\line\n"
|
"Public Domain\\line\n"
|
||||||
"\\line\n"
|
"\\line\n"
|
||||||
"SHA-1 checksum from GnuPG:\\line\n"
|
"SHA-1 digest functions from GnuPG:\\line\n"
|
||||||
"https://www.gnupg.org/\\line\n"
|
"https://www.gnupg.org/\\line\n"
|
||||||
"GNU General Public License (GPL) v3 or later\\line\n"
|
"GNU General Public License (GPL) v3 or later\\line\n"
|
||||||
"\\line\n"
|
"\\line\n"
|
||||||
"SHA-256 checksum from 7-zip by Igor Pavlov and Crypto++ by Wei Dai:\\line\n"
|
"SHA-256 digest functions 7-zip by Igor Pavlov and Crypto++ by Wei Dai:\\line\n"
|
||||||
"https://7-zip.org/\\line\n"
|
"https://7-zip.org/\\line\n"
|
||||||
"https://github.com/weidai11/cryptopp/\\line\n"
|
"https://github.com/weidai11/cryptopp/\\line\n"
|
||||||
"Public Domain\\line\n"
|
"Public Domain\\line\n"
|
||||||
"\\line\n"
|
"\\line\n"
|
||||||
|
"SHA-512 digest functions from libtomcrypt:\\line\n"
|
||||||
|
"https://github.com/libtom/libtomcrypt\\line\n"
|
||||||
|
"Public Domain\\line\n"
|
||||||
|
"\\line\n"
|
||||||
"About and License dialogs inspired by WinSCP by Martin Prikryl\\line\n"
|
"About and License dialogs inspired by WinSCP by Martin Prikryl\\line\n"
|
||||||
"https://winscp.net/\\line\n"
|
"https://winscp.net/\\line\n"
|
||||||
"GNU General Public License (GPL) v3 or later\\line\n"
|
"GNU General Public License (GPL) v3 or later\\line\n"
|
||||||
|
|
|
@ -35,7 +35,7 @@ const loc_control_id control_id[] = {
|
||||||
LOC_CTRL(IDD_LOG),
|
LOC_CTRL(IDD_LOG),
|
||||||
LOC_CTRL(IDD_UPDATE_POLICY),
|
LOC_CTRL(IDD_UPDATE_POLICY),
|
||||||
LOC_CTRL(IDD_NEW_VERSION),
|
LOC_CTRL(IDD_NEW_VERSION),
|
||||||
LOC_CTRL(IDD_CHECKSUM),
|
LOC_CTRL(IDD_HASH),
|
||||||
LOC_CTRL(IDD_LIST),
|
LOC_CTRL(IDD_LIST),
|
||||||
LOC_CTRL(IDC_DEVICE),
|
LOC_CTRL(IDC_DEVICE),
|
||||||
LOC_CTRL(IDC_FILE_SYSTEM),
|
LOC_CTRL(IDC_FILE_SYSTEM),
|
||||||
|
@ -532,6 +532,6 @@ loc_dlg_list loc_dlg[] = {
|
||||||
LOC_DLG(IDD_LOG),
|
LOC_DLG(IDD_LOG),
|
||||||
LOC_DLG(IDD_UPDATE_POLICY),
|
LOC_DLG(IDD_UPDATE_POLICY),
|
||||||
LOC_DLG(IDD_NEW_VERSION),
|
LOC_DLG(IDD_NEW_VERSION),
|
||||||
LOC_DLG(IDD_CHECKSUM),
|
LOC_DLG(IDD_HASH),
|
||||||
LOC_DLG(IDD_LIST),
|
LOC_DLG(IDD_LIST),
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define IDD_LOG 106
|
#define IDD_LOG 106
|
||||||
#define IDD_UPDATE_POLICY 107
|
#define IDD_UPDATE_POLICY 107
|
||||||
#define IDD_NEW_VERSION 108
|
#define IDD_NEW_VERSION 108
|
||||||
#define IDD_CHECKSUM 109
|
#define IDD_HASH 109
|
||||||
#define IDD_LIST 110
|
#define IDD_LIST 110
|
||||||
#define IDI_ICON 120
|
#define IDI_ICON 120
|
||||||
#define IDI_LANG_16 121
|
#define IDI_LANG_16 121
|
||||||
|
|
19
src/rufus.c
19
src/rufus.c
|
@ -865,7 +865,7 @@ static void EnableControls(BOOL enable, BOOL remove_checkboxes)
|
||||||
{
|
{
|
||||||
op_in_progress = !enable;
|
op_in_progress = !enable;
|
||||||
|
|
||||||
// The following only get disabled on format/checksum and otherwise remain enabled,
|
// The following only get disabled on format/hash and otherwise remain enabled,
|
||||||
// even if no device or image are selected
|
// even if no device or image are selected
|
||||||
EnableWindow(hDeviceList, enable);
|
EnableWindow(hDeviceList, enable);
|
||||||
EnableWindow(hBootType, enable);
|
EnableWindow(hBootType, enable);
|
||||||
|
@ -877,7 +877,7 @@ static void EnableControls(BOOL enable, BOOL remove_checkboxes)
|
||||||
SendMessage(hMultiToolbar, TB_ENABLEBUTTON, (WPARAM)IDC_ABOUT, (LPARAM)enable);
|
SendMessage(hMultiToolbar, TB_ENABLEBUTTON, (WPARAM)IDC_ABOUT, (LPARAM)enable);
|
||||||
SendMessage(hMultiToolbar, TB_ENABLEBUTTON, (WPARAM)IDC_SETTINGS, (LPARAM)enable);
|
SendMessage(hMultiToolbar, TB_ENABLEBUTTON, (WPARAM)IDC_SETTINGS, (LPARAM)enable);
|
||||||
|
|
||||||
// Checksum button is enabled if an image has been selected
|
// Hash button is enabled if an image has been selected
|
||||||
EnableWindow(hHashToolbar, enable && (boot_type == BT_IMAGE) && (image_path != NULL));
|
EnableWindow(hHashToolbar, enable && (boot_type == BT_IMAGE) && (image_path != NULL));
|
||||||
|
|
||||||
// Toggle CLOSE/CANCEL
|
// Toggle CLOSE/CANCEL
|
||||||
|
@ -2320,7 +2320,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
static ULONG ulRegister = 0;
|
static ULONG ulRegister = 0;
|
||||||
static LPITEMIDLIST pidlDesktop = NULL;
|
static LPITEMIDLIST pidlDesktop = NULL;
|
||||||
static SHChangeNotifyEntry NotifyEntry;
|
static SHChangeNotifyEntry NotifyEntry;
|
||||||
static DWORD_PTR thread_affinity[CHECKSUM_MAX + 1];
|
static DWORD_PTR thread_affinity[HASH_MAX + 1];
|
||||||
static HFONT hyperlink_font = NULL;
|
static HFONT hyperlink_font = NULL;
|
||||||
static wchar_t wtooltip[128];
|
static wchar_t wtooltip[128];
|
||||||
LONG lPos;
|
LONG lPos;
|
||||||
|
@ -2742,14 +2742,14 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
// Disable all controls except cancel
|
// Disable all controls except cancel
|
||||||
EnableControls(FALSE, FALSE);
|
EnableControls(FALSE, FALSE);
|
||||||
InitProgress(FALSE);
|
InitProgress(FALSE);
|
||||||
SetThreadAffinity(thread_affinity, CHECKSUM_MAX + 1);
|
SetThreadAffinity(thread_affinity, HASH_MAX + 1);
|
||||||
format_thread = CreateThread(NULL, 0, SumThread, (LPVOID)thread_affinity, 0, NULL);
|
format_thread = CreateThread(NULL, 0, HashThread, (LPVOID)thread_affinity, 0, NULL);
|
||||||
if (format_thread != NULL) {
|
if (format_thread != NULL) {
|
||||||
SetThreadPriority(format_thread, default_thread_priority);
|
SetThreadPriority(format_thread, default_thread_priority);
|
||||||
PrintInfo(0, -1);
|
PrintInfo(0, -1);
|
||||||
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
uprintf("Unable to start checksum thread");
|
uprintf("Unable to start hash thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
}
|
}
|
||||||
|
@ -3855,11 +3855,14 @@ relaunch:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if defined(_DEBUG) || defined(TEST) || defined(ALPHA)
|
#if defined(_DEBUG) || defined(TEST) || defined(ALPHA)
|
||||||
extern int TestChecksum(void);
|
extern int TestHashes(void);
|
||||||
// Ctrl-T => Alternate Test mode that doesn't require a full rebuild
|
// Ctrl-T => Alternate Test mode that doesn't require a full rebuild
|
||||||
if ((ctrl_without_focus || ((GetKeyState(VK_CONTROL) & 0x8000) && (msg.message == WM_KEYDOWN)))
|
if ((ctrl_without_focus || ((GetKeyState(VK_CONTROL) & 0x8000) && (msg.message == WM_KEYDOWN)))
|
||||||
&& (msg.wParam == 'T')) {
|
&& (msg.wParam == 'T')) {
|
||||||
TestChecksum();
|
// uint8_t sum[32] = { 0 };
|
||||||
|
// PE256("D:\\Incoming\\bootx64.efi", sum);
|
||||||
|
// DumpBufferHex(sum, 32);
|
||||||
|
TestHashes();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
14
src/rufus.h
14
src/rufus.h
|
@ -307,12 +307,12 @@ enum image_option_type {
|
||||||
IMOP_MAX
|
IMOP_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum checksum_type {
|
enum hash_type {
|
||||||
CHECKSUM_MD5 = 0,
|
HASH_MD5 = 0,
|
||||||
CHECKSUM_SHA1,
|
HASH_SHA1,
|
||||||
CHECKSUM_SHA256,
|
HASH_SHA256,
|
||||||
CHECKSUM_SHA512,
|
HASH_SHA512,
|
||||||
CHECKSUM_MAX
|
HASH_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum file_io_type {
|
enum file_io_type {
|
||||||
|
@ -721,7 +721,7 @@ extern HANDLE CreatePreallocatedFile(const char* lpFileName, DWORD dwDesiredAcce
|
||||||
#define GetTextWidth(hDlg, id) GetTextSize(GetDlgItem(hDlg, id), NULL).cx
|
#define GetTextWidth(hDlg, id) GetTextSize(GetDlgItem(hDlg, id), NULL).cx
|
||||||
|
|
||||||
DWORD WINAPI SaveImageThread(void* param);
|
DWORD WINAPI SaveImageThread(void* param);
|
||||||
DWORD WINAPI SumThread(void* param);
|
DWORD WINAPI HashThread(void* param);
|
||||||
|
|
||||||
/* Hash tables */
|
/* Hash tables */
|
||||||
typedef struct htab_entry {
|
typedef struct htab_entry {
|
||||||
|
|
14
src/rufus.rc
14
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 4.2.2047"
|
CAPTION "Rufus 4.2.2048"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -95,7 +95,7 @@ BEGIN
|
||||||
DEFPUSHBUTTON "OK",IDOK,253,216,50,12,WS_GROUP
|
DEFPUSHBUTTON "OK",IDOK,253,216,50,12,WS_GROUP
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_CHECKSUM DIALOGEX 0, 0, 301, 110
|
IDD_HASH DIALOGEX 0, 0, 301, 110
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Checksums"
|
CAPTION "Checksums"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
|
@ -351,7 +351,7 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_CHECKSUM, DIALOG
|
IDD_HASH, DIALOG
|
||||||
BEGIN
|
BEGIN
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -392,8 +392,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 4,2,2047,0
|
FILEVERSION 4,2,2048,0
|
||||||
PRODUCTVERSION 4,2,2047,0
|
PRODUCTVERSION 4,2,2048,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -411,13 +411,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "4.2.2047"
|
VALUE "FileVersion", "4.2.2048"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-4.2.exe"
|
VALUE "OriginalFilename", "rufus-4.2.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "4.2.2047"
|
VALUE "ProductVersion", "4.2.2048"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue