aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--embeddable-dll-service/csharp/Service.cs14
-rw-r--r--embeddable-dll-service/main.go4
2 files changed, 4 insertions, 14 deletions
diff --git a/embeddable-dll-service/csharp/Service.cs b/embeddable-dll-service/csharp/Service.cs
index 1375a3cb..4ad9fe47 100644
--- a/embeddable-dll-service/csharp/Service.cs
+++ b/embeddable-dll-service/csharp/Service.cs
@@ -19,20 +19,8 @@ namespace Tunnel
private const string LongName = "Example WireGuard Tunnel Client";
private const string Description = "A WireGuard tunnel created by example code.";
- [StructLayout(LayoutKind.Sequential)]
- private struct GoString
- {
- public string str;
- public long len;
- }
-
[DllImport("tunnel.dll", EntryPoint = "WireGuardTunnelService", CallingConvention = CallingConvention.Cdecl)]
- private static extern bool WireGuardTunnelService(GoString configFile);
-
- public static bool Run(string configFile)
- {
- return WireGuardTunnelService(new GoString { str = configFile, len = configFile.Length });
- }
+ public static extern bool Run([MarshalAs(UnmanagedType.LPWStr)] string configFile);
public static NamedPipeClientStream GetPipe(string configFile)
{
diff --git a/embeddable-dll-service/main.go b/embeddable-dll-service/main.go
index edf72fba..27fca4ee 100644
--- a/embeddable-dll-service/main.go
+++ b/embeddable-dll-service/main.go
@@ -9,6 +9,7 @@ import (
"C"
"golang.org/x/crypto/curve25519"
+ "golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/conf"
"golang.zx2c4.com/wireguard/windows/tunnel"
@@ -20,7 +21,8 @@ import (
)
//export WireGuardTunnelService
-func WireGuardTunnelService(confFile string) bool {
+func WireGuardTunnelService(confFile16 *uint16) bool {
+ confFile := windows.UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(confFile16))[:])
conf.PresetRootDirectory(filepath.Dir(confFile))
tunnel.UseFixedGUIDInsteadOfDeterministic = true
err := tunnel.Run(confFile)