RivaTuner Statistics Server 7.3.3 incompatible with latest MS PowerToys (v0.58.0)

Discussion in 'Rivatuner Statistics Server (RTSS) Forum' started by r01100011, May 4, 2022.

Tags:
  1. r01100011

    r01100011 Guest

    Messages:
    3
    Likes Received:
    0
    GPU:
    MSI GeForce 3080Ti
  2. Astyanax

    Astyanax Ancient Guru

    Messages:
    17,011
    Likes Received:
    7,353
    GPU:
    GTX 1080ti
    Just another app that doesn't need overlay hooking and experiences issues with globals,
     
  3. r01100011

    r01100011 Guest

    Messages:
    3
    Likes Received:
    0
    GPU:
    MSI GeForce 3080Ti
    So the issue is with PowerToys, and not RTSS?
     
  4. Andy_K

    Andy_K Master Guru

    Messages:
    842
    Likes Received:
    240
    GPU:
    RTX 3060
    Running MSI AB 4.6.4 (build 16255), RTSS 7.3.4 beta 1 and Powertoys 0.58.0 on Windows 10.0.19044.1645 64bit
    Having 3D detection exclusions in RTSS for
    • PowerToys.ColorPickerUI.exe
    • PowerToys.exe
    • PowerToys.FancyZones.exe
    • PowerToys.Settings.exe

    Added those exclusions by shift+click "Add"-button in RTSS to get all detected running active 3D apps. Really easy to do.

    MSI AB, RTSS and PowerToys are running elevated.
    No issues at all.
    PowerToys and settings page working as intended

    Is there a way to add something like PowerToys.* exclusion maybe even per default?
     
    boogieman likes this.

  5. Astyanax

    Astyanax Ancient Guru

    Messages:
    17,011
    Likes Received:
    7,353
    GPU:
    GTX 1080ti
    Unwinder has to repackage the installer with the appname.exe.cfg profiles included in the profiletemplates directory.
     
  6. Andy_K

    Andy_K Master Guru

    Messages:
    842
    Likes Received:
    240
    GPU:
    RTX 3060
    That wasn't my point and I know it, my question was if there is a way to have an exclusion with a wildcard (*) so you do not to have exclude every single one.
    Could be neat, because of every tool there is and that will be added in the future begins with PowerToys.*
     
    r01100011 likes this.
  7. Astyanax

    Astyanax Ancient Guru

    Messages:
    17,011
    Likes Received:
    7,353
    GPU:
    GTX 1080ti
    no, nor should there be.
     
  8. r01100011

    r01100011 Guest

    Messages:
    3
    Likes Received:
    0
    GPU:
    MSI GeForce 3080Ti
    This would be very helpful.
     
  9. JackTheDipper

    JackTheDipper Guest

    Messages:
    2
    Likes Received:
    1
    GPU:
    Nvidia GTX
    I'm probably not the last person to run into this so here's an alternative and easy to update way to add the exceptions:
    1. Open Windows PowerShell as Admin
    2. Run following script

    Code:
    Set-Location "C:\Program Files (x86)\RivaTuner Statistics Server\ProfileTemplates"
    
    New-Item -Path . -Name "PowerToys.AlwaysOnTop.exe.cfg" -ItemType "file" -Value "[Hooking]
    EnableHooking        = 0"
    
    New-Item -Path . -Name "PowerToys.ColorPickerUI.exe.cfg" -ItemType "file" -Value "[Hooking]
    EnableHooking        = 0"
    
    New-Item -Path . -Name "PowerToys.exe.cfg" -ItemType "file" -Value "[Hooking]
    EnableHooking        = 0"
    
    New-Item -Path . -Name "PowerToys.FancyZones.exe.cfg" -ItemType "file" -Value "[Hooking]
    EnableHooking        = 0"
    
    New-Item -Path . -Name "PowerToys.Settings.exe.cfg" -ItemType "file" -Value "[Hooking]
    EnableHooking        = 0"
    
    
     
    Last edited: May 6, 2022
    Astyanax likes this.
  10. Unwinder

    Unwinder Ancient Guru Staff Member

    Messages:
    17,127
    Likes Received:
    6,691
    Finally had a chance to look into it. It is nether 3D API hook incompatibility nor fundamental WinUI3 incompatibility. PowerToy's new WinUI3 settings GUI seem to be initialized in limited stack space conditions causing a few nested CBT hook handlers to overflow it. There is nothing much I can do to solve it besides adding it to built-in exceptions list.

    There is a way to do so, profile mapper can use wildcards. It is defined in ProfileMap entry located in [Settings] section of .\ProfileTemplates\Config. However, it is not the best idea to use wildcards and profile mapper for this specific case - profile mapper entry is being processed in context of ANY process when it starts, so each extra item added there eats a bit of application startup performance. So it should be as short as possible and shouldn't contain anything, that can be defined with finite profiles list. So I'll just add those 4 profiles instead. Also, it is probably a good idea to add WinUI3 framework libs as injection ignore triggers similar to WPF framework libs listed there.
     
    Last edited: May 24, 2022
    Andy_K and blurp33 like this.

  11. beeradmoore

    beeradmoore New Member

    Messages:
    4
    Likes Received:
    2
    GPU:
    MSI Gaming X 4090
    Hey Unwinder. Sorry for the thread bump but this seems related to the above. I am a developer for DLSS Swapper, a WinUI based application for swapping upgraded DLSS dlls into games. I recently came across some users reporting issues where RTSS was causing the app not to launch. After digging around I came across the original post of PowerToys linked above, as well as a few other WinUI3 apps (eg. EarTrumpet).

    I went to check release notes to see if it is a known issue but instead I see that you are not only aware of the issue but have fixed it.

    I double checked with my users and they seem to have the latest version of RTSS installed so the fix should be in place. I was not able to replicate the issue, and the only common thread between these users was they were using Windows in Chinese language (I even tried to replicate this). It is hard to tell if the launch failures are intermittent, or if I am not getting clear info when the sample size is 2 -_-.

    Aside from creating a FAQ myself with some instructions on how to manually add `DLSS Swapper.exe` to the ignore list in RTSS, is there anything that you can think of from your side why this may still be happening?

    I can see you have Microsoft.WinUI.dll on the InjectionIgnoreTriggers and confirmed this is the exact file my app is loading. Should that hook ignore any app that uses that dll? Using ProcessExplorer I can see RTSSHooks64.dll is loaded in my application, I assume this means it is indeed still hooking?

    (EDIT: holding shift while I click Add in RTSS does not show DLSS Swapper as an application to add, so I guess on my machine it is not being hooked)

    (EDIT 2: Second PC I did the same and DLSS Swapper does appear in the shift+add list. Both running Windows 11 :|, both running RTSS 7.3.4)

    Aside from asking very nicely if we could get a `DLSS Swapper.exe.cfg` to ignore this app out of the box, is there anything I can do on my side to try prevent the hook happening?

    Thanks for your time.
     
    Last edited: Jul 20, 2023
  12. Unwinder

    Unwinder Ancient Guru Staff Member

    Messages:
    17,127
    Likes Received:
    6,691
    Sure, I can add DLSS Swapper.exe.cfg to default built-in exclusions list. You can also prevent your application from hooking via declaring the following export in your executable:

    // extern "C"
    // {
    // __declspec(dllexport) DWORD RTSSHooksCompatibility = 0x00000000;
    // }

    It entirely depends on hooked application behavior. A module listed inside InjectionIgnoreTriggers will only prevent RTSS from hooking the process if the trigger module is loaded into target process context _before_ loading Direct3D runtimes. If the process does something causing Direct3D runtimes to be loaded and hooked inside it before loading trigger module - it won't have any effect and won't prevent hooking. And no, just seeing RTSSHooks64.dll loaded into the application doesn't mean that it is still hooking it. It is the way CBT hooks work.
     
    Last edited: Jul 20, 2023
    beeradmoore likes this.
  13. beeradmoore

    beeradmoore New Member

    Messages:
    4
    Likes Received:
    2
    GPU:
    MSI Gaming X 4090
    Hey Unwinder, sorry for the late reply, I didn't get an email so wasn't sure there was any reply. Happened to look for this again after another user just reported the issue.

    Thanks for adding us to the exclusions list. I'll also look at adding that code to prevent hooks, if not to help those who don't have an RTSS update but also to help others browsing for solutions in their own apps to try come across a fix without having to get put onto the exclusions list as well.

    EDIT: DLSS Swapper is written in .NET. Looks like around the time of .NET 5 MS thought about adding a DllExport attribute but it doesn't seem like it ever got added. There are some other libraries that seem to say they add it but I am seeing a lot of people saying it no longer works. So I'll dig deeper into that.

    I assume the answer is yes, but checking just in case, does the export need to be in the main executable? EG if I made a DLSS Swapper.dll that had RTSSHooksCompatibility in it and the main executable loaded that, I assume that won't work.
     
    Last edited: Oct 19, 2023
  14. Unwinder

    Unwinder Ancient Guru Staff Member

    Messages:
    17,127
    Likes Received:
    6,691
    Export needs to be inside the executable of course.
     
  15. beeradmoore

    beeradmoore New Member

    Messages:
    4
    Likes Received:
    2
    GPU:
    MSI Gaming X 4090
    I managed to get it working, thanks for the info. Threw the sample up here. Now to see if I can enable this for my WinUI app.

    Out of curiosuty if someone adds the RTSSHooksCompatibility link in the above sample game, is it possible from RTSS to force override and hook that application anyway or will it always stop once it finds that? Manually adding my sample game to RTSS didn't seem to make it want to show overlays again.
     

  16. Unwinder

    Unwinder Ancient Guru Staff Member

    Messages:
    17,127
    Likes Received:
    6,691
    Yes, it is possible to override it via setting ForceHooking=1 in [Hooking] section in desired profile or globally.
     
  17. beeradmoore

    beeradmoore New Member

    Messages:
    4
    Likes Received:
    2
    GPU:
    MSI Gaming X 4090
    Thanks for the quick response. Updated my repo to include that for people who may need it.
     
    Dan Longman and Unwinder like this.

Share This Page