Update mei-disable.c

This commit is contained in:
Sam Sneed 2024-05-24 00:02:34 +00:00 committed by GitHub
parent 2105cad09f
commit 77b7bec3b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
@ -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);