| View previous topic :: View next topic |
| Author |
Message |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Thu Jan 12, 2006 5:21 am Post subject: Finding the addres of the BSS segment |
|
|
Hi,
In my desperate search of figuring out how to get information about the volume level on the PSP I've started to dig into the sceWM8750_Driver module, which is the driver for the audio codec on the PSP. I don't have any experience on assembly on the MIPS platform, so the code basically doesn't say me anything. But I've figured out where the driver stores the information I need for the volume level.
So now I need to know how to figure out where the BSS segment for a prx is located. Using PSPInside, I can see the module info, which is returned by sceKernelQueryModuleInfo. This information lists the two segments (text and data) and the size of these. It also lists the size of the BSS segment, but where is this stored ?
Judgeing from the memory dumps I've studied in PSPInside, it is located right after the data segment, but is this always the case ? If this is normal, I can make a quite simple hack, by querying info from the codec driver and use the information directly. But I'm not much into how a prx and the segments are stored in memory.
Can anyone enlighten me on info about the BSS segment ?
Please :) I've spend quite a lot of time in this quest now, and I'm so close to finish it :) _________________ Br, Sandberg |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Thu Jan 26, 2006 7:55 am Post subject: |
|
|
| Oki, yes the bss should be after the data always, that is the way the psp allocates its stuff so you should be safe to base your address on the address of the data segment from sceKernelGetModuleInfo. |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Thu Jan 26, 2006 8:03 am Post subject: |
|
|
Thanks TyRaNiD .. I'll give it a try and see what comes out of it. If it works I'll post the code here, so that others can use it. _________________ Br, Sandberg |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Fri Jan 27, 2006 1:14 am Post subject: |
|
|
If you want to be really paranoid, you could always parse the EBOOT.PBP to find the ELF, then parse its headers to find the definitive info on BSS.
But Tyranid is right, in every PSP ELF I've ever seen (and I've looked at quite a few...) the BSS is right after the data. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Fri Jan 27, 2006 1:25 am Post subject: |
|
|
| Fanjita wrote: | If you want to be really paranoid, you could always parse the EBOOT.PBP to find the ELF, then parse its headers to find the definitive info on BSS.
But Tyranid is right, in every PSP ELF I've ever seen (and I've looked at quite a few...) the BSS is right after the data. |
Thanks, but it's not from an eboot, it's from a systems prx, which I need access to its BSS segment. I'll hack some code together tonight to do this. _________________ Br, Sandberg |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Fri Jan 27, 2006 1:34 am Post subject: |
|
|
Oops, sorry, I just noticed that and was about to go back and edit.
Never mind. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Fri Jan 27, 2006 6:19 am Post subject: |
|
|
Hi again,
Does any of you have experience with using the sceKernelGetModuleIdList and sceKernelQueryModuleInfo functions ?
I've just tried to do a simple loop to see what it came up with. But it only returns 5 modules ? and when calling sceKernelQueryModuleInfo to get info about these 5 modules it always fails ?
Is there something specific I should know about these functions ? I.e. PSPInside is able to list all loaded modules, so it should somehow be possible.
The code below is run in user mode.
| Code: |
int modulecount;
int counter;
SceUID modulelist[1024];
SceKernelModuleInfo modinfo;
if (!sceKernelGetModuleIdList(modulelist, 1024, &modulecount))
{
/* Iterate through all the modules to find the one we're looking for */
for (counter = 0 ; counter < modulecount ; counter++)
{
if(!sceKernelQueryModuleInfo(modulelist[counter], &modinfo))
{
/* Check if the name matches */
}
}
}
|
_________________ Br, Sandberg |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Fri Jan 27, 2006 6:46 am Post subject: |
|
|
Yah, to get the module info you must memset the structure (though probably not really necessary) and then set the size member to the size of the structure, i.e. memset(&modinfo, 0, sizeof(modinfo)); modinfo.size = sizeof(modinfo);
As for why your list is only returning 5 modules I am not sure, there could be permission issues but I am assuming you are running in kernel mode otherwise you will not be able to access the kernel module stuff.
You are not by chance running on a v1 are you? If you are then GetModuleIdList isn't support, and QueryModuleInfo doesn't actually work ;) THere are equivalent functions in the sdk library (libpspsdk.a) which do the same thing on v1 firmware. |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Fri Jan 27, 2006 7:22 am Post subject: |
|
|
If you're trying to run on v2.0 then you need to be careful about which functions you're using, as Tyranid says.
You will also find that you don't get full details back for most of the modules - not many modules, plus virtually no information about most of them, are hallmarks of running these functions in user mode.
For reference, the usable ones from user mode are sceKernelGetModuleIdList and sceKernelQueryModuleInfo - so it sounds like you are using the right ones.
Remember also to check the parameters you're passing to GetModuleIdList, the 'readbufSize' parameter is in bytes rather than longs, if I remember rightly - so you might inadvertently be passing a value that's smaller than you intend, which can limit the results you get. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Fri Jan 27, 2006 7:53 am Post subject: |
|
|
Thanks guys.
Running it in kernel mode (it ran in user mode before) and setting the size of the structure did the trick, and gave me a list of 68 modules, where the audio codec is one of them.
But I guess after all that this is not the best way to do it :) .. It most likely wouldn't work on 2.0 either. So I guess I have to figure out how to use the UART which is used for communication with the audio codec.
But thanks a lot for your help, I got to learn a lot figuring all this out. _________________ Br, Sandberg |
|
| Back to top |
|
 |
|