Created
August 17, 2020 13:08
-
-
Save tewilove/aa5d93ece528f7b2f5fdbb55272d5f07 to your computer and use it in GitHub Desktop.
Enables or disables N-02E diag interface without root.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
typedef int (*nv_cmd_remote_t)(int, int, void *); | |
int main(int argc, char *argv[]) | |
{ | |
int rc; | |
void *h; | |
nv_cmd_remote_t nv_cmd_remote; | |
int disabled; | |
unsigned char data[128]; | |
int fd; | |
int one; | |
if (argc != 2) | |
return 1; | |
disabled = !(!!atoi(argv[1])); | |
memset(data, 0, sizeof(data)); | |
one = !disabled; | |
fd = open("/dev/diag", O_RDWR); | |
h = dlopen("libnv.so", RTLD_NOW); | |
nv_cmd_remote = dlsym(h, "nv_cmd_remote"); | |
/* diag port */ | |
data[0] = disabled; | |
rc = nv_cmd_remote(1, 61171, data); | |
/* diag traffic */ | |
data[0] = !disabled; | |
rc |= nv_cmd_remote(1, 61168, data); | |
/* /system/bin/ncmdiagd */ | |
rc | = nv_cmd_remote(1, 61167, data); | |
printf("Turn %s DIAG returned %d.\n", disabled ? "OFF" : "ON", rc); | |
ioctl(fd, 0x26b, &one); | |
close(fd); | |
if (rc) | |
return 1; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment