summaryrefslogtreecommitdiff
path: root/driver/driver.cpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-01-05 18:05:48 -0500
committera1xd <[email protected]>2021-01-05 18:05:48 -0500
commit6969310edd56edb555dd98acbc1478caa5728593 (patch)
tree52915ea646db380cad119c17c484660b38ff8724 /driver/driver.cpp
parentUpdate driver/driver.h (diff)
downloadrawaccel-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
Diffstat (limited to 'driver/driver.cpp')
-rw-r--r--driver/driver.cpp47
1 files changed, 31 insertions, 16 deletions
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.
//