Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

Monthly Seminars at OSR Headquarters

East Coast USA
Windows Internals and SW Drivers, Dulles (Sterling) VA, 9 April 2018

Writing WDF Drivers I: Core Concepts, Manchester, NH, 7 May 2018

Kernel Debugging & Crash Analysis for Windows, Manchester, NH, 21 May 2018

Go Back   OSR Online Lists > ntfsd
Welcome, Guest
You must login to post to this list
  Message 1 of 1  
12 Jan 18 09:25
makrurisan makkeln
Join Date: 12 Jan 2018
Posts To This List: 3
Windows Filter driver on different keyboards

Hi All, I am writing an filter driver and want to attach the filter to more than one physical keyboard in the system. If I attach the filter to the first keyboard "\Device\KeyboardClass0" it works fine but it works not for the other keyboards. The IoAttachDevice failed for "\Device\KeyboardClass1". The same with other class. I have attached 3 physical keyboard. Now I have changed the creation of the device to work with IoCreateFile. The routines create and attach my device but now in the DispatchRead the return IoCallDriver(pDevExt->kbdDevice, Irp); ((PDEVICE_EXTENSION)DeviceObject->DeviceExtension) the "kbdDevice" is NULL. The function status = IoAttachDeviceToDeviceStackSafe(pDevObj, pLBKdev, &pDevExt->kbdDevice); calls correctly at the time of creation. It worked before the modification. Now the routine which create and attach the device: RtlInitUnicodeString(&devNameFlt, L"\\Device\\KeyboardClass1"); RtlInitUnicodeString(&devName, L"\\Device\\MultikeyboardCnt"); status = IoCreateDevice(pDriverObject, sizeof(DEVICE_EXTENSION), &devName, FILE_DEVICE_KEYBOARD, SYNCHRONIZE, FALSE, &pDevObj); if (!NT_SUCCESS(status)) { DbgPrint("%s, IoCreateDevice failed:0x%0x\n", __FUNCTION__, status); return status; } HANDLE hFile; OBJECT_ATTRIBUTES oa = { sizeof(oa), 0, 0, OBJ_CASE_INSENSITIVE }; oa.ObjectName = &devNameFlt; IO_STATUS_BLOCK iosb; status = IoCreateFile(&hFile, SYNCHRONIZE, &oa, &iosb, 0, 0, FILE_SHARE_VALID_FLAGS, FILE_OPEN, 0, 0, 0, CreateFileTypeNone, 0, IO_ATTACH_DEVICE); if (!NT_SUCCESS(status)) { DbgPrint("%s, IoCreateFile failed to call:0x%0x\n", __FUNCTION__, status); return status; } /* Get File Object */ PFILE_OBJECT LocalFileObject; status = ObReferenceObjectByHandle(hFile, 0, *IoFileObjectType, KernelMode, (PVOID*)&LocalFileObject, NULL); pLBKdev = IoGetRelatedDeviceObject(LocalFileObject); DbgPrint("%s at IoCreateFile ok\n", __FUNCTION__); ObReferenceObject(pLBKdev); /* * Retrieve device extension pointer from device object */ pDevExt = (PDEVICE_EXTENSION)pLBKdev->DeviceExtension; status = IoAttachDeviceToDeviceStackSafe(pDevObj, pLBKdev, &pDevExt->kbdDevice); if (status != STATUS_SUCCESS) { DbgPrint("IoGetDeviceObjectPointer failed with error = 0x%0x\n", status); goto cleanup_failure; } pDevObj->Flags |= DO_BUFFERED_IO; pDevObj->Flags &= ~DO_DEVICE_INITIALIZING; /* * Create the symbolic link name, this is not mandatory * but can be helpful for user mode apps to communicate */ status = IoCreateSymbolicLink(&symLinkNameFlt, &devNameFlt); if (!NT_SUCCESS(status)) { // if it fails now, must delete Device object DbgPrint("IoCreateSymbolicLink failed with error = 0x%0x\n", status); goto cleanup_failure; } --
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntfsd list to be able to post.

All times are GMT -5. The time now is 06:20.

Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license