Modify KMDOD sample for USB display

hi, Tim,

What you mean is that use the PDO at the nexttop for URB send?

This is normal case, but if there is a lower filter driver inserted, this will not the case.

Oh, my god.

I just use the KMDOD sample to install on a USB dongle.
What I do is just add the USB VID and PID of a dongle into the sample INF file.

And from the print log:
Installation just call the Driver Entry and AddDevice.
But it failed with Code 31.

System does not give the chance to call PnpStart function.

Why?

After I update Win8 9200 to Win8.1 pro 9600

the intel(r) q45/q43 express chipset(Microsoft corporation - wddm1.1)

Win8 pro build 9200 not work case
now it worked.

Does this related to WDDM1.1 and Win8.1 is WDDM1.2?

And:
Does KMDOD is designed to not support USB device?

And another two PCIe cards:

NVIDIA Quadro NVS 285 can?t install KMDOD

NVIDIA Geforce 210 could install and work(print)

If this KMDOD is not designed for USB dongle, what should I do?

I have change the INF class from Display to USB
it also failed wiTH CODE 31

workingmailing wrote:

What you mean is that use the PDO at the nexttop for URB send?
This is normal case, but if there is a lower filter driver inserted, this will not the case.

Yes, but that is #225 on the list of problems you are going to encounter. Worry about that later.

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

I just search the KMDOD on USB device issue.

No one have come cross this issue before.

And some one on web suggest to look the setupapi.dev.log file and use devcon instead of UI to
install the driver onto usb dongle.

I am curious about, what can I found by this log file and any difference between devcon and UI driver install wizard?

dvi: {DIF_INSTALLDEVICEFILES - exit(0x00000000)} 20:24:02.778
flq: File ‘C:\WINDOWS\system32\DRIVERS\SampleDisplay.sys’ pruned from copy.
dvi: {DIF_REGISTER_COINSTALLERS} 20:24:02.778
dvi: Class installer: Enter 20:24:02.778
dvi: Class installer: Exit
dvi: Default installer: Enter 20:24:02.778
dvi: Default installer: Exit
dvi: {DIF_REGISTER_COINSTALLERS - exit(0x00000000)} 20:24:02.778
dvi: {DIF_INSTALLINTERFACES} 20:24:02.778
dvi: No CoInstallers found
dvi: Class installer: Enter 20:24:02.778
dvi: Class installer: Exit
dvi: Default installer: Enter 20:24:02.778
dvi: Default installer: Exit
dvi: {DIF_INSTALLINTERFACES - exit(0x00000000)} 20:24:02.778
dvi: {DIF_INSTALLDEVICE} 20:24:02.778
dvi: Class installer: Enter 20:24:02.778
inf: AddService=KDODSamp,0x00000002,KDODSamp_Service_Inst, (oem20.inf line 75)
dvi: Add Service: Modified existing service ‘KDODSamp’.
dvi: {Install DEVICE}
dvi: {Writing Device Properties}
dvi: Strong Name=oem20.inf:dfb9e9faa6dfdd7f:KDODSamp_Inst:1.25.19.453:usb\vid_045e&pid_078e
dvi: {Writing Device Properties - Complete}
inf: AddService=KDODSamp,0x00000002,KDODSamp_Service_Inst, (sampledisplay.inf line 75)
dvi: Add Service: Modified existing service ‘KDODSamp’.
dvi: {Install DEVICE exit (0x00000000)}
dvi: Install Device: Starting device. 20:24:02.793
dvi: Install Device: Starting device completed. 20:24:02.918
!!! dvi: Device not started: Device has problem: 0x1f: CM_PROB_FAILED_ADD.
dvi: {Build Driver List} 20:24:02.918

What does your wdfdevice routine look like? CM_PROB_FAILED_ADD indicates a returned failure

d

Bent from my phone


From: workingmailing@163.commailto:workingmailing
Sent: ?6/?19/?2014 10:16 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] Modify KMDOD sample for USB display

dvi: {DIF_INSTALLDEVICEFILES - exit(0x00000000)} 20:24:02.778
flq: File ‘C:\WINDOWS\system32\DRIVERS\SampleDisplay.sys’ pruned from copy.
dvi: {DIF_REGISTER_COINSTALLERS} 20:24:02.778
dvi: Class installer: Enter 20:24:02.778
dvi: Class installer: Exit
dvi: Default installer: Enter 20:24:02.778
dvi: Default installer: Exit
dvi: {DIF_REGISTER_COINSTALLERS - exit(0x00000000)} 20:24:02.778
dvi: {DIF_INSTALLINTERFACES} 20:24:02.778
dvi: No CoInstallers found
dvi: Class installer: Enter 20:24:02.778
dvi: Class installer: Exit
dvi: Default installer: Enter 20:24:02.778
dvi: Default installer: Exit
dvi: {DIF_INSTALLINTERFACES - exit(0x00000000)} 20:24:02.778
dvi: {DIF_INSTALLDEVICE} 20:24:02.778
dvi: Class installer: Enter 20:24:02.778
inf: AddService=KDODSamp,0x00000002,KDODSamp_Service_Inst, (oem20.inf line 75)
dvi: Add Service: Modified existing service ‘KDODSamp’.
dvi: {Install DEVICE}
dvi: {Writing Device Properties}
dvi: Strong Name=oem20.inf:dfb9e9faa6dfdd7f:KDODSamp_Inst:1.25.19.453:usb\vid_045e&pid_078e
dvi: {Writing Device Properties - Complete}
inf: AddService=KDODSamp,0x00000002,KDODSamp_Service_Inst, (sampledisplay.inf line 75)
dvi: Add Service: Modified existing service ‘KDODSamp’.
dvi: {Install DEVICE exit (0x00000000)}
dvi: Install Device: Starting device. 20:24:02.793
dvi: Install Device: Starting device completed. 20:24:02.918
!!! dvi: Device not started: Device has problem: 0x1f: CM_PROB_FAILED_ADD.
dvi: {Build Driver List} 20:24:02.918


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:workingmailing>

I am not familiar with wdfdevice routine.

But, nothing changed from the KMDOD smaple, just add the USB VID PID into the INF file for
install the sample driver onto it.

*************************************************

NTSTATUS
BddDdiAddDevice(
In DEVICE_OBJECT* pPhysicalDeviceObject,
Outptr PVOID* ppDeviceContext)
{
PAGED_CODE();

if ((pPhysicalDeviceObject == NULL) ||
(ppDeviceContext == NULL))
{
BDD_LOG_ERROR2(“One of pPhysicalDeviceObject (0x%I64x), ppDeviceContext (0x%I64x) is NULL”,
pPhysicalDeviceObject, ppDeviceContext);
return STATUS_INVALID_PARAMETER;
}
*ppDeviceContext = NULL;

BASIC_DISPLAY_DRIVER* pBDD = new(NonPagedPoolNx) BASIC_DISPLAY_DRIVER(pPhysicalDeviceObject);
if (pBDD == NULL)
{
BDD_LOG_LOW_RESOURCE0(“pBDD failed to be allocated”);
return STATUS_NO_MEMORY;
}

*ppDeviceContext = pBDD;

return STATUS_SUCCESS;
}

*****************************************************

And the inf file added:

*****************************************************

[MS]
;
; Allow the driver to be loaded on VGA and XGA
;
“Kernel mode display only sample driver” = KDODSamp_Inst, PCI\CC_0300
“Kernel mode display only sample driver” = KDODSamp_Inst, PCI\CC_0301
“USB Display Dev” = KDODSamp_Inst, USB\VID_xxxx&PID_xxxx

[MS.NTamd64]

And did you step through BddDdiAddDevice to see what was being returned?

d

Bent from my phone


From: workingmailing@163.commailto:workingmailing
Sent: ?6/?19/?2014 10:47 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] Modify KMDOD sample for USB display

I am not familiar with wdfdevice routine.

But, nothing changed from the KMDOD smaple, just add the USB VID PID into the INF file for
install the sample driver onto it.

***********************************************

NTSTATUS
BddDdiAddDevice(
In DEVICE_OBJECT
pPhysicalDeviceObject,
Outptr PVOID
ppDeviceContext)
{
PAGED_CODE();

if ((pPhysicalDeviceObject == NULL) ||
(ppDeviceContext == NULL))
{
BDD_LOG_ERROR2(“One of pPhysicalDeviceObject (0x%I64x), ppDeviceContext (0x%I64x) is NULL”,
pPhysicalDeviceObject, ppDeviceContext);
return STATUS_INVALID_PARAMETER;
}
ppDeviceContext = NULL;

BASIC_DISPLAY_DRIVER
pBDD = new(NonPagedPoolNx) BASIC_DISPLAY_DRIVER(pPhysicalDeviceObject);
if (pBDD == NULL)
{
BDD_LOG_LOW_RESOURCE0(“pBDD failed to be allocated”);
return STATUS_NO_MEMORY;
}

*ppDeviceContext = pBDD;

return STATUS_SUCCESS;
}

*****************************************************

And the inf file added:

*****************************************************

[MS]
;
; Allow the driver to be loaded on VGA and XGA
;
“Kernel mode display only sample driver” = KDODSamp_Inst, PCI\CC_0300
“Kernel mode display only sample driver” = KDODSamp_Inst, PCI\CC_0301
“USB Display Dev” = KDODSamp_Inst, USB\VID_xxxx&PID_xxxx

[MS.NTamd64]


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:workingmailing>

thank you for you reply, Doron,

But from the sample:
it return STATUS_SUCCESS in the last line of BddDdiAddDevice.

Here I use the Notebook as host with Win7 and Dell 780 PC as target with Win8.1 build 9600 pro.
The com debug always hang when I try to set a breakpoint.

And can’t not setup with the gadget of Ajays debug cable for USB debug.

kt133a

How to load modules symbols?

I have set the path for my own code pdb file.
Here my host is Win7 and target is Win8.1 pro build 9600.

I have change the debug from COM to NET, and it works.

Reply 11 and 15 tell you why it is failing.
Reply 64 confirms this. Obviously DOD can
only work if installed on REAL Display Adapter
with correct WDDM version.
Why are you still asking?

In reply 15 I told you that you cannot fake
hardware resources on USB bus.
Why do you still try to install on USB?

Reply 44 tells you that it needs to be two separate drivers.
Why do you still do one driver only?

How can you expect things to work if you are
not even listening to the simplest basic advice?

The code you posted above is so wrong that
I would not even know where to start discussing…

IoCreateDevice() and IoAttachDeviceToDeviceStack()
in a miniport tsk,tsk,tsk… (*)

Since it is obviously necessary to repeat things again here:
USB displays and virtual displays are not supported
by the Windows operating system. Fullstop.

PS: (*) Such WDM escapes in miniports CAN actually be done
in all miniports (WDDM, NDIS, Kernel Steaming, etc.). BUT
it needs an approach which is about twenty times more elaborate
than yours. In your case it will still not help (see reply 11+15+44 again).

Marcel Ruedinger
datronicsoft

Thank you Marcel.

  1. IoCreateDevice and IoAttachDeviceToDeviceStack is just a try.

  2. Before do this thing by self, you can’t not all believe anyone else said is right or wrong.

  3. After review the KMDOD code, and running on several video cards, with the DbgPrint output, it seems that KMDOD is not a complicated driver.
    So we decide to migrate it onto USB device.

  4. Even no code is changed, just add the USB VID, PID into the INF file, the adddevice return STATUS_SUCCESS, the driver install on a USB device is failed.
    After this DIY, we get to know that this driver install on USB will fail.
    But we still does not clear the reason, why it will fail, cause the adddevice return STATUS_SUCCESS, and DxgkCbAcquirePostDisplayOwnership is called at StartDevice, before StartDevice, how does system know your device is USB, without or with resource like PCI video adapter or not?

We now verify DOD not work with USB, but we need to dig out the reason, and then, found any method to fix it, or fullstop.

I like your statement (2) - very true :wink:

To dig out the reason, you need a Windows Checked Build
and debug dxgkrnl.sys in assembly language.
I did this a few years ago for full WDDM drivers.
I assume, it is still the same and it also applies to DOD.
WDDM videos of first build conference on Channel 9
indicate that the same applies to DOD.

The reason (hope I correctly remember the details):
After even successfully returning IRP_MN_START_DEVICE,
a separate thread of dxgkrnl.sys checked the
PCI configuration space if it is really a display device.
If not, it called IoInvalidateDeviceState() and then
reported PNP_DEVICE_FAILED upon IRP_MN_QUERY_PNP_DEVICE_STATE.

Marcel Ruedinger
datronicsoft

I think it just wants an interrupt and memory and doesn’t explicitly care
about pci. The OP is going to have to figure out how to meet those
requirements.

Mark Roddy

On Fri, Jun 20, 2014 at 6:28 AM, wrote:

> I like your statement (2) - very true :wink:
>
> To dig out the reason, you need a Windows Checked Build
> and debug dxgkrnl.sys in assembly language.
> I did this a few years ago for full WDDM drivers.
> I assume, it is still the same and it also applies to DOD.
> WDDM videos of first build conference on Channel 9
> indicate that the same applies to DOD.
>
> The reason (hope I correctly remember the details):
> After even successfully returning IRP_MN_START_DEVICE,
> a separate thread of dxgkrnl.sys checked the
> PCI configuration space if it is really a display device.
> If not, it called IoInvalidateDeviceState() and then
> reported PNP_DEVICE_FAILED upon IRP_MN_QUERY_PNP_DEVICE_STATE.
>
> Marcel Ruedinger
> datronicsoft
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> 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
>

WDDM never needed memory and always needed an interrupt.

I would bet that it still needs either a PCI device of
PCI Device Class 03 “Display Controller”, or a display
exposed by the BIOS as it always did before DOD.
You can easily find out for yourself with a non-PCI device
that has interrupts.
Install your own working DOD driver or the DOD sample on a
non-PCI device with interrupts (e.g. VMWare floppy disk controler)
and let us know if dxgkrnl.sys cooperates.

BTW, there is another question which I always wanted to ask you:
In a different thread, we discussed that DOD crashes the
operating system with Blue Screen of Death “by design”
upon entering sleep state (no joke!). You said:
“This is indeed a silly limitation. It can be removed.”
But you did not tell how to do this. It would be
interesting to see if this approach of removal also
applies to USB display consumer scenarios.

Marcel Ruedinger
datronicsoft

Marcel Ruedinger wrote:

To dig out the reason, you need a Windows Checked
Build and debug dxgkrnl.sys in assembly language. I
did this a few years ago for full WDDM drivers. I assume,
it is still the same and it also applies to DOD. WDDM videos
of first build conference on Channel 9 indicate that the same
applies to DOD.

The reason (hope I correctly remember the details): After
even successfully returning IRP_MN_START_DEVICE, a
separate thread of dxgkrnl.sys checked the PCI configuration
space if it is really a display device. If not, it called
IoInvalidateDeviceState() and then reported PNP_DEVICE_FAILED
upon IRP_MN_QUERY_PNP_DEVICE_STATE.

Only 9 man-years left for wesley now.