Hook into Windows desktop

  • pneumatic
  • Topic Author
More
7 years 6 months ago #1 by pneumatic Hook into Windows desktop was created by pneumatic
Is there any chance to hook ReShade into the windows desktop? I want to inject CustomFX(grain, colorcorrection) into the desktop for calibrating monitors with Nvidia GPUus to correct the horrible banding artefacts. It works perfectly for games (huge thanks to Marty McFly!) just need it at the desktop too!

Also want to write my own shader that takes screen uniformity measurements from DispcalGUI to correct the colour uniformity of the screen.

I notice DXTory (or was it Fraps?) is able to overlay a FPS counter onto the desktop, so it seems to be possible in theory.
Here is a library that may offer some help
github.com/DarthTon/Xenos

Please Log in or Create an account to join the conversation.

  • pneumatic
  • Topic Author
More
7 years 6 months ago #2 by pneumatic Replied by pneumatic on topic Hook into Windows desktop
So the desktop window manager (windows\system32\dwm.exe) is the process which does all the desktop compositing in DX9. Does that mean I can install ReShade files to the system32 folder , replacing the d3d9.dll in system32 folder with the ReShade one?

I'm thinking it will not work and break something :lol:

Might have to backup my computer first and then try replacing the files in safe mode or something.

Would be so awesome if it worked 3d LUT calibration with dithering on everything, and even the future possibility of screen uniformity correction.

Please Log in or Create an account to join the conversation.

  • JBeckman
More
7 years 6 months ago - 7 years 6 months ago #3 by JBeckman Replied by JBeckman on topic Hook into Windows desktop
You don't want to replace the core d3d9.dll, dxgi,dll or opengl32.dll files in the Windows folder, ever. :)
(It'll break DirectX after all - or OpenGL if that's the file you were to replace. - and the DirectX runtime setup from MS only adds the supplementary files whereas these core files require a full OS reinstall to correct if dism or sfc can't restore them properly.)
Last edit: 7 years 6 months ago by JBeckman.

Please Log in or Create an account to join the conversation.

  • crosire
More
7 years 6 months ago #4 by crosire Replied by crosire on topic Hook into Windows desktop
It will break ReShade too. Never ever replace the system DLLs.
The desktop is not rendered via 3D acceleration, so ReShade cannot hook into it.

Please Log in or Create an account to join the conversation.

  • pneumatic
  • Topic Author
More
7 years 6 months ago - 7 years 6 months ago #5 by pneumatic Replied by pneumatic on topic Hook into Windows desktop
Thanks, I will not be messing with those files anytime soon :)

But crosire, are you sure about that because here it says Desktop Window Manager uses DirectX9: en.wikipedia.org/wiki/Desktop_Window_Manager

Since dwm.exe resides in /system32 I presume it uses the d3d9.dll's in there too?

And here is a video where you can see Fraps can overlay its FPS meter onto the Aero desktop which means it is somehow getting its hooks into dwm.exe .



If only there was a way to hook reshade in too!

edit: maybe it's not getting a hook, just "always on top" :oops:
Last edit: 7 years 6 months ago by pneumatic.

Please Log in or Create an account to join the conversation.

  • JBeckman
More
7 years 6 months ago #6 by JBeckman Replied by JBeckman on topic Hook into Windows desktop
Fraps, MSI Afterburner or any other overlay using a exe would work since they could target explorer.exe without needing to replace the core DirectX .dll files.

If made compatible with it the "AppInit" (I think that's what it's called.) global injection method would also work without replacing system files but it requires a very well maintained blacklist or a strict whitelisting system since you do not want ReShade to inject into every single process in Windows not to mention any other application on the system since ReShade32.dll or ReShade64.dll would otherwise always be loaded into a application as it was started.
(GeDoSaTo uses this via a whitelist only system as if it's newer versions.)

Has other drawbacks too such as potentially triggering SecureBoot functionality of modern UEFI bioses to block the injection unless disabled.

Please Log in or Create an account to join the conversation.

  • NoMansReshade
More
7 years 4 months ago #7 by NoMansReshade Replied by NoMansReshade on topic Hook into Windows desktop
I managed to created a dummy D3D9 Application that reshade can hook into. Working on making shaders actually show up :P

The following user(s) said Thank You: brucethemoose, Snoutie, kikhyc

Please Log in or Create an account to join the conversation.

  • Martigen
More
7 years 4 months ago #8 by Martigen Replied by Martigen on topic Hook into Windows desktop
I might actually use this :) Just started watching a show (Con Man -- great!) bought on Steam, and there's no way to improve Steam's streaming player as far as I can tell at the moment, but injecting Resahde to desktop would solve that.

Please Log in or Create an account to join the conversation.

  • v00d00m4n
More
7 years 2 months ago #9 by v00d00m4n Replied by v00d00m4n on topic Hook into Windows desktop
google for windows shim engine and app compat toolkit, you can re-route dwm.exe and explorer.exe to reshade dll outside of system folder.

Please Log in or Create an account to join the conversation.

  • NoMansReshade
More
7 years 2 months ago #10 by NoMansReshade Replied by NoMansReshade on topic Hook into Windows desktop

v00d00m4n wrote: google for windows shim engine and app compat toolkit, you can re-route dwm.exe and explorer.exe to reshade dll outside of system folder.


How would we hook into it correctly, though? "dwm.exe" Uses no frameworks such as OpenGL, or DirectX.

Please Log in or Create an account to join the conversation.

  • v00d00m4n
More
7 years 2 months ago #11 by v00d00m4n Replied by v00d00m4n on topic Hook into Windows desktop
oops, my bad. Just checked with pe analyzer, and it seems like it does rendering via:
api-ms-win-dx-d3dkmt-l1-1-0.dll

I cant find much of information about it, and I cant even find this dll in windows folder, similar api-ms*.dll files has small size of 3-5 kb and it seems like it some sort of api set stub and something like symlinks references that windows re-routes to actual api components, or actuelly traces to kernel. Need to check with debugger to get better idea of how it works. There is no info on MSDN about that, looks like it one of things MS use internally and does not talk much about.

Please Log in or Create an account to join the conversation.

  • v00d00m4n
More
7 years 2 months ago #12 by v00d00m4n Replied by v00d00m4n on topic Hook into Windows desktop

NoMansReshade wrote: I managed to created a dummy D3D9 Application that reshade can hook into. Working on making shaders actually show up :P

btw, its quite a good idea.

You can try to "catch desktop" and "render it" in borderless window on top of actual desktop, but you need to figure out how to solve "top window" problem and makes it act like it not exist or inactive, so that all of windows bellow could get input.

Please Log in or Create an account to join the conversation.

  • LegoPepper
More
6 years 10 months ago #13 by LegoPepper Replied by LegoPepper on topic Hook into Windows desktop

NoMansReshade wrote: I managed to created a dummy D3D9 Application that reshade can hook into. Working on making shaders actually show up :P

Sorry for the bump, but did you get anywhere with this?

Please Log in or Create an account to join the conversation.

  • Muf
More
6 years 10 months ago #14 by Muf Replied by Muf on topic Hook into Windows desktop
OBS-Classic is able to hook into the DWM on Windows 7. I'm not sure how much has changed between 7 and 10, but that could be a helpful starting point since OBS is open source. I think it might be a bit outside of ReShade's scope though, so it might be better to start a new project focused on providing 3DLUT / colour management on the desktop for Windows using DWM hooking.

Please Log in or Create an account to join the conversation.

  • miwalker
More
5 years 6 months ago - 5 years 6 months ago #15 by miwalker Replied by miwalker on topic Hook into Windows desktop
I manged to (sort-of) accomplish by injecting the latest reshade into the latest version of obs studio. Reshade came up, and shaders appeared to be working fine. I then used a program called WindowsTop to make the capture window stay on top and enable click through input. The only issue is, when attempting to create a fullscreen capture with resahde, I get extreme visual glitches using Reshade making it nearly impossible to actually use. So it works, but not that well. Maybe someone else can use this information to figure something else out.

EDIT: Actually, I figured out why there were so many visual glitches when attempting to use resahde on a window that was being captured onto that same window, it's simply because reshade is reshading itself infinitely. This works just like the "inception" effect of obs or any screen recording, when the display is displaying itself displaying itself...and so on. So it's sorta like stacking a million shaders over themselves, it looks like a garbled, distorted, ultra sharpened mess. Cool for random visuals though haha.

So there are two options.

1:Get a second monitor and create a display capture, fullscreen it, drag it over to your main monitor, use WindowTop to make it on top and click-through, then drag your mouse to your other monitor to use your cursor properly. It actually works. Too bad my other monitor is 1080p and my main is 1440p, so the image quality is garbage.
2: Simply use OBS's window capture function, and do the same steps as number 1. Although in this case, there appears to be quite apparent visual compression of the capture, so even though this will technically let you use reshade on a capture that is on the same screen it is capturing, it doesn't look that great tbh. Also, another drawback is that you are limited to only that window having reshade applied to it, not the whole actual desktop unlike the first option.

So in conclusion, it's not that great, but it's definitely the closest of gotten to be able to sue reshade over my desktop or non game/video applications (Firefox looked dope with some FilmicPass haha).
Last edit: 5 years 6 months ago by miwalker. Reason: New information discovered.
The following user(s) said Thank You: kikhyc

Please Log in or Create an account to join the conversation.

  • Shady
More
4 years 7 months ago #16 by Shady Replied by Shady on topic Hook into Windows desktop
Can somebody post the app code on github for desktop catch and render with reshade? I want to use it for netflix stream video improvement with deband, gamma, contrast and sharpen.

Please Log in or Create an account to join the conversation.

  • Aelius Maximus
More
4 years 7 months ago - 4 years 7 months ago #17 by Aelius Maximus Replied by Aelius Maximus on topic Hook into Windows desktop
I've been doing this on and off for years using OBS classic 64 bit in Windows 7, using it to capture the desktop and various games and apps (Forza Gears of War 4 etc) that dont work with reshade (also providing you run everything in window mode (any exclusive fullscreen apps are obviously going to block the OBS being viewed). Its easy providing you have 2 displays, i am capturing my desktop which i've moved to my old 1080p display and viewing it on my 4k display (with the only app being OBS on the 4k display) using "monitor capture" and moving all other windows over to the 1080p display, if image quality is a problem the trick is to use a downsampled resolution for the 1080p resolution display using nvidia custom resolution, so i have the 1080p capture upscaled to 4k to match the display im viewing OBS on (the upscaled display should now show up as a 3840 x 2160 monitor in OBS). Here is a side by side (original on left) screenshot of discord with a few tonemaps and sharpening filters turned on.

Last edit: 4 years 7 months ago by Aelius Maximus.
The following user(s) said Thank You: Fu-Bama, kikhyc

Please Log in or Create an account to join the conversation.

  • kikhyc
More
3 years 11 months ago #18 by kikhyc Replied by kikhyc on topic Hook into Windows desktop
huge bump here, but i can't stress enough how much this is what i have been looking for, for ages: something that would allow me to hook shaders to windows desktop (i.e. on top of everything, which includes desktop/browsing/youtube/netflix/VLC/gaming/etc).

now I read that Aelius Maximus, NoMansReshade, or miwalker, all have some possible solutions but I couldn't find anything for someone beginner.
Also, it doesn't look like the proposed current solution (OBS) would be applied to fullscreen apps (such as games) as well, and that a second monitor is needed.
Which basically defeats the initial purpose.

I also found out some C++ functions (GetDC and Bitblt) that would allow me to do that, but same issue as stated below: it does this inception effects and won't work on same monitor...

Isn't there any other way to do that ? by doing the visual changes to the source, before displaying it + excluding the result from being considered as the source again (to avoid the inception loop)...

Thanks in advance for any help anyone can provide!

Please Log in or Create an account to join the conversation.

  • Shregg
More
3 years 1 month ago #19 by Shregg Replied by Shregg on topic Hook into Windows desktop
I too would love to know if there's been any breakthroughs on this.

Please Log in or Create an account to join the conversation.

  • dogelition
More
3 years 2 weeks ago #20 by dogelition Replied by dogelition on topic Hook into Windows desktop
It's not exactly ReShade, but I managed to make DLL that applies a 3D LUT to the Windows Desktop. Only works with the (as of today) latest Windows 10 update and with a single monitor.

Source code, instructions and the compiled DLL can be found here .

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.