summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-12-05 21:28:08 -0500
committerGitHub <[email protected]>2020-12-05 21:28:08 -0500
commitc8503654da5bc40a129e58914549cd394349d059 (patch)
treee4760c579597d0e292c7b03dff95d19bb8f3c750 /driver
parentMerge pull request #45 from JacobPalecki/fix (diff)
parentupdate signed, add installers (diff)
downloadrawaccel-c8503654da5bc40a129e58914549cd394349d059.tar.xz
rawaccel-c8503654da5bc40a129e58914549cd394349d059.zip
Merge pull request #46 from a1xd/1.3
Diffstat (limited to 'driver')
-rw-r--r--driver/driver.cpp88
-rw-r--r--driver/driver.rc47
-rw-r--r--driver/driver.vcxproj27
3 files changed, 115 insertions, 47 deletions
diff --git a/driver/driver.cpp b/driver/driver.cpp
index 778f3be..a99a70b 100644
--- a/driver/driver.cpp
+++ b/driver/driver.cpp
@@ -1,10 +1,9 @@
#include <rawaccel.hpp>
+#include <rawaccel-io-def.h>
+#include <rawaccel-version.h>
#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 +143,75 @@ 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<LONGLONG>(ra::WRITE_DELAY) * -10000;
- KeDelayExecutionThread(KernelMode, FALSE, &interval);
-
+ switch (IoControlCode) {
+ case RA_READ:
+ status = WdfRequestRetrieveOutputBuffer(
+ Request,
+ sizeof(ra::settings),
+ &buffer,
+ NULL
+ );
+ if (!NT_SUCCESS(status)) {
+ DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status));
+ }
+ else {
+ *reinterpret_cast<ra::settings*>(buffer) = global.args;
+ }
+ break;
+ case RA_WRITE:
status = WdfRequestRetrieveInputBuffer(
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;
}
+ else {
+ LARGE_INTEGER interval;
+ interval.QuadPart = static_cast<LONGLONG>(ra::WRITE_DELAY) * -10000;
+ KeDelayExecutionThread(KernelMode, FALSE, &interval);
- ra::settings new_settings = *reinterpret_cast<ra::settings*>(buffer);
+ ra::settings new_settings = *reinterpret_cast<ra::settings*>(buffer);
- if (new_settings.time_min <= 0 || _isnanf(static_cast<float>(new_settings.time_min))) {
- new_settings.time_min = ra::settings{}.time_min;
- }
-
- global.args = new_settings;
- global.modifier = { global.args, global.lookups };
+ if (new_settings.time_min <= 0 || _isnanf(static_cast<float>(new_settings.time_min))) {
+ new_settings.time_min = ra::settings{}.time_min;
+ }
- WdfRequestComplete(Request, STATUS_SUCCESS);
- }
- else if (IoControlCode == RA_READ && OutputBufferLength == sizeof(ra::settings)) {
+ global.args = new_settings;
+ global.modifier = { global.args, global.lookups };
+ }
+ break;
+ case RA_GET_VERSION:
status = WdfRequestRetrieveOutputBuffer(
Request,
- sizeof(ra::settings),
+ sizeof(ra::version_t),
&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;
}
-
- *reinterpret_cast<ra::settings*>(buffer) = global.args;
-
- 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);
+ else {
+ *reinterpret_cast<ra::version_t*>(buffer) = { RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH };
+ }
+ break;
+ default:
+ status = STATUS_INVALID_DEVICE_REQUEST;
+ break;
}
+ WdfRequestComplete(Request, status);
+
}
#pragma warning(pop) // enable 28118 again
@@ -404,7 +408,7 @@ Error:
WdfObjectDelete(controlDevice);
}
- DebugPrint(("CreateControlDevice failed\n", status));
+ DebugPrint(("CreateControlDevice failed with status code 0x%x\n", status));
}
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 <winver.h>
+#include <ntdef.h>
+
+#include <rawaccel-version.h>
+
+#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 7df16a0..9034680 100644
--- a/driver/driver.vcxproj
+++ b/driver/driver.vcxproj
@@ -22,9 +22,9 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <TargetVersion>Windows10</TargetVersion>
+ <TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
@@ -32,9 +32,9 @@
<SpectreMitigation>Spectre</SpectreMitigation>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <TargetVersion>Windows10</TargetVersion>
+ <TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Desktop</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
@@ -55,10 +55,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>rawaccel</TargetName>
<EnableInf2cat>false</EnableInf2cat>
+ <TimeStampServer>http://timestamp.globalsign.com/scripts/timstamp.dll</TimeStampServer>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>rawaccel</TargetName>
<EnableInf2cat>false</EnableInf2cat>
+ <TimeStampServer>http://timestamp.globalsign.com/scripts/timstamp.dll</TimeStampServer>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -93,6 +95,12 @@
</IgnoreAllDefaultLibraries>
<AdditionalDependencies>%(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</AdditionalDependencies>
</Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>$(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <DriverSign>
+ <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
+ </DriverSign>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
@@ -101,7 +109,7 @@
<ExceptionHandling>
</ExceptionHandling>
<AdditionalOptions>/Kernel %(AdditionalOptions)</AdditionalOptions>
- <LanguageStandard>stdcpplatest</LanguageStandard>
+ <LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories);$(SolutionDir)\external;$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
<RuntimeLibrary>
</RuntimeLibrary>
@@ -116,6 +124,12 @@
</IgnoreAllDefaultLibraries>
<AdditionalDependencies>%(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</AdditionalDependencies>
</Link>
+ <DriverSign>
+ <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
+ </DriverSign>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>$(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="driver.cpp" />
@@ -130,5 +144,8 @@
<ItemGroup>
<ClInclude Include="driver.h" />
</ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="driver.rc" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project> \ No newline at end of file