Advertisement
SKGleba

vstor_gpx proper patch

Oct 28th, 2020
2,447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. // fixed storage params gen with exfat & small partitions support
  2. int custom_vstor_gpx(void) {
  3.     DBG("vstor_get_sparams\n");
  4.     int ret = vstor_gpx();
  5.     if (ret != 2)
  6.         return ret;
  7.     DBG("c_gpx open %s\n", mpath);
  8.     int permz = ksceKernelSetPermission(0x40);
  9.     int fd = ksceIoOpen(mpath, SCE_O_RDWR, 0777);
  10.     if (fd < 0)
  11.         goto ded;
  12.     *(uint32_t *)(vstor_params_table + 0xc) = fd;
  13.     DBG("c_gpx verify mbr\n");
  14.     char mbr[0x200];
  15.     memset(mbr, 0, 0x200);
  16.     ksceIoRead(fd, mbr, 0x200);
  17.     if (*(uint16_t *)(mbr + 0x1fe) != 0xaa55)
  18.         goto ded;
  19.     // set sector and device size
  20.     *(uint32_t *)(vstor_params_table + 0x50) = (uint16_t)0x200;
  21.     if (memcmp(mbr + 0x3, "EXFAT", 5) == 0) { // ExFAT device
  22.         DBG("c_gpx set mode exfat\n");
  23.         *(uint32_t *)(vstor_params_table + 0x10) = *(uint32_t *)(mbr + 0x48);
  24.     } else {
  25.         DBG("c_gpx set mode fat16\n");
  26.         if (*(uint32_t *)(mbr + 0x20) > 0) // Use big sectors
  27.             *(uint32_t *)(vstor_params_table + 0x10) = *(uint32_t *)(mbr + 0x20);
  28.         else // Use small sectors
  29.             *(uint32_t *)(vstor_params_table + 0x10) = (uint32_t)*(uint16_t *)(mbr + 0x13);
  30.     }
  31.     DBG("c_gpx done set evf\n");
  32.     if (ksceIoLseek(fd, 0, SCE_SEEK_END) < 0)
  33.         goto ded;
  34.     ksceKernelSetPermission(permz);
  35.     ksceKernelSetEventFlag(*(uint32_t *)(vstor_params_table + 0x38), 0x200);
  36.     return 0;
  37. ded:
  38.     DBG("c_gpx died\n");
  39.     if (fd > 0)
  40.         ksceIoClose(fd);
  41.     *(uint32_t *)(vstor_params_table + 0xc) = -1;
  42.     ksceKernelSetPermission(permz);
  43.     return -0x7fdbbeee;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement