From 77b7bec3b6237fe18bbce841c49f3d97133b3b5d Mon Sep 17 00:00:00 2001 From: Sam Sneed <163201376+sam-sneed@users.noreply.github.com> Date: Fri, 24 May 2024 00:02:34 +0000 Subject: [PATCH] Update mei-disable.c --- mei-disable.c | 60 +++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/mei-disable.c b/mei-disable.c index 614f62f..753c656 100644 --- a/mei-disable.c +++ b/mei-disable.c @@ -3,13 +3,16 @@ #include #include #include +#include #include #include #include +#include #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);