Advertising (This ad goes away for registered users. You can Login or Register)

Binary Loader's bug

This is the development forum of the half-byte loader project. For general Half Byte Loader questions, visit the Half Byte Loader forum.
Forum rules
This forum is for HBL Development discussions ONLY. For User support or HBL general discussions, go to viewforum.php?f=3 . Messages that are not development related will be deleted.
neur0n
Guru
Posts: 46
Joined: Tue Sep 28, 2010 2:52 am
Contact:

Binary Loader's bug

Post by neur0n »

I found a bug in the Binary Loader.
This bug, h.bin will remain open.

Look at loader.s code.

Code: Select all

move $a0, $v0		/* set the return value of the function for arg0 of the next function */

lui $a1, 0x08D2 
lui $a2, 1		
jal 0x08A88578		/* sceIoRead */
nop

jal 0x08A88590		/* sceIoClose   <-- a0 has lost ! */
nop
sceIoClose needs file-uid. It must be stored in $a0.
But $a0 value has been already lost when call sceIoRead .
sceIoClose can not close h.bin! :o

So I suggest to edit code like this.

Code: Select all

move $a0, $v0		/* set the return value of the function for arg0 of the next function */

lui $a1, 0x08D2 
lui $a2, 1		
jal 0x08A88578		/* sceIoRead */
move $s0, $a0		/*Backup $a0 value*/

jal 0x08A88590		/* sceIoClose */
move $a0, $s0		/*Restore $a0 value*/
If you want to confirm that opened file status , start psplink and type "uidlist Iob". :)
Advertising
I have two Savedata Exploit.
One is Monster Hunter :)
wololo
Site Admin
Posts: 3621
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Binary Loader's bug

Post by wololo »

Thanks. Hmm, it means we'll need to update all the save files :/
Advertising
If you need US PSN Codes, this technique is what I recommend.

Looking for guest bloggers and news hunters here at wololo.net, PM me!
JJS
Big Beholder
Posts: 1416
Joined: Mon Sep 27, 2010 2:18 pm
Contact:

Re: Binary Loader's bug

Post by JJS »

I added this code to the SVN in R107. Thank you neur0n!

Together with the addition of two more sceKernelReleaseSubIntrHandler() calls in FreeMem(), this fixes Mobile Assault on Patapon 2.
Attachments
UCUS98732_DATA02.zip
New Patapon 2 savedata.
(137.35 KiB) Downloaded 436 times
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Binary Loader's bug

Post by m0skit0 »

Bad calling interface. $aX should not be modified by callee. Thumbs down Sony! :roll:
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
coyotebean
Guru
Posts: 96
Joined: Mon Sep 27, 2010 3:22 pm

Re: Binary Loader's bug

Post by coyotebean »

m0skit0 wrote:Bad calling interface. $aX should not be modified by callee. Thumbs down Sony! :roll:
The spec of EABI states that only "s" registers need to be preserved by callee.
mips eabi documentation http://www.cygwin.com/ml/binutils/2003-06/msg00436.html
GBASP x1, GBM x2, NDSL x2, PSP 100X x3, PSP 200X x6, PSP 300X x5, PSP Go x4, Wii x1
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Binary Loader's bug

Post by m0skit0 »

SDK function prototypes state that variables are passed by value and not by reference.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
coyotebean
Guru
Posts: 96
Joined: Mon Sep 27, 2010 3:22 pm

Re: Binary Loader's bug

Post by coyotebean »

m0skit0 wrote:SDK function prototypes state that variables are passed by value and not by reference.
C prototypes doesn't 100% applies to assembly. e.g. at assembly level, a function only returns a 32-bit value in $v0 for "C" return value of byte/short/int. The compiler generate codes to deal with it. You can see that most routines will push "s" registers to the stack and save the arguments (a0-a3,t0-t3) in "s" registers if the value needed to be used repeatedly.
GBASP x1, GBM x2, NDSL x2, PSP 100X x3, PSP 200X x6, PSP 300X x5, PSP Go x4, Wii x1
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Binary Loader's bug

Post by m0skit0 »

coyotebean wrote:C prototypes doesn't 100% applies to assembly
You're wrong. SDK prototypes (whatever the high language used) MUST apply to assembly 100%, otherwise it makes no sense to have those prototypes. That's the compiler duty. I understand here that either Sony's compiler or SDK is faulty.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
Nymphaea
Retired Mod
Posts: 158
Joined: Fri Oct 01, 2010 8:40 pm
Contact:

Re: Binary Loader's bug

Post by Nymphaea »

Technically, the prototypes do hold. Remember that $a0 is a register, not a variable, when assembled from C the program probably reloads all the arguments before each function from the actual variable. You just have to get used to the wierdness of MIPS I guess. I'm mostly not used to the way the stack works, I miss push(a) and pop(a) :P
There are 10 types of people in the world:
jocks,
nerds,
preps,
emos,
punks,
crazies,
losers,
ghosts,
individuals
and people who don't give a dang about the stupid binary joke.
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Binary Loader's bug

Post by m0skit0 »

Nymphaea wrote:when assembled from C the program probably reloads all the arguments before each function from the actual variable
Callee should save all arguments into the stack if he's gonna change their values, and then restore them before returning to caller.
Nymphaea wrote:You just have to get used to the wierdness of MIPS I guess
Sorry, but x86 is WAY weirder than MIPS.
Nymphaea wrote:'m mostly not used to the way the stack works, I miss push(a) and pop(a)
Disagree as well. I prefer having clear instructions than two pseudo-instruction that only hide what's the processor actually doing (just like CALL on x86 as well). It way more confuse. That's why MIPS is RISC and Intel's nonsense is definitely CISC.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
Locked

Return to “Half Byte Loader Development”