From e3abf499ba304fb45e1d02316df1495bb83a3b4b Mon Sep 17 00:00:00 2001 From: Allex Rodrigues Date: Mon, 28 Dec 2020 18:33:26 -0300 Subject: [PATCH] Changing CRC32 implementation --- UWPHook/Crc32.cs | 48 ------------------------------------- UWPHook/GamesWindow.xaml.cs | 5 ++-- UWPHook/UWPHook.csproj | 3 +++ UWPHook/packages.config | 1 + 4 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 UWPHook/Crc32.cs diff --git a/UWPHook/Crc32.cs b/UWPHook/Crc32.cs deleted file mode 100644 index 7cf768f..0000000 --- a/UWPHook/Crc32.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace UWPHook -{ - public class Crc32 - { - uint[] table; - - public uint ComputeChecksum(byte[] bytes) - { - uint crc = 0xffffffff; - for (int i = 0; i < bytes.Length; ++i) - { - byte index = (byte)(((crc) & 0xff) ^ bytes[i]); - crc = (uint)((crc >> 8) ^ table[index]); - } - return ~crc; - } - - public byte[] ComputeChecksumBytes(byte[] bytes) - { - return BitConverter.GetBytes(ComputeChecksum(bytes)); - } - - public Crc32() - { - uint poly = 0xedb88320; - table = new uint[256]; - uint temp = 0; - for (uint i = 0; i < table.Length; ++i) - { - temp = i; - for (int j = 8; j > 0; --j) - { - if ((temp & 1) == 1) - { - temp = (uint)((temp >> 1) ^ poly); - } - else - { - temp >>= 1; - } - } - table[i] = temp; - } - } - } -} diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs index 126b266..684308a 100644 --- a/UWPHook/GamesWindow.xaml.cs +++ b/UWPHook/GamesWindow.xaml.cs @@ -1,4 +1,5 @@ -using SharpSteam; +using Force.Crc32; +using SharpSteam; using System; using System.Collections.Generic; using System.ComponentModel; @@ -112,7 +113,7 @@ namespace UWPHook private UInt64 GenerateSteamGridAppId(string appName, string appTarget) { byte[] nameTargetBytes = Encoding.UTF8.GetBytes(appTarget + appName + ""); - UInt64 crc = new Crc32().ComputeChecksum(nameTargetBytes); + UInt64 crc = Crc32Algorithm.Compute(nameTargetBytes); UInt64 gameId = crc | 0x80000000; return gameId; diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj index 7ac201b..6d4fa79 100644 --- a/UWPHook/UWPHook.csproj +++ b/UWPHook/UWPHook.csproj @@ -59,6 +59,9 @@ UWPHook.App + + ..\packages\Crc32.NET.1.2.0\lib\net20\Crc32.NET.dll + ..\packages\MaterialDesignColors.1.2.6\lib\net45\MaterialDesignColors.dll diff --git a/UWPHook/packages.config b/UWPHook/packages.config index b43367d..804c406 100644 --- a/UWPHook/packages.config +++ b/UWPHook/packages.config @@ -1,5 +1,6 @@  +