Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions popsloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,85 +42,85 @@ all:
@cp -f proheaparea/proheaparea.prx dist/modules
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_302=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/302
@cp -f popcorn/popcorn.prx dist/modules/302/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_303=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/303
@cp -f popcorn/popcorn.prx dist/modules/303/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_310=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/310
@cp -f popcorn/popcorn.prx dist/modules/310/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_311=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/311
@cp -f popcorn/popcorn.prx dist/modules/311/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_330=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/330
@cp -f popcorn/popcorn.prx dist/modules/330/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_340=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/340
@cp -f popcorn/popcorn.prx dist/modules/340/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_350=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/350
@cp -f popcorn/popcorn.prx dist/modules/350/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_351=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/351
@cp -f popcorn/popcorn.prx dist/modules/351/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_352=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/352
@cp -f popcorn/popcorn.prx dist/modules/352/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_371=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/371
@cp -f popcorn/popcorn.prx dist/modules/371/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_372=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/372
@cp -f popcorn/popcorn.prx dist/modules/372/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_380=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/380
@cp -f popcorn/popcorn.prx dist/modules/380/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_390=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/390
@cp -f popcorn/popcorn.prx dist/modules/390/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_393=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/393
@cp -f popcorn/popcorn.prx dist/modules/393/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_396=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/396
@cp -f popcorn/popcorn.prx dist/modules/396/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_401=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/401
@cp -f popcorn/popcorn.prx dist/modules/401/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_500=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/500
@cp -f popcorn/popcorn.prx dist/modules/500/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_501=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/501
@cp -f popcorn/popcorn.prx dist/modules/501/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_503=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/503
@cp -f popcorn/popcorn.prx dist/modules/503/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_550=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/550
@cp -f popcorn/popcorn.prx dist/modules/550/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_551=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/551
@cp -f popcorn/popcorn.prx dist/modules/551/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_600=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/600
@cp -f popcorn/popcorn.prx dist/modules/600/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_610=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/610
@cp -f popcorn/popcorn.prx dist/modules/610/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_620=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/620
@cp -f popcorn/popcorn.prx dist/modules/620/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_635=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/635
@cp -f popcorn/popcorn.prx dist/modules/635/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_639=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/639
@cp -f popcorn/popcorn.prx dist/modules/639/
make $(EXTRA_OPTIONS) clean -C popcorn
make $(EXTRA_OPTIONS) CONFIG_660=1 -C popcorn
@cp -f popcorn/popcorn.prx dist/modules/660
@cp -f popcorn/popcorn.prx dist/modules/660/

clean:
make clean -C proheaparea
Expand Down
122 changes: 105 additions & 17 deletions popsloader/common/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,118 @@ typedef struct _CONFIG {

struct popsloader_config g_conf;

static char disc_id[16];
char __disc_id[16];
static int config_offset = -1;

#define MAX_FAIL 100

#if 0
static int get_disc_id()
{
void* (*sceKernelGetGameInfo_k)();
int failed = 0;

retry:
memset(disc_id, 0, sizeof(disc_id));
memset(__disc_id, 0, sizeof(__disc_id));
sceKernelGetGameInfo_k = (void *)sctrlHENFindFunction("sceSystemMemoryManager", "SysMemForKernel", 0xCD617A94);

if(sceKernelGetGameInfo_k != NULL) {
char *info_buff = sceKernelGetGameInfo_k();
memcpy(disc_id, info_buff + 0x44, 9);
}

if (*disc_id == '\0' && failed < MAX_FAIL) {
sceKernelDelayThread(10000);
failed++;
goto retry;
memcpy(__disc_id, info_buff + 0x44, 9);
}

return 0;
}
#endif

///
static unsigned int read32(const void *p){
const unsigned char *x=(const unsigned char*)p;
return x[0]|(x[1]<<8)|(x[2]<<16)|(x[3]<<24);
}
static unsigned short read16(const void *p){
const unsigned char *x=(const unsigned char*)p;
return x[0]|(x[1]<<8);
}
static char head[16];
//#define Z(S) (S),strlen(S)
static int get_disc_id()
{
void* (*sceKernelGetGameInfo_k)();
//SceUID f=sceIoOpen("ms0:/pops.log", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777);

memset(__disc_id, 0, sizeof(__disc_id));
sceKernelGetGameInfo_k = (void *)sctrlHENFindFunction("sceSystemMemoryManager", "SysMemForKernel", 0xCD617A94);

if(sceKernelGetGameInfo_k != NULL) {
char *info_buff = sceKernelGetGameInfo_k();
memcpy(__disc_id, info_buff + 0x44, 9); //seems not working

// in this point, sceKernelGetGameInfo() doesn't grub Disc ID.
// instead, I'm going to parse EBOOT.PBP's PARAM.SFO
// *** This clause can be used under any term (CC0). [popsdeco]
if(!*__disc_id){
//sceIoWrite(f,Z("Entering Fallback mode.\n"));
//sceIoWrite(f,info_buff,0x100);
SceUID fd=sceIoOpen(info_buff + 0x74,PSP_O_RDONLY,0777);
sceIoRead(fd,head,16);
if(memcmp(head,"\0PBP",4)){ //||read32(head+4)!=0x00010000){ //rare case? 0x00010001
sceIoClose(fd);
//sceIoWrite(f,Z("PBP magic error.\n"));
goto end;//return 0;
}
int param_offset=read32(head+8);
int param_size=read32(head+12)-param_offset;
SceUID uid=sceKernelAllocPartitionMemory(2,"EBOOTReader",PSP_SMEM_Low,param_size,NULL);
if(uid<0){
sceIoClose(fd);
//sceIoWrite(f,Z("malloc failed.\n"));
goto end;//return 0;
}
char *p=sceKernelGetBlockHeadAddr(uid);//malloc(param_size);
//char p[0x400];
sceIoLseek(fd,param_offset,SEEK_SET);
sceIoRead(fd,p,param_size);
sceIoClose(fd);
if(memcmp(p,"\0PSF",4)||read32(p+4)!=0x00000101){
//free(p);
sceKernelFreePartitionMemory(uid);
//sceIoWrite(f,Z("PSF magic error.\n"));
goto end;//return 0;
}
int label_offset=read32(p+8);
int data_offset=read32(p+12);
int nlabel=read32(p+16);
int i=0;
for(;i<nlabel;i++){
if(!strcmp(p+label_offset+read16(p+20+16*i),"DISC_ID")){
memcpy(__disc_id,p+data_offset+read32(p+20+16*i+12),9);
//sceIoWrite(f,Z(__disc_id));
//sceIoWrite(f,Z("\n"));
break;
}
}
//fwrite(p,1,param_size,stdout);
//free(p);
sceKernelFreePartitionMemory(uid);
}
/// parse EBOOT end.
}
end:
//sceIoClose(f);
return 0;
}
///
#if 0
static inline int is_ef0(void)
{
return psp_model == PSP_GO && sctrlKernelBootFrom() == 0x50 ? 1 : 0;
}
#endif
int save_config(void)
{
SceUID fd;
char path[256];
CONFIG cnf;

if(!*__disc_id)return 0;

sprintf(path, "%s%s", is_ef0() ? "ef" : "ms", CFG_PATH);
fd = sceIoOpen(path, (config_offset >= 0)? PSP_O_RDWR : PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777);

Expand All @@ -82,11 +160,14 @@ int save_config(void)
}

memset(&cnf, 0, sizeof(cnf));
memcpy(cnf.disc_id, disc_id, 12);
memcpy(cnf.disc_id, __disc_id, 12);
cnf.version = g_conf.pops_fw_version;

if(config_offset >= 0) {
sceIoLseek(fd, config_offset * sizeof(CONFIG), PSP_SEEK_SET);
}else{
SceIoStat st;
if(sceIoGetstat(path,&st)>=0)config_offset=st.st_size>>4;
}

sceIoWrite(fd, &cnf, sizeof(cnf));
Expand All @@ -104,26 +185,33 @@ static int _load_config(void)
int offset = 0;

sprintf(path, "%s%s", is_ef0() ? "ef" : "ms", CFG_PATH);
{
SceIoStat stat;
if(sceIoGetstat(path,&stat)>=0 && (stat.st_size&0xf)){
sceIoRemove(path); //need to remove v1 conf
return -1;
}
}
fd = sceIoOpen(path, PSP_O_RDONLY, 0777);

if(fd < 0) {
return fd;
}

while((size = sceIoRead(fd, config, sizeof(CONFIG) * 32)) > 0) {
int cnt = size / sizeof(CONFIG);
int cnt = size / sizeof(CONFIG);

if(cnt > 0) {
int i;

for(i=0; i<cnt; i++) {
if(0 == memcmp(disc_id, config[i].disc_id, 9)) {
if(0 == memcmp(__disc_id, config[i].disc_id, 9)) {
sceIoClose(fd);
g_conf.pops_fw_version = config[i].version;
config_offset = offset + i;

return 0;
}
}
}

offset += cnt;
Expand Down
6 changes: 5 additions & 1 deletion popsloader/common/libs.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ unsigned int find_import_bynid(SceModule *pMod, char *library, unsigned int nid)
return 0;
}

extern u32 me_fw;
/**
* Remember you have to export the hooker function if using syscall hook
*/
Expand Down Expand Up @@ -111,7 +112,10 @@ int hook_import_bynid(SceModule *pMod, char *library, unsigned int nid, void *fu
if(syscall) {
u32 syscall_num;

syscall_num = sctrlKernelQuerySystemCall(func);
int sctrlKernelQuerySystemCall_patch(void *addr);
syscall_num = me_fw?
sctrlKernelQuerySystemCall_patch(func):
sctrlKernelQuerySystemCall(func);

if(syscall_num == (u32)-1) {
printk("%s: cannot find syscall in %s_%08X\n", __func__, library, nid);
Expand Down
Loading