diff --git a/shadowsocks-csharp/Data/libcrypto-3-x64.dll.gz b/shadowsocks-csharp/Data/libcrypto-3-x64.dll.gz new file mode 100644 index 000000000..756bda5b4 Binary files /dev/null and b/shadowsocks-csharp/Data/libcrypto-3-x64.dll.gz differ diff --git a/shadowsocks-csharp/Data/libsscrypto64.dll.gz b/shadowsocks-csharp/Data/libsscrypto64.dll.gz new file mode 100644 index 000000000..5954b357e Binary files /dev/null and b/shadowsocks-csharp/Data/libsscrypto64.dll.gz differ diff --git a/shadowsocks-csharp/Encryption/MbedTLS.cs b/shadowsocks-csharp/Encryption/MbedTLS.cs index be6816702..4c276eff4 100644 --- a/shadowsocks-csharp/Encryption/MbedTLS.cs +++ b/shadowsocks-csharp/Encryption/MbedTLS.cs @@ -12,7 +12,12 @@ public static class MbedTLS { private static Logger logger = LogManager.GetCurrentClassLogger(); +#if AMD64 + private const string DPDLLNAME = "libcrypto-3-x64.dll"; + private const string DLLNAME = "libsscrypto64.dll"; +#else private const string DLLNAME = "libsscrypto.dll"; +#endif public const int MBEDTLS_ENCRYPT = 1; public const int MBEDTLS_DECRYPT = 0; @@ -20,9 +25,19 @@ public static class MbedTLS static MbedTLS() { string dllPath = Utils.GetTempPath(DLLNAME); +#if AMD64 + string dpDllPath = Utils.GetTempPath(DPDLLNAME); + +#endif try { +#if AMD64 + FileManager.UncompressFile(dpDllPath, Resources.libcrypto_3_x64_dll); + FileManager.UncompressFile(dllPath, Resources.libsscrypto64_dll); +#else FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll); +#endif + } catch (IOException) { @@ -31,13 +46,17 @@ static MbedTLS() { logger.LogUsefulException(e); } +#if AMD64 + LoadLibrary(dpDllPath); + +#endif LoadLibrary(dllPath); } public static byte[] MD5(byte[] input) { byte[] output = new byte[16]; - if (md5_ret(input, (uint) input.Length, output) != 0) + if (md5_ret(input, (uint)input.Length, output) != 0) throw new System.Exception("mbedtls: MD5 failure"); return output; } diff --git a/shadowsocks-csharp/Encryption/OpenSSL.cs b/shadowsocks-csharp/Encryption/OpenSSL.cs index 00056a04c..ccea93df3 100644 --- a/shadowsocks-csharp/Encryption/OpenSSL.cs +++ b/shadowsocks-csharp/Encryption/OpenSSL.cs @@ -16,7 +16,12 @@ public static class OpenSSL { private static Logger logger = LogManager.GetCurrentClassLogger(); +#if AMD64 + private const string DPDLLNAME = "libcrypto-3-x64.dll"; + private const string DLLNAME = "libsscrypto64.dll"; +#else private const string DLLNAME = "libsscrypto.dll"; +#endif public const int OPENSSL_ENCRYPT = 1; public const int OPENSSL_DECRYPT = 0; @@ -28,9 +33,19 @@ public static class OpenSSL static OpenSSL() { string dllPath = Utils.GetTempPath(DLLNAME); +#if AMD64 + string dpDllPath = Utils.GetTempPath(DPDLLNAME); + +#endif try { +#if AMD64 + FileManager.UncompressFile(dpDllPath, Resources.libcrypto_3_x64_dll); + FileManager.UncompressFile(dllPath, Resources.libsscrypto64_dll); +#else FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll); +#endif + } catch (IOException) { @@ -39,6 +54,10 @@ static OpenSSL() { logger.LogUsefulException(e); } +#if AMD64 + LoadLibrary(dpDllPath); + +#endif LoadLibrary(dllPath); } diff --git a/shadowsocks-csharp/Encryption/Sodium.cs b/shadowsocks-csharp/Encryption/Sodium.cs index 6b9441dd5..bdcd1c4e4 100755 --- a/shadowsocks-csharp/Encryption/Sodium.cs +++ b/shadowsocks-csharp/Encryption/Sodium.cs @@ -12,7 +12,12 @@ public static class Sodium { private static Logger logger = LogManager.GetCurrentClassLogger(); +#if AMD64 + private const string DPDLLNAME = "libcrypto-3-x64.dll"; + private const string DLLNAME = "libsscrypto64.dll"; +#else private const string DLLNAME = "libsscrypto.dll"; +#endif private static bool _initialized = false; private static readonly object _initLock = new object(); @@ -22,9 +27,19 @@ public static class Sodium static Sodium() { string dllPath = Utils.GetTempPath(DLLNAME); +#if AMD64 + string dpDllPath = Utils.GetTempPath(DPDLLNAME); + +#endif try { +#if AMD64 + FileManager.UncompressFile(dpDllPath, Resources.libcrypto_3_x64_dll); + FileManager.UncompressFile(dllPath, Resources.libsscrypto64_dll); +#else FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll); +#endif + } catch (IOException) { @@ -33,6 +48,10 @@ static Sodium() { logger.LogUsefulException(e); } +#if AMD64 + LoadLibrary(dpDllPath); + +#endif LoadLibrary(dllPath); lock (_initLock) diff --git a/shadowsocks-csharp/Properties/Resources.Designer.cs b/shadowsocks-csharp/Properties/Resources.Designer.cs index e3cd3ddf4..f21f19b0a 100644 --- a/shadowsocks-csharp/Properties/Resources.Designer.cs +++ b/shadowsocks-csharp/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ namespace Shadowsocks.Properties { /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// 一个强类型的资源类,用于查找本地化的字符串等。 /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -33,7 +33,7 @@ internal Resources() { } /// - /// Returns the cached ResourceManager instance used by this class. + /// 返回此类使用的缓存的 ResourceManager 实例。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Resources() { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Looks up a localized string similar to /* eslint-disable */ + /// 查找类似 /* eslint-disable */ ///// Was generated by gfwlist2pac in precise mode ///// https://github.com/clowwindy/gfwlist2pac /// @@ -80,7 +80,7 @@ internal Resources() { /// rules.push(s); ///} /// - /// [rest of string was truncated]";. + /// [字符串的其余部分被截断]"; 的本地化字符串。 /// public static string abp_js { get { @@ -89,7 +89,7 @@ public static string abp_js { } /// - /// Looks up a localized resource of type System.Byte[]. + /// 查找 System.Byte[] 类型的本地化资源。 /// public static byte[] dlc_dat { get { @@ -99,7 +99,7 @@ public static byte[] dlc_dat { } /// - /// Looks up a localized string similar to en,ru-RU,zh-CN,zh-TW,ja,ko,fr + /// 查找类似 en,ru-RU,zh-CN,zh-TW,ja,ko,fr ///#Restart program to apply translation,,,,,, ///#This is comment line,,,,,, ///#Always keep language name at head of file,,,,,, @@ -111,7 +111,7 @@ public static byte[] dlc_dat { ///,,,,,, ///#Menu,,,,,, ///,,,,,, - ///System Proxy,Системный прокси-сервер,系统代理,系統代理,システムプロキシ,시스템 프록시,P [rest of string was truncated]";. + ///System Proxy,Системный прокси-сервер,系统代理,系統代理,システムプロキシ,시스템 프록시,P [字符串的其余部分被截断]"; 的本地化字符串。 /// public static string i18n_csv { get { @@ -120,7 +120,17 @@ public static string i18n_csv { } /// - /// Looks up a localized resource of type System.Byte[]. + /// 查找 System.Byte[] 类型的本地化资源。 + /// + public static byte[] libcrypto_3_x64_dll { + get { + object obj = ResourceManager.GetObject("libcrypto_3_x64_dll", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// 查找 System.Byte[] 类型的本地化资源。 /// public static byte[] libsscrypto_dll { get { @@ -130,13 +140,23 @@ public static byte[] libsscrypto_dll { } /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?> + /// 查找 System.Byte[] 类型的本地化资源。 + /// + public static byte[] libsscrypto64_dll { + get { + object obj = ResourceManager.GetObject("libsscrypto64_dll", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// 查找类似 <?xml version="1.0" encoding="utf-8" ?> ///<!-- Warning: Configuration may reset after shadowsocks upgrade. --> ///<!-- If you messed it up, delete this file and Shadowsocks will create a new one. --> ///<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> /// <targets> /// <!-- This line is managed by Shadowsocks. Do not modify it unless you know what you are doing.--> - /// <target name="file" xsi:type="File" fileName="ss_win_temp\shadowsocks.log" writ [rest of string was truncated]";. + /// <target name="file" xsi:type="File" fileName="ss_win_temp\shadowsocks.log" writ [字符串的其余部分被截断]"; 的本地化字符串。 /// public static string NLog_config { get { @@ -145,7 +165,7 @@ public static string NLog_config { } /// - /// Looks up a localized string similar to listen-address __PRIVOXY_BIND_IP__:__PRIVOXY_BIND_PORT__ + /// 查找类似 listen-address __PRIVOXY_BIND_IP__:__PRIVOXY_BIND_PORT__ ///toggle 0 ///logfile ss_privoxy.log ///show-on-task-bar 0 @@ -153,7 +173,7 @@ public static string NLog_config { ///forward-socks5 / __SOCKS_HOST__:__SOCKS_PORT__ . ///max-client-connections 2048 ///hide-console - ///. + /// 的本地化字符串。 /// public static string privoxy_conf { get { @@ -162,7 +182,7 @@ public static string privoxy_conf { } /// - /// Looks up a localized resource of type System.Byte[]. + /// 查找 System.Byte[] 类型的本地化资源。 /// public static byte[] privoxy_exe { get { @@ -172,7 +192,7 @@ public static byte[] privoxy_exe { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// public static System.Drawing.Bitmap ss32Fill { get { @@ -182,7 +202,7 @@ public static System.Drawing.Bitmap ss32Fill { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// public static System.Drawing.Bitmap ss32In { get { @@ -192,7 +212,7 @@ public static System.Drawing.Bitmap ss32In { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// public static System.Drawing.Bitmap ss32Out { get { @@ -202,7 +222,7 @@ public static System.Drawing.Bitmap ss32Out { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// public static System.Drawing.Bitmap ss32Outline { get { @@ -212,7 +232,7 @@ public static System.Drawing.Bitmap ss32Outline { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// public static System.Drawing.Bitmap ssw128 { get { @@ -222,7 +242,7 @@ public static System.Drawing.Bitmap ssw128 { } /// - /// Looks up a localized resource of type System.Byte[]. + /// 查找 System.Byte[] 类型的本地化资源。 /// public static byte[] sysproxy_exe { get { @@ -232,7 +252,7 @@ public static byte[] sysproxy_exe { } /// - /// Looks up a localized resource of type System.Byte[]. + /// 查找 System.Byte[] 类型的本地化资源。 /// public static byte[] sysproxy64_exe { get { @@ -242,9 +262,9 @@ public static byte[] sysproxy64_exe { } /// - /// Looks up a localized string similar to ! Put user rules line by line in this file. + /// 查找类似 ! Put user rules line by line in this file. ///! See https://adblockplus.org/en/filter-cheatsheet - ///. + /// 的本地化字符串。 /// public static string user_rule { get { diff --git a/shadowsocks-csharp/Properties/Resources.resx b/shadowsocks-csharp/Properties/Resources.resx index 94f4f48e0..28e020897 100755 --- a/shadowsocks-csharp/Properties/Resources.resx +++ b/shadowsocks-csharp/Properties/Resources.resx @@ -127,6 +127,12 @@ ..\Data\i18n.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + ..\Data\libcrypto-3-x64.dll.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Data\libsscrypto64.dll.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Data\libsscrypto.dll.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index f5ec02b83..7aff07815 100644 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -69,6 +69,27 @@ app.manifest + + true + bin\x64\Debug\ + TRACE;DEBUG;AMD64 + full + x64 + 7.3 + prompt + ManagedMinimumRules.ruleset + + + true + bin\x64\Release\ + TRACE;AMD64 + true + pdbonly + x64 + 7.3 + prompt + ManagedMinimumRules.ruleset + ..\packages\Caseless.Fody.1.9.0\lib\net452\Caseless.dll @@ -359,7 +380,9 @@ + + diff --git a/shadowsocks-windows.sln b/shadowsocks-windows.sln index d00484377..c05ba5643 100644 --- a/shadowsocks-windows.sln +++ b/shadowsocks-windows.sln @@ -13,22 +13,28 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Debug|Any CPU.ActiveCfg = Debug|x86 + {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Debug|x64.ActiveCfg = Debug|x64 {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Debug|x86.ActiveCfg = Debug|x86 {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Debug|x86.Build.0 = Debug|x86 {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Debug|x86.Deploy.0 = Debug|x86 {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Release|Any CPU.ActiveCfg = Release|x86 + {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Release|x64.ActiveCfg = Release|x64 {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Release|x86.ActiveCfg = Release|x86 {8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}.Release|x86.Build.0 = Release|x86 {45913187-0685-4903-B250-DCEF0479CD86}.Debug|Any CPU.ActiveCfg = Debug|x86 + {45913187-0685-4903-B250-DCEF0479CD86}.Debug|x64.ActiveCfg = Debug|x86 {45913187-0685-4903-B250-DCEF0479CD86}.Debug|x86.ActiveCfg = Debug|x86 {45913187-0685-4903-B250-DCEF0479CD86}.Debug|x86.Build.0 = Debug|x86 {45913187-0685-4903-B250-DCEF0479CD86}.Release|Any CPU.ActiveCfg = Release|x86 + {45913187-0685-4903-B250-DCEF0479CD86}.Release|x64.ActiveCfg = Release|x86 {45913187-0685-4903-B250-DCEF0479CD86}.Release|x86.ActiveCfg = Release|x86 {45913187-0685-4903-B250-DCEF0479CD86}.Release|x86.Build.0 = Release|x86 EndGlobalSection