Browse Source

embed polarssl into exe

tags/3.2
clowwindy 10 years ago
parent
commit
17765a772f
7 changed files with 38 additions and 8 deletions
  1. +8
    -1
      shadowsocks-csharp/PolipoRunner.cs
  2. +12
    -3
      shadowsocks-csharp/Program.cs
  3. +4
    -4
      shadowsocks-csharp/Properties/AssemblyInfo.cs
  4. +10
    -0
      shadowsocks-csharp/Properties/Resources.Designer.cs
  5. +3
    -0
      shadowsocks-csharp/Properties/Resources.resx
  6. BIN
      shadowsocks-csharp/polarssl.dll.gz
  7. +1
    -0
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 8
- 1
shadowsocks-csharp/PolipoRunner.cs View File

@@ -90,7 +90,14 @@ namespace shadowsocks_csharp
if (process != null)
{
process.Kill();
process.WaitForExit();
try
{
process.WaitForExit();
}
catch (InvalidOperationException)
{
// do nothing
}
process = null;
}
}


+ 12
- 3
shadowsocks-csharp/Program.cs View File

@@ -1,12 +1,17 @@
using System;
using shadowsocks_csharp.Properties;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace shadowsocks_csharp
{
static class Program
{
[DllImport("Kernel32.dll")]
private static extern IntPtr LoadLibrary(string path);
/// <summary>
/// 应用程序的主入口点。
/// </summary>
@@ -14,14 +19,18 @@ namespace shadowsocks_csharp
static void Main()
{
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);
TextWriter tmp = Console.Out;
StreamWriter sw = new StreamWriter(fs);
sw.AutoFlush = true;
Console.SetOut(sw);
Console.SetError(sw);
}
catch (IOException e)
{


+ 4
- 4
shadowsocks-csharp/Properties/AssemblyInfo.cs View File

@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// 有关程序集的常规信息通过下列属性集
// 控制。更改这些属性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("shadowsocks-csharp")]
[assembly: AssemblyTitle("Shadowsocks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("clowwindy")]
[assembly: AssemblyProduct("shadowsocks-csharp")]
[assembly: AssemblyProduct("Shadowsocks")]
[assembly: AssemblyCopyright("Copyright © clowwindy 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.2")]
[assembly: AssemblyFileVersion("1.1.2")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]

+ 10
- 0
shadowsocks-csharp/Properties/Resources.Designer.cs View File

@@ -61,6 +61,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>
/// Looks up a localized string similar to # Sample configuration file for Polipo. -*-sh-*-
///
///# You should not need to use a configuration file; all configuration


+ 3
- 0
shadowsocks-csharp/Properties/Resources.resx View File

@@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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">
<value>..\config.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value>
</data>


BIN
shadowsocks-csharp/polarssl.dll.gz View File


+ 1
- 0
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -115,6 +115,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="polarssl.dll.gz" />
<None Include="polipo.exe.gz" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>


Loading…
Cancel
Save