forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wrighting to flash0 | Source

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
pyrosama



Joined: 13 May 2005
Posts: 66

PostPosted: Sun Nov 06, 2005 4:07 pm    Post subject: Wrighting to flash0 | Source Reply with quote

This is the source to a tool I put together to with the help of many others to replace files in the firmware.

So let's see an updated version of PSPersonalize....

Code:
/* 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;
}


Thanks,
PyroSama aka Canti
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Mon Nov 07, 2005 2:03 am    Post subject: Reply with quote

If you are writing/stealing code like this, then you definitely should not be messing with your firmware.
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Mon Nov 07, 2005 2:44 am    Post subject: Reply with quote

I am not sure I understood correctly, but it seems there are some people here who really want to kill homebrew psp development.
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
pyrosama



Joined: 13 May 2005
Posts: 66

PostPosted: Mon Nov 07, 2005 3:20 am    Post subject: Reply with quote

I just wanted to make available a working sample. Yoshi's code doesnt compile, dot's didnt work, and with those two and some help from others we made a working sample people can use...


And this isnt here to "kill homebrew psp development" it's to help it. Granted some people may attempt some not so great applications that cause damage but it's still a tool that should be made available. If a person is stupid enough to use it then they deserve a brick as I did.


Thanks,
PyroSama
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Mon Nov 07, 2005 12:45 pm    Post subject: Reply with quote

mmmh where did you get the source to yoshis bricker from?
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
pyrosama



Joined: 13 May 2005
Posts: 66

PostPosted: Mon Nov 07, 2005 12:45 pm    Post subject: Reply with quote

These forums.
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Mon Nov 07, 2005 12:49 pm    Post subject: Reply with quote

??? care to give a link?
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
placasoft



Joined: 28 Mar 2005
Posts: 53

PostPosted: Mon Nov 07, 2005 10:52 pm    Post subject: Reply with quote

Next time use search function ;)
http://forums.ps2dev.org/viewtopic.php?t=2214&highlight=flash

EDIT :
Ok guys, the above code is veeerrrry dangerous! Because if a file does not exist, he just copy a file with 0 byte ... so here is a code with check function ;)

Code:

/*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

int exist = 0;

/* 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];


// Checkfunction, too look if a file exist!


void check(const char* zFile)
{
   int fd3;
       fd3 = sceIoOpen(zFile, PSP_O_RDONLY, 0);
       if(fd3 < 0)
          {
            exist = 0;
            }else{
            exist = 1;
            }
  sceIoClose(fd3);
}


/* This code is taken from Yoshi's bricker + Placa check code ;)*/

void CopyExecute(const char* zFileSrc , const char* zFileDest) {
   check(zFileSrc);
   if (exist == 1){
   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);
  }else{
  printf("%s does not exist\n", zFileSrc);
   }
}

/* 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;
}
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Tue Nov 08, 2005 7:01 am    Post subject: Reply with quote

i HIGHLY do not recommend
anyone to attempt any of these
sample code snippets...they are
guaranteed psp brick ...if that is what
you want then have a blast ;)

but dont start crying if not and
dont say you havent been warned
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Tue Mar 21, 2006 2:24 am    Post subject: Reply with quote

There is an error in both samples:
CopyExecute("ms0:/system_pluging_bg.rco","flash0:/vsh/resource/system_plugin_bg.rco");

"system_pluging.rco"?
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Tue Mar 21, 2006 4:29 am    Post subject: Reply with quote

well you really shouldnt follow these verbatim
the correct path is indeed flash0:/vsh/resource/system_plugin_bg.rco
but you shouldnt have to mess with that file
in fact DO NOT mess around with that file
its basically useless and only affects the wavy lines
in xmb menu of psp
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Tue Mar 21, 2006 11:18 am    Post subject: Reply with quote

I was pointing out the spelling of 'plugin', not the file path.
The error would result in a definite brick with the first example without checking because the file spelled 'pluging'would not be found.

That whole first example should be edited out of this forum, it is a VIRUS.

I am messing with other flash0 files using similar example code.
I know the risks, have bricked two PSPs.
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Tue Mar 21, 2006 8:45 pm    Post subject: Reply with quote

a virus??? LOL
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Wed Mar 22, 2006 9:04 am    Post subject: Reply with quote

it is not a virus ...no such things exist for a psp
and dont let anyone tell you otherwise

what you see above is highly incorrect code in C
shoot its not even code at all :P...its like when kids
have paint ...they have blue and red and yellow
and then they just mix around with their hands ..making a mess
and yes that typo would result in a brick ...which
is why mostly anyone will tell you to not look at
this thread any longer ;)
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Thu Mar 23, 2006 5:43 pm    Post subject: Reply with quote

Ok, I guess you got me.
There's no way for any PSP program to perpetuate itself.

Do you have an example of a text (debug or graphics) menu that
you'd share with a C beginner? or a link to find one that can easily be
seperated from the rest of it's program?
Cheers, Art.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Wed Jul 26, 2006 4:07 pm    Post subject: Reply with quote

I read correctly if the third poster said that the second poster wants to kill homebrew development.

There is some homebrew that has been shoved to my attention that uses
the first example, and one of them is a real screamer.

It seems this piece of work does find a way to perpetuate itself :p
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Thu Jul 27, 2006 2:52 pm    Post subject: Reply with quote

you are the one who perpetuated it :P
this thread should not have been revived
frankly it should be locked already as
theres no more knowledge to gain from just
talking ...flash access is very common thing
these days now
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group