Guest User

Untitled

a guest
Jun 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. /*
  2. *
  3. * A Random Hacker MacBook Air SuperDrive enabler
  4. * No guarantee
  5. * The MBA SuperDrive needs 1100mA supply from the host USB Port
  6. * No promises if you ignore this.
  7. *
  8. * This is a first attempt ‚ I don‚ think the enabler packet is optimal
  9. * It could probably be improved ‚but hey I just wanted to prove a point.
  10. *
  11. * BTW ‚ the firmware on the ATA->USB bridge board can be rewritten
  12. * You would then be able to have this fix applied permanently.
  13. * Hint: vend_ax , also Cy4611B is useful here ( processCBW )
  14. *
  15. * This code is for Linux I'm sure the same could be performed under windows
  16. * gcc -o mba_powerup mba_powerup.c
  17. */
  18. #include <fcntl.h>
  19. #include <sys/ioctl.h>
  20. #include <scsi/sg.h>
  21. #include <stdio.h>
  22. #include <string.h>
  23. void mba_powerup (const char *device)
  24. {
  25. int fd;
  26. sg_io_hdr_t IO_hdr;
  27. // The magic incantation
  28. unsigned char magic[] = {0xea,0x00,0x00,0x00,0x00,0x00,0x01};
  29. unsigned char sbuf[32];
  30. unsigned char dxfp[32];
  31.  
  32. fd = open(device, O_RDWR|O_NONBLOCK);
  33. if (fd < 0) {
  34. fprintf(stderr, "Error opening device \"%s\".\n", device);
  35. return;
  36. }
  37. else {
  38. memset(&IO_hdr, 0, sizeof(sg_io_hdr_t));
  39. IO_hdr.interface_id = 'S';
  40. IO_hdr.cmd_len = sizeof(magic);
  41. IO_hdr.mx_sb_len = sizeof(sbuf);
  42. IO_hdr.dxfer_direction = SG_DXFER_TO_DEV;
  43. IO_hdr.dxfer_len = sizeof(dxfp);
  44. IO_hdr.dxferp = dxfp;
  45. IO_hdr.cmdp = magic;
  46. IO_hdr.sbp = sbuf;
  47. IO_hdr.timeout = 1000;
  48. if ( ioctl(fd, SG_IO, &IO_hdr)< 0) {
  49. fprintf(stderr, "Error powering MBA SuperDrive.\n");
  50. return;
  51. }
  52. close(fd);
  53. }
  54. }
  55.  
  56. // Usage: "mba_powerup /dev/dvd" (obviously change this to the appropriate device for your system)
  57. int main(int argc,char **argv)
  58. {
  59. mba_powerup(argv[1]);
  60. return 0;
  61. }
Add Comment
Please, Sign In to add comment