mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-12-18 16:01:58 +01:00
Forwarder changes:
*Fixed Codedumps from Preload *Fixed USB not working *Changed back to old LoadMii dolloader (which is working with preloader too now)
This commit is contained in:
parent
02d53a5e09
commit
124c3f05ed
@ -8,7 +8,7 @@
|
||||
|
||||
#include "cfg.h"
|
||||
|
||||
char update_path[150]="";
|
||||
char update_path[150];
|
||||
|
||||
static char *cfg_name, *cfg_val;
|
||||
|
||||
|
@ -1,74 +1,54 @@
|
||||
// this code was contributed by shagkur of the devkitpro team, thx!
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
|
||||
typedef struct _dolheader {
|
||||
u32 text_pos[7];
|
||||
u32 data_pos[11];
|
||||
u32 text_start[7];
|
||||
u32 data_start[11];
|
||||
u32 text_size[7];
|
||||
u32 data_size[11];
|
||||
u32 bss_start;
|
||||
u32 bss_size;
|
||||
u32 entry_point;
|
||||
} dolheader;
|
||||
|
||||
u32 load_dol_image (void *dolstart) {
|
||||
u32 i;
|
||||
dolheader *dolfile;
|
||||
|
||||
if (dolstart) {
|
||||
dolfile = (dolheader *) dolstart;
|
||||
for (i = 0; i < 7; i++) {
|
||||
if ((!dolfile->text_size[i]) ||
|
||||
(dolfile->text_start[i] < 0x100))
|
||||
continue;
|
||||
|
||||
/*printf ("loading text section %u @ 0x%08x "
|
||||
"(0x%08x bytes)\n",
|
||||
i, dolfile->text_start[i],
|
||||
dolfile->text_size[i]);*/
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
ICInvalidateRange ((void *) dolfile->text_start[i],
|
||||
dolfile->text_size[i]);
|
||||
memmove ((void *) dolfile->text_start[i],
|
||||
dolstart+dolfile->text_pos[i],
|
||||
dolfile->text_size[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < 11; i++) {
|
||||
if ((!dolfile->data_size[i]) ||
|
||||
(dolfile->data_start[i] < 0x100))
|
||||
continue;
|
||||
|
||||
/*printf ("loading data section %u @ 0x%08x "
|
||||
"(0x%08x bytes)\n",
|
||||
i, dolfile->data_start[i],
|
||||
dolfile->data_size[i]);*/
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
memmove ((void*) dolfile->data_start[i],
|
||||
dolstart+dolfile->data_pos[i],
|
||||
dolfile->data_size[i]);
|
||||
DCFlushRangeNoSync ((void *) dolfile->data_start[i],
|
||||
dolfile->data_size[i]);
|
||||
}
|
||||
|
||||
//printf ("clearing bss\n");
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
|
||||
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
|
||||
|
||||
return dolfile->entry_point;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <gccore.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dolloader.h"
|
||||
|
||||
typedef struct _dolheader {
|
||||
u32 text_pos[7];
|
||||
u32 data_pos[11];
|
||||
u32 text_start[7];
|
||||
u32 data_start[11];
|
||||
u32 text_size[7];
|
||||
u32 data_size[11];
|
||||
u32 bss_start;
|
||||
u32 bss_size;
|
||||
u32 entry_point;
|
||||
} dolheader;
|
||||
|
||||
u32 load_dol_image (void *dolstart, struct __argv *argv) {
|
||||
u32 i;
|
||||
dolheader *dolfile;
|
||||
|
||||
if (dolstart) {
|
||||
dolfile = (dolheader *) dolstart;
|
||||
for (i = 0; i < 7; i++) {
|
||||
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue;
|
||||
VIDEO_WaitVSync();
|
||||
ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]);
|
||||
memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < 11; i++) {
|
||||
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
|
||||
VIDEO_WaitVSync();
|
||||
memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]);
|
||||
DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]);
|
||||
}
|
||||
|
||||
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
|
||||
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
|
||||
|
||||
if (argv && argv->argvMagic == ARGV_MAGIC) {
|
||||
void *new_argv = (void *)(dolfile->entry_point + 8);
|
||||
memmove(new_argv, argv, sizeof(*argv));
|
||||
DCFlushRange(new_argv, sizeof(*argv));
|
||||
}
|
||||
return dolfile->entry_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef _DOLLOADER_H_
|
||||
#define _DOLLOADER_H_
|
||||
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@ -12,23 +10,9 @@ extern "C"
|
||||
#define EXECUTABLE_MEM_ADDR 0x92000000
|
||||
/* dol header */
|
||||
|
||||
|
||||
extern void __exception_closeall();
|
||||
typedef void (*entrypoint) (void);
|
||||
|
||||
|
||||
typedef struct _dolheader {
|
||||
u32 text_pos[7];
|
||||
u32 data_pos[11];
|
||||
u32 text_start[7];
|
||||
u32 data_start[11];
|
||||
u32 text_size[7];
|
||||
u32 data_size[11];
|
||||
u32 bss_start;
|
||||
u32 bss_size;
|
||||
u32 entry_point;
|
||||
} dolheader;
|
||||
|
||||
u32 load_dol_image (void *dolstart, struct __argv *argv);
|
||||
|
||||
|
||||
|
@ -25,13 +25,10 @@
|
||||
*/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <fat.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
|
||||
#include "pngu/pngu.h"
|
||||
@ -43,8 +40,8 @@
|
||||
#include "fatmounter.h"
|
||||
|
||||
|
||||
PNGUPROP imgProp;
|
||||
IMGCTX ctx;
|
||||
static PNGUPROP imgProp;
|
||||
static IMGCTX ctx;
|
||||
|
||||
|
||||
u8 * GetImageData(void) {
|
||||
@ -108,49 +105,65 @@ int main(int argc, char **argv)
|
||||
/* check devices */
|
||||
SDCard_Init();
|
||||
USBDevice_Init();
|
||||
|
||||
char cfgpath[256];
|
||||
bool result = false;
|
||||
|
||||
sprintf(cfgpath, "SD:/config/GXGlobal.cfg");
|
||||
if(!cfg_parsefile(cfgpath, &cfg_set)) //no cfg-File on SD: try USB:
|
||||
result = cfg_parsefile(cfgpath, &cfg_set);
|
||||
if(!result) //no cfg-File on SD: try USB:
|
||||
{
|
||||
sprintf(cfgpath, "USB:/config/GXGlobal.cfg");
|
||||
cfg_parsefile(cfgpath, &cfg_set);
|
||||
result = cfg_parsefile(cfgpath, &cfg_set);
|
||||
}
|
||||
if(update_path[0] == '\0') // non cfg-File loaded or update_path not set
|
||||
|
||||
if(result)
|
||||
{
|
||||
sprintf(cfgpath, "%sboot.dol", update_path);
|
||||
/* Open dol File and check exist */
|
||||
exeFile = fopen (cfgpath, "rb");
|
||||
if (exeFile==NULL)
|
||||
{
|
||||
sprintf(cfgpath, "%sboot.elf", update_path);
|
||||
exeFile = fopen (cfgpath,"rb");
|
||||
}
|
||||
if (exeFile==NULL)
|
||||
result = false;
|
||||
else
|
||||
result = true;
|
||||
}
|
||||
|
||||
if(!result) // non cfg-File loaded or update_path not set
|
||||
{
|
||||
/* Open dol File and check exist */
|
||||
strcpy(cfgpath, "SD:/apps/usbloader_gx/boot.dol");
|
||||
sprintf(cfgpath, "SD:/apps/usbloader_gx/boot.dol");
|
||||
exeFile = fopen (cfgpath ,"rb");
|
||||
if (exeFile==NULL)
|
||||
{
|
||||
strcpy(cfgpath, "SD:/apps/usbloader_gx/boot.elf");
|
||||
sprintf(cfgpath, "SD:/apps/usbloader_gx/boot.elf");
|
||||
exeFile = fopen (cfgpath ,"rb");
|
||||
}
|
||||
if (exeFile==NULL)
|
||||
{
|
||||
strcpy(cfgpath, "USB:/apps/usbloader_gx/boot.dol");
|
||||
sprintf(cfgpath, "USB:/apps/usbloader_gx/boot.dol");
|
||||
exeFile = fopen (cfgpath ,"rb");
|
||||
}
|
||||
if (exeFile==NULL)
|
||||
{
|
||||
strcpy(cfgpath, "USB:/apps/usbloader_gx/boot.elf");
|
||||
sprintf(cfgpath, "USB:/apps/usbloader_gx/boot.elf");
|
||||
exeFile = fopen (cfgpath ,"rb");
|
||||
}
|
||||
if (exeFile==NULL)
|
||||
// if nothing found exiting
|
||||
if (exeFile==NULL) {
|
||||
printf("\n\n\t\tCan't find DOL File...\n");
|
||||
Menu_Render();
|
||||
sleep(3);
|
||||
fclose (exeFile);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
StopGX();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(cfgpath, "%sboot.dol", update_path);
|
||||
/* Open dol File and check exist */
|
||||
exeFile = fopen (cfgpath, "rb");
|
||||
if (exeFile==NULL)
|
||||
{
|
||||
sprintf(cfgpath, "%sboot.elf", update_path);
|
||||
exeFile = fopen (cfgpath,"rb");
|
||||
}
|
||||
if (exeFile==NULL)
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
fseek (exeFile, 0, SEEK_END);
|
||||
@ -159,7 +172,13 @@ int main(int argc, char **argv)
|
||||
|
||||
if(fread (exeBuffer, 1, exeSize, exeFile) != (unsigned int) exeSize)
|
||||
{
|
||||
printf("Can't open DOL File...\n");
|
||||
printf("\n\n\t\tCan't open DOL File...\n");
|
||||
Menu_Render();
|
||||
fclose (exeFile);
|
||||
sleep(3);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
StopGX();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
fclose (exeFile);
|
||||
@ -172,7 +191,7 @@ int main(int argc, char **argv)
|
||||
args.commandLine = (char*)malloc(args.length);
|
||||
if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
strcpy(args.commandLine, cfgpath);
|
||||
args.commandLine[args.length - 1] = '\x00';
|
||||
args.commandLine[args.length - 1] = '\0';
|
||||
args.argc = 1;
|
||||
args.argv = &args.commandLine;
|
||||
args.endARGV = args.argv + 1;
|
||||
@ -195,6 +214,12 @@ int main(int argc, char **argv)
|
||||
StopGX();
|
||||
if (exeEntryPointAddress == 0) {
|
||||
printf("EntryPointAddress failed...\n");
|
||||
Menu_Render();
|
||||
sleep(3);
|
||||
fclose (exeFile);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
StopGX();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);;
|
||||
}
|
||||
exeEntryPoint = (entrypoint) exeEntryPointAddress;
|
||||
|
Loading…
Reference in New Issue
Block a user