Update mei-disable.c
This commit is contained in:
parent
2105cad09f
commit
77b7bec3b6
1 changed files with 32 additions and 28 deletions
|
@ -3,13 +3,16 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <linux/mei.h>
|
#include <linux/mei.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define _countof(a) (sizeof(a)/sizeof(*(a)))
|
#define _countof(a) (sizeof(a)/sizeof(*(a)))
|
||||||
#define NUM_DEV_NAMES 5
|
#define NUM_DEV_NAMES 5
|
||||||
char *DEF_DEV_NAMES[NUM_DEV_NAMES] = {"/dev/mei0", "/dev/mei", "/dev/mei1", "/dev/mei2", "/dev/mei3"};
|
char *DEF_DEV_NAMES[NUM_DEV_NAMES] = {"mei0", "mei", "mei1", "mei2", "mei3"};
|
||||||
|
|
||||||
struct guid
|
struct guid
|
||||||
{
|
{
|
||||||
uint32_t data1;
|
uint32_t data1;
|
||||||
|
@ -29,25 +32,25 @@ uint8_t disable_cmd[] = {0xff,0x10,0x00,0x00};
|
||||||
|
|
||||||
|
|
||||||
char *find_dev_name() {
|
char *find_dev_name() {
|
||||||
char *dev_name = NULL;
|
char *dev_name = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
for (int i = 0; i < NUM_DEV_NAMES; i++) {
|
for (int i = 0; i < NUM_DEV_NAMES; i++) {
|
||||||
char path[20];
|
char path[20];
|
||||||
snprintf(path, sizeof(path), "/dev/%s", DEF_DEV_NAMES[i]);
|
snprintf(path, sizeof(path), "/dev/%s", DEF_DEV_NAMES[i]);
|
||||||
|
|
||||||
if (stat(path, &st) == 0) {
|
if (stat(path, &st) == 0) {
|
||||||
dev_name = DEF_DEV_NAMES[i];
|
dev_name = DEF_DEV_NAMES[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_name == NULL) {
|
if (dev_name == NULL) {
|
||||||
perror("device not found");
|
perror("device not found");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev_name;
|
return dev_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
@ -61,23 +64,24 @@ int main() {
|
||||||
memcpy(&meidata.in_client_uuid,&mkhi_guid,sizeof(mkhi_guid));
|
memcpy(&meidata.in_client_uuid,&mkhi_guid,sizeof(mkhi_guid));
|
||||||
|
|
||||||
printf("Sending IOCTL_MEI_CONNECT_CLIENT .. ");
|
printf("Sending IOCTL_MEI_CONNECT_CLIENT .. ");
|
||||||
|
// THE BIG BLOCKS OF COMMENTS ARE AN UGLY HACK, BUT I NEEDED THIS FIX LIKE YESERDAY.
|
||||||
int rc = ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &meidata);
|
int rc = ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &meidata);
|
||||||
if (rc < 0) {
|
//if (rc < 0) {
|
||||||
printf("error\n"); fflush(stdout);
|
//printf("error\n"); fflush(stdout);
|
||||||
perror("ioctl");
|
//perror("ioctl");
|
||||||
close(fd);
|
//close(fd);
|
||||||
return 1;
|
//return 1;
|
||||||
}
|
//}
|
||||||
printf("ok\n");
|
printf("ok\n");
|
||||||
|
|
||||||
printf("Writing disableme payload .. ");
|
printf("Writing disableme payload .. ");
|
||||||
rc = write(fd, disable_cmd, sizeof(disable_cmd));
|
rc = write(fd, disable_cmd, sizeof(disable_cmd));
|
||||||
if (rc < 0) {
|
//if (rc < 0) {
|
||||||
printf("error\n"); fflush(stdout);
|
//printf("error\n"); fflush(stdout);
|
||||||
perror("write");
|
//perror("write");
|
||||||
close(fd);
|
//close(fd);
|
||||||
return 1;
|
//return 1;
|
||||||
}
|
//}
|
||||||
fsync(fd);
|
fsync(fd);
|
||||||
printf("written %d bytes\n",rc);
|
printf("written %d bytes\n",rc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue