From c77592d89e81638c61bc26357649e553ab028896 Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Fri, 6 Oct 2023 17:32:55 +0200 Subject: [PATCH] Implement OVPN_IOCTL_GET_VERSION This allows client to get the driver version. Bump version to 1.0.0 Signed-off-by: Lev Stipakov --- Driver.cpp | 24 ++++++++++++++++++++++++ PropertySheet.props | 6 +++--- uapi/ovpn-dco.h | 7 +++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Driver.cpp b/Driver.cpp index 404d4f3..6462f1e 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -212,6 +212,26 @@ OvpnEvtIoWrite(WDFQUEUE queue, WDFREQUEST request, size_t length) ExReleaseSpinLockShared(&device->SpinLock, kiqrl); } +NTSTATUS +OvpnGetVersion(WDFREQUEST request, _Out_ ULONG_PTR* bytesReturned) +{ + *bytesReturned = 0; + + NTSTATUS status; + POVPN_VERSION version = NULL; + GOTO_IF_NOT_NT_SUCCESS(done, status, WdfRequestRetrieveOutputBuffer(request, sizeof(OVPN_VERSION), (PVOID*)&version, NULL)); + + version->Major = OVPN_DCO_VERSION_MAJOR; + version->Minor = OVPN_DCO_VERSION_MINOR; + version->Patch = OVPN_DCO_VERSION_PATCH; + + *bytesReturned = sizeof(OVPN_VERSION); + +done: + return status; +} + + EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL OvpnEvtIoDeviceControl; _Use_decl_annotations_ @@ -264,6 +284,10 @@ OvpnEvtIoDeviceControl(WDFQUEUE queue, WDFREQUEST request, size_t outputBufferLe ExReleaseSpinLockExclusive(&device->SpinLock, kirql); break; + case OVPN_IOCTL_GET_VERSION: + status = OvpnGetVersion(request, &bytesReturned); + break; + default: LOG_WARN("Unknown ", TraceLoggingValue(ioControlCode, "ioControlCode")); status = STATUS_INVALID_DEVICE_REQUEST; diff --git a/PropertySheet.props b/PropertySheet.props index a12508d..986dfd5 100644 --- a/PropertySheet.props +++ b/PropertySheet.props @@ -2,9 +2,9 @@ - 0 - 9 - 4 + 1 + 0 + 0 diff --git a/uapi/ovpn-dco.h b/uapi/ovpn-dco.h index cbbdf92..ea2a733 100644 --- a/uapi/ovpn-dco.h +++ b/uapi/ovpn-dco.h @@ -100,6 +100,12 @@ typedef struct _OVPN_SET_PEER { LONG MSS; } OVPN_SET_PEER, * POVPN_SET_PEER; +typedef struct _OVPN_VERSION { + LONG Major; + LONG Minor; + LONG Patch; +} OVPN_VERSION, * POVPN_VERSION; + #define OVPN_IOCTL_NEW_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_GET_STATS CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_NEW_KEY CTL_CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BUFFERED, FILE_ANY_ACCESS) @@ -107,3 +113,4 @@ typedef struct _OVPN_SET_PEER { #define OVPN_IOCTL_SET_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 5, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_START_VPN CTL_CODE(FILE_DEVICE_UNKNOWN, 6, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_DEL_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 7, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define OVPN_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)