@@ -90,7 +90,14 @@ namespace shadowsocks_csharp | |||||
if (process != null) | if (process != null) | ||||
{ | { | ||||
process.Kill(); | process.Kill(); | ||||
process.WaitForExit(); | |||||
try | |||||
{ | |||||
process.WaitForExit(); | |||||
} | |||||
catch (InvalidOperationException) | |||||
{ | |||||
// do nothing | |||||
} | |||||
process = null; | process = null; | ||||
} | } | ||||
} | } | ||||
@@ -1,12 +1,17 @@ | |||||
using System; | |||||
using shadowsocks_csharp.Properties; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.IO; | using System.IO; | ||||
using System.Runtime.InteropServices; | |||||
using System.Windows.Forms; | using System.Windows.Forms; | ||||
namespace shadowsocks_csharp | namespace shadowsocks_csharp | ||||
{ | { | ||||
static class Program | static class Program | ||||
{ | { | ||||
[DllImport("Kernel32.dll")] | |||||
private static extern IntPtr LoadLibrary(string path); | |||||
/// <summary> | /// <summary> | ||||
/// 应用程序的主入口点。 | /// 应用程序的主入口点。 | ||||
/// </summary> | /// </summary> | ||||
@@ -14,14 +19,18 @@ namespace shadowsocks_csharp | |||||
static void Main() | static void Main() | ||||
{ | { | ||||
try | try | ||||
{ | |||||
{ | |||||
string tempPath = Path.GetTempPath(); | |||||
string dllPath = tempPath + "/polarssl.dll"; | |||||
PolipoRunner.UncompressFile(dllPath, Resources.polarssl_dll); | |||||
LoadLibrary(dllPath); | |||||
FileStream fs = new FileStream("shadowsocks.log", FileMode.Append); | FileStream fs = new FileStream("shadowsocks.log", FileMode.Append); | ||||
TextWriter tmp = Console.Out; | TextWriter tmp = Console.Out; | ||||
StreamWriter sw = new StreamWriter(fs); | StreamWriter sw = new StreamWriter(fs); | ||||
sw.AutoFlush = true; | sw.AutoFlush = true; | ||||
Console.SetOut(sw); | Console.SetOut(sw); | ||||
Console.SetError(sw); | Console.SetError(sw); | ||||
} | } | ||||
catch (IOException e) | catch (IOException e) | ||||
{ | { | ||||
@@ -5,11 +5,11 @@ using System.Runtime.InteropServices; | |||||
// 有关程序集的常规信息通过下列属性集 | // 有关程序集的常规信息通过下列属性集 | ||||
// 控制。更改这些属性值可修改 | // 控制。更改这些属性值可修改 | ||||
// 与程序集关联的信息。 | // 与程序集关联的信息。 | ||||
[assembly: AssemblyTitle("shadowsocks-csharp")] | |||||
[assembly: AssemblyTitle("Shadowsocks")] | |||||
[assembly: AssemblyDescription("")] | [assembly: AssemblyDescription("")] | ||||
[assembly: AssemblyConfiguration("")] | [assembly: AssemblyConfiguration("")] | ||||
[assembly: AssemblyCompany("clowwindy")] | [assembly: AssemblyCompany("clowwindy")] | ||||
[assembly: AssemblyProduct("shadowsocks-csharp")] | |||||
[assembly: AssemblyProduct("Shadowsocks")] | |||||
[assembly: AssemblyCopyright("Copyright © clowwindy 2014")] | [assembly: AssemblyCopyright("Copyright © clowwindy 2014")] | ||||
[assembly: AssemblyTrademark("")] | [assembly: AssemblyTrademark("")] | ||||
[assembly: AssemblyCulture("")] | [assembly: AssemblyCulture("")] | ||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | |||||
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, | ||||
// 方法是按如下所示使用“*”: | // 方法是按如下所示使用“*”: | ||||
// [assembly: AssemblyVersion("1.0.*")] | // [assembly: AssemblyVersion("1.0.*")] | ||||
[assembly: AssemblyVersion("1.1.2")] | |||||
[assembly: AssemblyFileVersion("1.1.2")] | |||||
[assembly: AssemblyVersion("2.0.0")] | |||||
[assembly: AssemblyFileVersion("2.0.0")] |
@@ -60,6 +60,16 @@ namespace shadowsocks_csharp.Properties { | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// Looks up a localized resource of type System.Byte[]. | |||||
/// </summary> | |||||
internal static byte[] polarssl_dll { | |||||
get { | |||||
object obj = ResourceManager.GetObject("polarssl_dll", resourceCulture); | |||||
return ((byte[])(obj)); | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// Looks up a localized string similar to # Sample configuration file for Polipo. -*-sh-*- | /// Looks up a localized string similar to # Sample configuration file for Polipo. -*-sh-*- | ||||
/// | /// | ||||
@@ -118,6 +118,9 @@ | |||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||||
</resheader> | </resheader> | ||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | ||||
<data name="polarssl_dll" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||||
<value>..\polarssl.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||||
</data> | |||||
<data name="polipo_config" type="System.Resources.ResXFileRef, System.Windows.Forms"> | <data name="polipo_config" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||
<value>..\config.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value> | <value>..\config.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value> | ||||
</data> | </data> | ||||
@@ -115,6 +115,7 @@ | |||||
<DesignTime>True</DesignTime> | <DesignTime>True</DesignTime> | ||||
</Compile> | </Compile> | ||||
<None Include="app.config" /> | <None Include="app.config" /> | ||||
<None Include="polarssl.dll.gz" /> | |||||
<None Include="polipo.exe.gz" /> | <None Include="polipo.exe.gz" /> | ||||
<None Include="Properties\Settings.settings"> | <None Include="Properties\Settings.settings"> | ||||
<Generator>SettingsSingleFileGenerator</Generator> | <Generator>SettingsSingleFileGenerator</Generator> | ||||