Artemis-RGB / Artemis.Plugins

Repository containing official Artemis plugins
Other
31 stars 36 forks source link

Logitech G HUB Update breaks Plugin - Failed to initialize Logitech-SDK. #159

Closed Xyaren closed 1 year ago

Xyaren commented 1 year ago

On both my and my friends computer the Logitech plugin stopped loading with the following exception:

System.AggregateException: One or more errors occurred. (RGB.NET threw exception: Failed to initialize Logitech-SDK.)
 ---> Artemis.Core.ArtemisPluginException: RGB.NET threw exception: Failed to initialize Logitech-SDK.
 ---> RGB.NET.Core.RGBDeviceException: Failed to initialize Logitech-SDK.
   --- End of inner exception stack trace ---
   at Artemis.Core.Services.RgbService.AddDeviceProvider(IRGBDeviceProvider deviceProvider) in D:\a\1\s\Artemis\src\Artemis.Core\Services\RgbService.cs:line 201
   at Artemis.Plugins.Devices.Logitech.LogitechDeviceProvider.Enable() in D:\a\1\s\Artemis.Plugins\src\Devices\Artemis.Plugins.Devices.Logitech\LogitechDeviceProvider.cs:line 38
   at Artemis.Core.PluginFeature.InternalEnable() in D:\a\1\s\Artemis\src\Artemis.Core\Plugins\PluginFeature.cs:line 178
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(TimeSpan timeout)
   at Artemis.Core.PluginFeature.SetEnabled(Boolean enable, Boolean isAutoEnable) in D:\a\1\s\Artemis\src\Artemis.Core\Plugins\PluginFeature.cs:line 151
   at Artemis.Core.Services.PluginManagementService.EnablePluginFeature(PluginFeature pluginFeature, Boolean saveState, Boolean isAutoEnable) in D:\a\1\s\Artemis\src\Artemis.Core\Services\PluginManagementService.cs:line 660

Artemis Build: 20221114.1 LGHUB: 2022.11.345634

We tried reinstalling LGHUB with intermittent restarts, but no chance.

diogotr7 commented 1 year ago

We discussed this in the Discord, several users are experiencing this. We think Logitech broke the SDK with the latest SDK. I've managed to fix it on my machine:

  1. Open Regedit
  2. Paste this in the bar Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{a6519e67-7632-4375-afdf-caa889744403}\ServerBinary
  3. Change the default value to C:\ProgramData\LGHUB\depots\148856\core\sdks\sdk_legacy_led_x64.dll

Note that the old version of the dll I have in that depots path might be different for you. The general idea is to tell the SDK to use an older DLL instead of the most recent one.

Xyaren commented 1 year ago

So for me that would be C:\Program Files\LGHUB\sdks\sdk_legacy_led_x64.dll ?

Discord Discussion: https://discord.com/channels/392093058352676874/1050193328752308284

diogotr7 commented 1 year ago

No, that is the most recent version. Look in that depots file for another one. I meant that the depot number might differ, i'm not sure.

Xyaren commented 1 year ago

Interesting. Does Logitech actually deploy two different versions of the sdk or is this some kind of "backup" folder ? For me the path is C:\ProgramData\LGHUB\depots\155943\core\sdks\sdk_legacy_led_x64.dll

diogotr7 commented 1 year ago

I'm not sure. My guess is that it has to do with updating. Perhaps when it updates, it leaves those files there.

Xyaren commented 1 year ago

Quick Update from the Discord: My DLL did not work.

After downloading the one from the discord discussion it, and storing the path in the mentioned registry key, it is working again.

robercy commented 1 year ago

Hello, @Xyaren. Can you share the correct DLL ? Thanks.

Xyaren commented 1 year ago

sdk_legacy_led_x64.zip (Zipped because you can't upload .dll files) Version: 9.2.6382.0 Signed on ‎‎21. October ‎2022 22:46:54

RobertBeekman commented 1 year ago

I've contacted Logitech about the issue, hopefully they reply!

robercy commented 1 year ago

Thanks, @Xyaren. You rocks !!

KonradStuewe commented 1 year ago

Latest G HUB update broke the plugin for me again. 2023.1.364016 Could fix it by following the instructions posted by diogotr7.

DragRedSim commented 1 year ago

I have a suspicion on this; I was having this issue, and prepared an older version of the SDK. The first thing I tried was changing the value of the Artemis key in that registry to the older version, but it still gave me an error. Looking at the default key, I saw that it was actually pointing to a DLL in the Logitech wrapper plugin (which is what brings in the LED colours from those games), and tried changing that one to the newest SDK library (the one in Program Files, not in a depot folder). Worked first try after that. I suspect that it is actually the Logitech wrapper not passing through certain requests properly, causing the SDK pointed to by the Artemis key not to load properly.

I wonder if this has been part of the setup for anybody else who had this error?

diogotr7 commented 1 year ago

I'm thinking about what to do about that wrapper actually, it's a tough problem to solve. Recently i rewrote the artemis side of the wrapper with compatibility for the original, unmodified LGS dll. This makes it so games that do not load custom dlls (battlefield 5, for example), can be used with the wrapper. Here are the main differences:

Old Wrapper

  1. The current wrapper should allow users with official logitech software installed to still work with artemis. This works because the dll has special behaviour when loaded by the artemis exe name. In short: If i have LGHUB installed, with artemis + this plugin the following are possible:
    • get artemis lighting, and non-artemis lighting as well, without the need for extra tweaks. I can close artemis and open up, say, aurora of bf1 and it will still work on logitech hardware with LGUB.
    • I can get bf1 lighting into Artemis, while at the same time having artemis send its lighting to LGHUB. This means i can, for example, combine BF1's lighting with my own custom layers.
  2. Games that check for the signature of the dll will NOT work, since our custom dll isn't signed by logitech. I do not know of a way around this. This makes this method useless for most recent games.
  3. how it works: The registry path is overwritten to point to our custom dll. Also, the original path is written to the "artemis" registry key. This allows our dll to look for the original one, and forward calls to it.

New wrapper

  1. Is completely incompatible with any logitech users. Be it LGS or GHUB. This is because it relies on changing the registry path to point to the lgs dll (that the plugin comes with, so that the user doesn't need to download it themselves). This means any game or app (including artemis, unfortunately) will NOT work properly with LGHUB.
  2. Is compatible with newer games, for users without Logitech hardware. BF5 is a good example.

Possible Fixes

  1. use the old method and give up this new one, also giving up several games
  2. hardcode something in artemis (rgb.net) allowing it to load the actual logitech dll forcefully. This is a code smell. I suspect Darth wouldn't like code that does this in RGB.NET. This is also the approach that Aurora uses. We could ship the latest LGHUB dll alongside the Logitech plugin and load that, instead of loading the official "LedEnginesWrapper" binary.

Note: all this "LedEnginesWrapper" dll does is look at the mentioned registry and load the dll at its path. It does not do any signature checking that i know of. Newer games DO NOT use this binary. I suspect Logitech has a game-dev-only version of this that does check the signature.

For more deep discussion on this I'm always on the Discord if you want @DragRedSim