So let's see an updated version of PSPersonalize....
Code: Select all
/* This is the source to a simple flash tool based on CleanSweep's alpha code by Dot_blank, Yoshi's bricker, and alot of help from ph0rkeh.
Good work guys and thanks for all the help! - Shout out to all my m8's at irc.toc2rta.com #pspchat who have helped me with my random projects. */
//
// Bricker Sample.
//
/*Standard headers*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/unistd.h>
/*PSPSDK headers*/
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspiofilemgr.h>
#include <psptypes.h>
#include <pspumd.h>
/*
================================================================================
standard psp stuff
================================================================================
*/
PSP_MODULE_INFO("CleanSweep", 0x1000, 1, 1); // 0x1000 = Kernel MODE
PSP_MAIN_THREAD_ATTR(0); // 0 for kernel mode too
#define printf pspDebugScreenPrintf
/* Define buffer size */
#define BUFSIZE 65536
char buf[BUFSIZE];
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
/* Define a write buffer */
char write_buffer[128*1024];
/* This code is taken from Yoshi's bricker.*/
void CopyExecute(const char* zFileSrc , const char* zFileDest) {
int fd1,fd2,len;
//Read
fd1 = sceIoOpen(zFileSrc, PSP_O_RDONLY, 0);
//Write
fd2 = sceIoOpen(zFileDest,PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
if(fd1 < 0)
{
printf("Error Message if the file is not there. \n");
}else{
while(1) {
len = sceIoRead(fd1, buf, BUFSIZE);
if (len == 0) break;
sceIoWrite(fd2,buf,len);
}
}
sceIoClose(fd1);
sceIoClose(fd2);
}
/* Menu */
void show_menu(void)
{
//basic description stuff
printf("This is a line that will be printed on the screen when the application is launched. \n");
//inputs for user
printf("Press Circle to replace system_plugin_bg.rco.\n");
}
/* main routine */
int main(void)
{
//assign buttons
SceCtrlData pad;
//basic psp startup stuff
pspDebugScreenSetBackColor(0xFFFFFFFF);
pspDebugScreenSetTextColor(0);
pspDebugScreenInit();
SetupCallbacks();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(1);
/* This displays the main menu for the application */
show_menu();
/* Assign the flash device. */
sceIoUnassign("flash0:");
sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", 0, NULL, 0);
/* Main Loop */
for(;;)
{
/* Watch for Circle being pressed */
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CIRCLE)
{
/* This is the line that deals the final blow. Be carefull I bricked my PSP with this bad boy. */
CopyExecute("ms0:/system_pluging_bg.rco","flash0:/vsh/resource/system_plugin_bg.rco");
/* Clear the screen after flashing is done. */
pspDebugScreenClear();
/* This prints a message after flashing is complete */
printf("Congratz you have just bricked your PSP.\n");
}
sceDisplayWaitVblankStart();
}
//lets go back to psp menu
sceKernelExitGame();
//just for good luck :)
return 0;
}
PyroSama aka Canti