TDI Filter using KMDF

All,

I am developing a TDI Client filter drvier using KMDF. The driver loads as a
legacy driver. In the driver entry routine (code is below), I am trying to
create an IO Target using TCPIP.sys and then layering a control device on
top of it. It seems like I can attach to the device stack but I don’t get
any IO in the default event handler. Can someone tell me what I am doing
wrong?

TIA,
Dale

NTSTATUS

DriverEntry(

IN PDRIVER_OBJECT pDriver,

IN PUNICODE_STRING pRegPath)

{

NTSTATUS status;

DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
TIMESTAMP));

#if DBG

DbgBreakPoint();

#endif

// Create the KMDF driver object

WDF_DRIVER_CONFIG configParms;

WDFDRIVER hDriver;

WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);

configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;

configParms.EvtDriverUnload = ISTDriverUnload;

status = WdfDriverCreate(pDriver,

pRegPath,

WDF_NO_OBJECT_ATTRIBUTES,

&configParms,

&hDriver);

if (!NT_SUCCESS(status))

{

DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));

}

// Create a control device object

//

//

PWDFDEVICE_INIT pDevInit;

pDevInit = WdfControlDeviceInitAllocate(

hDriver,

&SDDL_DEVOBJ_SYS_ALL);

if (pDevInit == NULL)

{

DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO. Status:
0x%x.\n”,

status));

return STATUS_INSUFFICIENT_RESOURCES;

}

// Init the attributes for the device object

WDF_OBJECT_ATTRIBUTES attribs;

WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);

// Create the CDO device

WDFDEVICE hCDODevice;

status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);

if (!NT_SUCCESS(status))

{

DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO. Status:
0x%x\n”, status));

WdfDeviceInitFree(pDevInit);

return status;

}

PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);

// Store the device handle

pDevExt->hDevice = hCDODevice;

// Configure the default IO qeue

WDF_IO_QUEUE_CONFIG ioQConfig;

WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,

WdfIoQueueDispatchParallel);

ioQConfig.EvtIoDefault = ISTEvtIoDefault;

status = WdfIoQueueCreate(hCDODevice,

&ioQConfig,

WDF_NO_OBJECT_ATTRIBUTES,

&pDevExt->hDeviceDefaultIoQueue);

if (!NT_SUCCESS (status))

{

DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue. Status:
0x%x\n”,

status));

return status;

}

WdfControlFinishInitializing(hCDODevice);

// Create the TCP/IP Io Target

//

// Init the attributes for the device object

WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);

// Create the CDO device

WDFDEVICE hTCPDevice;

PWDFDEVICE_INIT pTCPDevInit;

pTCPDevInit = WdfControlDeviceInitAllocate(

hDriver,

&SDDL_DEVOBJ_SYS_ALL);

if (pTCPDevInit == NULL)

{

DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO. Status:
0x%x.\n”,

status));

return STATUS_INSUFFICIENT_RESOURCES;

}

status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);

if (!NT_SUCCESS(status))

{

DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
Status: 0x%x\n”, status));

WdfDeviceInitFree(pDevInit);

return status;

}

WdfControlFinishInitializing(hTCPDevice);

// Get the TCP device object

UNICODE_STRING uniDevName;

RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");

// Create the TCP/IP Io Device

WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);

status = WdfIoTargetCreate(hTCPDevice, &attribs, &pDevExt->hTcpIpTarget);

if (!NT_SUCCESS(status))

{

DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
0x%x.\n”,

status));

return status;

}

// Open a handle to the device

WDF_IO_TARGET_OPEN_PARAMS openParms;

WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(

&openParms,

&uniDevName,

FILE_WRITE_ACCESS | FILE_READ_ACCESS);

openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;

status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);

if (!NT_SUCCESS(status))

{

DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
0x%x.\n”,

status));

// Delete the IO Target

WdfObjectDelete(pDevExt->hTcpIpTarget);

pDevExt->hTcpIpTarget = 0;

return status;

}

// Attach the CDO to the Tcp/Ip Target

PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);

PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);

pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
pTcpIpDevice);

if (pDevExt->pLowerDevice == NULL)

{

DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));

return STATUS_UNSUCCESSFUL;

}

return STATUS_SUCCESS;

}

Ok I realize that code sample was completely illegable. Let me try re-asking
the question.

How do you develop the following code using the KMDF model. The objective is
to have a layer device object (pFilterDevice) attached to the top of the
TCP/IP stack.

UNICODE_STRING uniDevName;
RtlInitUnicodeString(L\Device\Tcp);
PDEVICE pDevTarget;
PFILE_OBJECT pFileTarget;

status = IoGetDeviceObjectPointer(&uniDevName,
FILE_READ_ATTRIBUTES,
&pFileTarget,
&pDevTarget);
PDVICE_OBJECT pLowerDevice;

pLowerDevice = IoAttachDeviceToDeviceStack(pFilterDevice, pDevTarget);

TIA,
Dale

“Dale Hill” wrote in message news:xxxxx@ntdev…
> All,
>
> I am developing a TDI Client filter drvier using KMDF. The driver loads as
> a legacy driver. In the driver entry routine (code is below), I am trying
> to create an IO Target using TCPIP.sys and then layering a control device
> on top of it. It seems like I can attach to the device stack but I don’t
> get any IO in the default event handler. Can someone tell me what I am
> doing wrong?
>
> TIA,
> Dale
>
> NTSTATUS
>
> DriverEntry(
>
> IN PDRIVER_OBJECT pDriver,
>
> IN PUNICODE_STRING pRegPath)
>
> {
>
> NTSTATUS status;
>
> DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
> TIMESTAMP ));
>
> #if DBG
>
> DbgBreakPoint();
>
> #endif
>
>
> // Create the KMDF driver object
>
> WDF_DRIVER_CONFIG configParms;
>
> WDFDRIVER hDriver;
>
> WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);
>
> configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;
>
> configParms.EvtDriverUnload = ISTDriverUnload;
>
> status = WdfDriverCreate(pDriver,
>
> pRegPath,
>
> WDF_NO_OBJECT_ATTRIBUTES,
>
> &configParms,
>
> &hDriver);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));
>
> }
>
> // Create a control device object
>
> //
>
> //
>
> PWDFDEVICE_INIT pDevInit;
>
> pDevInit = WdfControlDeviceInitAllocate(
>
> hDriver,
>
> &SDDL_DEVOBJ_SYS_ALL);
>
> if (pDevInit == NULL)
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
> Status: 0x%x.\n”,
>
> status));
>
> return STATUS_INSUFFICIENT_RESOURCES;
>
> }
>
> // Init the attributes for the device object
>
> WDF_OBJECT_ATTRIBUTES attribs;
>
> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>
>
> // Create the CDO device
>
> WDFDEVICE hCDODevice;
>
> status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO. Status:
> 0x%x\n”, status));
>
> WdfDeviceInitFree(pDevInit);
>
> return status;
>
> }
>
> PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);
>
> // Store the device handle
>
> pDevExt->hDevice = hCDODevice;
>
> // Configure the default IO qeue
>
> WDF_IO_QUEUE_CONFIG ioQConfig;
>
> WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
>
> WdfIoQueueDispatchParallel);
>
> ioQConfig.EvtIoDefault = ISTEvtIoDefault;
>
> status = WdfIoQueueCreate(hCDODevice,
>
> &ioQConfig,
>
> WDF_NO_OBJECT_ATTRIBUTES,
>
> &pDevExt->hDeviceDefaultIoQueue);
>
> if (!NT_SUCCESS (status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue. Status:
> 0x%x\n”,
>
> status));
>
> return status;
>
> }
>
> WdfControlFinishInitializing(hCDODevice);
>
> // Create the TCP/IP Io Target
>
> //
>
> // Init the attributes for the device object
>
> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>
>
> // Create the CDO device
>
> WDFDEVICE hTCPDevice;
>
> PWDFDEVICE_INIT pTCPDevInit;
>
> pTCPDevInit = WdfControlDeviceInitAllocate(
>
> hDriver,
>
> &SDDL_DEVOBJ_SYS_ALL);
>
> if (pTCPDevInit == NULL)
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
> Status: 0x%x.\n”,
>
> status));
>
> return STATUS_INSUFFICIENT_RESOURCES;
>
> }
>
> status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
> Status: 0x%x\n”, status));
>
> WdfDeviceInitFree(pDevInit);
>
> return status;
>
> }
>
> WdfControlFinishInitializing(hTCPDevice);
>
> // Get the TCP device object
>
> UNICODE_STRING uniDevName;
>
> RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");
>
> // Create the TCP/IP Io Device
>
> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>
> status = WdfIoTargetCreate(hTCPDevice, &attribs, &pDevExt->hTcpIpTarget);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
> 0x%x.\n”,
>
> status));
>
> return status;
>
> }
>
> // Open a handle to the device
>
> WDF_IO_TARGET_OPEN_PARAMS openParms;
>
> WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
>
> &openParms,
>
> &uniDevName,
>
> FILE_WRITE_ACCESS | FILE_READ_ACCESS);
>
> openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;
>
> status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
> 0x%x.\n”,
>
> status));
>
> // Delete the IO Target
>
> WdfObjectDelete(pDevExt->hTcpIpTarget);
>
> pDevExt->hTcpIpTarget = 0;
>
> return status;
>
> }
>
> // Attach the CDO to the Tcp/Ip Target
>
> PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);
>
> PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);
>
> pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
> pTcpIpDevice);
>
> if (pDevExt->pLowerDevice == NULL)
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));
>
> return STATUS_UNSUCCESSFUL;
>
> }
>
>
> return STATUS_SUCCESS;
>
> }
>
>
>

Dale,

Not that this answers your question but what do you expect to leverage from
WDF in a TDI Filter Driver?

Regards,
Dave Cattley
Consulting Engineer
Systems Software Development

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dale Hill
Sent: Monday, February 02, 2009 11:59 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI Filter using KMDF

Ok I realize that code sample was completely illegable. Let me try re-asking

the question.

How do you develop the following code using the KMDF model. The objective is

to have a layer device object (pFilterDevice) attached to the top of the
TCP/IP stack.

UNICODE_STRING uniDevName;
RtlInitUnicodeString(L\Device\Tcp);
PDEVICE pDevTarget;
PFILE_OBJECT pFileTarget;

status = IoGetDeviceObjectPointer(&uniDevName,

FILE_READ_ATTRIBUTES,
&pFileTarget,
&pDevTarget);
PDVICE_OBJECT pLowerDevice;

pLowerDevice = IoAttachDeviceToDeviceStack(pFilterDevice, pDevTarget);

TIA,
Dale

“Dale Hill” wrote in message news:xxxxx@ntdev…
> All,
>
> I am developing a TDI Client filter drvier using KMDF. The driver loads as

> a legacy driver. In the driver entry routine (code is below), I am trying
> to create an IO Target using TCPIP.sys and then layering a control device
> on top of it. It seems like I can attach to the device stack but I don’t
> get any IO in the default event handler. Can someone tell me what I am
> doing wrong?
>
> TIA,
> Dale
>
> NTSTATUS
>
> DriverEntry(
>
> IN PDRIVER_OBJECT pDriver,
>
> IN PUNICODE_STRING pRegPath)
>
> {
>
> NTSTATUS status;
>
> DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
> TIMESTAMP ));
>
> #if DBG
>
> DbgBreakPoint();
>
> #endif
>
>
> // Create the KMDF driver object
>
> WDF_DRIVER_CONFIG configParms;
>
> WDFDRIVER hDriver;
>
> WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);
>
> configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;
>
> configParms.EvtDriverUnload = ISTDriverUnload;
>
> status = WdfDriverCreate(pDriver,
>
> pRegPath,
>
> WDF_NO_OBJECT_ATTRIBUTES,
>
> &configParms,
>
> &hDriver);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));
>
> }
>
> // Create a control device object
>
> //
>
> //
>
> PWDFDEVICE_INIT pDevInit;
>
> pDevInit = WdfControlDeviceInitAllocate(
>
> hDriver,
>
> &SDDL_DEVOBJ_SYS_ALL);
>
> if (pDevInit == NULL)
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
> Status: 0x%x.\n”,
>
> status));
>
> return STATUS_INSUFFICIENT_RESOURCES;
>
> }
>
> // Init the attributes for the device object
>
> WDF_OBJECT_ATTRIBUTES attribs;
>
> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>
>
> // Create the CDO device
>
> WDFDEVICE hCDODevice;
>
> status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO. Status:
> 0x%x\n”, status));
>
> WdfDeviceInitFree(pDevInit);
>
> return status;
>
> }
>
> PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);
>
> // Store the device handle
>
> pDevExt->hDevice = hCDODevice;
>
> // Configure the default IO qeue
>
> WDF_IO_QUEUE_CONFIG ioQConfig;
>
> WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
>
> WdfIoQueueDispatchParallel);
>
> ioQConfig.EvtIoDefault = ISTEvtIoDefault;
>
> status = WdfIoQueueCreate(hCDODevice,
>
> &ioQConfig,
>
> WDF_NO_OBJECT_ATTRIBUTES,
>
> &pDevExt->hDeviceDefaultIoQueue);
>
> if (!NT_SUCCESS (status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue. Status:
> 0x%x\n”,
>
> status));
>
> return status;
>
> }
>
> WdfControlFinishInitializing(hCDODevice);
>
> // Create the TCP/IP Io Target
>
> //
>
> // Init the attributes for the device object
>
> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>
>
> // Create the CDO device
>
> WDFDEVICE hTCPDevice;
>
> PWDFDEVICE_INIT pTCPDevInit;
>
> pTCPDevInit = WdfControlDeviceInitAllocate(
>
> hDriver,
>
> &SDDL_DEVOBJ_SYS_ALL);
>
> if (pTCPDevInit == NULL)
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
> Status: 0x%x.\n”,
>
> status));
>
> return STATUS_INSUFFICIENT_RESOURCES;
>
> }
>
> status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
> Status: 0x%x\n”, status));
>
> WdfDeviceInitFree(pDevInit);
>
> return status;
>
> }
>
> WdfControlFinishInitializing(hTCPDevice);
>
> // Get the TCP device object
>
> UNICODE_STRING uniDevName;
>
> RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");
>
> // Create the TCP/IP Io Device
>
> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>
> status = WdfIoTargetCreate(hTCPDevice, &attribs, &pDevExt->hTcpIpTarget);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
> 0x%x.\n”,
>
> status));
>
> return status;
>
> }
>
> // Open a handle to the device
>
> WDF_IO_TARGET_OPEN_PARAMS openParms;
>
> WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
>
> &openParms,
>
> &uniDevName,
>
> FILE_WRITE_ACCESS | FILE_READ_ACCESS);
>
> openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;
>
> status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);
>
> if (!NT_SUCCESS(status))
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
> 0x%x.\n”,
>
> status));
>
> // Delete the IO Target
>
> WdfObjectDelete(pDevExt->hTcpIpTarget);
>
> pDevExt->hTcpIpTarget = 0;
>
> return status;
>
> }
>
> // Attach the CDO to the Tcp/Ip Target
>
> PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);
>
> PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);
>
> pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
> pTcpIpDevice);
>
> if (pDevExt->pLowerDevice == NULL)
>
> {
>
> DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));
>
> return STATUS_UNSUCCESSFUL;
>
> }
>
>
> return STATUS_SUCCESS;
>
> }
>
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hi David,

I am hoping that it will make the task easier by allowing me to focus on the
driver’s application as opposed to the nitty gritty driver details.

Thanks,
Dale

“David R. Cattley” wrote in message news:xxxxx@ntdev…
> Dale,
>
> Not that this answers your question but what do you expect to leverage
> from
> WDF in a TDI Filter Driver?
>
> Regards,
> Dave Cattley
> Consulting Engineer
> Systems Software Development
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dale Hill
> Sent: Monday, February 02, 2009 11:59 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] TDI Filter using KMDF
>
> Ok I realize that code sample was completely illegable. Let me try
> re-asking
>
> the question.
>
> How do you develop the following code using the KMDF model. The objective
> is
>
> to have a layer device object (pFilterDevice) attached to the top of the
> TCP/IP stack.
>
>
> UNICODE_STRING uniDevName;
> RtlInitUnicodeString(L\Device\Tcp);
> PDEVICE pDevTarget;
> PFILE_OBJECT pFileTarget;
>
> status = IoGetDeviceObjectPointer(&uniDevName,
>
> FILE_READ_ATTRIBUTES,
> &pFileTarget,
> &pDevTarget);
> PDVICE_OBJECT pLowerDevice;
>
> pLowerDevice = IoAttachDeviceToDeviceStack(pFilterDevice, pDevTarget);
>
> TIA,
> Dale
>
> “Dale Hill” wrote in message news:xxxxx@ntdev…
>> All,
>>
>> I am developing a TDI Client filter drvier using KMDF. The driver loads
>> as
>
>> a legacy driver. In the driver entry routine (code is below), I am trying
>> to create an IO Target using TCPIP.sys and then layering a control device
>> on top of it. It seems like I can attach to the device stack but I don’t
>> get any IO in the default event handler. Can someone tell me what I am
>> doing wrong?
>>
>> TIA,
>> Dale
>>
>> NTSTATUS
>>
>> DriverEntry(
>>
>> IN PDRIVER_OBJECT pDriver,
>>
>> IN PUNICODE_STRING pRegPath)
>>
>> {
>>
>> NTSTATUS status;
>>
>> DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
>> TIMESTAMP ));
>>
>> #if DBG
>>
>> DbgBreakPoint();
>>
>> #endif
>>
>>
>> // Create the KMDF driver object
>>
>> WDF_DRIVER_CONFIG configParms;
>>
>> WDFDRIVER hDriver;
>>
>> WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);
>>
>> configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;
>>
>> configParms.EvtDriverUnload = ISTDriverUnload;
>>
>> status = WdfDriverCreate(pDriver,
>>
>> pRegPath,
>>
>> WDF_NO_OBJECT_ATTRIBUTES,
>>
>> &configParms,
>>
>> &hDriver);
>>
>> if (!NT_SUCCESS(status))
>>
>> {
>>
>> DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));
>>
>> }
>>
>> // Create a control device object
>>
>> //
>>
>> //
>>
>> PWDFDEVICE_INIT pDevInit;
>>
>> pDevInit = WdfControlDeviceInitAllocate(
>>
>> hDriver,
>>
>> &SDDL_DEVOBJ_SYS_ALL);
>>
>> if (pDevInit == NULL)
>>
>> {
>>
>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>> Status: 0x%x.\n”,
>>
>> status));
>>
>> return STATUS_INSUFFICIENT_RESOURCES;
>>
>> }
>>
>> // Init the attributes for the device object
>>
>> WDF_OBJECT_ATTRIBUTES attribs;
>>
>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>
>>
>> // Create the CDO device
>>
>> WDFDEVICE hCDODevice;
>>
>> status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);
>>
>> if (!NT_SUCCESS(status))
>>
>> {
>>
>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO. Status:
>> 0x%x\n”, status));
>>
>> WdfDeviceInitFree(pDevInit);
>>
>> return status;
>>
>> }
>>
>> PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);
>>
>> // Store the device handle
>>
>> pDevExt->hDevice = hCDODevice;
>>
>> // Configure the default IO qeue
>>
>> WDF_IO_QUEUE_CONFIG ioQConfig;
>>
>> WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
>>
>> WdfIoQueueDispatchParallel);
>>
>> ioQConfig.EvtIoDefault = ISTEvtIoDefault;
>>
>> status = WdfIoQueueCreate(hCDODevice,
>>
>> &ioQConfig,
>>
>> WDF_NO_OBJECT_ATTRIBUTES,
>>
>> &pDevExt->hDeviceDefaultIoQueue);
>>
>> if (!NT_SUCCESS (status))
>>
>> {
>>
>> DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue. Status:
>> 0x%x\n”,
>>
>> status));
>>
>> return status;
>>
>> }
>>
>> WdfControlFinishInitializing(hCDODevice);
>>
>> // Create the TCP/IP Io Target
>>
>> //
>>
>> // Init the attributes for the device object
>>
>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>
>>
>> // Create the CDO device
>>
>> WDFDEVICE hTCPDevice;
>>
>> PWDFDEVICE_INIT pTCPDevInit;
>>
>> pTCPDevInit = WdfControlDeviceInitAllocate(
>>
>> hDriver,
>>
>> &SDDL_DEVOBJ_SYS_ALL);
>>
>> if (pTCPDevInit == NULL)
>>
>> {
>>
>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>> Status: 0x%x.\n”,
>>
>> status));
>>
>> return STATUS_INSUFFICIENT_RESOURCES;
>>
>> }
>>
>> status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);
>>
>> if (!NT_SUCCESS(status))
>>
>> {
>>
>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
>> Status: 0x%x\n”, status));
>>
>> WdfDeviceInitFree(pDevInit);
>>
>> return status;
>>
>> }
>>
>> WdfControlFinishInitializing(hTCPDevice);
>>
>> // Get the TCP device object
>>
>> UNICODE_STRING uniDevName;
>>
>> RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");
>>
>> // Create the TCP/IP Io Device
>>
>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>
>> status = WdfIoTargetCreate(hTCPDevice, &attribs, &pDevExt->hTcpIpTarget);
>>
>> if (!NT_SUCCESS(status))
>>
>> {
>>
>> DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
>> 0x%x.\n”,
>>
>> status));
>>
>> return status;
>>
>> }
>>
>> // Open a handle to the device
>>
>> WDF_IO_TARGET_OPEN_PARAMS openParms;
>>
>> WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
>>
>> &openParms,
>>
>> &uniDevName,
>>
>> FILE_WRITE_ACCESS | FILE_READ_ACCESS);
>>
>> openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;
>>
>> status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);
>>
>> if (!NT_SUCCESS(status))
>>
>> {
>>
>> DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
>> 0x%x.\n”,
>>
>> status));
>>
>> // Delete the IO Target
>>
>> WdfObjectDelete(pDevExt->hTcpIpTarget);
>>
>> pDevExt->hTcpIpTarget = 0;
>>
>> return status;
>>
>> }
>>
>> // Attach the CDO to the Tcp/Ip Target
>>
>> PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);
>>
>> PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);
>>
>> pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
>> pTcpIpDevice);
>>
>> if (pDevExt->pLowerDevice == NULL)
>>
>> {
>>
>> DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));
>>
>> return STATUS_UNSUCCESSFUL;
>>
>> }
>>
>>
>> return STATUS_SUCCESS;
>>
>> }
>>
>>
>>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>

TDI filter is not a PnP driver, so, most of the value of KMDF is gone.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Dale Hill” wrote in message news:xxxxx@ntdev…
> Hi David,
>
> I am hoping that it will make the task easier by allowing me to focus on the
> driver’s application as opposed to the nitty gritty driver details.
>
> Thanks,
> Dale
>
>
> “David R. Cattley” wrote in message news:xxxxx@ntdev…
>> Dale,
>>
>> Not that this answers your question but what do you expect to leverage
>> from
>> WDF in a TDI Filter Driver?
>>
>> Regards,
>> Dave Cattley
>> Consulting Engineer
>> Systems Software Development
>>
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Dale Hill
>> Sent: Monday, February 02, 2009 11:59 PM
>> To: Windows System Software Devs Interest List
>> Subject: Re:[ntdev] TDI Filter using KMDF
>>
>> Ok I realize that code sample was completely illegable. Let me try
>> re-asking
>>
>> the question.
>>
>> How do you develop the following code using the KMDF model. The objective
>> is
>>
>> to have a layer device object (pFilterDevice) attached to the top of the
>> TCP/IP stack.
>>
>>
>> UNICODE_STRING uniDevName;
>> RtlInitUnicodeString(L\Device\Tcp);
>> PDEVICE pDevTarget;
>> PFILE_OBJECT pFileTarget;
>>
>> status = IoGetDeviceObjectPointer(&uniDevName,
>>
>> FILE_READ_ATTRIBUTES,
>> &pFileTarget,
>> &pDevTarget);
>> PDVICE_OBJECT pLowerDevice;
>>
>> pLowerDevice = IoAttachDeviceToDeviceStack(pFilterDevice, pDevTarget);
>>
>> TIA,
>> Dale
>>
>> “Dale Hill” wrote in message news:xxxxx@ntdev…
>>> All,
>>>
>>> I am developing a TDI Client filter drvier using KMDF. The driver loads
>>> as
>>
>>> a legacy driver. In the driver entry routine (code is below), I am trying
>>> to create an IO Target using TCPIP.sys and then layering a control device
>>> on top of it. It seems like I can attach to the device stack but I don’t
>>> get any IO in the default event handler. Can someone tell me what I am
>>> doing wrong?
>>>
>>> TIA,
>>> Dale
>>>
>>> NTSTATUS
>>>
>>> DriverEntry(
>>>
>>> IN PDRIVER_OBJECT pDriver,
>>>
>>> IN PUNICODE_STRING pRegPath)
>>>
>>> {
>>>
>>> NTSTATUS status;
>>>
>>> DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
>>> TIMESTAMP ));
>>>
>>> #if DBG
>>>
>>> DbgBreakPoint();
>>>
>>> #endif
>>>
>>>
>>> // Create the KMDF driver object
>>>
>>> WDF_DRIVER_CONFIG configParms;
>>>
>>> WDFDRIVER hDriver;
>>>
>>> WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);
>>>
>>> configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;
>>>
>>> configParms.EvtDriverUnload = ISTDriverUnload;
>>>
>>> status = WdfDriverCreate(pDriver,
>>>
>>> pRegPath,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &configParms,
>>>
>>> &hDriver);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));
>>>
>>> }
>>>
>>> // Create a control device object
>>>
>>> //
>>>
>>> //
>>>
>>> PWDFDEVICE_INIT pDevInit;
>>>
>>> pDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES attribs;
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hCDODevice;
>>>
>>> status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO. Status:
>>> 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);
>>>
>>> // Store the device handle
>>>
>>> pDevExt->hDevice = hCDODevice;
>>>
>>> // Configure the default IO qeue
>>>
>>> WDF_IO_QUEUE_CONFIG ioQConfig;
>>>
>>> WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
>>>
>>> WdfIoQueueDispatchParallel);
>>>
>>> ioQConfig.EvtIoDefault = ISTEvtIoDefault;
>>>
>>> status = WdfIoQueueCreate(hCDODevice,
>>>
>>> &ioQConfig,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &pDevExt->hDeviceDefaultIoQueue);
>>>
>>> if (!NT_SUCCESS (status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue. Status:
>>> 0x%x\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hCDODevice);
>>>
>>> // Create the TCP/IP Io Target
>>>
>>> //
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hTCPDevice;
>>>
>>> PWDFDEVICE_INIT pTCPDevInit;
>>>
>>> pTCPDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pTCPDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
>>> Status: 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hTCPDevice);
>>>
>>> // Get the TCP device object
>>>
>>> UNICODE_STRING uniDevName;
>>>
>>> RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");
>>>
>>> // Create the TCP/IP Io Device
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>> status = WdfIoTargetCreate(hTCPDevice, &attribs, &pDevExt->hTcpIpTarget);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Open a handle to the device
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS openParms;
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
>>>
>>> &openParms,
>>>
>>> &uniDevName,
>>>
>>> FILE_WRITE_ACCESS | FILE_READ_ACCESS);
>>>
>>> openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;
>>>
>>> status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> // Delete the IO Target
>>>
>>> WdfObjectDelete(pDevExt->hTcpIpTarget);
>>>
>>> pDevExt->hTcpIpTarget = 0;
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Attach the CDO to the Tcp/Ip Target
>>>
>>> PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);
>>>
>>> PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);
>>>
>>> pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
>>> pTcpIpDevice);
>>>
>>> if (pDevExt->pLowerDevice == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));
>>>
>>> return STATUS_UNSUCCESSFUL;
>>>
>>> }
>>>
>>>
>>> return STATUS_SUCCESS;
>>>
>>> }
>>>
>>>
>>>
>>
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>>
>
>
>

KMDF would provide support for IRP queueing and sending in this configuration, but honestly, we have never tested KMDF this way (control devobj attaching to a stack outside of KMDF doing the attach) so YMMV, but for all intents and purposes it should just work.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Tuesday, February 03, 2009 11:52 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI Filter using KMDF

TDI filter is not a PnP driver, so, most of the value of KMDF is gone.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Dale Hill” wrote in message news:xxxxx@ntdev…
> Hi David,
>
> I am hoping that it will make the task easier by allowing me to focus on the
> driver’s application as opposed to the nitty gritty driver details.
>
> Thanks,
> Dale
>
>
> “David R. Cattley” wrote in message news:xxxxx@ntdev…
>> Dale,
>>
>> Not that this answers your question but what do you expect to leverage
>> from
>> WDF in a TDI Filter Driver?
>>
>> Regards,
>> Dave Cattley
>> Consulting Engineer
>> Systems Software Development
>>
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Dale Hill
>> Sent: Monday, February 02, 2009 11:59 PM
>> To: Windows System Software Devs Interest List
>> Subject: Re:[ntdev] TDI Filter using KMDF
>>
>> Ok I realize that code sample was completely illegable. Let me try
>> re-asking
>>
>> the question.
>>
>> How do you develop the following code using the KMDF model. The objective
>> is
>>
>> to have a layer device object (pFilterDevice) attached to the top of the
>> TCP/IP stack.
>>
>>
>> UNICODE_STRING uniDevName;
>> RtlInitUnicodeString(L\Device\Tcp);
>> PDEVICE pDevTarget;
>> PFILE_OBJECT pFileTarget;
>>
>> status = IoGetDeviceObjectPointer(&uniDevName,
>>
>> FILE_READ_ATTRIBUTES,
>> &pFileTarget,
>> &pDevTarget);
>> PDVICE_OBJECT pLowerDevice;
>>
>> pLowerDevice = IoAttachDeviceToDeviceStack(pFilterDevice, pDevTarget);
>>
>> TIA,
>> Dale
>>
>> “Dale Hill” wrote in message news:xxxxx@ntdev…
>>> All,
>>>
>>> I am developing a TDI Client filter drvier using KMDF. The driver loads
>>> as
>>
>>> a legacy driver. In the driver entry routine (code is below), I am trying
>>> to create an IO Target using TCPIP.sys and then layering a control device
>>> on top of it. It seems like I can attach to the device stack but I don’t
>>> get any IO in the default event handler. Can someone tell me what I am
>>> doing wrong?
>>>
>>> TIA,
>>> Dale
>>>
>>> NTSTATUS
>>>
>>> DriverEntry(
>>>
>>> IN PDRIVER_OBJECT pDriver,
>>>
>>> IN PUNICODE_STRING pRegPath)
>>>
>>> {
>>>
>>> NTSTATUS status;
>>>
>>> DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
>>> TIMESTAMP ));
>>>
>>> #if DBG
>>>
>>> DbgBreakPoint();
>>>
>>> #endif
>>>
>>>
>>> // Create the KMDF driver object
>>>
>>> WDF_DRIVER_CONFIG configParms;
>>>
>>> WDFDRIVER hDriver;
>>>
>>> WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);
>>>
>>> configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;
>>>
>>> configParms.EvtDriverUnload = ISTDriverUnload;
>>>
>>> status = WdfDriverCreate(pDriver,
>>>
>>> pRegPath,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &configParms,
>>>
>>> &hDriver);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));
>>>
>>> }
>>>
>>> // Create a control device object
>>>
>>> //
>>>
>>> //
>>>
>>> PWDFDEVICE_INIT pDevInit;
>>>
>>> pDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES attribs;
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hCDODevice;
>>>
>>> status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO. Status:
>>> 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);
>>>
>>> // Store the device handle
>>>
>>> pDevExt->hDevice = hCDODevice;
>>>
>>> // Configure the default IO qeue
>>>
>>> WDF_IO_QUEUE_CONFIG ioQConfig;
>>>
>>> WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
>>>
>>> WdfIoQueueDispatchParallel);
>>>
>>> ioQConfig.EvtIoDefault = ISTEvtIoDefault;
>>>
>>> status = WdfIoQueueCreate(hCDODevice,
>>>
>>> &ioQConfig,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &pDevExt->hDeviceDefaultIoQueue);
>>>
>>> if (!NT_SUCCESS (status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue. Status:
>>> 0x%x\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hCDODevice);
>>>
>>> // Create the TCP/IP Io Target
>>>
>>> //
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hTCPDevice;
>>>
>>> PWDFDEVICE_INIT pTCPDevInit;
>>>
>>> pTCPDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pTCPDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
>>> Status: 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hTCPDevice);
>>>
>>> // Get the TCP device object
>>>
>>> UNICODE_STRING uniDevName;
>>>
>>> RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");
>>>
>>> // Create the TCP/IP Io Device
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>> status = WdfIoTargetCreate(hTCPDevice, &attribs, &pDevExt->hTcpIpTarget);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Open a handle to the device
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS openParms;
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
>>>
>>> &openParms,
>>>
>>> &uniDevName,
>>>
>>> FILE_WRITE_ACCESS | FILE_READ_ACCESS);
>>>
>>> openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;
>>>
>>> status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> // Delete the IO Target
>>>
>>> WdfObjectDelete(pDevExt->hTcpIpTarget);
>>>
>>> pDevExt->hTcpIpTarget = 0;
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Attach the CDO to the Tcp/Ip Target
>>>
>>> PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);
>>>
>>> PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);
>>>
>>> pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
>>> pTcpIpDevice);
>>>
>>> if (pDevExt->pLowerDevice == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));
>>>
>>> return STATUS_UNSUCCESSFUL;
>>>
>>> }
>>>
>>>
>>> return STATUS_SUCCESS;
>>>
>>> }
>>>
>>>
>>>
>>
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>>
>
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Doron:

What is KMDF going to do with an IRP that does not have enough stack
locations to forward down-stack in this case?

(just curious since that is one of the biggest PITA aspects of dealing with
TDI filters).

Thanks,
-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, February 03, 2009 4:01 PM
To: Windows System Software Devs Interest List
Subject: RE: Re:[ntdev] TDI Filter using KMDF

KMDF would provide support for IRP queueing and sending in this
configuration, but honestly, we have never tested KMDF this way (control
devobj attaching to a stack outside of KMDF doing the attach) so YMMV, but
for all intents and purposes it should just work.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Tuesday, February 03, 2009 11:52 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI Filter using KMDF

TDI filter is not a PnP driver, so, most of the value of KMDF is gone.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Dale Hill” wrote in message news:xxxxx@ntdev…
> Hi David,
>
> I am hoping that it will make the task easier by allowing me to focus on
the
> driver’s application as opposed to the nitty gritty driver details.
>
> Thanks,
> Dale
>
>
> “David R. Cattley” wrote in message
news:xxxxx@ntdev…
>> Dale,
>>
>> Not that this answers your question but what do you expect to leverage
>> from
>> WDF in a TDI Filter Driver?
>>
>> Regards,
>> Dave Cattley
>> Consulting Engineer
>> Systems Software Development
>>
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Dale Hill
>> Sent: Monday, February 02, 2009 11:59 PM
>> To: Windows System Software Devs Interest List
>> Subject: Re:[ntdev] TDI Filter using KMDF
>>
>> Ok I realize that code sample was completely illegable. Let me try
>> re-asking
>>
>> the question.
>>
>> How do you develop the following code using the KMDF model. The objective
>> is
>>
>> to have a layer device object (pFilterDevice) attached to the top of the
>> TCP/IP stack.
>>
>>
>> UNICODE_STRING uniDevName;
>> RtlInitUnicodeString(L\Device\Tcp);
>> PDEVICE pDevTarget;
>> PFILE_OBJECT pFileTarget;
>>
>> status = IoGetDeviceObjectPointer(&uniDevName,
>>
>> FILE_READ_ATTRIBUTES,
>> &pFileTarget,
>> &pDevTarget);
>> PDVICE_OBJECT pLowerDevice;
>>
>> pLowerDevice = IoAttachDeviceToDeviceStack(pFilterDevice, pDevTarget);
>>
>> TIA,
>> Dale
>>
>> “Dale Hill” wrote in message news:xxxxx@ntdev…
>>> All,
>>>
>>> I am developing a TDI Client filter drvier using KMDF. The driver loads
>>> as
>>
>>> a legacy driver. In the driver entry routine (code is below), I am
trying
>>> to create an IO Target using TCPIP.sys and then layering a control
device
>>> on top of it. It seems like I can attach to the device stack but I don’t
>>> get any IO in the default event handler. Can someone tell me what I am
>>> doing wrong?
>>>
>>> TIA,
>>> Dale
>>>
>>> NTSTATUS
>>>
>>> DriverEntry(
>>>
>>> IN PDRIVER_OBJECT pDriver,
>>>
>>> IN PUNICODE_STRING pRegPath)
>>>
>>> {
>>>
>>> NTSTATUS status;
>>>
>>> DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
>>> TIMESTAMP ));
>>>
>>> #if DBG
>>>
>>> DbgBreakPoint();
>>>
>>> #endif
>>>
>>>
>>> // Create the KMDF driver object
>>>
>>> WDF_DRIVER_CONFIG configParms;
>>>
>>> WDFDRIVER hDriver;
>>>
>>> WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);
>>>
>>> configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;
>>>
>>> configParms.EvtDriverUnload = ISTDriverUnload;
>>>
>>> status = WdfDriverCreate(pDriver,
>>>
>>> pRegPath,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &configParms,
>>>
>>> &hDriver);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));
>>>
>>> }
>>>
>>> // Create a control device object
>>>
>>> //
>>>
>>> //
>>>
>>> PWDFDEVICE_INIT pDevInit;
>>>
>>> pDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES attribs;
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hCDODevice;
>>>
>>> status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO.
Status:
>>> 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);
>>>
>>> // Store the device handle
>>>
>>> pDevExt->hDevice = hCDODevice;
>>>
>>> // Configure the default IO qeue
>>>
>>> WDF_IO_QUEUE_CONFIG ioQConfig;
>>>
>>> WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
>>>
>>> WdfIoQueueDispatchParallel);
>>>
>>> ioQConfig.EvtIoDefault = ISTEvtIoDefault;
>>>
>>> status = WdfIoQueueCreate(hCDODevice,
>>>
>>> &ioQConfig,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &pDevExt->hDeviceDefaultIoQueue);
>>>
>>> if (!NT_SUCCESS (status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue.
Status:
>>> 0x%x\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hCDODevice);
>>>
>>> // Create the TCP/IP Io Target
>>>
>>> //
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hTCPDevice;
>>>
>>> PWDFDEVICE_INIT pTCPDevInit;
>>>
>>> pTCPDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pTCPDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
>>> Status: 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hTCPDevice);
>>>
>>> // Get the TCP device object
>>>
>>> UNICODE_STRING uniDevName;
>>>
>>> RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");
>>>
>>> // Create the TCP/IP Io Device
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>> status = WdfIoTargetCreate(hTCPDevice, &attribs,
&pDevExt->hTcpIpTarget);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Open a handle to the device
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS openParms;
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
>>>
>>> &openParms,
>>>
>>> &uniDevName,
>>>
>>> FILE_WRITE_ACCESS | FILE_READ_ACCESS);
>>>
>>> openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;
>>>
>>> status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> // Delete the IO Target
>>>
>>> WdfObjectDelete(pDevExt->hTcpIpTarget);
>>>
>>> pDevExt->hTcpIpTarget = 0;
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Attach the CDO to the Tcp/Ip Target
>>>
>>> PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);
>>>
>>> PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);
>>>
>>> pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
>>> pTcpIpDevice);
>>>
>>> if (pDevExt->pLowerDevice == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));
>>>
>>> return STATUS_UNSUCCESSFUL;
>>>
>>> }
>>>
>>>
>>> return STATUS_SUCCESS;
>>>
>>> }
>>>
>>>
>>>
>>
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>>
>
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

By calling IoAttachDeviceToDeviceStack your DeviceObject’s StackCount will be set to deviceYouAreAttachingTo->StackSize+1 which means all irps allocated and sent by the io manager on newly opened handles will have the right stack size. For existing handles or pre allocated irps that do not have enough stack locations, KMDF does nothing directly to solve this problem if you want a completion routine. For send & forget, it would work just fine. For the completion routine path you would need to allocate your own WDFREQUEST to send down the stack, just like you would need to alloc a PIRP in a wdm tdi filter

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of David R. Cattley
Sent: Tuesday, February 03, 2009 2:12 PM
To: Windows System Software Devs Interest List
Subject: RE: Re:[ntdev] TDI Filter using KMDF

Doron:

What is KMDF going to do with an IRP that does not have enough stack
locations to forward down-stack in this case?

(just curious since that is one of the biggest PITA aspects of dealing with
TDI filters).

Thanks,
-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, February 03, 2009 4:01 PM
To: Windows System Software Devs Interest List
Subject: RE: Re:[ntdev] TDI Filter using KMDF

KMDF would provide support for IRP queueing and sending in this
configuration, but honestly, we have never tested KMDF this way (control
devobj attaching to a stack outside of KMDF doing the attach) so YMMV, but
for all intents and purposes it should just work.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Tuesday, February 03, 2009 11:52 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI Filter using KMDF

TDI filter is not a PnP driver, so, most of the value of KMDF is gone.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Dale Hill” wrote in message news:xxxxx@ntdev…
> Hi David,
>
> I am hoping that it will make the task easier by allowing me to focus on
the
> driver’s application as opposed to the nitty gritty driver details.
>
> Thanks,
> Dale
>
>
> “David R. Cattley” wrote in message
news:xxxxx@ntdev…
>> Dale,
>>
>> Not that this answers your question but what do you expect to leverage
>> from
>> WDF in a TDI Filter Driver?
>>
>> Regards,
>> Dave Cattley
>> Consulting Engineer
>> Systems Software Development
>>
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Dale Hill
>> Sent: Monday, February 02, 2009 11:59 PM
>> To: Windows System Software Devs Interest List
>> Subject: Re:[ntdev] TDI Filter using KMDF
>>
>> Ok I realize that code sample was completely illegable. Let me try
>> re-asking
>>
>> the question.
>>
>> How do you develop the following code using the KMDF model. The objective
>> is
>>
>> to have a layer device object (pFilterDevice) attached to the top of the
>> TCP/IP stack.
>>
>>
>> UNICODE_STRING uniDevName;
>> RtlInitUnicodeString(L\Device\Tcp);
>> PDEVICE pDevTarget;
>> PFILE_OBJECT pFileTarget;
>>
>> status = IoGetDeviceObjectPointer(&uniDevName,
>>
>> FILE_READ_ATTRIBUTES,
>> &pFileTarget,
>> &pDevTarget);
>> PDVICE_OBJECT pLowerDevice;
>>
>> pLowerDevice = IoAttachDeviceToDeviceStack(pFilterDevice, pDevTarget);
>>
>> TIA,
>> Dale
>>
>> “Dale Hill” wrote in message news:xxxxx@ntdev…
>>> All,
>>>
>>> I am developing a TDI Client filter drvier using KMDF. The driver loads
>>> as
>>
>>> a legacy driver. In the driver entry routine (code is below), I am
trying
>>> to create an IO Target using TCPIP.sys and then layering a control
device
>>> on top of it. It seems like I can attach to the device stack but I don’t
>>> get any IO in the default event handler. Can someone tell me what I am
>>> doing wrong?
>>>
>>> TIA,
>>> Dale
>>>
>>> NTSTATUS
>>>
>>> DriverEntry(
>>>
>>> IN PDRIVER_OBJECT pDriver,
>>>
>>> IN PUNICODE_STRING pRegPath)
>>>
>>> {
>>>
>>> NTSTATUS status;
>>>
>>> DBGPRINT(5, (“TDI Filter Driver Entry. Driver built on: %s\n”,
>>> TIMESTAMP ));
>>>
>>> #if DBG
>>>
>>> DbgBreakPoint();
>>>
>>> #endif
>>>
>>>
>>> // Create the KMDF driver object
>>>
>>> WDF_DRIVER_CONFIG configParms;
>>>
>>> WDFDRIVER hDriver;
>>>
>>> WDF_DRIVER_CONFIG_INIT(&configParms, WDF_NO_EVENT_CALLBACK);
>>>
>>> configParms.DriverInitFlags |= WdfDriverInitNonPnpDriver;
>>>
>>> configParms.EvtDriverUnload = ISTDriverUnload;
>>>
>>> status = WdfDriverCreate(pDriver,
>>>
>>> pRegPath,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &configParms,
>>>
>>> &hDriver);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the KMDF driver object\n”));
>>>
>>> }
>>>
>>> // Create a control device object
>>>
>>> //
>>>
>>> //
>>>
>>> PWDFDEVICE_INIT pDevInit;
>>>
>>> pDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES attribs;
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hCDODevice;
>>>
>>> status = WdfDeviceCreate(&pDevInit, &attribs, &hCDODevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create CDO.
Status:
>>> 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> PIST_TDI_EXT pDevExt = GetDevExt(hCDODevice);
>>>
>>> // Store the device handle
>>>
>>> pDevExt->hDevice = hCDODevice;
>>>
>>> // Configure the default IO qeue
>>>
>>> WDF_IO_QUEUE_CONFIG ioQConfig;
>>>
>>> WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
>>>
>>> WdfIoQueueDispatchParallel);
>>>
>>> ioQConfig.EvtIoDefault = ISTEvtIoDefault;
>>>
>>> status = WdfIoQueueCreate(hCDODevice,
>>>
>>> &ioQConfig,
>>>
>>> WDF_NO_OBJECT_ATTRIBUTES,
>>>
>>> &pDevExt->hDeviceDefaultIoQueue);
>>>
>>> if (!NT_SUCCESS (status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the Default IO queue.
Status:
>>> 0x%x\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hCDODevice);
>>>
>>> // Create the TCP/IP Io Target
>>>
>>> //
>>>
>>> // Init the attributes for the device object
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>>
>>> // Create the CDO device
>>>
>>> WDFDEVICE hTCPDevice;
>>>
>>> PWDFDEVICE_INIT pTCPDevInit;
>>>
>>> pTCPDevInit = WdfControlDeviceInitAllocate(
>>>
>>> hDriver,
>>>
>>> &SDDL_DEVOBJ_SYS_ALL);
>>>
>>> if (pTCPDevInit == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create DEVICE_INIT for the CDO.
>>> Status: 0x%x.\n”,
>>>
>>> status));
>>>
>>> return STATUS_INSUFFICIENT_RESOURCES;
>>>
>>> }
>>>
>>> status = WdfDeviceCreate(&pTCPDevInit, &attribs, &hTCPDevice);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“Driver Entry: WdfDeviceCreate failed to create TCPDevice.
>>> Status: 0x%x\n”, status));
>>>
>>> WdfDeviceInitFree(pDevInit);
>>>
>>> return status;
>>>
>>> }
>>>
>>> WdfControlFinishInitializing(hTCPDevice);
>>>
>>> // Get the TCP device object
>>>
>>> UNICODE_STRING uniDevName;
>>>
>>> RtlInitUnicodeString(&uniDevName, L"\Device\Tcp");
>>>
>>> // Create the TCP/IP Io Device
>>>
>>> WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attribs, IST_TDI_EXT);
>>>
>>> status = WdfIoTargetCreate(hTCPDevice, &attribs,
&pDevExt->hTcpIpTarget);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to create the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Open a handle to the device
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS openParms;
>>>
>>> WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
>>>
>>> &openParms,
>>>
>>> &uniDevName,
>>>
>>> FILE_WRITE_ACCESS | FILE_READ_ACCESS);
>>>
>>> openParms.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;
>>>
>>> status = WdfIoTargetOpen(pDevExt->hTcpIpTarget, &openParms);
>>>
>>> if (!NT_SUCCESS(status))
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to open the TCP/IP target. Status:
>>> 0x%x.\n”,
>>>
>>> status));
>>>
>>> // Delete the IO Target
>>>
>>> WdfObjectDelete(pDevExt->hTcpIpTarget);
>>>
>>> pDevExt->hTcpIpTarget = 0;
>>>
>>> return status;
>>>
>>> }
>>>
>>> // Attach the CDO to the Tcp/Ip Target
>>>
>>> PDEVICE_OBJECT pCDODevice = WdfDeviceWdmGetDeviceObject(hCDODevice);
>>>
>>> PDEVICE_OBJECT pTcpIpDevice = WdfDeviceWdmGetDeviceObject(hTCPDevice);
>>>
>>> pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pCDODevice,
>>> pTcpIpDevice);
>>>
>>> if (pDevExt->pLowerDevice == NULL)
>>>
>>> {
>>>
>>> DBGPRINT(5, (“DriverEntry: Failed to attach to the TCP/IP target.\n”));
>>>
>>> return STATUS_UNSUCCESSFUL;
>>>
>>> }
>>>
>>>
>>> return STATUS_SUCCESS;
>>>
>>> }
>>>
>>>
>>>
>>
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>>
>
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer