Asus A3000 Mail LED
Hejsa, jeg sidder med en asus bærbar og fandt følgende kode som så vidt jeg har forstået tænder alle leds'ne på en M6N bærbar, og nu er jeg blevet nysgerrig om hvordan jeg kan finde de "keys" der passer til min A3000N, og også gerne en gennemgang af hvordan det program virker, jeg er lidt inde i C men ikke ret meget./* leds.c -- Asus M6N LED control program
Copyright (C) 2004 Howard Chu - hyc <at> highlandsun.com
This file is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the license is available on the web at
http://www.fsf.org/licenses/gpl.html
*/
/* This program only works on Windows XP. It talks to the
ASUS ATKACPI driver, so you must have that already installed. */
#include <windows.h>
#include <stdio.h>
HANDLE ATKACPIhandle;
/* There are several magic values that the Asus driver recognizes... */
#define MLED 0x44454c4d
#define TLED 0x44454c54
#define WLED 0x44454c57
#define LED 0x44454c00
int CtrlACPI(int code, int hasArg, int arg)
{
long bytes = 0;
long inbuf[5];
struct cmbuf {
short cmds[2];
long cm2;
} cbuf;
long outbuf[192];
int ret;
cbuf.cmds[0] = 0;
cbuf.cmds[1] = 4;
cbuf.cm2 = arg;
inbuf[0] = 2;
inbuf[1] = code;
inbuf[2] = hasArg;
inbuf[3] = 8 * hasArg;
inbuf[4] = (long)&cbuf;
ret = DeviceIoControl(ATKACPIhandle, 0x222404, inbuf, sizeof(inbuf),
outbuf, sizeof(outbuf), &bytes, NULL);
return ret;
}
int main(int argc, char *argv[]) {
int code = LED;
int onoff;
if (argc != 3) {
fputs("usage: ",stderr);
fputs(argv[0],stderr);
fputs(" M|T|W 0|1\n",stderr);
exit(1);
}
/* Open the Asus device driver. If it's not there,
there's nothing we can do. */
ATKACPIhandle = CreateFile("\\\\.\\ATKACPI",
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
0, NULL);
if (ATKACPIhandle) {
code |= argv[1][0];
onoff = argv[2][0] & 1;
CtrlACPI(code, 1, onoff);
}
}