Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

Strategy to merge a vendor WDF driver with Directshow (WDM) example

wtneowtneo Member Posts: 8

I have a vendor supplied PCIe driver that performs DMA from card to system memory, written in WDF (Window Driver Foundation) model. I would like to merge this driver's code with Microsoft Directshow sample driver, AVSHWS so that I can capture video from card and playback on screen using any Directshow players. But this Directshow sample is written using WDM model.

When I simply copy the source code from Directshow driver into PCIe driver, it compiles successfully. However, it crashes Windows 10 when driver is installed.

Anyone can advise how to combine these 2 drivers?

Thanks in advance,

wtneo

Comments

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,645

    I am guessing the DirectShow driver is using a port + miniport driver model (portcls or avstream, i can never remember). If that is true, the port driver is taking over the request dispatching and "fighting" with WDF which is trying to do the same. One solution is to use WDF in miniport mode. This allows you to reuse the DMA code, but you need to remove the WDFQUEUE and IO processing logic and in the WDM/avstream IO processing functions, call into the DMA object.

    d
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,109

    Right. AVStream is a port/miniport model. The driver calls into AVStream in DriverEntry (KsInitializeDevice), and it then handles all the dispatching. WDF in miniport mode is the right answer.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • wtneowtneo Member Posts: 8

    Thanks Doron and Tim. In that case I nee to learn what is miniport then. Still new to Windows driver.

  • wtneowtneo Member Posts: 8

    After some struggle I am still unable to start merge my PCIe WDF driver into AVStream as a miniport driver. Microsoft documents seems to target NDIS which I find it different from my needs. Also, it reads more like a reference guide than a tutorial.

    So I still don't know where to insert my WdfDriverCreate, EvtDevicePrepareHardware etc :'( .
    Are there other online instruction that can I can refer? Or a better Microsoft example that I may have missed?

  • gordon_lewisgordon_lewis Member Posts: 9
    edited October 12

    You call WdfDriverCreate in DriverEntry. You put a callback to EvtDevicePrepareHardware in your device add callback. If you are mixing models, then you want to implement the WDF driver as a miniport driver (options to WdfDriverCreate) which means it would not have a EvtDevicePrepareHardware callback. The sysvad sample driver is an example of a non-NDIS driver that is both a WDF miniport driver and a different kind of driver (an audio portcls driver). It calls WdfDriverCreate in DriverEntry.

    If you really have both a PCIe WDF driver and an AVStream driver, maybe you are better off having two separate drivers: one for PCIe WDF driver, one for AVStream and the AVStream driver communicates with the PCIe WDF driver.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Internals & Software Drivers 15 November 2021 Live, Online
Writing WDF Drivers 24 January 2022 Live, Online
Developing Minifilters 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online