Loading an external dol/elf file June 17, 2010 04:09PM | Registered: 14 years ago Posts: 68 |
Re: Loading an external dol/elf file June 17, 2010 05:41PM | Moderator Registered: 15 years ago Posts: 5,075 |
Re: Loading an external dol/elf file June 17, 2010 11:34PM | Registered: 14 years ago Posts: 68 |
Re: Loading an external dol/elf file June 20, 2010 12:39AM | Registered: 14 years ago Posts: 68 |
Re: Loading an external dol/elf file June 20, 2010 12:52AM | Registered: 14 years ago Posts: 68 |
Re: Loading an external dol/elf file June 20, 2010 02:29AM | Registered: 15 years ago Posts: 444 |
if (kMap & KEY_A) { if (getItem(index)->size == 0) { updatePath(getItem(index)->name); index = 0; } else { if (supportedFile(getItem(index)->name)) { u8 *bufPtr = memoryLoad(getItem(index)); void (*entry)() = (void*)0x80001400; /* Do the right relocation. */ switch (validateHeader(bufPtr)) { case 0x0: entry = (void *)relocateDol(bufPtr); break; case 0x1: entry = (void *)relocateElf(bufPtr); break; } IOS_ReloadIOS(LOADMII_DEFAULT_IOS); cleanup(); entry(); } } }Lets rewright this in psudo code:
If the key A is pressed if the item has no size if it is a folder, then goto that folder set the index(current file selected to 0) otherwise if the file is a supported type .elf/.dol load the file into memory, and then store a pointer to it called bufPtr set the entry point to 0x80001400(not that this matters, it will be replaced later) if the file is a .dol set up the file as a dol otherwise set up the file as a elf load the correct IOS delete allocated memory that is no longer needed start the programI hope this helped, if you want a more indepth look at any of the functions just ask. A lot of what this program does is pointer manipulation.
Re: Loading an external dol/elf file June 20, 2010 11:47AM | Registered: 14 years ago Posts: 68 |
{ if (supportedFile(*file location*)) { u8 *bufPtr = memoryLoad(getItem(index)); void (*entry)() = (void*)0x80001400; /* Do the right relocation. */ switch (validateHeader(bufPtr)) { case 0x0: entry = (void *)relocateDol(bufPtr); break; case 0x1: entry = (void *)relocateElf(bufPtr); break; } IOS_ReloadIOS(LOADMII_DEFAULT_IOS); cleanup(); entry(); } }and then include all the other bits in that code.
Re: Loading an external dol/elf file June 21, 2010 12:10AM | Registered: 15 years ago Posts: 122 |
Re: Loading an external dol/elf file June 21, 2010 03:39AM | Registered: 15 years ago Posts: 444 |
u8 *bufPtr = 0x92000000; FILE *fp = fopen("path to file starting from root","rb") fread(bufPtr,1,size_of_file,fp) void (*entry)(); entry = (void *)relocateDol(bufPtr) IOS_ReloadIOS(correctIOS) //Do clean up stuff, like deallocating memory entry();assuming that correctIOS is the IOS you want to use, and that the file you want to use is a .dol this should work, but I haven't tested it yet. You also need to know the size of the file. I know there is an easy way to find this out, but I can't remember it at the moment.
Re: Loading an external dol/elf file June 21, 2010 09:51AM | Registered: 14 years ago Posts: 68 |
Re: Loading an external dol/elf file June 21, 2010 07:27PM | Registered: 15 years ago Posts: 444 |
Re: Loading an external dol/elf file June 21, 2010 08:54PM | Moderator Registered: 15 years ago Posts: 5,075 |
Re: Loading an external dol/elf file June 21, 2010 11:09PM | Registered: 14 years ago Posts: 68 |
u8 *bufPtr = 0x92000000; int size_of_file FILE *fp = fopen("path to file starting from root","rb") fseek(fp, 0, SEEK_END); size_of_file = ftell(fp); fseek(fp, 0, SEEK_SET); fread(bufPtr,1,size_of_file,fp) void (*entry)(); entry = (void *)relocateDol(bufPtr)IOS_ReloadIOS(correctIOS)//Do clean up stuff, like deallocating memory entry();