WiiFlow_Lite/resources/app_booter/source/main.c

40 lines
1004 B
C
Raw Normal View History

2012-01-21 21:57:41 +01:00
/* Copyright 2011 Dimok
This code is licensed to you under the terms of the GNU GPL, version 2;
see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */
#include <gccore.h>
#include <stdio.h>
#include <stdarg.h>
#include "string.h"
#include "dolloader.h"
#include "elfloader.h"
#include "sync.h"
#define EXECUTABLE_MEM_ADDR 0x91000000
2012-01-21 21:57:41 +01:00
#define SYSTEM_ARGV ((struct __argv *) 0x93200000)
void main(void)
{
void *exeBuffer = (void *)EXECUTABLE_MEM_ADDR;
2012-01-21 21:57:41 +01:00
u32 exeEntryPointAddress = 0;
entrypoint exeEntryPoint;
if(valid_elf_image(exeBuffer) == 1)
2012-01-21 21:57:41 +01:00
exeEntryPointAddress = load_elf_image(exeBuffer);
else
exeEntryPointAddress = load_dol_image(exeBuffer);
exeEntryPoint = (entrypoint)exeEntryPointAddress;
if(!exeEntryPoint)
2012-01-21 21:57:41 +01:00
return;
if(SYSTEM_ARGV->argvMagic == ARGV_MAGIC)
2012-01-21 21:57:41 +01:00
{
void *new_argv = (void *) (exeEntryPointAddress + 8);
memcpy(new_argv, SYSTEM_ARGV, sizeof(struct __argv));
sync_before_exec(new_argv, sizeof(struct __argv));
}
exeEntryPoint();
2012-01-21 21:57:41 +01:00
}