控制ACPI设备的滞后
我在一家笔记本电脑经销商公司工作,他们正在为笔记本电脑建立控制中心。他们使用的是使用ACPI方法更改RGB颜色的键盘。 我已经将以前的控制中心分解,并导出了2个功能以用于使用。
第一个是
private void WriteACPI(uint ioctrl, int addr, int data)
{
IntPtr intPtr = CreateFile("\\\\.\\ACPIDriver", [hidden], 3u, IntPtr.Zero, 3u, 0u, IntPtr.Zero);
if (intPtr != IntPtr.Zero)
{
int[] source = new int[2] { addr, data };
IntPtr intPtr2 = Marshal.AllocHGlobal(8);
Marshal.Copy(source, 0, intPtr2, 2);
int outBuffer = 0;
DeviceIoControl(intPtr, ioctrl, intPtr2, 8, ref outBuffer, 4, out var _, IntPtr.Zero);
//Console.WriteLine("out buffer: " + outBuffer);
Marshal.FreeHGlobal(intPtr2);
CloseHandle(intPtr);
}
}
,但是由于驱动程序中有一个(我认为)间隔,因此每次0.7秒就会获取命令(更改键盘的颜色)。
我导出的第二个功能使用WMI命令。
Stopwatch sw = new Stopwatch();
ManagementScope s = new(@"\\.\root\WMI");
ManagementPath p = new("AcpiTest_MULong.InstanceName='ACPI\\PNP0C14\\1_1'");
managementObject = new ManagementObject(s, p, null);
sw.Start();
Value <<= 16;
Addr = Value + Addr;
managementObject.InvokeMethod("GetSetULong", new object[] { Addr });
sw.Stop();
Console.WriteLine("sw in testing : " + sw.ElapsedMilliseconds);
这里的问题是InvokeMethod大约需要180毫秒。它比第一种方法快,但是由于我将其调用时间(对于R,G和B值,对于1个触发变更值),它再次获得700毫秒。
我尝试在InvokeMethod对象数组中发送4个乌龙一以在180毫秒内快速,但它只是将第一个对象带入了该数组中。
我的目的是添加梯度更改和音乐模式等模式,因此我应该能够每秒至少10次(小于100 ms)控制键盘。
我想知道是否有另一种方法可以将ACPI命令发送到ECRAM,或者是一种使WMI更快的方法。 (我无法访问驱动程序的源代码,我尝试使用IDAPRO进行分解.SYS文件,并获得了类似C的文件,但我无法获得太多信息) 谢谢。
I am working in a laptop reseller company and they are making a control center for their laptops. The keyboards they are using use ACPI methods to change their RGB colors.
I have decompiled the previous control center and exported 2 functions to use.
First one is
private void WriteACPI(uint ioctrl, int addr, int data)
{
IntPtr intPtr = CreateFile("\\\\.\\ACPIDriver", [hidden], 3u, IntPtr.Zero, 3u, 0u, IntPtr.Zero);
if (intPtr != IntPtr.Zero)
{
int[] source = new int[2] { addr, data };
IntPtr intPtr2 = Marshal.AllocHGlobal(8);
Marshal.Copy(source, 0, intPtr2, 2);
int outBuffer = 0;
DeviceIoControl(intPtr, ioctrl, intPtr2, 8, ref outBuffer, 4, out var _, IntPtr.Zero);
//Console.WriteLine("out buffer: " + outBuffer);
Marshal.FreeHGlobal(intPtr2);
CloseHandle(intPtr);
}
}
But since there is an (I think) interval in the driver, It gets the commands (changes the keyboard's colors) every approximately 0.7 seconds.
The second function I exported uses WMI commands.
Stopwatch sw = new Stopwatch();
ManagementScope s = new(@"\\.\root\WMI");
ManagementPath p = new("AcpiTest_MULong.InstanceName='ACPI\\PNP0C14\\1_1'");
managementObject = new ManagementObject(s, p, null);
sw.Start();
Value <<= 16;
Addr = Value + Addr;
managementObject.InvokeMethod("GetSetULong", new object[] { Addr });
sw.Stop();
Console.WriteLine("sw in testing : " + sw.ElapsedMilliseconds);
The problem here is that InvokeMethod takes about 180 milliseconds. It is faster than the first method but since I am invoking it for times (for r, g and b values, and for 1 triggering the change value) It gets up to 700 milliseconds again.
I have tried sending 4 ulongs in InvokeMethod object array to make it quick in 180 ms but it just took the first object in that array.
My purpose is to add Gradient change and Music mode etc modes so I should be able to control the keyboard at least 10 times a second (less than 100 ms).
I want to know if there is an alternative method to send ACPI commands to ECRam or a method to make WMI faster. (I have no access to driver's source code, I tried decompiling .sys file with IDAPro and got a C-like file but I couldn't get much information I can use)
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论