embed polarssl into exe

This commit is contained in:
clowwindy
2014-11-06 01:55:37 +08:00
parent 56365fdf96
commit 17765a772f
7 changed files with 38 additions and 8 deletions
+8 -1
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
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)
{
@@ -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
View File
@@ -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>
/// 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>
</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
View File
Binary file not shown.
@@ -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>