Skip to content

Commit

Permalink
fixed file browser
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Jul 10, 2023
1 parent 10eb954 commit 1078e0a
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 39 deletions.
2 changes: 1 addition & 1 deletion common/include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#define ARK_MAJOR_VERSION 4
#define ARK_MINOR_VERSION 20
#define ARK_MICRO_VERSION 60
#define ARK_REVISION 6
#define ARK_REVISION 7
#define MAX_FLASH0_SIZE 0x32000

/*
Expand Down
19 changes: 8 additions & 11 deletions core/compat/vitapops/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ STMOD_HANDLER previous = NULL;
ARKConfig* ark_config = NULL;

extern void ARKVitaPopsOnModuleStart(SceModule2* mod);
extern int (*prev_start)(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt);
extern int StartModuleHandler(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt);

// Flush Instruction and Data Cache
void flushCache()
Expand Down Expand Up @@ -53,13 +55,12 @@ static void processArkConfig(){
// Boot Time Entry Point
int module_start(SceSize args, void * argp)
{
/*
#ifdef DEBUG
_sw(0x44000000, 0xBC800100);
setScreenHandler(&copyPSPVram);
initVitaPopsVram();
colorDebug(0xFF);
_sw(0,0);
*/
colorDebug(0xFF00);
#endif

// set rebootex for VitaPOPS
sctrlHENSetRebootexOverride(rebootbuffer_vitapops);
Expand All @@ -69,19 +70,15 @@ int module_start(SceSize args, void * argp)
// set screen handler for color debugging
setScreenHandler(&pops_vram_handler);
#endif

/*
_sw(0x44000000, 0xBC800100);
setScreenHandler(&copyPSPVram);
initVitaPopsVram();
colorDebug(0xFF00);
*/

// copy configuration
processArkConfig();

// Register Module Start Handler
previous = sctrlHENSetStartModuleHandler(ARKVitaPopsOnModuleStart);

// Register custom start module
prev_start = sctrlSetStartModuleExtra(StartModuleHandler);

// Return Success
return 0;
Expand Down
6 changes: 2 additions & 4 deletions core/compat/vitapops/popcorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,8 @@ int patchPopsMan(SceModule2 *mod) {
original = 1;

int (* SetCompiledSdkVersion)() = (void *)sctrlHENFindFunction("sceSystemMemoryManager", "SysMemUserForUser", 0x358CA1BB);
if (!SetCompiledSdkVersion)
return 1;

SetCompiledSdkVersion(0x06060110);
if (SetCompiledSdkVersion)
SetCompiledSdkVersion(0x06060110);

u32 text_addr = mod->text_addr;

Expand Down
76 changes: 60 additions & 16 deletions core/compat/vitapops/syspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,6 @@ int sceKernelResumeThreadPatched(SceUID thid) {
void ARKVitaPopsOnModuleStart(SceModule2 * mod){

static int booted = 0;

if (DisplaySetFrameBuf){
static int screen_init = 0;
if (!screen_init){
setScreenHandler(&copyPSPVram);
initVitaPopsVram();
initScreen(DisplaySetFrameBuf);
screen_init = 1;
}
cls();
PRTSTR1("mod: %s", mod->modname);
}

// Patch display in PSX exploits
if(strcmp(mod->modname, "sceDisplay_Service") == 0) {
Expand All @@ -142,11 +130,25 @@ void ARKVitaPopsOnModuleStart(SceModule2 * mod){
patchKermitPeripheral(&_ktbl);
goto flush;
}
/*
if (strcmp(mod->modname, "sceIOFileManager") == 0){
// remove k1 checks -> move $a2, 0
_sw(0x00003021, 0x8805769c); // IoRead
_sw(0x00003021, 0x880577b0); // IoWrite
goto flush;
}
if (strcmp(mod->modname, "sceLoadExec") == 0){
// patch IO checks
_sw(JR_RA, mod->text_addr + 0x0000222C);
_sw(LI_V0(0), mod->text_addr + 0x00002230);
goto flush;
}
*/

/*
if (strcmp(mod->modname, "scePops_Manager") == 0){
patchPopsMan(mod);
goto flush;
}
if (strcmp(mod->modname, "pops") == 0) {
Expand All @@ -156,13 +158,15 @@ void ARKVitaPopsOnModuleStart(SceModule2 * mod){
}
*/

/*
if (strcmp(mod->modname, "CWCHEATPRX") == 0) {
if (sceKernelInitKeyConfig() == PSP_INIT_KEYCONFIG_POPS) {
hookImportByNID(mod, "ThreadManForKernel", 0x9944F31F, sceKernelSuspendThreadPatched);
hookImportByNID(mod, "ThreadManForKernel", 0x75156E8F, sceKernelResumeThreadPatched);
goto flush;
}
}
*/

// Boot Complete Action not done yet
if(booted == 0)
Expand All @@ -171,12 +175,12 @@ void ARKVitaPopsOnModuleStart(SceModule2 * mod){
if(isSystemBooted())
{
// Set fake framebuffer so that cwcheat can be displayed
DisplaySetFrameBuf((void *)fake_vram, PSP_SCREEN_LINE, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_NEXTFRAME);
memset((void *)fake_vram, 0, SCE_PSPEMU_FRAMEBUFFER_SIZE);
//DisplaySetFrameBuf((void *)fake_vram, PSP_SCREEN_LINE, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_NEXTFRAME);
//memset((void *)fake_vram, 0, SCE_PSPEMU_FRAMEBUFFER_SIZE);

// Start control poller thread so we can exit via combo on PS1 games
if (sceKernelInitApitype() == 0x144){
startControlPoller();
//startControlPoller();
}

// Boot Complete Action done
Expand All @@ -193,3 +197,43 @@ void ARKVitaPopsOnModuleStart(SceModule2 * mod){
// Forward to previous Handler
if(previous) previous(mod);
}

int (*prev_start)(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt) = NULL;
int StartModuleHandler(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt){

SceModule2* mod = (SceModule2*) sceKernelFindModuleByUID(modid);

if (DisplaySetFrameBuf){
static int screen_init = 0;
if (!screen_init){
setScreenHandler(&copyPSPVram);
initVitaPopsVram();
initScreen(DisplaySetFrameBuf);
screen_init = 1;
}
cls();
PRTSTR1("mod: %s", mod->modname);
}

/*
static SceModule2* popsman = NULL;
if (mod){
if (strcmp(mod->modname, "scePops_Manager") == 0){
//patchPopsMan(mod);
popsman = mod;
}
else if (strcmp(mod->modname, "sceKernelLibrary") == 0 && popsman){
int modid = sceKernelLoadModule("flash0:/kd/ark_popcorn.prx", 0, 0);
sceKernelStartModule(modid, 0, 0, 0, 0);
}
}
*/

// forward to previous or default StartModule
if (prev_start) return prev_start(modid, argsize, argp, modstatus, opt);
return -1;
}
1 change: 1 addition & 0 deletions core/popcorn/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ int module_start(SceSize args, void* argp)
#ifdef DEBUG
printk("pops disc id: %s\r\n", g_DiscID);
#endif

g_pspFwVersion = sceKernelDevkitVersion();

getKeys();
Expand Down
5 changes: 4 additions & 1 deletion extras/menus/arkMenu/src/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,10 @@ void Browser::refreshDirs(const char* retry){
vector<Entry*> files;

pspMsPrivateDirent *pri_dirent = (pspMsPrivateDirent*)malloc(sizeof(pspMsPrivateDirent));
memset(pri_dirent, 0, sizeof(pspMsPrivateDirent));
pri_dirent->size = sizeof(pspMsPrivateDirent);
dit.d_private = (void*)pri_dirent;
static int bufid = 0;

while ((sceIoDread(dir, &dit)) > 0){
printf("got entry: %s -> %s\n", dit.d_name, pri_dirent);

Expand Down Expand Up @@ -889,6 +890,7 @@ void Browser::recursiveFolderDelete(string path){
memset(&entry, 0, sizeof(SceIoDirent));

pspMsPrivateDirent *pri_dirent = (pspMsPrivateDirent*)malloc(sizeof(pspMsPrivateDirent));
memset(pri_dirent, 0, sizeof(pspMsPrivateDirent));
pri_dirent->size = sizeof(pspMsPrivateDirent);
entry.d_private = (void*)pri_dirent;

Expand Down Expand Up @@ -943,6 +945,7 @@ long Browser::recursiveSize(string path){
memset(&entry, 0, sizeof(SceIoDirent));

pspMsPrivateDirent *pri_dirent = (pspMsPrivateDirent*)malloc(sizeof(pspMsPrivateDirent));
memset(pri_dirent, 0, sizeof(pspMsPrivateDirent));
pri_dirent->size = sizeof(pspMsPrivateDirent);
entry.d_private = (void*)pri_dirent;

Expand Down
4 changes: 2 additions & 2 deletions extras/menus/arkMenu/src/browser_entries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ BrowserFile::~BrowserFile(){
}

void BrowserFile::setShortName(string shortname){
if (shortname.size() > 0){
this->shortname = "";
if (shortname.size() > 0 && shortname[0] != 0x14){
if (this->name.size() < shortname.size()){
this->path = this->parent + shortname;
this->name = shortname;
this->shortname = "";
}
else {
this->shortname = shortname;
Expand Down
2 changes: 1 addition & 1 deletion extras/menus/arkMenu/src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ void common::setThemePath(char* path){
}

bool common::isFolder(SceIoDirent* dit){
return (dit->d_stat.st_attr == FIO_SO_IFDIR || dit->d_stat.st_attr == 48 || dit->d_stat.st_attr == 22);
return FIO_SO_ISDIR(dit->d_stat.st_attr) || FIO_S_ISDIR(dit->d_stat.st_mode);
}

bool common::fileExists(const std::string &path){
Expand Down
40 changes: 37 additions & 3 deletions extras/menus/provsh/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,42 @@ __attribute__((noinline)) void PSXFlashScreen(u32 color)
while(vram < vramend) *(u16*)(vram += 2) = color16;
}

void testIo(){
static char tmp[256];
int res;

int fd = sceIoOpen("ms0:/iolog.txt", PSP_O_WRONLY|PSP_O_CREAT|PSP_O_TRUNC, 0777);

res = sceIoOpen("ms0:/__test__.txt", PSP_O_WRONLY|PSP_O_CREAT|PSP_O_TRUNC, 0777);
sceIoClose(res);
sprintf(tmp, "sceIoOpen: %p\n", res);
sceIoWrite(fd, tmp, strlen(tmp));

res = sceIoRemove("ms0:/__test__.txt");
sprintf(tmp, "sceIoRemove: %p\n", res);
sceIoWrite(fd, tmp, strlen(tmp));

res = sceIoMkdir("ms0:/PSP/SAVEDATA/__testdir__", 0777);
sprintf(tmp, "sceIoMkdir: %p\n", res);
sceIoWrite(fd, tmp, strlen(tmp));

res = sceIoDopen("ms0:/PSP/SAVEDATA/__testdir__");
sceIoDclose(res);
sprintf(tmp, "sceIoDopen: %p\n", res);
sceIoWrite(fd, tmp, strlen(tmp));

res = sceIoRmdir("ms0:/PSP/SAVEDATA/__testdir__");
sprintf(tmp, "sceIoRmdir: %p\n", res);
sceIoWrite(fd, tmp, strlen(tmp));

SceIoStat stat;
res = sceIoGetstat("ms0:/PSP/SAVEDATA/ARK_01234/ARK4.BIN", &stat);
sprintf(tmp, "sceIoGetstat: %p\n", res);
sceIoWrite(fd, tmp, strlen(tmp));

sceIoClose(fd);
}

// Entry Point
int main(int argc, char * argv[])
{
Expand All @@ -141,9 +177,7 @@ int main(int argc, char * argv[])
}
*/

int fd = sceIoOpen("ms0:/proshell.log", PSP_O_WRONLY|PSP_O_CREAT|PSP_O_APPEND, 0777);
sceIoWrite(fd, "hello\n", 6);
sceIoClose(fd);
testIo();

// Set Start Path
strcpy(cwd, START_PATH);
Expand Down
3 changes: 3 additions & 0 deletions loader/live/kernel/psxloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ int exploitEntry(){
// Switch to Kernel Permission Level
setK1Kernel();

int (*DisplaySetHoldMode)(int) = FindFunction("sceDisplay_Service", "sceDisplay", 0x7ED59BC4);
DisplaySetHoldMode(0);

PRTSTR("ARK-X Loader Started");

scanArkFunctions(g_tbl);
Expand Down

0 comments on commit 1078e0a

Please sign in to comment.