From 309e3111a0034c6ebb346fa16625670f0f7b7e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Thu, 15 Jun 2023 14:51:19 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E8=AE=BE=E7=BD=AE=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E4=BB=A5=E7=AE=A1=E7=90=86=E5=91=98=E6=9D=83=E9=99=90=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=202.=20=E9=87=8D=E5=91=BD=E5=90=8D=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NetTunnelApp/Form1.cs | 20 --- ...Form1.Designer.cs => MainForm.Designer.cs} | 13 +- NetTunnelApp/MainForm.cs | 26 ++++ NetTunnelApp/MainForm.resx | 120 ++++++++++++++++++ NetTunnelApp/NetTunnelApp.csproj | 19 ++- NetTunnelApp/NetTunnelLib.cs | 42 ++++++ NetTunnelApp/Program.cs | 2 +- NetTunnelApp/Properties/app.manifest | 3 +- tunnel_windows.sln | 3 + 9 files changed, 218 insertions(+), 30 deletions(-) delete mode 100644 NetTunnelApp/Form1.cs rename NetTunnelApp/{Form1.Designer.cs => MainForm.Designer.cs} (77%) create mode 100644 NetTunnelApp/MainForm.cs create mode 100644 NetTunnelApp/MainForm.resx create mode 100644 NetTunnelApp/NetTunnelLib.cs diff --git a/NetTunnelApp/Form1.cs b/NetTunnelApp/Form1.cs deleted file mode 100644 index 4f7e96c..0000000 --- a/NetTunnelApp/Form1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace NetTunnelApp -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/NetTunnelApp/Form1.Designer.cs b/NetTunnelApp/MainForm.Designer.cs similarity index 77% rename from NetTunnelApp/Form1.Designer.cs rename to NetTunnelApp/MainForm.Designer.cs index 76cd7e1..178487f 100644 --- a/NetTunnelApp/Form1.Designer.cs +++ b/NetTunnelApp/MainForm.Designer.cs @@ -1,6 +1,6 @@ namespace NetTunnelApp { - partial class Form1 + partial class MainForm { /// /// 必需的设计器变量。 @@ -28,10 +28,17 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.SuspendLayout(); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; + this.Name = "MainForm"; + this.Text = "NetTunnelApp"; + this.ResumeLayout(false); + } #endregion diff --git a/NetTunnelApp/MainForm.cs b/NetTunnelApp/MainForm.cs new file mode 100644 index 0000000..11beb93 --- /dev/null +++ b/NetTunnelApp/MainForm.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace NetTunnelApp +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + + NetTunnelLib.TunnelSDKInitEnv(); + + string path = System.Environment.CurrentDirectory + "\\tunnelsdk_" + + string.Format("{0:yyyyMMdd_HHmm}", System.DateTime.Now) + ".log"; + NetTunnelLib.InitTunnelSDKLog(path, LogLevel.LOG_DEBUG); + } + } +} diff --git a/NetTunnelApp/MainForm.resx b/NetTunnelApp/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/NetTunnelApp/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/NetTunnelApp/NetTunnelApp.csproj b/NetTunnelApp/NetTunnelApp.csproj index 0f5a361..308486f 100644 --- a/NetTunnelApp/NetTunnelApp.csproj +++ b/NetTunnelApp/NetTunnelApp.csproj @@ -12,9 +12,10 @@ 512 true true + latest - AnyCPU + x64 true full false @@ -22,6 +23,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -36,7 +38,7 @@ LocalIntranet - true + false Properties\app.manifest @@ -55,14 +57,18 @@ - + Form - - Form1.cs + + MainForm.cs + + + MainForm.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -87,4 +93,7 @@ + + copy /y $(SolutionDir)x64\$(ConfigurationName)\*.dll $(TargetDir) + \ No newline at end of file diff --git a/NetTunnelApp/NetTunnelLib.cs b/NetTunnelApp/NetTunnelLib.cs new file mode 100644 index 0000000..6728833 --- /dev/null +++ b/NetTunnelApp/NetTunnelLib.cs @@ -0,0 +1,42 @@ +using System; +using System.Runtime.InteropServices; + +namespace NetTunnelApp; + +public enum ProtoCryptoType +{ + CRYPTO_NONE = 0, + CRYPTO_BASE64 = 1, + CRYPTO_AES128 = 2, + CRYPTO_3DES = 3, + CRYPTO_AES256 = 4 +} + +public enum LogLevel +{ + LOG_DEBUG = 0, + LOG_INFO = 1, + LOG_WARN = 2, + LOG_ERROR = 3 +} + +public class NetTunnelLib +{ + [DllImport("NetTunnelSDK.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int CreateTunnel(String lpszMsg); + + [DllImport("NetTunnelSDK.dll", CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr TestMessage(); + + [DllImport("NetTunnelSDK.dll", CallingConvention = CallingConvention.Cdecl)] + internal static extern Int32 Add(int a, int b); + + [DllImport("NetTunnelSDK.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int TunnelSDKInitEnv(); + + [DllImport("NetTunnelSDK.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int SetProtocolEncryptType(ProtoCryptoType type, String pProKey); + + [DllImport("NetTunnelSDK.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void InitTunnelSDKLog(String pProKey, LogLevel level); +} \ No newline at end of file diff --git a/NetTunnelApp/Program.cs b/NetTunnelApp/Program.cs index 7356590..cc09e06 100644 --- a/NetTunnelApp/Program.cs +++ b/NetTunnelApp/Program.cs @@ -16,7 +16,7 @@ namespace NetTunnelApp { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + Application.Run(new MainForm()); } } } diff --git a/NetTunnelApp/Properties/app.manifest b/NetTunnelApp/Properties/app.manifest index e8f334c..cb3e0ea 100644 --- a/NetTunnelApp/Properties/app.manifest +++ b/NetTunnelApp/Properties/app.manifest @@ -16,11 +16,12 @@ 如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此 元素。 --> + - + diff --git a/tunnel_windows.sln b/tunnel_windows.sln index 216dc8f..f21ca20 100644 --- a/tunnel_windows.sln +++ b/tunnel_windows.sln @@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetTunnelSDK", "NetTunnelSDK\NetTunnelSDK.vcxproj", "{1584BAD4-DBEC-43D2-BC06-08C23F02489A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetTunnelApp", "NetTunnelApp\NetTunnelApp.csproj", "{79995848-FD05-46F5-A7FE-46265E540E32}" + ProjectSection(ProjectDependencies) = postProject + {1584BAD4-DBEC-43D2-BC06-08C23F02489A} = {1584BAD4-DBEC-43D2-BC06-08C23F02489A} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution