예제 #1
0
static int lv2_patch_bdvdemu_446(uint32_t flags)
{
    int n;
    int flag =  0;
    int usb  = -1;
    int pos  = -1;
    int pos2 = -1;

    char * mem = temp_buffer;
    memset(mem, 0, 0x10 * 0x118);

    sys8_memcpy((u64) mem, LV2MOUNTADDR_446, 0x10 * 0x118);

    for(n = 0; n < 11; n++)
    {
        if(flags == (1 << n))
        {
            usb = n - 1;
            break;
        }
    }

    if(usb >= 0)
    {
        sprintf(path_name, "CELL_FS_IOS:USB_MASS_STORAGE00%c", 48 + usb);
        sprintf(&path_name[128], "dev_usb00%c", 48 + usb);
    }

    for(n = 0; n < 0x116c; n+= LV2MOUNTADDR_446_ESIZE)
    {
        if(noBDVD && !memcmp(mem + n, "CELL_FS_UTILITY:HDD1", 21)
            && !memcmp(mem + n + 0x69, "dev_bdvd", 9) && mem[n-9]== 1 && mem[n-13]== 1)
        {
            if(pos2 < 0) pos2 = n;

            if(usb >= 0)
                sys8_memcpy(LV2MOUNTADDR_446 + n + 0x69, (u64) "temp_bdvd", 10);

            flag++;
        }
        else
        if(!noBDVD && !memcmp(mem + n, "CELL_FS_IOS:PATA0_BDVD_DRIVE", 29)
            && (!memcmp(mem + n + 0x69, "dev_bdvd", 9)) && mem[n-9]== 1 && mem[n-13]== 1)
        {
            sys8_memcpy(LV2MOUNTADDR_446 + n + 0x69, (u64) "temp_bdvd", 10);
            flag++;
        }
        else
        if(!noBDVD && usb < 0 && !memcmp(mem + n, "CELL_FS_IOS:BDVD_DRIVE", 29)
            && !memcmp(mem + n + 0x69, "dev_ps2disc", 12) && mem[n-9]== 1 && mem[n-13]== 1)
        {
            if(pos2 < 0) pos2 = n;

            flag++;
        }
        else if(usb >= 0 && !memcmp(mem + n, path_name, 32) && mem[n-9]== 1 && mem[n-13]== 1)
        {
            if(noBDVD) pos = -1;
            sys8_memcpy(LV2MOUNTADDR_446 + n + 0x69, (u64) "dev_bdvd\0\0", 11);
            sys8_memcpy(LV2MOUNTADDR_446 + n + 0x79, (u64) &path_name[128], 11);

            flag += 10;
        }
        else if(usb < 0 && !memcmp(mem + n, "CELL_FS_UTILITY:HDD0", 21)
                && !memcmp(mem + n + 0x48, "CELL_FS_UFS", 11)
                && !memcmp(mem + n + 0x69, "dev_hdd0", 9) && mem[n-9] == 1 && mem[n-13] == 1)
        {
            if(pos < 0) pos = n;
        }
    }

    if(pos > 0 && pos2 > 0)
    {
      u64 dat;

      memcpy(mem + 0x1220, mem + pos2 - 0x10, LV2MOUNTADDR_446_CSIZE);
      dat = LV2MOUNTADDR_446 + (u64) (pos2 - 0x10);
      memcpy(mem + 0x1200, &dat, 0x8);
      dat = 0x8000000000000000ULL + (u64)UMOUNT_SYSCALL_OFFSET;
      memcpy(mem + 0x1208, &dat, 0x8);
      n = (int) 0xFBA100E8; // UMOUNT RESTORE
      memcpy(mem + 0x1210, &n, 0x4);
      n = (int) LV2MOUNTADDR_446_CSIZE; // CDATAS
      memcpy(mem + 0x1214, &n, 0x4);

      memcpy(mem + pos2, mem + pos, LV2MOUNTADDR_446_CSIZE - 0x10);
      memcpy(mem + pos2 + 0x69, "dev_bdvd\0\0", 11);
      memcpy(mem + pos2 + 0x79, "esp_bdvd\0\0", 11);
      memset(mem + pos2 + 0xa4, 0, 8);

      sys8_memcpy(0x80000000007EF000ULL , ((u64) mem + 0x1200), LV2MOUNTADDR_446_CSIZE + 0x20);
      sys8_memcpy(LV2MOUNTADDR_446 + (u64) pos2, ((u64) (mem + pos2)), (u64) (LV2MOUNTADDR_446_CSIZE - 0x10));

      for(int k = 0; k < 100; k++)
      {
        PATCH_CALL(UMOUNT_SYSCALL_OFFSET, PAYLOAD_UMOUNT_OFFSET); // UMOUNT ROUTINE PATCH
        usleep(1000);
      }

      flag = 100;
    }

    if(flag < 11) return -1;

    return 0;
}
예제 #2
0
static int lv2_patch_bdvdemu_355(uint32_t flags)
{
    int n;
    int flag = 0;
    int usb = -1;
    int pos=-1;
    int pos2 = -1;

    char * mem = temp_buffer;
    memset(mem, 0, 0xff0);

    sys8_memcpy((u64) mem, LV2MOUNTADDR_355, 0xff0);

    for(n = 0; n < 11; n++) 
    {
        if(flags == (1 << n))
        {
            usb = n - 1;
            break;
        }
    }
    
    if(usb >= 0) {
        sprintf(path_name, "CELL_FS_IOS:USB_MASS_STORAGE00%c", 48 + usb);
        sprintf(&path_name[128], "dev_usb00%c", 48 + usb);
    }

    for(n = 0; n< 0xff0; n+= 0x100)
    {
        if(!memcmp(mem + n, "CELL_FS_IOS:PATA0_BDVD_DRIVE", 29) && (usb >= 0 || !memcmp(mem + n + 0x69, "dev_bdvd", 9)))
        {
            pos2 = n;
            if(usb >= 0)
                sys8_memcpy(LV2MOUNTADDR_355 + n + 0x69, (u64) "temp_bdvd", 10);
            flag++;
        }
        else if(usb >= 0 && !memcmp(mem + n, path_name, 32))
        {
            sys8_memcpy(LV2MOUNTADDR_355 + n + 0x69, (u64) "dev_bdvd\0\0", 11);
            sys8_memcpy(LV2MOUNTADDR_355 + n + 0x79, (u64) &path_name[128], 11);
            flag+=10;
        }
        else if(usb < 0 && !memcmp(mem + n, "CELL_FS_UTILITY:HDD0", 21)
                && !memcmp(mem + n + 0x48, "CELL_FS_UFS", 11)
                && !memcmp(mem + n + 0x69, "dev_hdd0", 9))
        {
            pos = n;
        }
    }

    if(pos>0 && pos2>0) {
      u64 dat;

      sys8_memcpy(0x80000000007EF020ULL , LV2MOUNTADDR_355 + pos2, 0xf4);
      dat= LV2MOUNTADDR_355 + (u64) pos2;
      sys8_memcpy(0x80000000007EF000ULL , (u64) &dat, 0x8);
      dat= 0x8000000000000000ULL + (u64)UMOUNT_SYSCALL_OFFSET;
      sys8_memcpy(0x80000000007EF008ULL , (u64) &dat, 0x8);
      n=(int) 0xFBA100E8; // UMOUNT RESTORE
      sys8_memcpy(0x80000000007EF010ULL , (u64) &n, 0x4);

      sys8_memcpy(LV2MOUNTADDR_355 + pos2, ((u64) mem) + pos , 0xF4);
      
      sys8_memcpy(LV2MOUNTADDR_355 + pos2 + 0x69, (u64) "dev_bdvd\0\0", 11);
      sys8_memcpy(LV2MOUNTADDR_355 + pos2 + 0x79, (u64) "esp_bdvd\0\0", 11);

      if(is_sky) {
          sys8_memcpy(0x8000000000000000ULL + (u64) PAYLOAD_OFFSET + 0x500ULL, // copy umount routine
                      (u64) umount_355_bin, 
                      umount_355_bin_size);
          PATCH_CALL(UMOUNT_SYSCALL_OFFSET, (PAYLOAD_OFFSET+0x500)); // UMOUNT ROUTINE PATCH
      }
      
      flag = 100;
    }
    
    if(flag < 11)
        return -1;

    return 0;
}