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 

Memory dump problem

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



Joined: 13 Feb 2008
Posts: 4

PostPosted: Fri Feb 15, 2008 7:15 pm    Post subject: Memory dump problem Reply with quote

Hello

First of all sorry for my english, it is realy bad :( But i hope someone will help me anyway.

I need cfw-plugin that dumps region of memory to memory stick,
the region from where sceIoRead() was called.
I wrote it, but i have one little problem -
it works fine is XMB, but dont works at all in a game(i added it in seplugins/game.txt).
I added my source code below, what am i doing wrong? What should i do to make it work in game?

Actually I need this plugin in a game, not XMB.

Thanks.

Code:

#include<pspkernel.h>
#include<pspctrl.h>
#include "apihook.h"

PSP_MODULE_INFO("psplugin", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);

u32 ret;
int Caught=0, active=0;

int dump (void)
{
int fd = sceIoOpen ("ms0:/memdump.bin",PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);            
sceIoWrite (fd, (void*) (ret-1000), 5000);
sceIoClose (fd);
Caught=0;
return 0;
}



int sce_io_read(int fd, void* buff, int size)
{
if (active) {
   asm ("move %0, $ra\n": "=r" (ret));
   Caught=1;
   active=0;
   }
int res=sceIoRead(fd,buff,size);
return res;
}



int plugin_thread (SceSize argc, void* argp)
{

SceModule *pMod;
SceCtrlData pad;

pMod = sceKernelFindModuleByName("sceIOFileManager"); 
apiHookByName(pMod->modid, "IoFileMgrForKernel", "sceIoRead", sce_io_read);

while (1) {
   sceCtrlPeekBufferPositive (&pad, 1);
   if (pad.Buttons & PSP_CTRL_SELECT) active=1;
   if (Caught) dump();
   sceKernelDelayThread(100000);
   }
sceKernelExitDeleteThread(0);
return 0;
}


int module_start (SceSize argc, void* argp)
{
       SceUID thread = sceKernelCreateThread("plugin_thread", plugin_thread,  15, 0x800, 0, NULL);
          if (thread >= 0) {
               sceKernelStartThread (thread, argc, argp);
          }
          return 0;
}





I dont know for sure if $ra points to adress near sceIoRead call(probably it can point anywhere),
but XMB memdump shows that i'm right.


Code:

   0x000003D0: 0x00000000 '....' - nop       
   0x000003D4: 0x00000000 '....' - nop       
   0x000003D8: 0x408E6000 '.`.@' - mtc0       $t6, Status
   0x000003DC: 0x00000000 '....' - nop       
   0x000003E0: 0x01E0F809 '....' - jalr       $t7         <--- SceIoRead call (?)
   0x000003E4: 0x00000000 '....' - nop       
   0x000003E8: 0x00000000 '....' - nop                 <--- $ra points here
   0x000003EC: 0x70000026 '&..p' - mtic       $zr, $0
   0x000003F0: 0x00000000 '....' - nop       
   0x000003F4: 0x3C0FCCCC '...<' - lui        $t7, 0xCCCC
   0x000003F8: 0x35EFCCCC '...5' - ori        $t7, $t7, 0xCCCC
   0x000003FC: 0x3C0EBC00 '...<' - lui        $t6, 0xBC00
   0x00000400: 0x00000000 '....' - nop       

Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Feb 16, 2008 4:10 am    Post subject: Reply with quote

Erm for what purpose are you doing this? Do you want to dump sceIoRead in memory? Do you want to dump the location of the call to sceIoRead (which is going to be the syscall dispatch handler)? If you just want to dump sceIoRead there are simpler ways of doing so, in fact why just not decrypt the firmware and disassemble using prxtool ?
Back to top
View user's profile Send private message
Lexar



Joined: 13 Feb 2008
Posts: 4

PostPosted: Sat Feb 16, 2008 6:00 pm    Post subject: Reply with quote

Hello TyRaNiD
thanks for reply

Quote:

Erm for what purpose are you doing this?
Do you want to dump the location of the call to sceIoRead (which is going to be the syscall dispatch handler)?


For fun :) The idea is to know how the game loads saved games. I dont want to disassemble whole game so
I thought that dumping the locations of sceIoRead calls will give me necessary parts of code.
I almost forgot that games in usermode and are using syscalls, so my program will dump the syscall handler not
the game code. Ok, thank you for clarification i'll try to deal with this somehow...
Sorry for created topic, it may be deleted.


Quote:

If you just want to dump sceIoRead there are simpler ways of doing so, in fact why just not decrypt the
firmware and disassemble using prxtool ?


No, but it is interesting. Maybe i'll be back to this.
Back to top
View user's profile Send private message
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