Getting eboot images and names
Getting eboot images and names
how do i get the eboot image data from the eboot like icon0 and others if i can get the data and write it to an file to read it that would be good could someone make an function sample to get the image and names
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm
File format for PBP files: http://hitmen.c02.at/files/yapspd/psp_d ... ml#sec26.3
I been trying to get it but i dont know to much about binary file io so i was playing with it but couldnt figure it out here is the function i have so far can someone update it / change it to get it to work
[/code]
Code: Select all
void Test::loadData()
{
char * memblock;
ifstream::pos_type loc,size;
u32 offset,endset;
ifstream file ("EBOOT.PBP", ios::in|ios::binary|ios::ate);
if (file.is_open())
{
size = sizeof(u32) * 4;
memblock = new char[size];
loc = sizeof(u32) * 12;
file.seekg(loc,ios::beg);
file.read(memblock,size);
offset = (u32)memblock;
oslDebug("memblock size = %d",sizeof(memblock));
loc = sizeof(u32) * 16;
file.seekg(loc,ios::beg);
file.read(memblock,size);
endset = (u32)memblock;
oslDebug("memblock size = %d",sizeof(memblock));
oslDebug("offset = %i\nendset = %i",offset,endset);
loc = offset;
size = endset-offset;
delete[] memblock;
memblock = new char[size];
file.seekg(loc,ios::beg);
file.read(memblock,size);
ofstream out("icon0.png",ios::out|ios::binary);
if(out.is_open())
{
out.write(memblock,size);
output.setText("tried :load image & save it");
out.close();
}
else
output.setText("error writing");
delete[] memblock;
memblock = NULL;
file.close();
}
}
Do you want the function to just write out the PNG file or do you want it as a texture in memory that you can blit (or both)? If I have time tonight (depending on how quickly this audio development goes) I'll hack something together. Writing out a PNG will be trivial, converting to a texture will be a little more work using libpng, and you'll probably have to tweak it for the bit depth you want etc...
Here's a quick hack to extract the icon0.png data out of a PBP. Based loosely off my pspGetTitleFromEBOOT() code. http://forums.ps2dev.org/viewtopic.php?p=75257#75257
Code: Select all
u32 pspGetIcon0FromEBOOT(const char * EBOOTfileName, const char * icon0fileName){
const u32 BPBSignature = 0x50425000;
u32 foundPBPSig = 0;
u32 icon0Offset = 0;
u32 icon0EndOffset = 0;
u32 icon0DataLength = 0;
void * icon0Data = NULL;
SceUID fp = sceIoOpen(EBOOTfileName, PSP_O_RDONLY, 0777);
if(!fp){
return -1;
}
// Read the eboot signature
//
if(sceIoRead(fp, &foundPBPSig, 4) != 4){
sceIoClose(fp);
return -1;
}
// Check the PBP Signature
//
if(foundPBPSig != BPBSignature){
sceIoClose(fp);
return -1;
}
// Skip offsets that we dont need from the header
//
if(sceIoLseek32(fp, 8, SEEK_CUR) == 0){
sceIoClose(fp);
return -1;
}
// Read the offset to the start of the icon0 data in the eboot
//
if(sceIoRead(fp, &icon0Offset, 4) != 4){
sceIoClose(fp);
return -1;
}
// Read the offset to the end of the icon0 data in the eboot
//
if(sceIoRead(fp, &icon0EndOffset, 4) != 4){
sceIoClose(fp);
return -1;
}
// Calculate the length of the icon0 data
//
icon0DataLength = icon0EndOffset - icon0Offset;
// There is no data or the offsets are broken
//
if(icon0DataLength <= 0){
sceIoClose(fp);
return -1;
}
// Create a buffer just big enough for the icon0 data
//
icon0Data = malloc(icon0DataLength);
// If we ran out of memory
//
if(!icon0Data){
sceIoClose(fp);
return -1;
}
// Skip to the icon0 data
//
if(sceIoLseek32(fp, icon0Offset, SEEK_SET) == 0){
sceIoClose(fp);
return -1;
}
// Read the offset to the end of the icon0 data in the eboot
// return error if we couldn't read it all
//
if(sceIoRead(fp, icon0Data, icon0DataLength) != icon0DataLength){
sceIoClose(fp);
return -1;
}
// Close the EBOOT now that we're done with it
//
sceIoClose(fp);
fp = NULL;
// Delete the exiting destination file (if one exists)
//
sceIoRemove(icon0fileName);
// Open destination file to write out our data
//
fp = sceIoOpen(icon0fileName, PSP_O_WRONLY|PSP_O_CREAT, 0777);
if(!fp){
return -1;
}
// Write out our data. If it failed, clean up
//
if(sceIoWrite(fp, icon0Data, icon0DataLength) != icon0DataLength){
sceIoClose(fp);
sceIoRemove(icon0fileName);
return -1;
}
// We're all done here
//
sceIoClose(fp);
// Return success
//
return 1;
}