1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*
* smm.c -- Utility to test SMM BIOS calls on Inspiron 8000 laptops
*
* Copyright (C) 2017 Vitor Augusto <vitorafsr@gmail.com>
* Copyright (C) 2001 Massimo Dal Zotto <dz@debian.org>
*
* This program 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, or (at your option) any
* later version.
*
* This program 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.
*
* WARNING!!! READ CAREFULLY BEFORE USING THIS PROGRAM!!!
*
* THIS PROGRAM IS VERY DANGEROUS. IT CAN CRASH YOUR COMPUTER, DESTROY DATA
* ON THE HARDISK, CORRUPT THE BIOS, PHYSICALLY DAMAGE YOUR HARDWARE AND
* MAKE YOUR COMPUTER TOTALLY UNUSABLE.
*
* DON'T USE THIS PROGRAM UNLESS YOU REALLY KNOW WHAT YOU ARE DOING. I WILL
* NOT BE RESPONSIBLE FOR ANY DIRECT OR INDIRECT DAMAGE CAUSED BY USING THIS
* PROGRAM.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#define I8K_SMM _IOWR('i', 0x88, size_t)
int
main(int argc, char **argv)
{
int registers[6];
if (argc < 2) {
fprintf(stderr, "Usage: %s eax ebx ecx edx esi edi\n", argv[0]);
exit(1);
}
if (argc > 1) registers[0] = strtol(argv[1],NULL,16);
if (argc > 2) registers[1] = strtol(argv[2],NULL,16);
if (argc > 3) registers[2] = strtol(argv[3],NULL,16);
if (argc > 4) registers[3] = strtol(argv[4],NULL,16);
if (argc > 5) registers[4] = strtol(argv[5],NULL,16);
if (argc > 6) registers[5] = strtol(argv[6],NULL,16);
int fp = open("/proc/i8k", O_WRONLY);
if (fp == -1) {
perror("Error opening file /proc/i8k\n");
return -1;
}
fp = ioctl(fp, I8K_SMM, ®isters);
if (fp == -1) {
perror("Error on ioctl\n");
fprintf(stderr, "Err no. %d\n", fp);
close(fp);
return -1;
}
close(fp);
return 0;
}
/* end of file */
|