diff --git a/Dependencies/x64/librhash.dll b/Dependencies/x64/librhash.dll new file mode 100644 index 000000000..a1de5b32e Binary files /dev/null and b/Dependencies/x64/librhash.dll differ diff --git a/Dependencies/x86/librhash.dll b/Dependencies/x86/librhash.dll new file mode 100644 index 000000000..ded0ca61c Binary files /dev/null and b/Dependencies/x86/librhash.dll differ diff --git a/Dockerfile b/Dockerfile index 696802e68..d18772108 100755 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM mono:5.2 RUN curl https://bintray.com/user/downloadSubjectPublicKey?username=bintray | apt-key add - RUN echo "deb http://dl.bintray.com/cazzar/shoko-deps jesse main" | tee -a /etc/apt/sources.list -RUN apt-get update && apt-get install -y --force-yes libmediainfo0 sqlite.interop +RUN apt-get update && apt-get install -y --force-yes libmediainfo0 librhash0 sqlite.interop RUN mkdir -p /usr/src/app/source /usr/src/app/build COPY . /usr/src/app/source diff --git a/Shoko.Server.sln b/Shoko.Server.sln index f50b98a87..aba4b3dc3 100644 --- a/Shoko.Server.sln +++ b/Shoko.Server.sln @@ -1,13 +1,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.15 +VisualStudioVersion = 15.0.26730.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shoko.Server", "Shoko.Server\Shoko.Server.csproj", "{DA8F0783-0F82-4106-9860-6F09BA2EA522}" - ProjectSection(ProjectDependencies) = postProject - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C} = {4AB1249D-D635-48A3-8F82-FAB34B69AE4C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hasher", "hasher\Hasher.vcxproj", "{4AB1249D-D635-48A3-8F82-FAB34B69AE4C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CloudFilesystem", "CloudFilesystem", "{6568B082-7BB9-4D24-921A-840E8CF1612F}" EndProject @@ -32,7 +27,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shoko.UI", "Shoko.UI\Shoko. {865C8B13-EB43-439E-9D69-CE7B54DCA4FF} = {865C8B13-EB43-439E-9D69-CE7B54DCA4FF} {D202B61E-A658-4208-83FC-745E04F43BDE} = {D202B61E-A658-4208-83FC-745E04F43BDE} {2A705C96-21D4-4061-876F-1BB954E39D25} = {2A705C96-21D4-4061-876F-1BB954E39D25} - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C} = {4AB1249D-D635-48A3-8F82-FAB34B69AE4C} {D24D15AA-3E71-45A5-B2AF-7490681DEF68} = {D24D15AA-3E71-45A5-B2AF-7490681DEF68} {964A62E6-2DAE-4723-926D-D3E9597B5213} = {964A62E6-2DAE-4723-926D-D3E9597B5213} EndProjectSection @@ -45,6 +39,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shoko.CLI", "Shoko.CLI\Shoko.CLI.csproj", "{3A8E0177-9701-4A59-A6CD-16C6908839EA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{00DED27E-E274-4202-9527-4E7D07E384FC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "x86", "x86", "{700D0E2E-FF22-4810-8BC5-537207182EDF}" + ProjectSection(SolutionItems) = preProject + Dependencies\x86\librhash.dll = Dependencies\x86\librhash.dll + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "x64", "x64", "{99CC23E0-FC68-4531-8C8D-72D38CA98F06}" + ProjectSection(SolutionItems) = preProject + Dependencies\x64\librhash.dll = Dependencies\x64\librhash.dll + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CLI|Any CPU = CLI|Any CPU @@ -79,31 +85,6 @@ Global {DA8F0783-0F82-4106-9860-6F09BA2EA522}.Release|Mixed Platforms.Build.0 = Release|Any CPU {DA8F0783-0F82-4106-9860-6F09BA2EA522}.Release|Win32.ActiveCfg = Release|Any CPU {DA8F0783-0F82-4106-9860-6F09BA2EA522}.Release|x64.ActiveCfg = Release|Any CPU - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|Any CPU.ActiveCfg = Debug|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|Any CPU.Build.0 = Debug|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|Any CPU.Deploy.0 = Debug|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|Mixed Platforms.ActiveCfg = Debug|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|Mixed Platforms.Deploy.0 = Debug|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|Win32.ActiveCfg = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|Win32.Build.0 = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|x64.ActiveCfg = Debug|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|x64.Build.0 = Debug|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.CLI|x64.Deploy.0 = Debug|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Debug|Any CPU.Build.0 = Debug|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Debug|Win32.ActiveCfg = Debug|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Debug|x64.ActiveCfg = Release|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Debug|x64.Build.0 = Release|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|Any CPU.ActiveCfg = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|Any CPU.Build.0 = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|Mixed Platforms.Build.0 = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|Win32.ActiveCfg = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|Win32.Build.0 = Release|Win32 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|x64.ActiveCfg = Release|x64 - {4AB1249D-D635-48A3-8F82-FAB34B69AE4C}.Release|x64.Build.0 = Release|x64 {29861D1A-968C-49CA-A637-88B391AA5063}.CLI|Any CPU.ActiveCfg = Release|Any CPU {29861D1A-968C-49CA-A637-88B391AA5063}.CLI|Any CPU.Build.0 = Release|Any CPU {29861D1A-968C-49CA-A637-88B391AA5063}.CLI|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -354,5 +335,11 @@ Global {2A705C96-21D4-4061-876F-1BB954E39D25} = {6568B082-7BB9-4D24-921A-840E8CF1612F} {865C8B13-EB43-439E-9D69-CE7B54DCA4FF} = {6568B082-7BB9-4D24-921A-840E8CF1612F} {D24D15AA-3E71-45A5-B2AF-7490681DEF68} = {6568B082-7BB9-4D24-921A-840E8CF1612F} + {00DED27E-E274-4202-9527-4E7D07E384FC} = {64D264D0-B20E-4889-B535-EFDC52F921C0} + {700D0E2E-FF22-4810-8BC5-537207182EDF} = {00DED27E-E274-4202-9527-4E7D07E384FC} + {99CC23E0-FC68-4531-8C8D-72D38CA98F06} = {00DED27E-E274-4202-9527-4E7D07E384FC} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1486091B-315E-44FE-8C38-3F9D6E97919B} EndGlobalSection EndGlobal diff --git a/Shoko.Server/FileHelper/Hasher.cs b/Shoko.Server/FileHelper/Hasher.cs index df5858b9a..f5e0e3a7a 100644 --- a/Shoko.Server/FileHelper/Hasher.cs +++ b/Shoko.Server/FileHelper/Hasher.cs @@ -64,7 +64,7 @@ static Hasher() { FileInfo fi = new FileInfo(fullexepath); fullexepath = Path.Combine(fi.Directory.FullName, Environment.Is64BitProcess ? "x64" : "x86", - "hasher.dll"); + "librhash.dll"); Finalise.ModuleHandle = LoadLibraryEx(fullexepath, IntPtr.Zero, 0); } } @@ -131,15 +131,13 @@ public static Hashes CalculateHashes(string strPath, OnHashProgress onHashProgre try { string filename = strPath.StartsWith(@"\\") ? strPath : @"\\?\" + strPath; //only prepend non-UNC paths (or paths that have this already) - rval = CalculateHashes_dll(filename, ref hash, onHashProgress, getCRC32, getMD5, getSHA1); - if (0 == rval) - { - rhash.ED2K = HashToString(hash, 0, 16); - if (!string.IsNullOrEmpty(rhash.ED2K)) gotHash = true; - if (getCRC32) rhash.CRC32 = HashToString(hash, 16, 4); - if (getMD5) rhash.MD5 = HashToString(hash, 20, 16); - if (getSHA1) rhash.SHA1 = HashToString(hash, 36, 20); - } + + (string e2Dk, string crc32, string md5, string sha1) = NativeHasher.GetHash(filename); + rhash.ED2K = e2Dk; + if (!string.IsNullOrEmpty(rhash.ED2K)) gotHash = true; + if (getCRC32) rhash.CRC32 = crc32; + if (getMD5) rhash.MD5 = md5; + if (getSHA1) rhash.SHA1 = sha1; } catch (Exception ex) { diff --git a/Shoko.Server/FileHelper/NativeHasher.cs b/Shoko.Server/FileHelper/NativeHasher.cs index dec528aff..62652bded 100644 --- a/Shoko.Server/FileHelper/NativeHasher.cs +++ b/Shoko.Server/FileHelper/NativeHasher.cs @@ -36,16 +36,16 @@ public static (string e2dk, string crc32, string md5, string sha1) GetHash(strin IntPtr output = Marshal.AllocHGlobal(200); Native.rhash_print(output, ctx, RHashIds.RHASH_ED2K, RhashPrintSumFlags.RHPR_DEFAULT); - e2dk = Marshal.PtrToStringAuto(output); + e2dk = Marshal.PtrToStringAnsi(output); Native.rhash_print(output, ctx, RHashIds.RHASH_CRC32, RhashPrintSumFlags.RHPR_DEFAULT); - crc32 = Marshal.PtrToStringAuto(output); + crc32 = Marshal.PtrToStringAnsi(output); Native.rhash_print(output, ctx, RHashIds.RHASH_MD5, RhashPrintSumFlags.RHPR_DEFAULT); - md5 = Marshal.PtrToStringAuto(output); + md5 = Marshal.PtrToStringAnsi(output); Native.rhash_print(output, ctx, RHashIds.RHASH_SHA1, RhashPrintSumFlags.RHPR_DEFAULT); - sha1 = Marshal.PtrToStringAuto(output); + sha1 = Marshal.PtrToStringAnsi(output); Marshal.FreeHGlobal(output); diff --git a/Shoko.Server/app.config b/Shoko.Server/app.config index b50921a36..1527cc705 100644 --- a/Shoko.Server/app.config +++ b/Shoko.Server/app.config @@ -141,6 +141,7 @@ +