ligius-/lenovo-backlight-control

SetKeyboardBackLightStatus function params changed

Closed this issue · 5 comments

figrn commented

Lenovo has pushed an update to Keyboard_Core.dll that changed the definition of the SetKeyboardBackLightStatus function - it now takes a second parameter of type HidKbdData. Inspecting the definition it appears that the second parameter can be null. An update is needed that passes null for the second parameter, without it an error of System.Reflection.TargetParameterCountException: Parameter count mismatch occurs.

Below is the overview of the new function inspeted from JetBrains dotPeek:

public unsafe uint SetKeyboardBackLightStatus(int nStatus, HidKbdData hidKbdData) {
    if (hidKbdData != null) {
        ....
    } else {
        ....
    }
    return 0;
}

Good catch! I forked this project and posted a fixed release. I also created a pull request.

Thank you, I have a newer Thinkpad, but will update the old one and see if I can confirm the issue. I would anyway want to replace the .exe with PowerShell, I've already tried it on my C940 and it works, though the usage there is a bit different.

For what it's worth, I am using a ThinkPad X1 Yoga Gen 3. The only change I've had to make for my own usage is changing the AutoHotkey script's Keyboard_Core.dll location to C:\ProgramData\Lenovo\ImController\Plugins\ThinkKeyboardPlugin\x86\Keyboard_Core.dll, which is created by the Lenovo Vantage application. That change is included in the release I linked.

figrn commented

I can confirm that doing a new build with the "null" second parameter makes everything operational again.

  • T490s Thinkpad (4 months old)
  • Keyboard_Core.dll 2.0.0.15 (modified data 2020-12-01 9:10PM)
  • Path to Keyboard_Core.dll: %programdata%\Lenovo\ImController\Plugins\ThinkKeyboardPlugin\x86\

I've tested the change, merged it and published a new exe file and script (v02). Thank you @figrn and @SolUtain .