int is_psx(int check_ps2) { uint8_t *buf; int result; int ret = 0; if (page_allocate_auto(NULL, 2048, 0x2F, (void **)&buf) == 0) { result = read_real_disc_sector(buf, 0x10, 1, 3); if (result == 0) { // Check if it is a burned PS3 disk (deank) if(check_ps2==3) { ret = (memcmp(buf+1, "CD001", 5) == 0 && memcmp(buf+0x28, "PS3VOLUME", 9) == 0); if(!ret) { result = read_real_disc_sector(buf, 0x01, 1, 3); ret = (memcmp(buf, "PlayStation3", 12) == 0); } page_free(NULL, buf, 0x2F); return ret; } } page_free(NULL, buf, 0x2F); } return ret; }
int disable_cobra_stage() { cellFsUtilMount_h("CELL_FS_IOS:BUILTIN_FLSH1", "CELL_FS_FAT", "/dev_habib", 0, 0, 0, 0, 0); CellFsStat stat; cellFsStat(CB_LOCATION, &stat); uint64_t len=stat.st_size; uint8_t *buf; uint64_t size; int src; int dst; page_allocate_auto(NULL, 0x40000, 0x2F, (void **)&buf); if (cellFsOpen(CB_LOCATION, CELL_FS_O_RDONLY, &src, 0, NULL, 0) == 0) { cellFsRead(src, buf, len, &size); cellFsClose(src); } else { page_free(NULL, buf, 0x2F); return -1; } if (cellFsOpen(CB_LOCATION".bak", CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_TRUNC, &dst, 0666, NULL, 0) == 0) { cellFsWrite(dst, buf, len, &size); cellFsClose(dst); } else { page_free(NULL, buf, 0x2F); return -1; } page_free(NULL, buf, 0x2F); cellFsUnlink(CB_LOCATION); size=0x5343450000000000; cellFsOpen("/dev_hdd0/tmp/loadoptical", CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_TRUNC, &dst, 0666, NULL, 0); cellFsWrite(dst, &size, 4, &size); cellFsClose(dst); return 0; }
int process_read_disc_cmd(ReadDiscCmd *cmd) { lv1_stor_wrapper_var var; u64 dma_lpar; void *dma; int ret; // reasons to use lv1 calls here over lv2 storage functions // 1: this function may be called when lv2 storage functions haven't yet received the bdvd ready event, and thus, they don't work. // 2: this will read the real disc even with iso mounted, it may be useful in the future. ret = page_allocate_auto(NULL, 4096, 0x2F, &dma); memset(dma, 0x5B, 4096); if (ret == 0) { ret = kernel_ea_to_lpar_addr(dma, &dma_lpar); if (ret == 0) { suspend_intr(); uint64_t state = spin_lock_irqsave(); ret = lv1_stor_wrapper_open(LV1_BDVD_DEV_ID, dma, dma_lpar, 12, &var); if (ret == 0) { ret = lv1_stor_wrapper_read(&var, 0, cmd->start_sector, cmd->sector_count, 0x2, cmd->buf); lv1_stor_wrapper_close(&var); } spin_unlock_irqrestore(state); resume_intr(); } page_free(NULL, dma, 0x2F); } return ret; }
int sys_prx_load_vsh_plugin(unsigned int slot, char *path, void *arg, uint32_t arg_size) { #ifdef MAMBA_LOADER if (mamba_loaded == 1) return ECANCELED; //USE MAMBA INSTEAD TO LOAD THEM ! #endif if (!vsh_process) vsh_process = get_vsh_process(); if (!vsh_process) return ESRCH; void *kbuf, *vbuf; sys_prx_id_t prx; int ret; path = get_secure_user_ptr(path); arg = get_secure_user_ptr(arg); if (slot >= MAX_VSH_PLUGINS || (arg != NULL && arg_size > KB(64))) return EINVAL; if (vsh_plugins[slot] != 0) return EKRESOURCE; prx = prx_load_module(vsh_process, 0, 0, path); if (prx < 0) return prx; if (arg && arg_size > 0) { page_allocate_auto(vsh_process, KB(64), 0x2F, &kbuf); page_export_to_proc(vsh_process, kbuf, 0x40000, &vbuf); copy_from_user(arg, kbuf, arg_size); } else vbuf = NULL; ret = prx_start_module_with_thread(prx, vsh_process, 0, (uint64_t)vbuf); if (vbuf) { page_unexport_from_proc(vsh_process, vbuf); page_free(vsh_process, kbuf, 0x2F); } if (ret == 0) vsh_plugins[slot] = prx; else { prx_stop_module_with_thread(prx, vsh_process, 0, 0); prx_unload_module(prx, vsh_process); } return ret; }