Advertisement
saleks28

bos3_module_caller

Jan 13th, 2020
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #define _GNU_SOURCE
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. #include <sys/ioctl.h>
  5. #include <stdlib.h>
  6.  
  7. #include "caller.h"
  8.  
  9. int main(int argc, char **argv)
  10. {
  11.     argVenDev arg2;
  12.     int fd = -1;
  13.     if (argc != 2 && argc != 3)
  14.     {
  15.         puts("Usage: ./caller [Function-number] or ./caller [Vendor] [Device]\n");
  16.         return 1;
  17.     }
  18.    
  19.     fd = open(DEVPATH, O_RDWR);
  20.     if (fd < 0)
  21.     {
  22.         printf("Open device error: %m\n");
  23.         return 1;
  24.     }
  25.     if(argc == 2)
  26.     {
  27.         int arg = atoi(argv[1]);
  28.         int ret = ioctl(fd, IOCTL_GET_PSI_VENDEV, &arg);
  29.     }
  30.     else if(argc == 3)
  31.     {
  32.         arg2.vendor = atoi(argv[1]);
  33.         arg2.device = atoi(argv[2]);
  34.         int ret = ioctl(fd, IOCTL_GET_PSI_DEVFN, &arg2);
  35.     }
  36.  
  37.     close(fd);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement