From 17d807bbb3fea6e3b4d4f5583746a8ffedfcc81e Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 7 Nov 2021 21:18:33 +0100 Subject: [PATCH] Added runtime CPU detection for SSE2 capability to the GUI front-end. --- .../cpu-capabilities/cpu-capabilities-x64.dll | Bin 0 -> 7168 bytes .../cpu-capabilities/cpu-capabilities-x86.dll | Bin 0 -> 6656 bytes frontend/SlunkCrypt.vcxproj | 5 +- gui/Process/SlunkCryptRunner.cs | 18 +- gui/Properties/AssemblyInfo.cs | 4 +- gui/SlunkCryptGUI.csproj | 5 + gui/SlunkCryptGUI.xaml.cs | 15 +- gui/Utilities/CPU/CPUCapabilities.cs | 378 ++++++++++++++++++ gui/Utilities/CPUFeatures.cs | 41 ++ gui/Utilities/ProcessRunner.cs | 1 - libslunkcrypt/libSlunkCrypt.vcxproj | 5 +- libslunkcrypt/src/version.h | 2 +- mk-profiled.cmd | 7 +- mk-profiled.sh | 1 - 14 files changed, 454 insertions(+), 28 deletions(-) create mode 100644 etc/deps/cpu-capabilities/cpu-capabilities-x64.dll create mode 100644 etc/deps/cpu-capabilities/cpu-capabilities-x86.dll create mode 100644 gui/Utilities/CPU/CPUCapabilities.cs create mode 100644 gui/Utilities/CPUFeatures.cs diff --git a/etc/deps/cpu-capabilities/cpu-capabilities-x64.dll b/etc/deps/cpu-capabilities/cpu-capabilities-x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..d483af3c91e7a8e26739e97b84b0664a0cd280c2 GIT binary patch literal 7168 zcmeHLTWl298UA-!jPYP*L%298tp|INQ6(FLU4#-l*}>~Dt1O9y4T%CNtk;9tWH0W_ zEH$*1HY~2}j4Yu(RiqDyr#w^@Qlo^Br17l@zC^J@+8ReyY4Q*VX-lN4ifC2$`_IgH zZ3=1o(uat%I=BD)_y0fV%-KE9oTg<&6hNJyC%S;1OIWmD-OOTnb>+p?^vcTjHeK+= z-rLl1G-)b5Mz-6Cr+>ejFQYKktf@gbhb;cD=#k#xvbk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zj$6rWrU;BBJB_$;e7|m(OW^zUOjp(@%5h@J7I0ZzjYi?ooy*JyYR`K1%2J1*vFhly#F|_RwJKc7;|26 zj&)$n{imo0G3Fc`#imPPe6M`nJm4395h=LP`CQ$JeyN2%aXz)(0qzIl(L2DIKF`gP z;-i)LI5-X1*)Y*6{!nns`3TXEeBO-L_z2%m?Q{rjEA7Q7N>9=gm`Bk*hB2470)P3Z zb9%BST$~>1Dn*gOZe?Zg5Ldiga+!&=JZ4?=gW>kL$wuHBu*E z9i-tl^5MoZfYn7gN`T7~6sI((xwK$yAKEzepmqwrN#G>0Zc-g^Td4zh2kAlZ@#IFt zYC`DKBe1j3q&;jbD9n?tAf~XE>{_Q&MhXex}B%wER-VQ9bjLWwLzNgFWm`ibE zv>v?KPnO`Aft9I69{6heBaqJi($Nw6CKJ`FLoq*;ZFyqv)ALwhLb;%{BWv9;@A1qnH-HSmLQ{ zMsKb;uA4QFK2l!R6gN#h-I+SBfI-G=uE`mhhs?xLJsme|)5(O9HM2*o+C(<}P~1${ z9otr;q~n?75#6-hPZdWRSSd=AW#mkYKW|)aRsVroLzSQdrKu-!20l34IUt7qy&R*m7Z;^o#}kn*=wOh2ZlloYqkHE}bVIhK81H)@nzQcds&PIJwXc*@jk kl&uSVnzr6uO4HUQIyG%wFb?ERTRp#FA|iRO`8s*vU!30^@c;k- literal 0 HcmV?d00001 diff --git a/etc/deps/cpu-capabilities/cpu-capabilities-x86.dll b/etc/deps/cpu-capabilities/cpu-capabilities-x86.dll new file mode 100644 index 0000000000000000000000000000000000000000..7a47a83cb799a097f0104dd2b6057f475fa77a9c GIT binary patch literal 6656 zcmeHLdu&tZ6+d>|;1WZ;ESHK|jLwX1=s6bvXzOqW_^NsTK~SdrFmZj_?2kX$-%-dsrpN-dc33@3_?u zf82kpNWlHazlizma~F;+5Od$Lg<`Hg&hw&E&0>E0T(7`y4F@}zhoy0YpQz5}pdS{z zw%5X4Bm2?<+x#Wu1ZKX8eRm;dH@YNXw^-YW@&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 znkR#^LTwZSU9F%gN7|de)wmH*nV!Y1vcVH7s6rH{Ah>Lz07Y?{TMhP_F$Sm;y;blH zgC>l9jY>i5rzX(tq%VVyC3n5p4GMia1$7LXe0F{k?Vy9ShAL?n4wa%N&eX955>#jq zhThD16{y%UZeJJlmM$|Xr_4KvIDuATC{Zk%3>)RP{M7pre`1JrZljUq$*vFYdSyvv)q>b4{qLN z;v7zDaxkvq;gyAfQRVN(Aw>=~sNwzLh}0y^6n9{G;M-#fr)@^G)w_W#%JeX7|8<0KL7ytN;K2 literal 0 HcmV?d00001 diff --git a/frontend/SlunkCrypt.vcxproj b/frontend/SlunkCrypt.vcxproj index 4a01308..89b4589 100644 --- a/frontend/SlunkCrypt.vcxproj +++ b/frontend/SlunkCrypt.vcxproj @@ -209,7 +209,7 @@ false $(SolutionDir)bin\$(Configuration)\ $(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - slunkcrypt-cli-$(PlatformShortName) + slunkcrypt-cli-$(PlatformShortName)-sse2 false @@ -239,7 +239,7 @@ false $(SolutionDir)bin\$(Configuration)\ $(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - slunkcrypt-cli-$(PlatformShortName) + slunkcrypt-cli-$(PlatformShortName)-sse2 false @@ -421,6 +421,7 @@ Fast 4706;4204 false + NotSet Console diff --git a/gui/Process/SlunkCryptRunner.cs b/gui/Process/SlunkCryptRunner.cs index 15c6722..68294a6 100644 --- a/gui/Process/SlunkCryptRunner.cs +++ b/gui/Process/SlunkCryptRunner.cs @@ -25,6 +25,7 @@ namespace com.muldersoft.slunkcrypt.gui.process private const string COMMAND_DECRYPT = "-d"; private static readonly Regex RX_PROGRESS = new Regex(@"(\d+)\.(\d)%", RegexOptions.Compiled); + private readonly FileStream m_executableFile; // ============================================================================= @@ -77,15 +78,20 @@ namespace com.muldersoft.slunkcrypt.gui.process { FileStream executableFile = null; string appBaseDirectory = AppDomain.CurrentDomain.BaseDirectory; - if (Environment.Is64BitOperatingSystem) + CPUFeatures cpuFeatures = CPUFeatures.Features; + if (cpuFeatures.x64 && CheckExecutableFile(ref executableFile, appBaseDirectory, "x64")) { - if (CheckExecutableFile(ref executableFile, appBaseDirectory, "x64")) - { - return executableFile; - } + Trace.Assert(executableFile != null); + return executableFile; + } + if (cpuFeatures.sse2 && CheckExecutableFile(ref executableFile, appBaseDirectory, "x86-sse2")) + { + Trace.Assert(executableFile != null); + return executableFile; } if (CheckExecutableFile(ref executableFile, appBaseDirectory, "x86")) { + Trace.Assert(executableFile != null); return executableFile; } throw new ExecutableNotFoundException("SlunkCrypt executable file not found!", FILENAME_FORMAT); @@ -140,7 +146,7 @@ namespace com.muldersoft.slunkcrypt.gui.process return double.NaN; } - private string GetCommandString(Mode mode) + private static string GetCommandString(Mode mode) { switch(mode) { diff --git a/gui/Properties/AssemblyInfo.cs b/gui/Properties/AssemblyInfo.cs index 18fe4fc..c8c31b5 100644 --- a/gui/Properties/AssemblyInfo.cs +++ b/gui/Properties/AssemblyInfo.cs @@ -19,5 +19,5 @@ using System.Windows; [assembly: ComVisible(false)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.*")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/gui/SlunkCryptGUI.csproj b/gui/SlunkCryptGUI.csproj index 55426de..9c7ae44 100644 --- a/gui/SlunkCryptGUI.csproj +++ b/gui/SlunkCryptGUI.csproj @@ -79,8 +79,10 @@ PasswordToggleBox.xaml + + @@ -187,6 +189,9 @@ + + copy /Y "$(SolutionDir)\etc\deps\cpu-capabilities\*.dll" "$(TargetDir)" +