Maassoft / ColorControl

Easily change NVIDIA display settings and/or control LG TV's
GNU General Public License v3.0
937 stars 42 forks source link

Can't set dither registry key, subkeys missing #425

Open PhantomGamers opened 1 week ago

PhantomGamers commented 1 week ago

Clicking Set dither registry key under Settings -> Test dithering results in the following exception:

Exception in thread: Requested registry access is not allowed.
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
   at ColorControl.Services.NVIDIA.NvService.SetDitherRegistryKey(String displayRegId, UInt32 state, UInt32 bits, UInt32 mode) in .\Services\NVIDIA\NvService.cs:line 780
   at ColorControl.Services.NVIDIA.NvService.SetDithering(NvDitherState state, UInt32 bits, UInt32 mode, NvPreset preset, Display currentDisplay, Boolean setRegistryKey, Boolean restartDriver) in .\Services\NVIDIA\NvService.cs:line 887
   at ColorControl.Services.NVIDIA.NvDitherPanel.ApplyDitheringOptions(Boolean setRegistry, Boolean restartDriver) in .\Services\NVIDIA\NvDitherPanel.cs:line 109
   at ColorControl.Services.NVIDIA.NvDitherPanel.btnSetRegistryKey_Click(Object sender, EventArgs e) in .\Services\NVIDIA\NvDitherPanel.cs:line 160
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
   at ColorControl.Program.GlobalThreadExceptionHandler(Object sender, ThreadExceptionEventArgs e) in .\Program.cs:line 432
   at ColorControl.MainWorker.DoWork() in .\MainWorker.cs:line 70
   at ColorControl.Program.RunApp(String[] args) in .\Program.cs:line 161
   at ColorControl.Program.MainAsync(String[] args) in .\Program.cs:line 77
   at ColorControl.Program.Main(String[] args) in .\Program.cs:line 56

The exception points to this line https://github.com/Maassoft/ColorControl/blob/6f4b1e97790aae9c74593db0a8ca5c87cccf0cf2/ColorControl/Services/NVIDIA/NvService.cs#L780

Following the registry path set in the previous line to that SYSTEM\\CurrentControlSet\\Services\\nvlddmkm\\State\\DisplayDatabase, I see that on my machine this path has no subkeys.

Also I can only get this error when manually launching ColorControl as admin, using any of the alternative elevation methods (run as admin, windows service, dedicated elevated process) in the options just gives the following generic error with nothing actually showing up in the log: image

EDIT: Also if it's relevant I'm running Windows 11 23H2 build 22635.4300 with geforce driver version 565.90

Maassoft commented 1 week ago

That's strange. So you don't have any subkey (display) under the "DisplayDatabase" key, like this:

image

Do you have another display adapter (integrated graphics) and have connected the display to that?

Btw, the message "Requested registry access is not allowed" suggests that it doesn't have sufficient rights to open the key. Which is strange because the code is always executed with higher privileges (administrator). If you look in the Registry Editor at the Permissions on the "DisplayDatabase" key (right click), Is the Administrators group present with at least Read rights?

PhantomGamers commented 1 week ago

That's strange. So you don't have any subkey (display) under the "DisplayDatabase" key, like this:

Correct

image

Do you have another display adapter (integrated graphics) and have connected the display to that?

So my main setup is having my primary display connected to my nvidia gpu, and then I do have a 2nd display connected to my IGP. However I also tried connecting both displays to my gpu and restarting my system and the subkeys still were not populated.

If you look in the Registry Editor at the Permissions on the "DisplayDatabase" key (right click), Is the Administrators group present with at least Read rights?

This is what the permissions look like for that key image

Btw, the message "Requested registry access is not allowed" suggests that it doesn't have sufficient rights to open the key.

I initially believed this message is just misleading and that the error is caused by the fact that there are no subkeys in that path, so OpenSubKey fails.