converting wdm to wdf

hi ,
?'m begginer of writing device driver and i’m confused about wdm & wdf…
i have a sample of driver for a pci-e device. the codes have written with WDM for XP, i must modify them for windows 7 and i want to use WDF. Actually i dont know where i change. Briefly what is the difference of WDM and WDF about codes? Which blocks i should change?
Osman

Did you read the answers you received on NtFsd?

You begin with DriverEntry, since that is where all drivers begin.

Is this for learning only, or are you targeting a driver for commercial use? Your cheapest path to a marketable driver, if you have a well written WDM driver and have no pressing issues with hardware changes is to simply re-compile the driver under Win 7.

Gary G. Little

----- Original Message -----
From: xxxxx@netas.com.tr
To: “Windows System Software Devs Interest List”
Sent: Wednesday, February 2, 2011 9:17:33 AM
Subject: [ntdev] converting wdm to wdf

hi ,
?'m begginer of writing device driver and i’m confused about wdm & wdf…
i have a sample of driver for a pci-e device. the codes have written with WDM for XP, i must modify them for windows 7 and i want to use WDF. Actually i dont know where i change. Briefly what is the difference of WDM and WDF about codes? Which blocks i should change?
Osman


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

thanks u Gary,
i have read tha answers, my purpose of ask it again for ntdev is waiting
alternatve answers from ntdev members, cause they warned me that this
topic doesnt belong to ntfsd.

Osman


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Wednesday, February 02, 2011 5:48 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] converting wdm to wdf

Did you read the answers you received on NtFsd?

You begin with DriverEntry, since that is where all drivers begin.

Is this for learning only, or are you targeting a driver for commercial
use? Your cheapest path to a marketable driver, if you have a well
written WDM driver and have no pressing issues with hardware changes is
to simply re-compile the driver under Win 7.

Gary G. Little

----- Original Message -----
From: xxxxx@netas.com.tr
To: “Windows System Software Devs Interest List”
Sent: Wednesday, February 2, 2011 9:17:33 AM
Subject: [ntdev] converting wdm to wdf

hi ,
?'m begginer of writing device driver and i’m confused about wdm &
wdf…
i have a sample of driver for a pci-e device. the codes have written
with WDM for XP, i must modify them for windows 7 and i want to use WDF.
Actually i dont know where i change. Briefly what is the difference of
WDM and WDF about codes? Which blocks i should change?
Osman


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

Well the obvious question no one has asked, have you read the WDM to
KMDF porting guide? If not go to
http://www.microsoft.com/whdc/driver/wdf/wdf_port.mspx and start
reading.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Osman TOKER” wrote in message news:xxxxx@ntdev:

> thanks u Gary,
> i have read tha answers, my purpose of ask it again for ntdev is waiting
> alternatve answers from ntdev members, cause they warned me that this
> topic doesnt belong to ntfsd.
>
> Osman
>
> ________________________________
>
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
> Sent: Wednesday, February 02, 2011 5:48 PM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] converting wdm to wdf
>
>
> Did you read the answers you received on NtFsd?
>
> You begin with DriverEntry, since that is where all drivers begin.
>
> Is this for learning only, or are you targeting a driver for commercial
> use? Your cheapest path to a marketable driver, if you have a well
> written WDM driver and have no pressing issues with hardware changes is
> to simply re-compile the driver under Win 7.
>
> Gary G. Little
>
> ----- Original Message -----
> From: xxxxx@netas.com.tr
> To: “Windows System Software Devs Interest List”
> Sent: Wednesday, February 2, 2011 9:17:33 AM
> Subject: [ntdev] converting wdm to wdf
>
> hi ,
> ?'m begginer of writing device driver and i’m confused about wdm &
> wdf…
> i have a sample of driver for a pci-e device. the codes have written
> with WDM for XP, i must modify them for windows 7 and i want to use WDF.
> Actually i dont know where i change. Briefly what is the difference of
> WDM and WDF about codes? Which blocks i should change?
> Osman
>
> —
> 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

Hi,
I have a question about porting actually dispatch functions;
I’m trying porting old driver codes -WDM- to KMDF and driver type is
PCI.
Here is the DriverEntry of the WDM codes;

extern “C” NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{ // DriverEntry
KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject
%8.8lX\n", DriverObject));

// Save the name of the service key

servkey.Buffer = (PWSTR) ExAllocatePool(PagedPool,
RegistryPath->Length + sizeof(WCHAR));
if (!servkey.Buffer)
{
KdPrint((DRIVERNAME " - Unable to allocate %d bytes for
copy of service key name\n", RegistryPath->Length + sizeof(WCHAR)));
return STATUS_INSUFFICIENT_RESOURCES;
}
servkey.MaximumLength = RegistryPath->Length + sizeof(WCHAR);
RtlCopyUnicodeString(&servkey, RegistryPath);
servkey.Buffer[RegistryPath->Length / 2] = 0;

// Initialize function pointers

DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = AddDevice;

DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
DriverObject->MajorFunction[IRP_MJ_READ] = DispatchReadWrite;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup;
DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
DispatchWmi;

DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
DispatchControl;

return STATUS_SUCCESS;
} // DriverEntry

But 5. page on the Porting a Driver from WDM to KMDF (here is the
link:http://www.microsoft.com/whdc/driver/wdf/wdf_port.mspx), there is a
table about driver types supported by KDMF;
Table 1. Device and Driver Types Supported by KMDF
Device or driver type Previous driver model
Control and non-Plug and Play drivers Legacy
Human interface device (HID) drivers HID miniport (WDM-based)
IEEE 1394 client drivers1 Depends on device class
ISA, PCI, PCMCIA, and secure digital (SD) devices2 WDM
Network Driver Interface Specification (NDIS) protocol drivers WDM
upper edge and NDIS lower edge
NDIS WDM drivers NDIS upper edge and WDM lower edge
SoftModem drivers WDM with upper-edge support for Telephony
Application Programming Interface (TAPI) interface
Storage class drivers and filter drivers WDM
Transport driver interface (TDI) client drivers WDM
USB client drivers Depends on device class
Winsock client drivers WDM with a callback interface for
device-specific requests

1 Supported for devices that do not conform to existing device class
specifications.
2 Supported, if device class or port drivers do not provide the driver
dispatch functions.

So, Will I be able to use KMDF? Or how can i configurate WDM codes for
windows 7?

Osman.

You don’t say what the class of the device is, but yes you should be
able to convert it. Normally the descision is based on what the device
does (i.e. the class) since Microsoft has added support for some
devices.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Osman TOKER” wrote in message news:xxxxx@ntdev:

> Hi,
> I have a question about porting actually dispatch functions;
> I’m trying porting old driver codes -WDM- to KMDF and driver type is
> PCI.
> Here is the DriverEntry of the WDM codes;
>
> extern “C” NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,
> IN PUNICODE_STRING RegistryPath)
> { // DriverEntry
> KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject
> %8.8lX\n", DriverObject));
>
> // Save the name of the service key
>
> servkey.Buffer = (PWSTR) ExAllocatePool(PagedPool,
> RegistryPath->Length + sizeof(WCHAR));
> if (!servkey.Buffer)
> {
> KdPrint((DRIVERNAME " - Unable to allocate %d bytes for
> copy of service key name\n", RegistryPath->Length + sizeof(WCHAR)));
> return STATUS_INSUFFICIENT_RESOURCES;
> }
> servkey.MaximumLength = RegistryPath->Length + sizeof(WCHAR);
> RtlCopyUnicodeString(&servkey, RegistryPath);
> servkey.Buffer[RegistryPath->Length / 2] = 0;
>
> // Initialize function pointers
>
> DriverObject->DriverUnload = DriverUnload;
> DriverObject->DriverExtension->AddDevice = AddDevice;
>
> DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
> DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
> DriverObject->MajorFunction[IRP_MJ_READ] = DispatchReadWrite;
> DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup;
> DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
> DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
> DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
> DispatchWmi;
>
> DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
> DispatchControl;
>
> return STATUS_SUCCESS;
> } // DriverEntry
>
> But 5. page on the Porting a Driver from WDM to KMDF (here is the
> link:http://www.microsoft.com/whdc/driver/wdf/wdf_port.mspx), there is a
> table about driver types supported by KDMF;
> Table 1. Device and Driver Types Supported by KMDF
> Device or driver type Previous driver model
> Control and non-Plug and Play drivers Legacy
> Human interface device (HID) drivers HID miniport (WDM-based)
> IEEE 1394 client drivers1 Depends on device class
> ISA, PCI, PCMCIA, and secure digital (SD) devices2 WDM
> Network Driver Interface Specification (NDIS) protocol drivers WDM
> upper edge and NDIS lower edge
> NDIS WDM drivers NDIS upper edge and WDM lower edge
> SoftModem drivers WDM with upper-edge support for Telephony
> Application Programming Interface (TAPI) interface
> Storage class drivers and filter drivers WDM
> Transport driver interface (TDI) client drivers WDM
> USB client drivers Depends on device class
> Winsock client drivers WDM with a callback interface for
> device-specific requests
>
> 1 Supported for devices that do not conform to existing device class
> specifications.
> 2 Supported, if device class or port drivers do not provide the driver
> dispatch functions.
>
> So, Will I be able to use KMDF? Or how can i configurate WDM codes for
> windows 7?
>
> Osman.

Excuse me,
Device is a sound card (with pci-ex port).
So can we say the document is out of date?

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Tuesday, February 08, 2011 2:07 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] converting wdm to wdf

You don’t say what the class of the device is, but yes you should be
able to convert it. Normally the descision is based on what the device
does (i.e. the class) since Microsoft has added support for some
devices.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Osman TOKER” wrote in message news:xxxxx@ntdev:

> Hi,
> I have a question about porting actually dispatch functions; I’m
> trying porting old driver codes -WDM- to KMDF and driver type is PCI.
> Here is the DriverEntry of the WDM codes;
>
> extern “C” NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,
> IN PUNICODE_STRING RegistryPath)
> { // DriverEntry
> KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject
%8.8lX\n",
> DriverObject));
>
> // Save the name of the service key
>
> servkey.Buffer = (PWSTR) ExAllocatePool(PagedPool,
> RegistryPath->Length + sizeof(WCHAR));
> if (!servkey.Buffer)
> {
> KdPrint((DRIVERNAME " - Unable to allocate %d bytes for
copy of
> service key name\n", RegistryPath->Length + sizeof(WCHAR)));
> return STATUS_INSUFFICIENT_RESOURCES;
> }
> servkey.MaximumLength = RegistryPath->Length + sizeof(WCHAR);
> RtlCopyUnicodeString(&servkey, RegistryPath);
> servkey.Buffer[RegistryPath->Length / 2] = 0;
>
> // Initialize function pointers
>
> DriverObject->DriverUnload = DriverUnload;
> DriverObject->DriverExtension->AddDevice = AddDevice;
>
> DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
> DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
> DriverObject->MajorFunction[IRP_MJ_READ] = DispatchReadWrite;
> DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup;
> DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
> DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
> DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
DispatchWmi;
>
> DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
DispatchControl;
>
> return STATUS_SUCCESS;
> } // DriverEntry
>
> But 5. page on the Porting a Driver from WDM to KMDF (here is the
> link:http://www.microsoft.com/whdc/driver/wdf/wdf_port.mspx), there is

> a table about driver types supported by KDMF; Table 1. Device and
> Driver Types Supported by KMDF
> Device or driver type Previous driver model
> Control and non-Plug and Play drivers Legacy
> Human interface device (HID) drivers HID miniport (WDM-based)
> IEEE 1394 client drivers1 Depends on device class
> ISA, PCI, PCMCIA, and secure digital (SD) devices2 WDM
> Network Driver Interface Specification (NDIS) protocol drivers
WDM
> upper edge and NDIS lower edge
> NDIS WDM drivers NDIS upper edge and WDM lower edge
> SoftModem drivers WDM with upper-edge support for Telephony
> Application Programming Interface (TAPI) interface
> Storage class drivers and filter drivers WDM
> Transport driver interface (TDI) client drivers WDM
> USB client drivers Depends on device class
> Winsock client drivers WDM with a callback interface for
> device-specific requests
>
> 1 Supported for devices that do not conform to existing device class
> specifications.
> 2 Supported, if device class or port drivers do not provide the driver

> dispatch functions.
>
> So, Will I be able to use KMDF? Or how can i configurate WDM codes for

> windows 7?
>
> Osman.


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

Osman TOKER wrote:

Excuse me,
Device is a sound card (with pci-ex port).

Sound cards do not use KMDF, because there are already port drivers that
provide the dispatch functions.

Sound drivers are complicated. It would be better if you could make
your device follow the HDAudio standard; that way, the driver situation
becomes much simpler. Are you starting a new design from scratch here?

So can we say the document is out of date?

No, we can’t. Did you actually read the table? It doesn’t say that
ISA, PCI, and PCMCIA devices have to be WDM. That second column says
what driver model would PREVIOUSLY have been used for devices of that type.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you Tim,
At this situation, i have a pci-ex sound card and driver codes written
for XP on WDM and i want to run this device on windows 7.
Finally i know that i couldnt porting the codes to KMDF. But starting a
new design takes so long time. What is your suggestion?

Osman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, February 08, 2011 7:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] converting wdm to wdf

Osman TOKER wrote:

Excuse me,
Device is a sound card (with pci-ex port).

Sound cards do not use KMDF, because there are already port drivers that
provide the dispatch functions.

Sound drivers are complicated. It would be better if you could make
your device follow the HDAudio standard; that way, the driver situation
becomes much simpler. Are you starting a new design from scratch here?

So can we say the document is out of date?

No, we can’t. Did you actually read the table? It doesn’t say that
ISA, PCI, and PCMCIA devices have to be WDM. That second column says
what driver model would PREVIOUSLY have been used for devices of that
type.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


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

Osman TOKER wrote:

At this situation, i have a pci-ex sound card and driver codes written
for XP on WDM and i want to run this device on windows 7.

Are you saying you have a sound card that does not use either port-class
or stream-class? That’s hard to imagine. Does it work as a standard
system sound device?

Finally i know that i couldnt porting the codes to KMDF. But starting a
new design takes so long time. What is your suggestion?

WDM continues to work today just like it always has. Unless your driver
does something foolish, you should be able to use the exact same binary
on Win 7 (32 bit) that you are currently using on XP.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Let me explain,
This card is used for coding the voice packages(IMBE coding by embedded
dsp). Its class is sound card but the voice packages transmit and
receive by ethernet port.
PCI ports use some specific commands and communicating with registry
Only i need to run this device on Win 7(64 bit) and configurate the old
driver codes with WDM(?).

WDK 7.1 is useful for me for debugging and compiling? Or anytool else?

Osman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, February 09, 2011 2:34 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] converting wdm to wdf

Osman TOKER wrote:

At this situation, i have a pci-ex sound card and driver codes written

for XP on WDM and i want to run this device on windows 7.

Are you saying you have a sound card that does not use either port-class
or stream-class? That’s hard to imagine. Does it work as a standard
system sound device?

Finally i know that i couldnt porting the codes to KMDF. But starting
a new design takes so long time. What is your suggestion?

WDM continues to work today just like it always has. Unless your driver
does something foolish, you should be able to use the exact same binary
on Win 7 (32 bit) that you are currently using on XP.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


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

Osman TOKER wrote:

This card is used for coding the voice packages(IMBE coding by embedded
dsp). Its class is sound card but the voice packages transmit and
receive by ethernet port.

This is still not answering the question. Are you saying your INF file
has “Class=MEDIA”? What functions do you call in your DriverEntry? Do
you call PcInitializeAdapterDriver? Do you call
StreamClassRegisterMinidriver? Do you call KsInitializeDriver? A sound
driver will usually call one of those three functions in its DriverEntry
routine. Calling any of those three makes you a class/miniport driver
(either port class, stream class, or AVStream, respectively), for which
KMDF is not necessarily the best fit.

Is there a user-mode component to your driver? Some boards like this
have a completely custom kernel-mode driver with a user-mode installable
driver that connects to the mmsystem waveIn/waveOut functions.

WDK 7.1 is useful for me for debugging and compiling? Or anytool else?

That’s the one you want.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

No, INF class ; Class=Unknown and none of the functions you said calling
by Driver Entry. Only ExAllocatePool calling for buffer allocate.

Osman

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, February 10, 2011 2:59 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] converting wdm to wdf

Osman TOKER wrote:

This card is used for coding the voice packages(IMBE coding by
embedded dsp). Its class is sound card but the voice packages transmit

and receive by ethernet port.

This is still not answering the question. Are you saying your INF file
has “Class=MEDIA”? What functions do you call in your DriverEntry? Do
you call PcInitializeAdapterDriver? Do you call
StreamClassRegisterMinidriver? Do you call KsInitializeDriver? A sound
driver will usually call one of those three functions in its DriverEntry
routine. Calling any of those three makes you a class/miniport driver
(either port class, stream class, or AVStream, respectively), for which
KMDF is not necessarily the best fit.

Is there a user-mode component to your driver? Some boards like this
have a completely custom kernel-mode driver with a user-mode installable
driver that connects to the mmsystem waveIn/waveOut functions.

WDK 7.1 is useful for me for debugging and compiling? Or anytool else?

That’s the one you want.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


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

Osman TOKER wrote:

No, INF class ; Class=Unknown and none of the functions you said calling
by Driver Entry. Only ExAllocatePool calling for buffer allocate.

OK! Then this is NOT a sound card. It is a custom device that your
special software happens to use to process audio signals.

In that case, you certainly could convert it to KMDF, if you are
undertaking some other modifications. There is not much point in
rewriting it just for the sake of rewriting it; if all you need is
64-bit support, you should be able to recompile it.

It is unusual to call ExAllocatePool during DriverEntry.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.