Update mei-disable.c

Add said changes ;)
This commit is contained in:
Sam Sneed 2024-05-23 23:50:50 +00:00 committed by GitHub
parent a983cf1826
commit dcce50b71e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,15 +7,9 @@
#include <unistd.h>
#include <errno.h>
// Disable Intel ME engine.
// This was tested on Z87 board.
// Payload data taken from reverse-engineered fpt.exe v9.5.
#define _countof(a) (sizeof(a)/sizeof(*(a)))
static const char *DEV_NAME[] = { "/dev/mei", "/dev/mei0", "/dev/mei1", "/dev/mei2" };
#define NUM_DEV_NAMES 5
char *DEF_DEV_NAMES[NUM_DEV_NAMES] = {"/dev/mei0", "/dev/mei", "/dev/mei1", "/dev/mei2", "/dev/mei3"};
struct guid
{
uint32_t data1;
@ -33,34 +27,41 @@ static const struct guid mkhi_guid = {
uint8_t disable_cmd[] = {0xff,0x10,0x00,0x00};
int main(int argc, char *argv[])
{
int fd;
int rc;
int i;
struct mei_connect_client_data meidata;
for(int i=0;i<_countof(DEV_NAME);i++)
{
printf("Opening %s ... ",DEV_NAME[i]);
fd = open(DEV_NAME[i], O_RDWR);
break;
if (fd < 0) {
printf("%s\n", strerror(errno));
}
char *find_dev_name() {
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]);
if (stat(path, &st) == 0) {
dev_name = DEF_DEV_NAMES[i];
break;
}
}
if (fd<0)
{
printf("ME device not found\n");
return 1;
if (dev_name == NULL) {
perror("device not found");
exit(1);
}
return dev_name;
}
int main() {
char *dev_name = find_dev_name();
printf("Device found: %s\n", dev_name);
int fd = open(dev_name, O_RDWR);
struct mei_connect_client_data meidata;
printf("opened\n");
memcpy(&meidata.in_client_uuid,&mkhi_guid,sizeof(mkhi_guid));
printf("Sending IOCTL_MEI_CONNECT_CLIENT .. ");
rc = ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &meidata);
int rc = ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &meidata);
if (rc < 0) {
printf("error\n"); fflush(stdout);
perror("ioctl");