diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-12-23 15:58:45 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-04 13:33:10 +0100 |
commit | a9554a29e92e77161de64641554bf16a4dbe0cf4 (patch) | |
tree | 1507f3c047975a6bf9c84b8f3e426201a5e03063 /embeddable-dll-service | |
parent | build: update to go 1.16 beta1 (diff) | |
download | wireguard-windows-a9554a29e92e77161de64641554bf16a4dbe0cf4.tar.xz wireguard-windows-a9554a29e92e77161de64641554bf16a4dbe0cf4.zip |
embeddable-dll-service: fix code block types
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | embeddable-dll-service/README.md | 46 | ||||
-rw-r--r-- | embeddable-dll-service/csharp/Service.cs | 2 |
2 files changed, 26 insertions, 22 deletions
diff --git a/embeddable-dll-service/README.md b/embeddable-dll-service/README.md index 3ac0dbae..c93b4345 100644 --- a/embeddable-dll-service/README.md +++ b/embeddable-dll-service/README.md @@ -6,14 +6,16 @@ The basic setup to use `tunnel.dll` is: ##### 1. Install a service with these parameters: - Service Name: "SomeServiceName" - Display Name: "Some Service Name" - Service Type: SERVICE_WIN32_OWN_PROCESS - Start Type: StartAutomatic - Error Control: ErrorNormal, - Dependencies: [ "Nsi" ] - Sid Type: SERVICE_SID_TYPE_UNRESTRICTED - Executable: "C:\path\to\example\vpnclient.exe /service configfile.conf" +```text +Service Name: "WireGuardTunnel$SomeTunnelName" +Display Name: "Some Service Name" +Service Type: SERVICE_WIN32_OWN_PROCESS +Start Type: StartAutomatic +Error Control: ErrorNormal, +Dependencies: [ "Nsi", "TcpIp" ] +Sid Type: SERVICE_SID_TYPE_UNRESTRICTED +Executable: "C:\path\to\example\vpnclient.exe /service configfile.conf" +``` Some of these may have to be changed with `ChangeServiceConfig2` after the initial call to `CreateService` The `SERVICE_SID_TYPE_UNRESTRICTED` parameter @@ -21,19 +23,21 @@ is absolutely essential; do not forget it. ##### 2. Have your program's main function handle the `/service` switch: - if (!strcmp(argv[1], "/service") && argc == 3) { - HMODULE tunnel_lib = LoadLibrary("tunnel.dll"); - if (!tunnel_lib) - abort(); - tunnel_proc_t tunnel_proc = (tunnel_proc_t)GetProcAddress(tunnel_lib, "WireGuardTunnelService"); - if (!tunnel_proc) - abort(); - struct go_string conf_file = { - .str = argv[2], - .n = strlen(argv[2]) - }; - return tunnel_proc(conf_file); - } +```c +if (!strcmp(argv[1], "/service") && argc == 3) { + HMODULE tunnel_lib = LoadLibrary("tunnel.dll"); + if (!tunnel_lib) + abort(); + tunnel_proc_t tunnel_proc = (tunnel_proc_t)GetProcAddress(tunnel_lib, "WireGuardTunnelService"); + if (!tunnel_proc) + abort(); + struct go_string conf_file = { + .str = argv[2], + .n = strlen(argv[2]) + }; + return tunnel_proc(conf_file); +} +``` ##### 3. Scoop up logs by implementing a ringlogger format reader. diff --git a/embeddable-dll-service/csharp/Service.cs b/embeddable-dll-service/csharp/Service.cs index 3b438d24..0310d693 100644 --- a/embeddable-dll-service/csharp/Service.cs +++ b/embeddable-dll-service/csharp/Service.cs @@ -51,7 +51,7 @@ namespace Tunnel Win32.CloseServiceHandle(service); Remove(configFile); } - service = Win32.CreateService(scm, shortName, longName, Win32.ServiceAccessRights.AllAccess, Win32.ServiceType.Win32OwnProcess, Win32.ServiceStartType.Demand, Win32.ServiceError.Normal, pathAndArgs, null, IntPtr.Zero, "Nsi", null, null); + service = Win32.CreateService(scm, shortName, longName, Win32.ServiceAccessRights.AllAccess, Win32.ServiceType.Win32OwnProcess, Win32.ServiceStartType.Demand, Win32.ServiceError.Normal, pathAndArgs, null, IntPtr.Zero, "Nsi\0TcpIp", null, null); if (service == IntPtr.Zero) throw new Win32Exception(Marshal.GetLastWin32Error()); try |