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 

sceUtilitySavedataInitStart

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Tue Nov 01, 2005 4:13 pm    Post subject: sceUtilitySavedataInitStart Reply with quote

i'm trying to modify a save throught this function, by using as reference shine's savedata tool (thanks for this great tool :))
but after i called it and while waiting for it to finish the psp crashes, so i added the exception handler and i got this:
Code:

Exception - Adress load/inst fecth
EPC       - 0878B7A0
Cause       - 00000010
Status       - 20008613
BadVAddr    - 882EA1E4
zr: 00000000 at: 0008FF00 v0: 882EA1D8 v1: 08790000
a0: 0879272C a1: 08790000 a2: FFFFFFFF a3: 00000001
t0: FFFFFFFF t1: D3100000 t2: 00000018 t3: 0000000C
t4: 087FFE90 t5: 00000E00 t6: 0878B780 t7: 00008600
s0: DEADBEEF s1: DEADBEEF s2: DEADBEEF s3: DEADBEEF
s4: DEADBEEF s5: DEADBEEF s6: DEADBEEF s7: DEADBEEF
t8: 88225528 t9: 00000030 k0: 087FFF00 k1: 00000000
gp: 0879B790 sp: 087FFE90 fp: 087FFEC0 ra: 0878B780

then i tried psp-addr2line, but i got nothing
i can't understant what the problem this is the piece of code crashing

Code:
   printf("A");
  int lenght = strlen(name);
   printf("B%d", lenght);
  int parsepos = strlen(g_gameName);
  int result = 0;
     printf("C%d", parsepos);
 printf("C- %d - %d =", lenght-parsepos, (int)name+(lenght-parsepos));
   g_saveName = malloc((lenght-parsepos)*sizeof(char));
   memset(g_saveName,0, sizeof(g_saveName));
  strcpy(g_saveName, name+(lenght-parsepos+1));
     printf("D");

  printf("%s - %s", g_saveName, name);
       printf("E");
      SceUtilitySavedataParam savedata;
      initSavedata(&savedata, 0);
      savedata.readIcon0Buf = g_readIcon0;
      savedata.sizeOfReadIcon0Buf = 0x100000;
      savedata.readIcon1Buf = g_readIcon1;
      savedata.sizeOfReadIcon1Buf = 0x100000;
      savedata.readPic1Buf = g_readPic1;
      savedata.sizeOfReadPic1Buf = 0x100000;
      printf("ready\n");
      result = sceUtilitySavedataInitStart(savedata);
    printf("result: %d", result);

      if (result)
      {
         printf("sceUtilitySavedataInitStart failed");
         return -1;
      }
      while (1) {
         printf("while"); //when it arrives here i see a lot of while (3 lines) then crash without exeception handler, if there is the exception handler the while loop continue without any limit

         result = sceUtilitySavedataGetStatus();
         if (result == 3) break;
         sceUtilitySavedataUpdate(1);
         sceDisplayWaitVblankStart();
      }
            printf("stopping 1\n");

      sceUtilitySavedataShutdownStart();


thanks in advance
Back to top
View user's profile Send private message Visit poster's website
EdisonCarter



Joined: 31 Oct 2005
Posts: 2

PostPosted: Wed Nov 02, 2005 3:27 am    Post subject: Reply with quote

Hey, I was just working on the same stuff.

The problem is in this section of code:

printf("A");
int lenght = strlen(name);
printf("B%d", lenght);
int parsepos = strlen(g_gameName);
int result = 0;
printf("C%d", parsepos);
printf("C- %d - %d =", lenght-parsepos, (int)name+(lenght-parsepos));
g_saveName = malloc((lenght-parsepos)*sizeof(char));
memset(g_saveName,0, sizeof(g_saveName));
strcpy(g_saveName, name+(lenght-parsepos+1));
printf("D");

The strcpy is starting from the wrong place in the string instead of the part after the gamename like I think you intended. This string is going to be longer than the memory you allocated and overrun the buffer.

Also, the memset uses sizeof(g_saveName) which equals 4, the size of the pointer, not the size of the memory allocated, but that line isn't needed anyway.

Here it is with corrections:

printf("A");
int length = strlen(name);
printf("B%d", length);
int parsepos = strlen(g_gameName);
int result = 0;
printf("C%d", parsepos);
printf("C- %d - %d =", length-parsepos, (int)name+(length-parsepos));
g_saveName = malloc((length-parsepos+1)*sizeof(char)); // added +1 for the '\0' string terminator
strcpy(g_saveName, name+parsepos);
printf("D g_gameName=%s g_saveName=%s", g_gameName, g_saveName);

I would probably do it this way to be a little less error prone:

int parsepos = strlen(g_gameName);
if (parsepos > strlen(name))
parsepos = strlen(name);
g_saveName = malloc(strlen(name+parsepos)+1);
strcpy(g_saveName, name+parsepos);
Back to top
View user's profile Send private message Visit poster's website
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Wed Nov 02, 2005 4:24 am    Post subject: Reply with quote

ok, i tried also this but it still don't work :(
actually i tried also hardcoding the name but still it didn't work and commenting out that section but nothing.
so i decided to save on ms the structure as a file. the result file seems corrent, but being not an expert of how this function work it could be wrong. now i put the file up there. maybe i'll also put the source somewhere
Back to top
View user's profile Send private message Visit poster's website
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Wed Nov 02, 2005 4:33 am    Post subject: Reply with quote

that's the file in hexadecimal
C805000000000000000000001100000013000000120000001000000000000000000000000000000000000000000000000000
00000000000001000000554C4A533030303135000000000000002D3030300000000000000000000000000000000000000000
444154412E42494E000000000000000088DD9608000010000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000090DDA60800001000000000000000000098DDB608000010000000000000000000A0DDC6080000
100000000000000000000000000000000000000000000000000000000000

and this in ascii
............................................................ULJS00015.......-000....................
DATA.BIN............................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
................................................................................

as you can see teorycally it should be fine (at least from what i understood) but it still don't work :(
Back to top
View user's profile Send private message Visit poster's website
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Fri Nov 04, 2005 4:35 am    Post subject: Reply with quote

ok, i finally got it to work it was working under kernel mode and so crashing, i changed the main thread attribute to user and it started working perfectly :)
thanks EdisonCarter for the help and to the others over at irc channel and thanks to shine for his original source :)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    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