diff --git a/HashCheck.vcxproj b/HashCheck.vcxproj index 8a3aeff..c2cef95 100644 --- a/HashCheck.vcxproj +++ b/HashCheck.vcxproj @@ -279,7 +279,7 @@ - + diff --git a/HashCheck.vcxproj.filters b/HashCheck.vcxproj.filters index 921e9af..7e7abe3 100644 --- a/HashCheck.vcxproj.filters +++ b/HashCheck.vcxproj.filters @@ -63,9 +63,6 @@ Libraries - - Libraries - Libraries @@ -81,6 +78,9 @@ Libraries + + Libraries + diff --git a/HashCheckCommon.h b/HashCheckCommon.h index e98959a..3e3bca7 100644 --- a/HashCheckCommon.h +++ b/HashCheckCommon.h @@ -20,7 +20,7 @@ extern "C" { // Tuning constants #define MAX_PATH_BUFFER 0x800 -#define READ_BUFFER_SIZE 0x20000 +#define READ_BUFFER_SIZE 0x40000 #define BASE_STACK_SIZE 0x1000 #define MARQUEE_INTERVAL 100 // marquee progress bar animation interval diff --git a/installer/HashCheck.nsi b/installer/HashCheck.nsi index b003161..3ee2aa8 100644 --- a/installer/HashCheck.nsi +++ b/installer/HashCheck.nsi @@ -53,15 +53,15 @@ FunctionEnd !insertmacro MUI_LANGUAGE "Ukrainian" !insertmacro MUI_LANGUAGE "Catalan" -VIProductVersion "2.3.1.10" +VIProductVersion "2.3.2.11" VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "HashCheck Shell Extension" -VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.3.1.10" +VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.3.2.11" VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Installer distributed from https://github.com/gurnec/HashCheck/releases" VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "" VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "" VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © Kai Liu, Christopher Gurnee, Tim Schlueter. All rights reserved." VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installer (x86/x64) from https://github.com/gurnec/HashCheck/releases" -VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.3.1.10" +VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.3.2.11" ; With solid compression, files that are required before the ; actual installation should be stored first in the data block, diff --git a/libs/WinHash.c b/libs/WinHash.cpp similarity index 70% rename from libs/WinHash.c rename to libs/WinHash.cpp index 246c5bf..26eec45 100644 --- a/libs/WinHash.c +++ b/libs/WinHash.cpp @@ -2,16 +2,19 @@ * Windows Hashing/Checksumming Library * Last modified: 2016/02/21 * Original work copyright (C) Kai Liu. All rights reserved. - * Modified work copyright (C) 2014 Christopher Gurnee. All rights reserved. + * Modified work copyright (C) 2014, 2016 Christopher Gurnee. All rights reserved. * Modified work copyright (C) 2016 Tim Schlueter. All rights reserved. * * This is a wrapper for the CRC32, MD5, SHA1, SHA2-256, and SHA2-512 * algorithms. * - * WinHash.c is needed only if the WH*To* or WH*Ex functions are used. + * WinHash.cpp is needed only if the WH*To* or WH*Ex functions are used. **/ #include "WinHash.h" +#if _MSC_VER >= 1600 +#include +#endif // Macro to populate the extensions table. E.g. HASH_EXT_MD5, #define HASH_EXT_op(alg) HASH_EXT_##alg, @@ -130,6 +133,33 @@ VOID WHAPI WHInitEx( PWHCTXEX pContext ) VOID WHAPI WHUpdateEx( PWHCTXEX pContext, PCBYTE pbIn, UINT cbIn ) { +#if _MSC_VER >= 1600 + auto task_WHUpdateSHA512 = concurrency::make_task([&] { WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn); } ); + auto task_WHUpdateSHA256 = concurrency::make_task([&] { WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn); } ); + auto task_WHUpdateSHA1 = concurrency::make_task([&] { WHUpdateSHA1 (&pContext->ctxSHA1, pbIn, cbIn); } ); + auto task_WHUpdateMD5 = concurrency::make_task([&] { WHUpdateMD5 (&pContext->ctxMD5, pbIn, cbIn); } ); + auto task_WHUpdateCRC32 = concurrency::make_task([&] { WHUpdateCRC32 (&pContext->ctxCRC32, pbIn, cbIn); } ); + + concurrency::structured_task_group hashing_task_group; + + if (pContext->flags & WHEX_CHECKSHA512) + hashing_task_group.run(task_WHUpdateSHA512); + + if (pContext->flags & WHEX_CHECKSHA256) + hashing_task_group.run(task_WHUpdateSHA256); + + if (pContext->flags & WHEX_CHECKSHA1) + hashing_task_group.run(task_WHUpdateSHA1); + + if (pContext->flags & WHEX_CHECKMD5) + hashing_task_group.run(task_WHUpdateMD5); + + if (pContext->flags & WHEX_CHECKCRC32) + hashing_task_group.run(task_WHUpdateCRC32); + + hashing_task_group.wait(); + +#else if (pContext->flags & WHEX_CHECKCRC32) WHUpdateCRC32(&pContext->ctxCRC32, pbIn, cbIn); @@ -144,6 +174,7 @@ VOID WHAPI WHUpdateEx( PWHCTXEX pContext, PCBYTE pbIn, UINT cbIn ) if (pContext->flags & WHEX_CHECKSHA512) WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn); +#endif } VOID WHAPI WHFinishEx( PWHCTXEX pContext, PWHRESULTEX pResults ) diff --git a/libs/WinHash.h b/libs/WinHash.h index e2ca079..8d5ebcc 100644 --- a/libs/WinHash.h +++ b/libs/WinHash.h @@ -269,7 +269,7 @@ __inline void WHAPI WHFinishCRC32( PWHCTXCRC32 pContext ) #define WHFinishSHA512 SHA512Final /** - * WH*To* hex string conversion functions: These require WinHash.c + * WH*To* hex string conversion functions: These require WinHash.cpp **/ #define WHAPI __fastcall @@ -281,7 +281,7 @@ BOOL WHAPI WHHexToByte( PTSTR pszSrc, PBYTE pbDest, UINT cchHex ); PTSTR WHAPI WHByteToHex( PBYTE pbSrc, PTSTR pszDest, UINT cchHex, UINT8 uCaseMode ); /** - * WH*Ex functions: These require WinHash.c + * WH*Ex functions: These require WinHash.cpp **/ typedef struct { @@ -292,14 +292,15 @@ typedef struct { TCHAR szHexSHA512[SHA512_DIGEST_STRING_LENGTH]; } WHRESULTEX, *PWHRESULTEX; +// Align all the hash contexts to avoid false sharing (of L1/2 cache lines in multi-core systems) typedef struct { UINT8 flags; UINT8 uCaseMode; - WHCTXCRC32 ctxCRC32; - WHCTXMD5 ctxMD5; - WHCTXSHA1 ctxSHA1; - WHCTXSHA256 ctxSHA256; - WHCTXSHA512 ctxSHA512; + __declspec(align(64)) WHCTXCRC32 ctxCRC32; + __declspec(align(64)) WHCTXMD5 ctxMD5; + __declspec(align(64)) WHCTXSHA1 ctxSHA1; + __declspec(align(64)) WHCTXSHA256 ctxSHA256; + __declspec(align(64)) WHCTXSHA512 ctxSHA512; WHRESULTEX results; } WHCTXEX, *PWHCTXEX; diff --git a/version.h b/version.h index 978cb9c..fb2fff1 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ /** * HashCheck Shell Extension * Original work copyright (C) Kai Liu. All rights reserved. - * Modified work copyright (C) 2014 Christopher Gurnee. All rights reserved. + * Modified work copyright (C) 2014, 2016 Christopher Gurnee. All rights reserved. * Modified work copyright (C) 2016 Tim Schlueter. All rights reserved. * * Please refer to readme.txt for information about this source code. @@ -12,10 +12,10 @@ #define HASHCHECK_NAME_STR "HashCheck Shell Extension" // Full version: MUST be in the form of major,minor,revision,build -#define HASHCHECK_VERSION_FULL 2,3,1,10 +#define HASHCHECK_VERSION_FULL 2,3,2,11 // String version: May be any suitable string -#define HASHCHECK_VERSION_STR "2.3.1.10" +#define HASHCHECK_VERSION_STR "2.3.2.11" #ifdef _USRDLL // PE version: MUST be in the form of major.minor