diff options
| author | a1xd <[email protected]> | 2021-01-05 18:05:48 -0500 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-01-05 18:05:48 -0500 |
| commit | 6969310edd56edb555dd98acbc1478caa5728593 (patch) | |
| tree | 52915ea646db380cad119c17c484660b38ff8724 | |
| parent | Update driver/driver.h (diff) | |
| download | rawaccel-6969310edd56edb555dd98acbc1478caa5728593.tar.xz rawaccel-6969310edd56edb555dd98acbc1478caa5728593.zip | |
size device id/hwids based on docs
this also changes the connect ioctl to not abort when hwid query fails
| -rw-r--r-- | common/rawaccel-settings.h | 4 | ||||
| -rw-r--r-- | driver/driver.cpp | 47 | ||||
| -rw-r--r-- | driver/driver.h | 4 | ||||
| -rw-r--r-- | wrapper/wrapper.cpp | 2 |
4 files changed, 37 insertions, 20 deletions
diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h index c9bd247..f94e960 100644 --- a/common/rawaccel-settings.h +++ b/common/rawaccel-settings.h @@ -3,6 +3,8 @@ #include "vec2.h" #include "accel-base.hpp" +#define MAX_HWID_LEN 200 + namespace rawaccel { using milliseconds = double; @@ -23,7 +25,7 @@ namespace rawaccel { vec2d sens = { 1, 1 }; vec2d dir_multipliers = {}; milliseconds time_min = DEFAULT_TIME_MIN; - wchar_t device_hw_id[512] = {0}; + wchar_t device_hw_id[MAX_HWID_LEN] = {0}; }; } diff --git a/driver/driver.cpp b/driver/driver.cpp index 8b72562..ad837e7 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -56,8 +56,7 @@ Arguments: bool devMatch = true; if (global.args.device_hw_id[0] != 0) { - size_t max_cnt = sizeof(global.args.device_hw_id) / sizeof(global.args.device_hw_id[0]); - devMatch = wcsncmp(devExt->hwid, global.args.device_hw_id, max_cnt) == 0; + devMatch = wcsncmp(devExt->hwid, global.args.device_hw_id, MAX_HWID_LEN) == 0; } if (!(InputDataStart->Flags & MOUSE_MOVE_ABSOLUTE)) { @@ -569,7 +568,7 @@ Routine Description: // // Connect a mouse class device driver to the port driver. // - case IOCTL_INTERNAL_MOUSE_CONNECT: + case IOCTL_INTERNAL_MOUSE_CONNECT: { // // Only allow one connection. // @@ -577,26 +576,42 @@ Routine Description: status = STATUS_SHARING_VIOLATION; break; } - + // // Copy the connection parameters to the device extension. // - status = WdfRequestRetrieveInputBuffer(Request, - sizeof(CONNECT_DATA), - reinterpret_cast<PVOID*>(&connectData), - &length); - if(!NT_SUCCESS(status)){ + status = WdfRequestRetrieveInputBuffer(Request, + sizeof(CONNECT_DATA), + reinterpret_cast<PVOID*>(&connectData), + &length); + if (!NT_SUCCESS(status)) { DebugPrint(("WdfRequestRetrieveInputBuffer failed %x\n", status)); break; } - ULONG resultLen; - status = WdfDeviceQueryProperty(hDevice, DevicePropertyHardwareID, - sizeof(devExt->hwid), devExt->hwid, &resultLen); + // taken from REGSTR_VAL_MAX_HCID_LEN defined in um/RegStr.h + const size_t POOL_SIZE = sizeof(wchar_t) * 1024; - if (!NT_SUCCESS(status)) { - DebugPrint(("WdfDeviceQueryProperty failed: 0x%x\n", status)); - break; + auto pool = ExAllocatePoolWithTag(NonPagedPool, POOL_SIZE, 'AR'); + + if (!pool) { + DebugPrint(("RA - failed to allocate pool for hwid list\n")); + } + else { + RtlZeroMemory(pool, POOL_SIZE); + + ULONG resultLen; + NTSTATUS tmp = WdfDeviceQueryProperty(hDevice, DevicePropertyHardwareID, + POOL_SIZE, pool, &resultLen); + + if (!NT_SUCCESS(tmp)) { + DebugPrint(("WdfDeviceQueryProperty failed: 0x%x\n", tmp)); + } + else { + wcsncpy(devExt->hwid, reinterpret_cast<wchar_t*>(pool), MAX_HWID_LEN); + } + + ExFreePoolWithTag(pool, 'AR'); } devExt->counter = 0; @@ -612,7 +627,7 @@ Routine Description: connectData->ClassService = RawaccelCallback; break; - + } // // Disconnect a mouse class device driver from the port driver. // diff --git a/driver/driver.h b/driver/driver.h index ac42f4b..5b610fe 100644 --- a/driver/driver.h +++ b/driver/driver.h @@ -4,7 +4,7 @@ #include <kbdmou.h> #include <wdf.h> -#include "vec2.h" +#include "rawaccel-settings.h" #if DBG #define DebugPrint(_x_) DbgPrint _x_ @@ -21,7 +21,7 @@ typedef struct _DEVICE_EXTENSION { counter_t counter; vec2d carry; CONNECT_DATA UpperConnectData; - WCHAR hwid[512]; + WCHAR hwid[MAX_HWID_LEN]; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_EXTENSION, FilterGetData) diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 7ac3a8d..7e3f736 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -79,7 +79,7 @@ public ref struct DriverSettings double minimumTime; [JsonProperty("Device Hardware ID", Required = Required::Default)] - [MarshalAs(UnmanagedType::ByValTStr, SizeConst = 512)] + [MarshalAs(UnmanagedType::ByValTStr, SizeConst = MAX_HWID_LEN)] String^ deviceHardwareID; bool ShouldSerializeminimumTime() |