Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // fixed storage params gen with exfat & small partitions support
- int custom_vstor_gpx(void) {
- DBG("vstor_get_sparams\n");
- int ret = vstor_gpx();
- if (ret != 2)
- return ret;
- DBG("c_gpx open %s\n", mpath);
- int permz = ksceKernelSetPermission(0x40);
- int fd = ksceIoOpen(mpath, SCE_O_RDWR, 0777);
- if (fd < 0)
- goto ded;
- *(uint32_t *)(vstor_params_table + 0xc) = fd;
- DBG("c_gpx verify mbr\n");
- char mbr[0x200];
- memset(mbr, 0, 0x200);
- ksceIoRead(fd, mbr, 0x200);
- if (*(uint16_t *)(mbr + 0x1fe) != 0xaa55)
- goto ded;
- // set sector and device size
- *(uint32_t *)(vstor_params_table + 0x50) = (uint16_t)0x200;
- if (memcmp(mbr + 0x3, "EXFAT", 5) == 0) { // ExFAT device
- DBG("c_gpx set mode exfat\n");
- *(uint32_t *)(vstor_params_table + 0x10) = *(uint32_t *)(mbr + 0x48);
- } else {
- DBG("c_gpx set mode fat16\n");
- if (*(uint32_t *)(mbr + 0x20) > 0) // Use big sectors
- *(uint32_t *)(vstor_params_table + 0x10) = *(uint32_t *)(mbr + 0x20);
- else // Use small sectors
- *(uint32_t *)(vstor_params_table + 0x10) = (uint32_t)*(uint16_t *)(mbr + 0x13);
- }
- DBG("c_gpx done set evf\n");
- if (ksceIoLseek(fd, 0, SCE_SEEK_END) < 0)
- goto ded;
- ksceKernelSetPermission(permz);
- ksceKernelSetEventFlag(*(uint32_t *)(vstor_params_table + 0x38), 0x200);
- return 0;
- ded:
- DBG("c_gpx died\n");
- if (fd > 0)
- ksceIoClose(fd);
- *(uint32_t *)(vstor_params_table + 0xc) = -1;
- ksceKernelSetPermission(permz);
- return -0x7fdbbeee;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement