### Create WireGuard Adapters Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Initialize multiple WireGuard adapters using specific names, types, and GUIDs. ```C WIREGUARD_ADAPTER_HANDLE Adapter1 = WireGuardCreateAdapter(L"OfficeNet", L"WireGuard", &SomeFixedGUID1); WIREGUARD_ADAPTER_HANDLE Adapter2 = WireGuardCreateAdapter(L"HomeNet", L"WireGuard", &SomeFixedGUID2); WIREGUARD_ADAPTER_HANDLE Adapter3 = WireGuardCreateAdapter(L"Data Center", L"WireGuard", &SomeFixedGUID3); ``` -------------------------------- ### Get WireGuard Adapter Configuration Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Retrieves the configuration of an adapter, requiring a loop if ERROR_MORE_DATA is returned. ```c BOOL WireGuardGetConfiguration(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_INTERFACE *Config, DWORD *Bytes); ``` -------------------------------- ### Get Adapter State Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Retrieves the current operational state of the specified adapter. ```c BOOL WireGuardGetAdapterState(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_ADAPTER_STATE *State); ``` -------------------------------- ### Get Driver Version Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Returns the version of the loaded WireGuardNT driver. Returns zero if the driver is not loaded. ```c DWORD WireGuardGetRunningDriverVersion(VOID); ``` -------------------------------- ### Get Adapter LUID Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Retrieves the LUID of the specified adapter into the provided pointer. ```c VOID WireGuardGetAdapterLUID(WIREGUARD_ADAPTER_HANDLE Adapter, NET_LUID *Luid); ``` -------------------------------- ### Configure and Activate WireGuard Adapter Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Define the interface and peer configuration structure, apply it to an adapter, and set the adapter state to up. ```C struct { WIREGUARD_INTERFACE Interface; WIREGUARD_PEER FirstPeer; WIREGUARD_ALLOWED_IP FirstPeerAllowedIP1; WIREGUARD_ALLOWED_IP FirstPeerAllowedIP2; WIREGUARD_PEER SecondPeer; WIREGUARD_ALLOWED_IP SecondtPeerAllowedIP1; } Config = { .Interface = { .Flags = WIREGUARD_INTERFACE_HAS_PRIVATE_KEY, .PrivateKey = ..., .PeersCount = 2 }, .FirstPeer = { .Flags = WIREGUARD_PEER_HAS_PUBLIC_KEY | WIREGUARD_PEER_HAS_ENDPOINT, .PublicKey = ..., .Endpoint = ..., .AllowedIPsCount = 2 }, .FirstPeerAllowedIP1 = { ... }, ... }; WireGuardSetConfiguration(Adapter1, &Config.Interface, sizeof(Config)); WireGuardSetAdapterState(Adapter1, WIREGUARD_ADAPTER_STATE_UP); ``` -------------------------------- ### Create WireGuard Adapter Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Creates a new adapter instance. The returned handle must be released with WireGuardCloseAdapter. ```c WIREGUARD_ADAPTER_HANDLE WireGuardCreateAdapter(LPCWSTR Name, LPCWSTR TunnelType, const GUID *RequestedGUID); ``` -------------------------------- ### Open Existing WireGuard Adapter Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Opens an existing adapter by name. The returned handle must be released with WireGuardCloseAdapter. ```c WIREGUARD_ADAPTER_HANDLE WireGuardOpenAdapter(LPCWSTR Name); ``` -------------------------------- ### WireGuardGetConfiguration Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Retrieves the current configuration of a specified WireGuard adapter. ```APIDOC ## WireGuardGetConfiguration ### Description Gets the configuration of the specified adapter. The Config argument represents a WIREGUARD_INTERFACE structure, immediately followed in memory by zero or more WIREGUARD_PEER or WIREGUARD_ALLOWED_IP structures. ### Signature BOOL WireGuardGetConfiguration(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_INTERFACE *Config, DWORD *Bytes); ### Parameters - **Adapter** (WIREGUARD_ADAPTER_HANDLE) - Required - Adapter handle obtained with WireGuardCreateAdapter or WireGuardOpenAdapter. - **Config** (WIREGUARD_INTERFACE *) - Required - Adapter configuration (out). - **Bytes** (DWORD *) - Required - Pointer to number of bytes of Config allocation, on input, and is updated when the function returns to the amount of bytes required (in/out). ### Returns - **BOOL** - Returns TRUE if successful, or returns FALSE if not and sets LastError. If LastError is ERROR_MORE_DATA, Bytes is updated with the number of bytes needed. ``` -------------------------------- ### WireGuardOpenAdapter Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Opens an existing WireGuard adapter by name. ```APIDOC ## WireGuardOpenAdapter ### Description Opens an existing WireGuard adapter. ### Signature `WIREGUARD_ADAPTER_HANDLE WireGuardOpenAdapter(LPCWSTR Name);` ### Parameters - **Name** (LPCWSTR) - Required - The name of the adapter to open. ``` -------------------------------- ### Set Adapter Logging State Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Configures logging for a specific adapter handle. Requires a logger to be set previously via WireGuardSetLogger. ```c BOOL WireGuardSetAdapterLogging(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_ADAPTER_LOG_STATE LogState); ``` -------------------------------- ### WireGuardGetRunningDriverVersion Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Returns the version of the currently loaded WireGuardNT driver. ```APIDOC ## WireGuardGetRunningDriverVersion ### Description Returns the version of the WireGuardNT driver currently loaded, or zero on error. ``` -------------------------------- ### Set WireGuard Adapter Configuration Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Sets the configuration for a specified adapter using a WIREGUARD_INTERFACE structure. ```c BOOL WireGuardSetConfiguration(WIREGUARD_ADAPTER_HANDLE Adapter, const WIREGUARD_INTERFACE *Config, DWORD Bytes); ``` -------------------------------- ### WireGuardSetConfiguration Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Sets the configuration of a specified WireGuard adapter. The configuration structure is followed in memory by peer and allowed IP structures. ```APIDOC ## WireGuardSetConfiguration ### Description Sets the configuration of the specified adapter. The Config argument represents a WIREGUARD_INTERFACE structure, immediately followed in memory by zero or more WIREGUARD_PEER or WIREGUARD_ALLOWED_IP structures. ### Signature BOOL WireGuardSetConfiguration(WIREGUARD_ADAPTER_HANDLE Adapter, const WIREGUARD_INTERFACE *Config, DWORD Bytes); ### Parameters - **Adapter** (WIREGUARD_ADAPTER_HANDLE) - Required - Adapter handle obtained with WireGuardCreateAdapter or WireGuardOpenAdapter. - **Config** (WIREGUARD_INTERFACE *) - Required - Adapter configuration. - **Bytes** (DWORD) - Required - Number of bytes of Config allocation. ### Returns - **BOOL** - Returns TRUE if successful, or returns FALSE if not and sets LastError. ``` -------------------------------- ### WireGuardCreateAdapter Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Creates a new WireGuard adapter. Returns a handle that must be released with WireGuardCloseAdapter. ```APIDOC ## WireGuardCreateAdapter ### Description Creates a new WireGuard adapter instance. ### Signature `WIREGUARD_ADAPTER_HANDLE WireGuardCreateAdapter(LPCWSTR Name, LPCWSTR TunnelType, const GUID *RequestedGUID);` ### Parameters - **Name** (LPCWSTR) - Required - The requested name of the adapter (up to MAX_ADAPTER_NAME-1 characters). - **TunnelType** (LPCWSTR) - Required - Name of the adapter tunnel type (up to MAX_ADAPTER_NAME-1 characters). - **RequestedGUID** (GUID *) - Optional - The GUID of the created network adapter. If NULL, a random GUID is chosen. ``` -------------------------------- ### Set Adapter State Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Sets the adapter to an up or down state. Note that the process setting the adapter up gains ownership of the associated sockets. ```c BOOL WireGuardSetAdapterState(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_ADAPTER_STATE State); ``` -------------------------------- ### WireGuardSetLogger Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Registers a callback function for logging. ```APIDOC ## WireGuardSetLogger ### Description Registers a logger callback function. If NULL is passed, logging is disabled. ### Signature `VOID WireGuardSetLogger(WIREGUARD_LOGGER_CALLBACK NewLogger);` ### Parameters - **NewLogger** (WIREGUARD_LOGGER_CALLBACK) - Required - Pointer to the callback function. ``` -------------------------------- ### Register Logger Callback Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Registers a global logger callback. The callback may be invoked concurrently by multiple threads. ```c VOID WireGuardSetLogger(WIREGUARD_LOGGER_CALLBACK NewLogger); ``` -------------------------------- ### WireGuardCloseAdapter Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Closes an open adapter and releases its resources. ```APIDOC ## WireGuardCloseAdapter ### Description Releases WireGuard adapter resources and removes the adapter if it was created via WireGuardCreateAdapter. ### Signature `VOID WireGuardCloseAdapter(WIREGUARD_ADAPTER_HANDLE Adapter);` ### Parameters - **Adapter** (WIREGUARD_ADAPTER_HANDLE) - Required - The adapter handle to close. ``` -------------------------------- ### WireGuardSetAdapterLogging Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Sets whether adapter logs are generated for the specified adapter handle. ```APIDOC ## WireGuardSetAdapterLogging ### Description Sets whether and how the specified adapter logs to the logger previously set by WireGuardSetLogger. ### Signature BOOL WireGuardSetAdapterLogging(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_ADAPTER_LOG_STATE LogState); ### Parameters - **Adapter** (WIREGUARD_ADAPTER_HANDLE) - Adapter handle obtained with WireGuardCreateAdapter or WireGuardOpenAdapter. - **LogState** (WIREGUARD_ADAPTER_LOG_STATE) - Adapter logging state. ### Returns - **BOOL** - Returns TRUE if successful, or returns FALSE if not and sets LastError. ``` -------------------------------- ### WireGuardGetAdapterState Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Retrieves the current operational state of the specified adapter. ```APIDOC ## WireGuardGetAdapterState ### Description Gets whether the specified adapter is up or down. ### Signature BOOL WireGuardGetAdapterState(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_ADAPTER_STATE *State); ### Parameters - **Adapter** (WIREGUARD_ADAPTER_HANDLE) - Adapter handle obtained with WireGuardCreateAdapter or WireGuardOpenAdapter. - **State** (WIREGUARD_ADAPTER_STATE*) - Pointer to adapter state (out). ### Returns - **BOOL** - Returns TRUE if successful, or returns FALSE if not and sets LastError. ``` -------------------------------- ### WireGuardGetAdapterLUID Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Retrieves the LUID of a specific adapter. ```APIDOC ## WireGuardGetAdapterLUID ### Description Gets the LUID of an adapter. ### Signature `VOID WireGuardGetAdapterLUID(WIREGUARD_ADAPTER_HANDLE Adapter, NET_LUID *Luid);` ### Parameters - **Adapter** (WIREGUARD_ADAPTER_HANDLE) - Required - The adapter handle. - **Luid** (NET_LUID *) - Required - Pointer to receive the adapter LUID. ``` -------------------------------- ### Logger Callback Definition Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Defines the signature for the logging callback function invoked by the library. ```c VOID WireGuardLoggerCallback(WIREGUARD_LOGGER_LEVEL Level, DWORD64 Timestamp, LPCWSTR Message); ``` -------------------------------- ### Delete Driver Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Attempts to delete the WireGuardNT driver if no adapters are currently in use. ```c BOOL WireGuardDeleteDriver(VOID); ``` -------------------------------- ### WireGuardSetAdapterState Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Sets the operational state (up or down) of the specified adapter. ```APIDOC ## WireGuardSetAdapterState ### Description Sets the specified adapter up or down. Note that sockets used by the specified adapter are owned by the process that sets the adapter up. ### Signature BOOL WireGuardSetAdapterState(WIREGUARD_ADAPTER_HANDLE Adapter, WIREGUARD_ADAPTER_STATE State); ### Parameters - **Adapter** (WIREGUARD_ADAPTER_HANDLE) - Adapter handle obtained with WireGuardCreateAdapter or WireGuardOpenAdapter. - **State** (WIREGUARD_ADAPTER_STATE) - Adapter state (WIREGUARD_ADAPTER_STATE_DOWN or WIREGUARD_ADAPTER_STATE_UP). ### Returns - **BOOL** - Returns TRUE if successful, or returns FALSE if not and sets LastError. ``` -------------------------------- ### WireGuardDeleteDriver Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Attempts to delete the WireGuardNT driver if no adapters are in use. ```APIDOC ## WireGuardDeleteDriver ### Description Deletes the WireGuardNT driver if there are no more adapters in use. Returns TRUE if successful. ``` -------------------------------- ### Close WireGuard Adapter Source: https://github.com/wireguard/wireguard-nt/blob/master/README.md Closes an adapter handle and releases associated resources. If the adapter was created via WireGuardCreateAdapter, it is removed. ```c VOID WireGuardCloseAdapter(WIREGUARD_ADAPTER_HANDLE Adapter); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.