Random Homebrew: Odyssey emulator
Odyssey emulator
Friends: Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita

POPSECO: convert prxtool disasm output into pseudo-code

Forum rules
Any post not directly related to programming will be moderated.
Do not request people to code something for you.
Avoid posting messages that do not bring anything to the conversation. We want the threads in this subforum to stay focused.

POPSECO: convert prxtool disasm output into pseudo-code

Postby m0skit0 » Tue Apr 19, 2011 8:49 pm

I'll leave this small utility I wrote to help me RE PSP kernel modules. Only useful to people reverse engineering modules.

It's quite simple: it takes prxtool standard disassembly output and gives it a nicer and more direct look. Here's an example:

PRXTOOL bare output:

Code: Select all
module_start:
   0x00000000:   0x27BDFFF0 '...'' - addiu      $sp, $sp, -16
   0x00000004: 0x00A02021 '! ..' - move       $a0, $a1
   0x00000008: 0xAFBF0000 '....' - sw         $ra, 0($sp)
   0x0000000C: 0x0C0024F6 '.$..' - jal        sub_000093D8
   0x00000010: 0x00C02821 '!(..' - move       $a1, $a2
   0x00000014: 0x0C000C29 ')...' - jal        sceMSstor_driver_714782D6
   0x00000018: 0x00002021 '! ..' - move       $a0, $zr
   0x0000001C: 0x8FBF0000 '....' - lw         $ra, 0($sp)
   0x00000020: 0x03E00008 '....' - jr         $ra
   0x00000024: 0x27BD0010 '...'' - addiu      $sp, $sp, 16
   0x00000028: 0x27BDFFF0 '...'' - addiu      $sp, $sp, -16
   0x0000002C: 0xAFB00000 '....' - sw         $s0, 0($sp)

After being processed by popseco utility:

Code: Select all
module_start:
   0x00000000:   $sp = $sp + (-16);
   0x00000004: $a0 = $a1;
   0x00000008: 0($sp) = $ra;
   0x0000000C: sub_000093D8();
   0x00000010: $a1 = $a2;
   0x00000014: sceMSstor_driver_714782D6();
   0x00000018: $a0 = $zr;
   0x0000001C: $ra = 0($sp);
   0x00000020: ($ra)();
   0x00000024: $sp = $sp + (16);
   0x00000028: $sp = $sp + (-16);
   0x0000002C: 0($sp) = $s0;

Personally I find it easier to understand.

It's a Perl script, so you'll need a Perl interpreter to run it. It receives the file to process as an argument and spits the result to standard output. Recommended standard usage is:

Code: Select all
perl popseco.pl prxtool_output > prxtool_output_transformed


PS: be easy on me, it was my first Perl script, I was just starting to learn it :D

EDIT: added bug fixes by bluemimmosa, thanks! :)

popseco.pl.7z
(2.09 KiB) Downloaded 86 times
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4787
Joined: Mon Sep 27, 2010 6:01 pm

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby ultimakillz » Tue Apr 19, 2011 8:58 pm

very nice! might i ask which perl interpreter you suggest? the only one ive used is activeperl.
"Thanks to all you gays i am leaning allot" src
Which Linux Distro is right for me? Take A Quiz & Find Out or Compare Major Distros.
ultimakillz
Moderator
 
Posts: 1000
Joined: Mon Sep 27, 2010 6:55 pm
Location: Texas, USA

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby m0skit0 » Tue Apr 19, 2011 9:12 pm

I'm on Linux mate:

Code: Select all
m0skit0@sodiet:~$ perl -v

This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
(with 51 registered patches, see perl -V for more detail)

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4787
Joined: Mon Sep 27, 2010 6:01 pm

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby ultimakillz » Tue Apr 19, 2011 9:17 pm

ah ok. activeperl has versions for both linux (in fact it looks like thats whats included in linux) and windows, so its probably a good way to go, for those who need a perl interperter:
http://www.perl.org/get.html
"Thanks to all you gays i am leaning allot" src
Which Linux Distro is right for me? Take A Quiz & Find Out or Compare Major Distros.
ultimakillz
Moderator
 
Posts: 1000
Joined: Mon Sep 27, 2010 6:55 pm
Location: Texas, USA

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby m0skit0 » Tue Apr 19, 2011 9:19 pm

You can just simply install it from the repositories. That's Linux way to go ;)
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4787
Joined: Mon Sep 27, 2010 6:01 pm

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby ultimakillz » Tue Apr 19, 2011 9:22 pm

m0skit0 wrote:You can just simply install it from the repositories. That's Linux way to go ;)

agreed. i was simply thinking from a windows standpoint for the sake of others :lol:
"Thanks to all you gays i am leaning allot" src
Which Linux Distro is right for me? Take A Quiz & Find Out or Compare Major Distros.
ultimakillz
Moderator
 
Posts: 1000
Joined: Mon Sep 27, 2010 6:55 pm
Location: Texas, USA

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby m0skit0 » Tue Apr 19, 2011 9:25 pm

Windows users do not deserve using this awesome tool :lol:
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4787
Joined: Mon Sep 27, 2010 6:01 pm

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby ultimakillz » Tue Apr 19, 2011 9:44 pm

also fyi you've got a few references to advancedpsp.tk ( :cry: ) in the output and comments, im not sure if you would like to update those or not (lines 4 & 528, respectively).
"Thanks to all you gays i am leaning allot" src
Which Linux Distro is right for me? Take A Quiz & Find Out or Compare Major Distros.
ultimakillz
Moderator
 
Posts: 1000
Joined: Mon Sep 27, 2010 6:55 pm
Location: Texas, USA

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby m0skit0 » Tue Apr 19, 2011 9:48 pm

Nope, not likely to update anything tbh, but anyway people will find it here ;)
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4787
Joined: Mon Sep 27, 2010 6:01 pm

Re: POPSECO: convert prxtool disasm output into pseudo-code

Postby Davee » Mon Apr 25, 2011 5:35 pm

So it just literally translates the opcode...? |:
Follow me on twitter: @DaveeFTW
Davee
Guru
 
Posts: 294
Joined: Mon Jan 10, 2011 1:24 am

Next

Return to Programming

Who is online

Users browsing this forum: Jd8531 and 0 guests