forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting eboot images and names

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Tue Oct 21, 2008 11:58 pm    Post subject: Getting eboot images and names Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Oct 22, 2008 12:11 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Wed Oct 22, 2008 12:32 am    Post subject: Reply with quote

Look at the unpack-pbp source that comes with the SDK.
Back to top
View user's profile Send private message
Onii



Joined: 05 Oct 2008
Posts: 40

PostPosted: Wed Oct 22, 2008 10:13 am    Post subject: Reply with quote

File format for PBP files: http://hitmen.c02.at/files/yapspd/psp_doc/chap26.html#sec26.3
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Thu Oct 23, 2008 6:20 am    Post subject: Reply with quote

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:
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]
Back to top
View user's profile Send private message MSN Messenger
Onii



Joined: 05 Oct 2008
Posts: 40

PostPosted: Thu Oct 23, 2008 9:13 am    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message
Onii



Joined: 05 Oct 2008
Posts: 40

PostPosted: Thu Oct 23, 2008 12:51 pm    Post subject: Reply with quote

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:

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;
}
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Fri Oct 24, 2008 12:14 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group