Mark Scott
2010-07-06 06:51:09 UTC
Hi,
In one of my KMDF driver I have exported the interface using
WdfDeviceCreateDeviceInterface.
From another KMDF driver I want to get the IoTarget of the first
driver. The second driver is only aware of the GUID of the first
driver.
I have tried the following approach :
WDFIOTARGET GetIoTarget(GUID Guid)
{
NTSTATUS status = STATUS_SUCCESS;
PWSTR DevName;
PDEVICE_OBJECT OutDevice;
PFILE_OBJECT FileObject;
PUNICODE_STRING Dev = NULL;
WDFDEVICE device;
WDFIOTARGET IoTarget = NULL;
status = IoGetDeviceInterfaces( &Guid, NULL, 0, &DevName);
if (!NT_SUCCESS(status))
{
return NULL;
}
RtlCreateUnicodeString(Dev, DevName);
status = IoGetDeviceObjectPointer( Dev,
GENERIC_ALL,
&FileObject,
&OutDevice);
if (!NT_SUCCESS(status))
{
return NULL;
}
RtlFreeUnicodeString(Dev);
ExFreePool(DevName);
device = WdfWdmDeviceGetWdfDeviceHandle(OutDevice);
if( device == NULL )
{
return NULL;
}
IoTarget = WdfDeviceGetIoTarget(device);
return IoTarget;
}
However, this function fails to get the Device Name
(IoGetDeviceInterfaces returns success, with NULL in the DevName).
1. Is there anything wrong in the above approach ?
2. Is there any direct KMDF function call sequence that can be used
directly instead of using these WDM functions.
Thanks in Advance,
Mark
In one of my KMDF driver I have exported the interface using
WdfDeviceCreateDeviceInterface.
From another KMDF driver I want to get the IoTarget of the first
driver. The second driver is only aware of the GUID of the first
driver.
I have tried the following approach :
WDFIOTARGET GetIoTarget(GUID Guid)
{
NTSTATUS status = STATUS_SUCCESS;
PWSTR DevName;
PDEVICE_OBJECT OutDevice;
PFILE_OBJECT FileObject;
PUNICODE_STRING Dev = NULL;
WDFDEVICE device;
WDFIOTARGET IoTarget = NULL;
status = IoGetDeviceInterfaces( &Guid, NULL, 0, &DevName);
if (!NT_SUCCESS(status))
{
return NULL;
}
RtlCreateUnicodeString(Dev, DevName);
status = IoGetDeviceObjectPointer( Dev,
GENERIC_ALL,
&FileObject,
&OutDevice);
if (!NT_SUCCESS(status))
{
return NULL;
}
RtlFreeUnicodeString(Dev);
ExFreePool(DevName);
device = WdfWdmDeviceGetWdfDeviceHandle(OutDevice);
if( device == NULL )
{
return NULL;
}
IoTarget = WdfDeviceGetIoTarget(device);
return IoTarget;
}
However, this function fails to get the Device Name
(IoGetDeviceInterfaces returns success, with NULL in the DevName).
1. Is there anything wrong in the above approach ?
2. Is there any direct KMDF function call sequence that can be used
directly instead of using these WDM functions.
Thanks in Advance,
Mark