Giter Site home page Giter Site logo

iddsampledriver's Introduction

License MIT and CC0 or Public Domain (for changes I made, check with Microsoft for their license), whichever is least restrictive -- Use it

AS IS - NO IMPLICIT OR EXPLICIT warranty This may break your computer, it didn't break mine. It runs in User Mode which means it's less likely to cause system instability like the Blue Screen of Death. Check out the latest release to download, or find other versions below:

Newer Versions

Fork that is easy to install

https://github.com/ge9/IddSampleDriver

Fork with HDR

https://github.com/itsmikethetech/Virtual-Display-Driver

If you want me to build on this donate eth or similar here: 0xB01b6328F8Be53c852a54432bbEe630cE0Bd559a I now have a NEAR address: moopaloo.near

Thanks to https://github.com/akatrevorjay/edid-generator for the hi-res EDID.

Indirect Display Driver Sample

This is a sample driver that shows how to create a Windows Indirect Display Driver using the IddCx class extension driver.

Background reading

Start at the Indirect Display Driver Model Overview on MSDN.

Customizing the sample

The sample driver code is very simplistic and does nothing more than enumerate a single monitor when its device enters the D0/started power state. Throughout the code, there are TODO blocks with important information on implementing functionality in a production driver.

Code structure

  • Direct3DDevice class
    • Contains logic for enumerating the correct render GPU from DXGI and creating a D3D device.
    • Manages the lifetime of a DXGI factory and a D3D device created for the render GPU the system is using to render frames for your indirect display device's swap-chain.
  • SwapChainProcessor class
    • Processes frames for a swap-chain assigned to the monitor object on a dedicated thread.
    • The sample code does nothing with the frames, but demonstrates a correct processing loop with error handling and notifying the OS of frame completion.
  • IndirectDeviceContext class
    • Processes device callbacks from IddCx.
    • Manages the creation and arrival of the sample monitor.
    • Handles swap-chain arrival and departure by creating a Direct3DDevice and handing it off to a SwapChainProcessor.

First steps

Consider the capabilities of your device. If the device supports multiple monitors being hotplugged and removed at runtime, you may want to abstract the monitors further from the IndirectDeviceContext class.

The INF file included in the sample needs updating for production use. One field, DeviceGroupId, controls how the UMDF driver gets pooled with other UMDF drivers in the same process. Since indirect display drivers tend to be more complicated than other driver classes, it's highly recommended that you pick a unique string for this field which will cause instances of your device driver to pool in a dedicated process. This will improve system reliability in case your driver encounters a problem since other drivers will not be affected.

Ensure the device information reported to IddCxAdapterInitAsync is accurate. This information determines how the device is reported to the OS and what static features (like support for gamma tables) the device will have available. If some information cannot be known immediately in the EvtDeviceD0Entry callback, IddCx allows the driver to call IddCxAdapterInitAsync at any point after D0 entry, before D0 exit.

Careful attention should be paid to the frame processing loop. This will directly impact the performance of the user's system, so making use of the Multimedia Class Scheduler Service and DXGI's support for GPU prioritization should be considered. Any significant work should be performed outside the main processing loop, such as by queuing work in a thread pool. See SwapChainProcessor::RunCore for more information.

iddsampledriver's People

Contributors

ge9 avatar roshkins avatar sitiom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iddsampledriver's Issues

How can I create 2 virtual displays?

I called the function below twice, but only can create one virtual display, the second time it returned "SwDeviceCreate failed with 0x800700b7". Anyone knows how to create second virtual display?
HRESULT hr = SwDeviceCreate(L"IddSampleDriver",
L"HTREE\ROOT\0",
&createInfo,
0,
nullptr,
CreationCallback,
&hEvent,
&hSwDevice);

Cloning/duplicating display doesn't work, resolution messes up

I'm using this to try and get Parsec working on a headless computer, and after installation I set the resolution of the virtual monitor to the same as the monitor I had temporarily attached (1920x1080) and set it to duplicate, as I assumed (wrongly, it appears) that it would need to be that way for it to show the "normal" display on the virtual one for Parsec to use. But every time I try, it just resets it to an extremely low resolution, which makes everything big and messes up all my windows, which are now all resized very small and moved around when I revert back to extended vs duplicated. This is on a fairly recent Win10 ver (21H2 I think) and a GTX 770 with updated drivers outputting via HDMI to a FHD monitor, using the latest version (0.0.1.2) of IddSD.

Driver doesn't work if compiled between 21:00 and 24:00 (local time)

When I compiled the driver sometime between 21:00 and 24:00, building and installation were successful (no problem in device manager) but no virtual display showed up (it disappeared when the driver was updated).
This seemed to happen in every time zome. I live in UTC+9 time zone, and when I set my computer's time zone to UTC, the driver compiled between 6:00 and 9:00 didn't work. I tested some other time zones.
Also, the option /uselocaltime (included in my pull request) seemed irrelevant (it only makes building successful).

We can easily get around this problem by changing the computer's time zone, but I'm curious about why this happens.
Can anyone reproduce this?

Low Performance of just Windows Animations

As the title says, I could for example play intense games at same to normal speeds and such, however just pure windows anims such as opening start or minimizing a window appears very choppy on the real display and vdisplays.

Windows 11 (Stable) 22H2

Moonlight Streaming Alternating Display IDs

Hey! This is a fantastic project and I'm so thankful for it. With that being said, I do not use the virtual monitor as my main display and every time I restart my system the display ID for Sunshine needs to be changed. Is there any way to have a static display ID?

bypass HZ in monitor

hello i was wondering is it possible bypass 500hz? i try increase KHZ/MHZ even clock but without success

the max is 500hz i cant get over that

`const UINT64 MHZ = 10000000000;
const UINT64 KHZ = 10000000000;

constexpr DISPLAYCONFIG_VIDEO_SIGNAL_INFO dispinfo(UINT32 h, UINT32 v, UINT32 r) {
const UINT32 clock_rate = r * (v + 4) * (v + 4) + 10000;
return {
clock_rate, // pixel clock rate [Hz]
{ clock_rate, v + 4 }, // fractional horizontal refresh rate [Hz]
{ clock_rate, (v + 4) * (v + 4) }, // fractional vertical refresh rate [Hz]
{ h, v }, // (horizontal, vertical) active pixel resolution
{ h + 4, v + 4 }, // (horizontal, vertical) total pixel resolution
{ { 255, 0 }}, // video standard and vsync divider
DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE
};
}`

Properly remove and re-install new release

Hi,
I was wanted to create a driver for a custom resolution for my ultra wide. I compiled the code accordingly and installation through device manager works as expected.
However, after I remove the driver using pnputil.exe, everything seems to be alright and the display is removed in the device manager. However, whenever I install a new release I compiled, ad additional monitor is added despite my compiled driver only contains 1 display.

Now I have like 14 monitors in my device manager ๐Ÿ˜ž

Any help is appreciated

Mouse cursor is duplicated (enable/disable hw cursor support?)

Hi!
1st - thanks a lot for this stuff!!! Just saved my remote work!
BUT:
Under NoMachine connected to the station with this driver installed, I get cursor duplicated no matter what I tune up...
I'm not sure, but maybe it's related to the support of hw cursor cursor?
(https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/iddcx/nf-iddcx-iddcxmonitorsetuphardwarecursor )
Is it possible to implement this feature to get rid of this annoying double-cursor issue?

Thanks!

Device manager error

I wonder if anyone else has had issues trying to install this device manually with device manager. I've tried this while running device manager as an administrator and ran the bat file first. Even after rebooting I still get

"An error has occurred during the installation of the device."

I hope something can be done, it'd be lovely to enable a few extra monitors for VR use.

regards

Increase maximum resolution

The max resolution for the virtual monitors appears to be 1080p, is there a way to increase this (eg by editing the inf?)

Any way to change GPU?

So, I have Nvidia RTX 3060 Ti GPU and AMD integrated graphics. I am using driver for moonlight. Actually, driver is using integrated graphics, not my Nvidia GPU. Is there any way change that?

Code 19

I have installed the IddSampleDriver on 2 versions of windows on the same machine, the first one on an original installation of windows worked perfectly, but the second one is a tweaked windows called AtlasOS, and even through all other apps and services have been working so far, the driver install the certificate rightly but when I install it gives me code 19: "Windows cannot start this hardware device because its configuration information (in the registry) is incomplete or damaged. (Code 19)" I have tried to uninstall the driver and install again and many other already given solutions on the others issues but nothing seems to work, and I have no idea on how to make it work as a virtual monitor became basically essential to some of the tasks I do daily, so if anyone can help I'm going to be very happy about it.

Support 3:2 Aspect Ratio Resolutions

I use IddSampleDriver for Moonlight (NVIDIA Game Streaming) from my gaming PC to a Surface Pro 3 which is a 3:2 aspect ratio and 2160x1440 resolution. Unfortunately this is not an option in the resolution list and I have been unable to figure out creating a custom resolution since the option is gone from the NVIDIA Control Panel while my monitor is turned off. Please let me know if there is a way to easily add my own resolution, or if you can release an update with 3:2 resolutions such as 2160x1440, I am willing to donate some ETH.

Missing resolutions

This works well, but I have two issues. I can only scroll through 3 resolutions, 1920x1080, 1024x768, 800x600. I need more, and I think it's available, but for some reason I can't access them, is there a way I can fix this?

Second is, I use this fake virtual display driver so that I can switch off my main display when I'm mirroring it to another one. When the whole screen updates, or when a new window is being drawn, the driver stutters. Why does it stutter? Is that fixable too?

Moonlight Game Streaming (FOSS) - Invitation

Greetings from the Moonlight team over at https://moonlight-stream.org !

We're an open source community supporting a reverse-engineered client for Nvidia's GameStream functionality. One of the team members recently came across this project and we all got very excited.

When people are streaming their desktops, one of the most common problem is that their host displays are turned off, disconnected from the GPU or simply not playing along with Geforce Experience. Usually, the best solution is either leaving the monitor turned on, or buying a HDMI dummy plug. Sometimes this also raises questions about privacy, when their host computer is at home and they don't want other people spying on what they do remotely.

Moreover, second most important issue is that in order to stream HDR content, they must have a HDR-capable physical display connected to their host, even though their client device (such as HDR capable webOS TV's, phones, tablets, etc) supports it.

After some very hyped tests, your solution seems to be very promising, and therefore we'd like to invite you over on our official Discord ( https://moonlight-stream.org/discord ) to get access to a very broad range of systems, configurations and most importantly - very excited testers (over 14500 of them). Hopefully, the devs will also help chip in fixes and PR's. (We have a shiny role ready too)

Looking forward to seeing you there

Wrong refresh rate on multiple monitors

Hi there and thanks for very useful driver.
I'm using it in a QEMU-KVM linux virtualized environment where there is a Win11 guest with gpu passthrough.
A cable from the VGA output displays directly the virtual machine, while i'm using the created "virtual monitor" attached to "looking glass" so that i can extend the monitor to the host one.
Everything works correctly except for the refresh rate of the virtual monitor that should be at a144hz but is capped at 60hz (that is the refresh rate of the physical monitor).
If i exclude the physical monitor, and use the virtual one only the refresh rate is correctly set to 144hz (i can spot the difference from 60hz).
Is there any clue on this?
Thanks for your attention

Best regards

touchscreen monitor

is it possible to create a virtual monitor with touch screen?, will be greatly useful when streaming with tablet

Looking-Glass not showing screen until external monitor connected.

As the title hints. Looking-Glass only starts showing the screen when an external monitor is connected. After the initial connection is done I can unplug the monitor and quit and start Looking-Glass as many times I want and it will work. It just doesn't work for the initial connection somehow.

(Here what it looks like before connecting the external monitor)
image

How to uninstall?

Having five virtual displays is too much for me, and I am unable to uninstall them. Is there any solution?

not able to remove the monitor created

I'm not able to unistall the virtual monitor i've created, i could only "disconnect the display" but i'd like to know the procedure to remove it completly

BAT file

The BAT file doesn't work because it contains an error:
./CertMgr.exe /add IddSampleDriver.cer /s /r localMachine root
It should be .\ instead of ./
So the full working command is:
.\CertMgr.exe /add IddSampleDriver.cer /s /r localMachine root

some problems

  1. I set the virtual display resolution to my desired resolution, but the resolution is always reset when the computer reboots.

  2. If i install more than one virtual display using option.txt, it feels like Windows is lag. For example, when i open or close a folder window, it will be in slow motion. However, if i just install each virtual display separately, no lag occurs.

Notes on installation

Certificates

You certainly don't need certmgr.exe to install the certificates (I'm not even sure if you are even allowed to bundle that). Here is a command that equivalently works using builtin Windows commands:

certutil -addstore -f root IddSampleDriver.cer
certutil -addstore -f TrustedPublisher IddSampleDriver.cer

@roshkins Please remove certmgr.exe next time. You can replace the contents of installCert.bat with this:

@echo off

set CERTIFICATE="%~dp0IddSampleDriver.cer"

certutil -addstore -f root %CERTIFICATE%
certutil -addstore -f TrustedPublisher %CERTIFICATE%

pause

Silent installation

I have found out that nefcon allows you to do this, adding the proper device node and then installing the driver all in the command line (Perhaps I can use devcon to do this, but they don't provide publically available binaries and bundle it instead in the WDK). Example:

# alternatively you can use nefconw for no output
nefconc --create-device-node --hardware-id ROOT\iddsampledriver --class-name Display --class-guid 4d36e968-e325-11ce-bfc1-08002be10318
nefconc --install-driver --inf-path IddSampleDriver.inf

Installation Script

Now we can combine both of those to provide a single, easy-to-use script that sets up everything for you:

# Install certificates
certutil -addstore -f root IddSampleDriver.cer
certutil -addstore -f TrustedPublisher IddSampleDriver.cer

# Copy option.txt to C:\IddSampleDriver if it does not exist
if (!(Test-Path "C:\IddSampleDriver\option.txt")) {
    Write-Host -Foreground Yellow "'C:\IddSampleDriver\option.txt' not found. Creating..."
    mkdir -force "C:\IddSampleDriver" | Out-Null
    Copy-Item -Path option.txt -Destination "C:\IddSampleDriver"
}

# Install driver
nefconw --create-device-node --hardware-id ROOT\iddsampledriver --class-name Display --class-guid 4d36e968-e325-11ce-bfc1-08002be10318
nefconw --install-driver --inf-path IddSampleDriver.inf

I have added @ge9's IddSampleDriver to Scoop (ScoopInstaller/Nonportable#26). Installation is as easy as doing scoop bucket add nonportable and scoop install iddsampledriver-ge9-np -g in an elevated prompt. If anyone is interested in making a Chocolatey package, feel free to look here.

Ping @ge9, can you open the issues tab on your fork? People shouldn't be reporting installation issues from your fork in here.

Moonlight Performance

Hi there, thank you for this driver this will ideally solve one of the problems I am experiencing with gamestreaming at custom resolutions.

A problem I am having is that when streaming to moonlight using the virtual display vs a hardware display there is a noticeable drop in performance (120fps to around 20/30fps). The display also isn't being shown in Nvidia control panel and I am wondering if the two are linked (perhaps the GPU isn't being utilized correctly?). I am aware you may be working with the moonlight devs at the moment, have you found a fix for this?
Many thanks

The driver do not work on win 2016 server?

I build this driver with _NT_TARGET_VERSION Windows 10.0.14393, UMDF version 2.19 and IddCx version 1.2, it works on my win10 desktop. When I try to install the driver on win 2016 server, the driver is failed to load and error is CM_PROB_FAILED_ADD in system log.

I try to windbg and confirm that DllMain is called with true returned, then blocked with this call stack:

0:007> g
UMDF: User-mode debugger found - breaking in.
(1b18.17d4): Break instruction exception - code 80000003 (first chance)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\System32\KERNELBASE.dll - 
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\SYSTEM32\WUDFPlatform.dll - 
KERNELBASE!DebugBreak+0x2:
00007ffa`007a6142 cc              int     3
0:005> g
ModLoad: 00007ff9`f73c0000 00007ff9`f7552000   C:\Windows\System32\dbghelp.dll
Wudfx2000: FxDriverEntrydUm Enter PDRIVER_OBJECT_UM 0x0000019F78ADA4D0
ModLoad: 00007ff9`ebbb0000 00007ff9`ebc46000   C:\Windows\System32\WUDFx02000.dll
Wudfx2000: FxDriverEntryUm: PDRIVER_OBJECT_UM 0x0000019F78ADA4D0 Successfully bound to version library
ModLoad: 00007ff9`f3a10000 00007ff9`f3a3b000   C:\Windows\System32\drivers\UMDF\IddCx.dll
ModLoad: 00007ffa`00a10000 00007ffa`00bd9000   C:\Windows\System32\CRYPT32.dll
ModLoad: 00007ff9`ffc80000 00007ff9`ffc90000   C:\Windows\System32\MSASN1.dll
ModLoad: 00007ffa`009b0000 00007ffa`00a05000   C:\Windows\System32\WINTRUST.dll
UMDF: Breaking on load of module IddCx.dll
UMDF: Waiting 15 seconds for debugger to attach.
UMDF: User-mode debugger found - breaking in.
(1b18.17d4): Break instruction exception - code 80000003 (first chance)
KERNELBASE!DebugBreak+0x2:
00007ffa`007a6142 cc              int     3
0:005> g
Wudfx2000: FxDriverEntrydUm Enter PDRIVER_OBJECT_UM 0x0000019F78AE4DB0
Wudfx2000: FxDriverEntryUm: PDRIVER_OBJECT_UM 0x0000019F78AE4DB0 Successfully bound to version library
Wudfx2000: FxDriverEntryUm: PDRIVER_OBJECT_UM 0x0000019F78AE4DB0 Successfully bound to class library if present
Wudfx2000: FxDriverEntryUm: PDRIVER_OBJECT_UM 0x0000019F78AE4DB0 Successfully returned from driver's DriverEntry
(1b18.17d4): C++ EH exception - code e06d7363 (first chance)
FxStubBindClasses: VersionBindClass WDF_CLASS_BIND_INFO 0x00007FF9F6FEFB90, class IddCx, returned status 0xc000000d
(1b18.17d4): C++ EH exception - code e06d7363 (first chance)
Breakpoint 0 hit
IddSampleDriver!DllMain:
00007ff9`f6fd4ad0 4c89442418      mov     qword ptr [rsp+18h],r8 ss:0000006a`1acfecc0=0000019f78aca7e0
0:005> g
ntdll!NtWaitForWorkViaWorkerFactory+0x14:
00007ffa`03848634 c3              ret
0:002> g
       ^ No runnable debuggees error in 'g'
0:002> g
       ^ No runnable debuggees error in 'g'

It seems DriverEntry was called, but the breakpoint IddSampleDriver!DriverEntry not triggered.
I read the following article of msdn but don't what to do next.
https://learn.microsoft.com/en-us/windows-hardware/drivers/wdf/determining-why-the-umdf-driver-fails-to-load-or-the-umdf-device-fails

Broken not working

V0.0.1.3 windows 10 64bit

Installed using scoop, elevated command prompt, options set to 3 monitors, device manager shows adapter but even after restart windows new monitors do not show in Intel graphics settings nor the native windows display settings.

Broken. Doesn't work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.