From 2718800bc688bd8cf518cb075b31c75027c9e517 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sun, 29 Nov 2020 18:04:40 -0500 Subject: match debug and release lang std --- driver/driver.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'driver') diff --git a/driver/driver.vcxproj b/driver/driver.vcxproj index 7df16a0..f9b7b67 100644 --- a/driver/driver.vcxproj +++ b/driver/driver.vcxproj @@ -101,7 +101,7 @@ /Kernel %(AdditionalOptions) - stdcpplatest + stdcpp17 $(IntDir);%(AdditionalIncludeDirectories);$(SolutionDir)\external;$(MSBuildThisFileDirectory) -- cgit v1.2.3 From 7e1bd8c5e53c4d419b9f43cf22bd92621f040323 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Mon, 30 Nov 2020 23:37:18 -0500 Subject: fix dbgprint warning --- driver/driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'driver') diff --git a/driver/driver.cpp b/driver/driver.cpp index 778f3be..b158df6 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -404,7 +404,7 @@ Error: WdfObjectDelete(controlDevice); } - DebugPrint(("CreateControlDevice failed\n", status)); + DebugPrint(("CreateControlDevice failed with status code 0x%x\n", status)); } -- cgit v1.2.3 From b7bd9f5950d9712217e2dd5b40f2aeb82294e3c7 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Tue, 1 Dec 2020 01:41:22 -0500 Subject: refactor io --- driver/driver.cpp | 77 ++++++++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 44 deletions(-) (limited to 'driver') diff --git a/driver/driver.cpp b/driver/driver.cpp index b158df6..a4de824 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -1,10 +1,8 @@ #include +#include #include "driver.h" -#define RA_READ CTL_CODE(0x8888, 0x888, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) -#define RA_WRITE CTL_CODE(0x8888, 0x889, METHOD_BUFFERED, FILE_ANY_ACCESS) - #ifdef ALLOC_PRAGMA #pragma alloc_text (INIT, DriverEntry) #pragma alloc_text (PAGE, EvtDeviceAdd) @@ -144,70 +142,61 @@ Return Value: { NTSTATUS status; void* buffer; - size_t size; UNREFERENCED_PARAMETER(Queue); - - + UNREFERENCED_PARAMETER(OutputBufferLength); + UNREFERENCED_PARAMETER(InputBufferLength); PAGED_CODE(); DebugPrint(("Ioctl received into filter control object.\n")); - if (IoControlCode == RA_WRITE && InputBufferLength == sizeof(ra::settings)) { - LARGE_INTEGER interval; - interval.QuadPart = static_cast(ra::WRITE_DELAY) * -10000; - KeDelayExecutionThread(KernelMode, FALSE, &interval); - - status = WdfRequestRetrieveInputBuffer( + switch (IoControlCode) { + case RA_READ: + status = WdfRequestRetrieveOutputBuffer( Request, sizeof(ra::settings), &buffer, - &size + NULL ); - if (!NT_SUCCESS(status)) { - DebugPrint(("RetrieveInputBuffer failed: 0x%x\n", status)); - // status maps to win32 error code 1359: ERROR_INTERNAL_ERROR - WdfRequestComplete(Request, STATUS_MESSAGE_LOST); - return; + DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status)); } - - ra::settings new_settings = *reinterpret_cast(buffer); - - if (new_settings.time_min <= 0 || _isnanf(static_cast(new_settings.time_min))) { - new_settings.time_min = ra::settings{}.time_min; + else { + *reinterpret_cast(buffer) = global.args; } - - global.args = new_settings; - global.modifier = { global.args, global.lookups }; - - WdfRequestComplete(Request, STATUS_SUCCESS); - } - else if (IoControlCode == RA_READ && OutputBufferLength == sizeof(ra::settings)) { - status = WdfRequestRetrieveOutputBuffer( + break; + case RA_WRITE: + status = WdfRequestRetrieveInputBuffer( Request, sizeof(ra::settings), &buffer, - &size + NULL ); - if (!NT_SUCCESS(status)) { - DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status)); - // status maps to win32 error code 1359: ERROR_INTERNAL_ERROR - WdfRequestComplete(Request, STATUS_MESSAGE_LOST); - return; + DebugPrint(("RetrieveInputBuffer failed: 0x%x\n", status)); } + else { + LARGE_INTEGER interval; + interval.QuadPart = static_cast(ra::WRITE_DELAY) * -10000; + KeDelayExecutionThread(KernelMode, FALSE, &interval); - *reinterpret_cast(buffer) = global.args; + ra::settings new_settings = *reinterpret_cast(buffer); - WdfRequestComplete(Request, STATUS_SUCCESS); - } - else { - DebugPrint(("Received unknown request: in %uB, out %uB\n", InputBufferLength, OutputBufferLength)); - // status maps to win32 error code 1784: ERROR_INVALID_USER_BUFFER - WdfRequestComplete(Request, STATUS_INVALID_BUFFER_SIZE); + if (new_settings.time_min <= 0 || _isnanf(static_cast(new_settings.time_min))) { + new_settings.time_min = ra::settings{}.time_min; + } + + global.args = new_settings; + global.modifier = { global.args, global.lookups }; + } + break; + default: + status = STATUS_INVALID_DEVICE_REQUEST; + break; } + WdfRequestComplete(Request, status); + } #pragma warning(pop) // enable 28118 again -- cgit v1.2.3 From 7d14daf1d5fce4d09471a3abe2aca49cf7680816 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Wed, 2 Dec 2020 05:25:19 -0500 Subject: embed version info into assemblies check app versions against lib, lib against driver add an 'about' dialog which displays version details, accessible from menu refactor error handling + add check for negative offset --- driver/driver.cpp | 15 +++++++++++++++ driver/driver.rc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ driver/driver.vcxproj | 9 +++++++++ 3 files changed, 71 insertions(+) create mode 100644 driver/driver.rc (limited to 'driver') diff --git a/driver/driver.cpp b/driver/driver.cpp index a4de824..a99a70b 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "driver.h" @@ -190,6 +191,20 @@ Return Value: global.modifier = { global.args, global.lookups }; } break; + case RA_GET_VERSION: + status = WdfRequestRetrieveOutputBuffer( + Request, + sizeof(ra::version_t), + &buffer, + NULL + ); + if (!NT_SUCCESS(status)) { + DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status)); + } + else { + *reinterpret_cast(buffer) = { RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH }; + } + break; default: status = STATUS_INVALID_DEVICE_REQUEST; break; diff --git a/driver/driver.rc b/driver/driver.rc new file mode 100644 index 0000000..e351ac3 --- /dev/null +++ b/driver/driver.rc @@ -0,0 +1,47 @@ +// +// Include the necessary resources +// +#include +#include + +#include + +#ifdef RC_INVOKED + +// +// Set up debug information +// +#if DBG +#define VER_DBG VS_FF_DEBUG +#else +#define VER_DBG 0 +#endif + +// ------- version info ------------------------------------------------------- + +VS_VERSION_INFO VERSIONINFO +FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS VER_DBG +FILEOS VOS_NT +FILETYPE VFT_DRV +FILESUBTYPE VFT2_DRV_SYSTEM +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "mouse acceleration filter driver" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "rawaccel.sys" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1200 + END +END +#endif \ No newline at end of file diff --git a/driver/driver.vcxproj b/driver/driver.vcxproj index f9b7b67..d8cfd40 100644 --- a/driver/driver.vcxproj +++ b/driver/driver.vcxproj @@ -93,6 +93,9 @@ %(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfLdr.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfDriverEntry.lib;$(DDK_LIB_PATH)wdmsec.lib;$(DDK_LIB_PATH)libcntpr.lib + + $(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories) + @@ -116,6 +119,9 @@ %(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfLdr.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfDriverEntry.lib;$(DDK_LIB_PATH)wdmsec.lib;$(DDK_LIB_PATH)libcntpr.lib + + $(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories) + @@ -130,5 +136,8 @@ + + + \ No newline at end of file -- cgit v1.2.3 From 0aca62b28d1b071031460269ccfd7ffdb7b3e6fd Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Wed, 2 Dec 2020 05:47:12 -0500 Subject: support win7 while cross-signing is still available to be dropped by april 2021 --- driver/driver.vcxproj | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'driver') diff --git a/driver/driver.vcxproj b/driver/driver.vcxproj index d8cfd40..9034680 100644 --- a/driver/driver.vcxproj +++ b/driver/driver.vcxproj @@ -22,9 +22,9 @@ - Windows10 + Windows7 False - Universal + Desktop KMDF WindowsKernelModeDriver10.0 Driver @@ -32,9 +32,9 @@ Spectre - Windows10 + Windows7 True - Universal + Desktop KMDF WindowsKernelModeDriver10.0 Driver @@ -55,10 +55,12 @@ rawaccel false + http://timestamp.globalsign.com/scripts/timstamp.dll rawaccel false + http://timestamp.globalsign.com/scripts/timstamp.dll @@ -96,6 +98,9 @@ $(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories) + + sha256 + @@ -119,6 +124,9 @@ %(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfLdr.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfDriverEntry.lib;$(DDK_LIB_PATH)wdmsec.lib;$(DDK_LIB_PATH)libcntpr.lib + + sha256 + $(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories) -- cgit v1.2.3