mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-18 17:29:17 +01:00
30535c6f5d
formatted the code to make it easier to read. no functional changes at all. i didn't put anything from the libwiigui folder or banner folder in the beautifier. my automated .bat seems to have done a good job. the only places i see it fucked up was on (GXColor){blablabla}. it treated the brackets in the color like all the other brackets and put the color on a new line and indented it. i think i fixed most of them. not sure if it messed up anywhere else. also not sure about how it handled different linebreaks. it looks fine on windows. if it looks messed up on linux, it can be reverted. the code still compiles and runs fine.
193 lines
5.9 KiB
C
193 lines
5.9 KiB
C
/* mload.c (for PPC) (c) 2009, Hermes
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef __MLOAD_H__
|
|
#define __MLOAD_H__
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <ogcsys.h>
|
|
#include <gccore.h>
|
|
#include "unistd.h"
|
|
|
|
#define MLOAD_MLOAD_THREAD_ID 0x4D4C4400
|
|
#define MLOAD_LOAD_MODULE 0x4D4C4480
|
|
#define MLOAD_RUN_MODULE 0x4D4C4481
|
|
#define MLOAD_RUN_THREAD 0x4D4C4482
|
|
|
|
#define MLOAD_STOP_THREAD 0x4D4C4484
|
|
#define MLOAD_CONTINUE_THREAD 0x4D4C4485
|
|
|
|
#define MLOAD_GET_LOAD_BASE 0x4D4C4490
|
|
#define MLOAD_MEMSET 0x4D4C4491
|
|
|
|
#define MLOAD_GET_EHCI_DATA 0x4D4C44A0
|
|
|
|
#define MLOAD_SET_ES_IOCTLV 0x4D4C44B0
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
// from IOS ELF stripper of neimod
|
|
|
|
#define getbe32(x) ((adr[x]<<24) | (adr[x+1]<<16) | (adr[x+2]<<8) | (adr[x+3]))
|
|
|
|
typedef struct {
|
|
u32 ident0;
|
|
u32 ident1;
|
|
u32 ident2;
|
|
u32 ident3;
|
|
u32 machinetype;
|
|
u32 version;
|
|
u32 entry;
|
|
u32 phoff;
|
|
u32 shoff;
|
|
u32 flags;
|
|
u16 ehsize;
|
|
u16 phentsize;
|
|
u16 phnum;
|
|
u16 shentsize;
|
|
u16 shnum;
|
|
u16 shtrndx;
|
|
} elfheader;
|
|
|
|
typedef struct {
|
|
u32 type;
|
|
u32 offset;
|
|
u32 vaddr;
|
|
u32 paddr;
|
|
u32 filesz;
|
|
u32 memsz;
|
|
u32 flags;
|
|
u32 align;
|
|
} elfphentry;
|
|
|
|
typedef struct {
|
|
void *start;
|
|
int prio;
|
|
void *stack;
|
|
int size_stack;
|
|
} data_elf;
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// to init/test if the device is running
|
|
|
|
int mload_init();
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// to close the device (remember call it when rebooting the IOS!)
|
|
|
|
int mload_close();
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// to get the thread id of mload
|
|
|
|
int mload_get_thread_id();
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// get the base and the size of the memory readable/writable to load modules
|
|
|
|
int mload_get_load_base(u32 *starlet_base, int *size);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// load and run a module from starlet (it need to allocate MEM2 to send the elf file)
|
|
// the module must be a elf made with stripios
|
|
|
|
int mload_module(void *addr, int len);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// load a module from the PPC
|
|
// the module must be a elf made with stripios
|
|
|
|
int mload_elf(void *my_elf, data_elf *data_elf);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// run one thread (you can use to load modules or binary files)
|
|
|
|
int mload_run_thread(void *starlet_addr, void *starlet_top_stack, int stack_size, int priority);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// stops one starlet thread
|
|
|
|
int mload_stop_thread(int id);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// continue one stopped starlet thread
|
|
|
|
int mload_continue_thread(int id);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// fix starlet address to read/write (uses SEEK_SET, etc as mode)
|
|
|
|
int mload_seek(int offset, int mode);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// read bytes from starlet (it update the offset)
|
|
|
|
int mload_read(void* buf, u32 size);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// write bytes from starlet (it update the offset)
|
|
|
|
int mload_write(const void * buf, u32 size);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// fill a block (similar to memset)
|
|
|
|
int mload_memset(void *starlet_addr, int set, int len);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// get the ehci datas ( ehcmodule.elf uses this address)
|
|
|
|
void * mload_get_ehci_data();
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
|
|
// set the dev/es ioctlv in routine
|
|
|
|
int mload_set_ES_ioctlv_vector(void *starlet_addr);
|
|
|
|
/*--------------------------------------------------------------------------------------------------------------*/
|
|
int load_ehc_module();
|
|
int patch_cios_data();
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif
|