I need to write a Bluetooth filter driver to test some of the low level functions of the Vista Bluetooth stack for my undergrad thesis.
I am a newbie in driver development, my question is:
how can I attach to the Bluetooth driver (bthport.sys) service?
Here is the code I use in my DriverEntry routine, after IoCreateDevice, to try to do this:
pDeviceContext = (PDEVICE_EXTENSION)pDeviceObject->DeviceExtension;
RtlInitUnicodeString(&usDeviceToFilter, L"\Device\bthport");
NtStatus = IoAttachDevice(pDeviceObject,
&usDeviceToFilter,
&pDeviceContext->pNextDeviceInChain);
if (NT_SUCCESS (NtStatus))
{
DbgPrint(“OK!!!\r\n”);
}
else DbgPrint(“NO!\r\n”);
Each time I load the driver, DebugView shows that IoAttachDevice fails.
I use OSR Driver Loader to load the drivers. I noticed that bthport service is never running on my computer, and even if I start it manually IoAttachDevice fails. Using DeviceTree I saw that bthport, once started and running, doesn’t have any device associated.
Just to try, I also compiled using \device\bthenum0 and \device\bthpan and since those devices exist, IoAttachDevice ends successfully.
I thought I had to use Bthport because on the WDK documentation I read: “A profile driver communicates with its device by submitting IRPs down the driver stack to the primary driver of the Bluetooth driver stack, Bthport.sys.”
How can I do? If I can’t use bthport, which device should I attach to?
Thanks,
Davide