Getting eboot images and names

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Getting eboot images and names

Post by coolkehon »

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
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

EBOOT has a simple structure with a header that points to the contained files. Look at an EBOOT and figure it out, or google it.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Look at the unpack-pbp source that comes with the SDK.
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

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: 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();
	}
}
[/code]
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

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...
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

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&#40;icon0DataLength <= 0&#41;&#123;
        sceIoClose&#40;fp&#41;;
        return -1;
    &#125;

    // Create a buffer just big enough for the icon0 data
    //
    icon0Data = malloc&#40;icon0DataLength&#41;;

    // If we ran out of memory
    //
    if&#40;!icon0Data&#41;&#123;
        sceIoClose&#40;fp&#41;;
        return -1;
    &#125;

    // Skip to the icon0 data
    //
    if&#40;sceIoLseek32&#40;fp, icon0Offset, SEEK_SET&#41; == 0&#41;&#123;
        sceIoClose&#40;fp&#41;;
        return -1;
    &#125;

    // Read the offset to the end of the icon0 data in the eboot
    // return error if we couldn't read it all
    //
    if&#40;sceIoRead&#40;fp, icon0Data, icon0DataLength&#41; != icon0DataLength&#41;&#123;
        sceIoClose&#40;fp&#41;;
        return -1;
    &#125;

    // Close the EBOOT now that we're done with it
    //
    sceIoClose&#40;fp&#41;;

    fp = NULL;

    // Delete the exiting destination file &#40;if one exists&#41;
    //
    sceIoRemove&#40;icon0fileName&#41;;

    // Open destination file to write out our data
    //
    fp = sceIoOpen&#40;icon0fileName, PSP_O_WRONLY|PSP_O_CREAT, 0777&#41;;

    if&#40;!fp&#41;&#123;
        return -1;
    &#125;

    // Write out our data. If it failed, clean up
    //
    if&#40;sceIoWrite&#40;fp, icon0Data, icon0DataLength&#41; != icon0DataLength&#41;&#123;
        sceIoClose&#40;fp&#41;;
        sceIoRemove&#40;icon0fileName&#41;;
        return -1;
    &#125;

    // We're all done here
    //
    sceIoClose&#40;fp&#41;;

    // Return success
    //
    return 1;
&#125;
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

thanks man this forum is great and filled with programmers mabye now i can move on and look at your code and learn by example about some of this stuff kinda new to c++ and c

only wish my gmail wasnt blocked so it would email me about topic replies
Post Reply