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 <inttypes.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/mei.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define _countof(a) (sizeof(a)/sizeof(*(a)))
|
||||
#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
|
||||
{
|
||||
uint32_t data1;
|
||||
|
@ -29,25 +32,25 @@ uint8_t disable_cmd[] = {0xff,0x10,0x00,0x00};
|
|||
|
||||
|
||||
char *find_dev_name() {
|
||||
char *dev_name = NULL;
|
||||
struct stat st;
|
||||
char *dev_name = NULL;
|
||||
struct stat st;
|
||||
|
||||
for (int i = 0; i < NUM_DEV_NAMES; i++) {
|
||||
char path[20];
|
||||
snprintf(path, sizeof(path), "/dev/%s", DEF_DEV_NAMES[i]);
|
||||
for (int i = 0; i < NUM_DEV_NAMES; i++) {
|
||||
char path[20];
|
||||
snprintf(path, sizeof(path), "/dev/%s", DEF_DEV_NAMES[i]);
|
||||
|
||||
if (stat(path, &st) == 0) {
|
||||
dev_name = DEF_DEV_NAMES[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stat(path, &st) == 0) {
|
||||
dev_name = DEF_DEV_NAMES[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dev_name == NULL) {
|
||||
perror("device not found");
|
||||
exit(1);
|
||||
}
|
||||
if (dev_name == NULL) {
|
||||
perror("device not found");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return dev_name;
|
||||
return dev_name;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
@ -61,23 +64,24 @@ int main() {
|
|||
memcpy(&meidata.in_client_uuid,&mkhi_guid,sizeof(mkhi_guid));
|
||||
|
||||
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);
|
||||
if (rc < 0) {
|
||||
printf("error\n"); fflush(stdout);
|
||||
perror("ioctl");
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
//if (rc < 0) {
|
||||
//printf("error\n"); fflush(stdout);
|
||||
//perror("ioctl");
|
||||
//close(fd);
|
||||
//return 1;
|
||||
//}
|
||||
printf("ok\n");
|
||||
|
||||
printf("Writing disableme payload .. ");
|
||||
rc = write(fd, disable_cmd, sizeof(disable_cmd));
|
||||
if (rc < 0) {
|
||||
printf("error\n"); fflush(stdout);
|
||||
perror("write");
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
//if (rc < 0) {
|
||||
//printf("error\n"); fflush(stdout);
|
||||
//perror("write");
|
||||
//close(fd);
|
||||
//return 1;
|
||||
//}
|
||||
fsync(fd);
|
||||
printf("written %d bytes\n",rc);
|
||||
|
||||
|
|
Loading…
Reference in a new issue