mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 03:09:15 +01:00
*Made a little HBC inside our loader
*Added HomebrewFiles Class NOTE 1: In settings/custompaths you can change the HomebrewPath and the standard is SD:/apps/. Our browser searches for EVERY .dol and .elf file in the directory even if its not called boot.dol. NOTE 2: Giantpune and me tested the homebrewbooting and it worked for every homebrew we tested except our own application. (a bit ironic) NOTE 3: Right now the information on the Buttons is the path to the Homebrew. This and the BootPrompt will be replaced with the XML information inside the path of the homebrew later but for now i am taking a break NOTE 4: Right now the button to the HomebrewMenu is next to WiiMenuButton and has the same image as the listgamebrowser. I didnt have any images so i took what i had and cyrex will change the images when he is back. Also there will be a no icon image added later.
This commit is contained in:
parent
73d8ded0e5
commit
71adda33e0
2
Makefile
2
Makefile
@ -19,7 +19,7 @@ BUILD := build
|
||||
SOURCES := source source/libwiigui source/images source/fonts source/sounds \
|
||||
source/libwbfs source/unzip source/language source/mload source/patches \
|
||||
source/usbloader source/xml source/network source/settings source/prompts \
|
||||
source/ramdisc source/wad source/banner source/cheats
|
||||
source/ramdisc source/wad source/banner source/cheats source/homebrewboot
|
||||
INCLUDES := source
|
||||
SVNDEV := -D'SVN_REV="$(shell svnversion -n ..)"'
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
2
gui.pnps
2
gui.pnps
@ -1 +1 @@
|
||||
<pd><ViewState><e p="gui\source\mload" x="true"></e><e p="gui\source\settings" x="true"></e><e p="gui\source" x="true"></e><e p="gui\source\images" x="false"></e><e p="gui\source\libwbfs" x="true"></e><e p="gui\source\libwiigui" x="true"></e><e p="gui\source\patches" x="true"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="true"></e><e p="gui\source\network" x="true"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\language" x="true"></e></ViewState></pd>
|
||||
<pd><ViewState><e p="gui\source\mload" x="true"></e><e p="gui\source\settings" x="true"></e><e p="gui\source" x="true"></e><e p="gui\source\images" x="false"></e><e p="gui\source\libwbfs" x="true"></e><e p="gui\source\libwiigui" x="true"></e><e p="gui\source\patches" x="true"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="true"></e><e p="gui\source\network" x="true"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="true"></e></ViewState></pd>
|
80
source/homebrewboot/BootHomebrew.c
Normal file
80
source/homebrewboot/BootHomebrew.c
Normal file
@ -0,0 +1,80 @@
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "fatmounter.h"
|
||||
#include "dolloader.h"
|
||||
#include "elfloader.h"
|
||||
|
||||
int BootHomebrew(char * path)
|
||||
{
|
||||
void *buffer = NULL;
|
||||
u32 filesize = 0;
|
||||
entrypoint entry;
|
||||
u32 cpu_isr;
|
||||
|
||||
FILE * file = fopen(path, "rb");
|
||||
if(!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
|
||||
fseek (file, 0, SEEK_END);
|
||||
filesize = ftell(file);
|
||||
rewind(file);
|
||||
|
||||
buffer = malloc(filesize);
|
||||
|
||||
if(fread (buffer, 1, filesize, file) != filesize)
|
||||
{
|
||||
fclose (file);
|
||||
free(buffer);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
fclose (file);
|
||||
|
||||
struct __argv args;
|
||||
bzero(&args, sizeof(args));
|
||||
args.argvMagic = ARGV_MAGIC;
|
||||
args.length = strlen(path) + 2;
|
||||
args.commandLine = (char*)malloc(args.length);
|
||||
if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
strcpy(args.commandLine, path);
|
||||
args.commandLine[args.length - 1] = '\0';
|
||||
args.argc = 1;
|
||||
args.argv = &args.commandLine;
|
||||
args.endARGV = args.argv + 1;
|
||||
|
||||
int ret = valid_elf_image(buffer);
|
||||
if (ret == 1)
|
||||
entry = (entrypoint) load_elf_image(buffer);
|
||||
else
|
||||
entry = (entrypoint) load_dol(buffer, &args);
|
||||
|
||||
free(buffer);
|
||||
|
||||
if(!entry) {
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
WPAD_Flush(0);
|
||||
WPAD_Disconnect(0);
|
||||
WPAD_Shutdown();
|
||||
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
_CPU_ISR_Disable (cpu_isr);
|
||||
__exception_closeall();
|
||||
entry();
|
||||
_CPU_ISR_Restore (cpu_isr);
|
||||
|
||||
return 0;
|
||||
}
|
15
source/homebrewboot/BootHomebrew.h
Normal file
15
source/homebrewboot/BootHomebrew.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef _BOOTHOMEBREW_H_
|
||||
#define _BOOTHOMEBREW_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void BootHomebrew(char * path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
556
source/homebrewboot/HomebrewBrowse.cpp
Normal file
556
source/homebrewboot/HomebrewBrowse.cpp
Normal file
@ -0,0 +1,556 @@
|
||||
/****************************************************************************
|
||||
* HomebrewBrowse
|
||||
* USB Loader GX 2009
|
||||
*
|
||||
* Homebrew launcher for USB Loader GX
|
||||
*
|
||||
* homebrewbrowse.cpp
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "language/gettext.h"
|
||||
#include "libwiigui/gui.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "homebrewboot/HomebrewFiles.h"
|
||||
#include "menu.h"
|
||||
#include "filelist.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*** Extern functions ***/
|
||||
extern void ResumeGui();
|
||||
extern void HaltGui();
|
||||
|
||||
/*** Extern variables ***/
|
||||
extern GuiWindow * mainWindow;
|
||||
extern GuiSound * bgMusic;
|
||||
extern GuiImage * bgImg;
|
||||
extern u8 shutdown;
|
||||
extern u8 reset;
|
||||
|
||||
bool boothomebrew = false;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* roundup Function
|
||||
***************************************************************************/
|
||||
int roundup(float number)
|
||||
{
|
||||
if(number == (int) number)
|
||||
return (int) number;
|
||||
else
|
||||
return (int) (number+1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MenuHomebrewBrowse
|
||||
***************************************************************************/
|
||||
int MenuHomebrewBrowse()
|
||||
{
|
||||
int menu = MENU_NONE;
|
||||
int choice = 0;
|
||||
|
||||
HomebrewFiles HomebrewFiles(Settings.homebrewapps_path);
|
||||
|
||||
u32 filecount = HomebrewFiles.GetFilecount();
|
||||
|
||||
if(!filecount) {
|
||||
WindowPrompt(tr("No .dol or .elf files found."),0, tr("OK"));
|
||||
return MENU_DISCLIST;
|
||||
}
|
||||
|
||||
enum {
|
||||
FADE,
|
||||
LEFT,
|
||||
RIGHT
|
||||
};
|
||||
|
||||
int slidedirection = FADE;
|
||||
|
||||
/*** Sound Variables ***/
|
||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
GuiSound btnClick1(button_click_pcm, button_click_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
|
||||
/*** Image Variables ***/
|
||||
char imgPath[150];
|
||||
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
|
||||
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
|
||||
GuiImageData bgData(imgPath, settings_background_png);
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path);
|
||||
GuiImageData MainButtonImgData(imgPath, settings_title_png);
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path);
|
||||
GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png);
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path);
|
||||
GuiImageData arrow_left(imgPath, startgame_arrow_left_png);
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
|
||||
GuiImageData arrow_right(imgPath, startgame_arrow_right_png);
|
||||
|
||||
GuiImage background(&bgData);
|
||||
|
||||
/*** Trigger Variables ***/
|
||||
GuiTrigger trigA;
|
||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
GuiTrigger trigHome;
|
||||
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
|
||||
GuiTrigger trigB;
|
||||
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
|
||||
GuiTrigger trigL;
|
||||
trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
|
||||
GuiTrigger trigR;
|
||||
trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
|
||||
GuiTrigger trigMinus;
|
||||
trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
|
||||
GuiTrigger trigPlus;
|
||||
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
|
||||
|
||||
GuiText titleTxt(tr("Homebrew Launcher"), 28, (GXColor){0, 0, 0, 255});
|
||||
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
titleTxt.SetPosition(0,40);
|
||||
|
||||
GuiImageData *IconData[4];
|
||||
GuiImage *IconImg[4];
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
IconData[i] = NULL;
|
||||
IconImg[i] = NULL;
|
||||
}
|
||||
/*** Buttons ***/
|
||||
|
||||
GuiText backBtnTxt(tr("Back") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
|
||||
GuiImage backBtnImg(&btnOutline);
|
||||
if (Settings.wsprompt == yes){
|
||||
backBtnTxt.SetWidescreen(CFG.widescreen);
|
||||
backBtnImg.SetWidescreen(CFG.widescreen);
|
||||
}
|
||||
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1);
|
||||
backBtn.SetLabel(&backBtnTxt);
|
||||
backBtn.SetTrigger(&trigB);
|
||||
|
||||
GuiButton homo(1,1);
|
||||
homo.SetTrigger(&trigHome);
|
||||
|
||||
GuiImage GoLeftImg(&arrow_left);
|
||||
GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight());
|
||||
GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
GoLeftBtn.SetPosition(25, -25);
|
||||
GoLeftBtn.SetImage(&GoLeftImg);
|
||||
GoLeftBtn.SetSoundOver(&btnSoundOver);
|
||||
GoLeftBtn.SetSoundClick(&btnClick);
|
||||
GoLeftBtn.SetEffectGrow();
|
||||
GoLeftBtn.SetTrigger(&trigA);
|
||||
GoLeftBtn.SetTrigger(&trigL);
|
||||
GoLeftBtn.SetTrigger(&trigMinus);
|
||||
|
||||
GuiImage GoRightImg(&arrow_right);
|
||||
GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight());
|
||||
GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
||||
GoRightBtn.SetPosition(-25, -25);
|
||||
GoRightBtn.SetImage(&GoRightImg);
|
||||
GoRightBtn.SetSoundOver(&btnSoundOver);
|
||||
GoRightBtn.SetSoundClick(&btnClick);
|
||||
GoRightBtn.SetEffectGrow();
|
||||
GoRightBtn.SetTrigger(&trigA);
|
||||
GoRightBtn.SetTrigger(&trigR);
|
||||
GoRightBtn.SetTrigger(&trigPlus);
|
||||
|
||||
char MainButtonText[50];
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s", " ");
|
||||
|
||||
GuiImage MainButton1Img(&MainButtonImgData);
|
||||
GuiImage MainButton1ImgOver(&MainButtonImgOverData);
|
||||
GuiText MainButton1Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
|
||||
MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
|
||||
MainButton1Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
MainButton1Txt.SetPosition(148, 0);
|
||||
GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight());
|
||||
MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
MainButton1.SetPosition(0, 90);
|
||||
MainButton1.SetImage(&MainButton1Img);
|
||||
MainButton1.SetImageOver(&MainButton1ImgOver);
|
||||
MainButton1.SetLabel(&MainButton1Txt);
|
||||
MainButton1.SetSoundOver(&btnSoundOver);
|
||||
MainButton1.SetSoundClick(&btnClick1);
|
||||
MainButton1.SetEffectGrow();
|
||||
MainButton1.SetTrigger(&trigA);
|
||||
|
||||
GuiImage MainButton2Img(&MainButtonImgData);
|
||||
GuiImage MainButton2ImgOver(&MainButtonImgOverData);
|
||||
GuiText MainButton2Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
|
||||
MainButton2Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
MainButton2Txt.SetPosition(148, 0);
|
||||
MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
|
||||
GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight());
|
||||
MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
MainButton2.SetPosition(0, 160);
|
||||
MainButton2.SetImage(&MainButton2Img);
|
||||
MainButton2.SetImageOver(&MainButton2ImgOver);
|
||||
MainButton2.SetLabel(&MainButton2Txt);
|
||||
MainButton2.SetSoundOver(&btnSoundOver);
|
||||
MainButton2.SetSoundClick(&btnClick1);
|
||||
MainButton2.SetEffectGrow();
|
||||
MainButton2.SetTrigger(&trigA);
|
||||
|
||||
GuiImage MainButton3Img(&MainButtonImgData);
|
||||
GuiImage MainButton3ImgOver(&MainButtonImgOverData);
|
||||
GuiText MainButton3Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
|
||||
MainButton3Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
MainButton3Txt.SetPosition(148, 0);
|
||||
MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
|
||||
GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight());
|
||||
MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
MainButton3.SetPosition(0, 230);
|
||||
MainButton3.SetImage(&MainButton3Img);
|
||||
MainButton3.SetImageOver(&MainButton3ImgOver);
|
||||
MainButton3.SetLabel(&MainButton3Txt);
|
||||
MainButton3.SetSoundOver(&btnSoundOver);
|
||||
MainButton3.SetSoundClick(&btnClick1);
|
||||
MainButton3.SetEffectGrow();
|
||||
MainButton3.SetTrigger(&trigA);
|
||||
|
||||
GuiImage MainButton4Img(&MainButtonImgData);
|
||||
GuiImage MainButton4ImgOver(&MainButtonImgOverData);
|
||||
GuiText MainButton4Txt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
|
||||
MainButton4Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
MainButton4Txt.SetPosition(148, 0);
|
||||
MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
|
||||
GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight());
|
||||
MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
MainButton4.SetPosition(0, 300);
|
||||
MainButton4.SetImage(&MainButton4Img);
|
||||
MainButton4.SetImageOver(&MainButton4ImgOver);
|
||||
MainButton4.SetLabel(&MainButton4Txt);
|
||||
MainButton4.SetSoundOver(&btnSoundOver);
|
||||
MainButton4.SetSoundClick(&btnClick1);
|
||||
MainButton4.SetEffectGrow();
|
||||
MainButton4.SetTrigger(&trigA);
|
||||
|
||||
GuiWindow w(screenwidth, screenheight);
|
||||
|
||||
int pageToDisplay = 1;
|
||||
const int pages = roundup(filecount/4.0f);
|
||||
|
||||
while (menu == MENU_NONE) //set pageToDisplay to 0 to quit
|
||||
{
|
||||
VIDEO_WaitVSync ();
|
||||
|
||||
menu = MENU_NONE;
|
||||
bool changed = false;
|
||||
int fileoffset = pageToDisplay*4-4;
|
||||
|
||||
/** Standard procedure made in all pages **/
|
||||
MainButton1.StopEffect();
|
||||
MainButton2.StopEffect();
|
||||
MainButton3.StopEffect();
|
||||
MainButton4.StopEffect();
|
||||
|
||||
if(slidedirection == RIGHT) {
|
||||
MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
|
||||
MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
|
||||
MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
|
||||
MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
|
||||
while (MainButton1.GetEffect()>0) usleep(50);
|
||||
}
|
||||
else if(slidedirection == LEFT) {
|
||||
MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
|
||||
MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
|
||||
MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
|
||||
MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
|
||||
while (MainButton1.GetEffect()>0) usleep(50);
|
||||
}
|
||||
|
||||
HaltGui();
|
||||
|
||||
mainWindow->RemoveAll();
|
||||
|
||||
/** Set new icons **/
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(IconData[i] != NULL) {
|
||||
delete IconData[i];
|
||||
IconData[i] = NULL;
|
||||
}
|
||||
if(IconImg[i] != NULL) {
|
||||
delete IconImg[i];
|
||||
IconImg[i] = NULL;
|
||||
}
|
||||
if(fileoffset+i < (int) filecount) {
|
||||
char iconpath[200];
|
||||
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+i));
|
||||
IconData[i] = new GuiImageData(iconpath, 0);
|
||||
if(IconData[i]->GetImage()) {
|
||||
IconImg[i] = new GuiImage(IconData[i]);
|
||||
IconImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
IconImg[i]->SetPosition(12, 0);
|
||||
IconImg[i]->SetScale(0.95);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(IconImg[0] != 0)
|
||||
MainButton1.SetIcon(IconImg[0]);
|
||||
else
|
||||
MainButton1.SetIcon(NULL);
|
||||
if(IconImg[1] != 0)
|
||||
MainButton2.SetIcon(IconImg[1]);
|
||||
else
|
||||
MainButton2.SetIcon(NULL);
|
||||
if(IconImg[2] != 0)
|
||||
MainButton3.SetIcon(IconImg[2]);
|
||||
else
|
||||
MainButton3.SetIcon(NULL);
|
||||
if(IconImg[3] != 0)
|
||||
MainButton4.SetIcon(IconImg[3]);
|
||||
else
|
||||
MainButton4.SetIcon(NULL);
|
||||
|
||||
mainWindow->Append(&w);
|
||||
w.RemoveAll();
|
||||
w.Append(&background);
|
||||
w.Append(&titleTxt);
|
||||
w.Append(&backBtn);
|
||||
w.Append(&homo);
|
||||
w.Append(&GoRightBtn);
|
||||
w.Append(&GoLeftBtn);
|
||||
|
||||
if(pageToDisplay == pages) {
|
||||
int buttonsleft = filecount-(pages-1)*4;
|
||||
char * shortpath = NULL;
|
||||
char temp[200];
|
||||
if(buttonsleft > 0) {
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
|
||||
MainButton1Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton1);
|
||||
}
|
||||
if(buttonsleft > 1) {
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
|
||||
MainButton2Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton2);
|
||||
}
|
||||
if(buttonsleft > 2) {
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
|
||||
MainButton3Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton3);
|
||||
}
|
||||
if(buttonsleft > 3) {
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
|
||||
MainButton4Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton4);
|
||||
}
|
||||
} else {
|
||||
char temp[200];
|
||||
char *shortpath = NULL;
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
|
||||
MainButton1Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton1);
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
|
||||
MainButton2Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton2);
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
|
||||
MainButton3Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton3);
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
|
||||
MainButton4Txt.SetText(MainButtonText);
|
||||
w.Append(&MainButton4);
|
||||
}
|
||||
|
||||
MainButton1.StopEffect();
|
||||
MainButton2.StopEffect();
|
||||
MainButton3.StopEffect();
|
||||
MainButton4.StopEffect();
|
||||
|
||||
MainButton1.SetEffectGrow();
|
||||
MainButton2.SetEffectGrow();
|
||||
MainButton3.SetEffectGrow();
|
||||
MainButton4.SetEffectGrow();
|
||||
|
||||
if(slidedirection == FADE) {
|
||||
MainButton1.SetEffect(EFFECT_FADE, 20);
|
||||
MainButton2.SetEffect(EFFECT_FADE, 20);
|
||||
MainButton3.SetEffect(EFFECT_FADE, 20);
|
||||
MainButton4.SetEffect(EFFECT_FADE, 20);
|
||||
}
|
||||
else if(slidedirection == LEFT) {
|
||||
MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
|
||||
MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
|
||||
MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
|
||||
MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
|
||||
}
|
||||
else if(slidedirection == RIGHT) {
|
||||
MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
|
||||
MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
|
||||
MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
|
||||
MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
|
||||
}
|
||||
|
||||
mainWindow->Append(&w);
|
||||
|
||||
ResumeGui();
|
||||
|
||||
while(MainButton1.GetEffect() > 0) usleep(50);
|
||||
|
||||
while(!changed)
|
||||
{
|
||||
VIDEO_WaitVSync ();
|
||||
|
||||
if(MainButton1.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char * shortpath = NULL;
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
|
||||
int choice = WindowPrompt(tr("Do you want to boot?"), temp, tr("Yes"), tr("No"));
|
||||
if(choice == 1) {
|
||||
boothomebrew = true;
|
||||
menu = MENU_EXIT;
|
||||
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset), HomebrewFiles.GetFilename(fileoffset));
|
||||
break;
|
||||
}
|
||||
MainButton1.ResetState();
|
||||
}
|
||||
else if(MainButton2.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char * shortpath = NULL;
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
|
||||
int choice = WindowPrompt(tr("Do you want to boot?"), temp, tr("Yes"), tr("No"));
|
||||
if(choice == 1) {
|
||||
boothomebrew = true;
|
||||
menu = MENU_EXIT;
|
||||
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+1), HomebrewFiles.GetFilename(fileoffset+1));
|
||||
break;
|
||||
}
|
||||
MainButton2.ResetState();
|
||||
}
|
||||
else if(MainButton3.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char * shortpath = NULL;
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
|
||||
int choice = WindowPrompt(tr("Do you want to boot?"), temp, tr("Yes"), tr("No"));
|
||||
if(choice == 1) {
|
||||
boothomebrew = true;
|
||||
menu = MENU_EXIT;
|
||||
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+2), HomebrewFiles.GetFilename(fileoffset+2));
|
||||
break;
|
||||
}
|
||||
MainButton3.ResetState();
|
||||
}
|
||||
else if(MainButton4.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char * shortpath = NULL;
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
|
||||
shortpath = strrchr(temp, '/');
|
||||
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
|
||||
int choice = WindowPrompt(tr("Do you want to boot?"), temp, tr("Yes"), tr("No"));
|
||||
if(choice == 1) {
|
||||
boothomebrew = true;
|
||||
menu = MENU_EXIT;
|
||||
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+3), HomebrewFiles.GetFilename(fileoffset+3));
|
||||
break;
|
||||
}
|
||||
MainButton4.ResetState();
|
||||
}
|
||||
|
||||
else if(shutdown == 1)
|
||||
Sys_Shutdown();
|
||||
else if(reset == 1)
|
||||
Sys_Reboot();
|
||||
|
||||
else if(backBtn.GetState() == STATE_CLICKED) {
|
||||
menu = MENU_DISCLIST;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
else if(GoLeftBtn.GetState() == STATE_CLICKED) {
|
||||
pageToDisplay--;
|
||||
/** Change direction of the flying buttons **/
|
||||
if(pageToDisplay < 1)
|
||||
pageToDisplay = pages;
|
||||
slidedirection = LEFT;
|
||||
changed = true;
|
||||
GoLeftBtn.ResetState();
|
||||
}
|
||||
|
||||
else if(GoRightBtn.GetState() == STATE_CLICKED) {
|
||||
pageToDisplay++;
|
||||
/** Change direction of the flying buttons **/
|
||||
if(pageToDisplay > pages)
|
||||
pageToDisplay = 1;
|
||||
slidedirection = RIGHT;
|
||||
changed = true;
|
||||
GoRightBtn.ResetState();
|
||||
}
|
||||
|
||||
else if(homo.GetState() == STATE_CLICKED) {
|
||||
cfg_save_global();
|
||||
s32 thetimeofbg = bgMusic->GetPlayTime();
|
||||
bgMusic->Stop();
|
||||
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0);
|
||||
if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path))
|
||||
{
|
||||
bgMusic->Play();
|
||||
} else {
|
||||
bgMusic->PlayOggFile(Settings.ogg_path);
|
||||
}
|
||||
bgMusic->SetPlayTime(thetimeofbg);
|
||||
SetVolumeOgg(255*(Settings.volume/100.0));
|
||||
|
||||
if(choice == 3) {
|
||||
Sys_LoadMenu(); // Back to System Menu
|
||||
} else if (choice == 2) {
|
||||
Sys_BackToLoader();
|
||||
} else {
|
||||
homo.ResetState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
w.SetEffect(EFFECT_FADE, -20);
|
||||
while(w.GetEffect()>0) usleep(50);
|
||||
|
||||
HaltGui();
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(IconData[i] != NULL) {
|
||||
delete IconData[i];
|
||||
IconData[i] = NULL;
|
||||
}
|
||||
if(IconImg[i] != NULL) {
|
||||
delete IconImg[i];
|
||||
IconImg[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow->RemoveAll();
|
||||
mainWindow->Append(bgImg);
|
||||
|
||||
ResumeGui();
|
||||
|
||||
return menu;
|
||||
}
|
15
source/homebrewboot/HomebrewBrowse.h
Normal file
15
source/homebrewboot/HomebrewBrowse.h
Normal file
@ -0,0 +1,15 @@
|
||||
/****************************************************************************
|
||||
* HomebrewBrowse
|
||||
* USB Loader GX 2009
|
||||
*
|
||||
* Homebrew launcher for USB Loader GX
|
||||
*
|
||||
* homebrewbrowse.h
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _HOMEBREWBROWSE_H_
|
||||
#define _HOMEBREWBROWSE_H_
|
||||
|
||||
int MenuHomebrewBrowse();
|
||||
|
||||
#endif
|
102
source/homebrewboot/HomebrewFiles.cpp
Normal file
102
source/homebrewboot/HomebrewFiles.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
* HomebrewFiles Class
|
||||
* for USB Loader GX
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/dir.h>
|
||||
|
||||
#include "HomebrewFiles.h"
|
||||
|
||||
HomebrewFiles::HomebrewFiles(const char * path)
|
||||
{
|
||||
filecount = 0;
|
||||
this->LoadPath(path);
|
||||
this->SortList();
|
||||
}
|
||||
|
||||
HomebrewFiles::~HomebrewFiles()
|
||||
{
|
||||
}
|
||||
|
||||
bool HomebrewFiles::LoadPath(const char * folderpath)
|
||||
{
|
||||
struct stat st;
|
||||
DIR_ITER *dir = NULL;
|
||||
char filename[1024];
|
||||
|
||||
dir = diropen(folderpath);
|
||||
if(dir == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (dirnext(dir,filename,&st) == 0)
|
||||
{
|
||||
if((st.st_mode & S_IFDIR) != 0) {
|
||||
if(strcmp(filename,".") != 0 && strcmp(filename,"..") != 0) {
|
||||
char currentname[200];
|
||||
snprintf(currentname, sizeof(currentname), "%s%s/", folderpath, filename);
|
||||
this->LoadPath(currentname);
|
||||
}
|
||||
} else {
|
||||
char temp[5];
|
||||
for(int i = 0; i < 5; i++) {
|
||||
temp[i] = filename[strlen(filename)-4+i];
|
||||
}
|
||||
|
||||
if(strncasecmp(temp, ".dol", 4) == 0 || strncasecmp(temp, ".elf", 4) == 0
|
||||
&& filecount < MAXHOMEBREWS) {
|
||||
|
||||
strncpy(FileInfo[filecount].FilePath, folderpath, sizeof(FileInfo[filecount].FilePath));
|
||||
strncpy(FileInfo[filecount].FileName, filename, sizeof(FileInfo[filecount].FileName));
|
||||
FileInfo[filecount].FileSize = st.st_size;
|
||||
filecount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
dirclose(dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
char * HomebrewFiles::GetFilename(int ind)
|
||||
{
|
||||
if(ind > filecount)
|
||||
return NULL;
|
||||
else
|
||||
return FileInfo[ind].FileName;
|
||||
}
|
||||
|
||||
char * HomebrewFiles::GetFilepath(int ind)
|
||||
{
|
||||
if(ind > filecount)
|
||||
return NULL;
|
||||
else
|
||||
return FileInfo[ind].FilePath;
|
||||
}
|
||||
|
||||
unsigned int HomebrewFiles::GetFilesize(int ind)
|
||||
{
|
||||
if(ind > filecount)
|
||||
return NULL;
|
||||
else
|
||||
return FileInfo[ind].FileSize;
|
||||
}
|
||||
|
||||
int HomebrewFiles::GetFilecount()
|
||||
{
|
||||
return filecount;
|
||||
}
|
||||
|
||||
int ListCompare(const void *a, const void *b)
|
||||
{
|
||||
FileInfos *ab = (FileInfos*) a;
|
||||
FileInfos *bb = (FileInfos*) b;
|
||||
|
||||
return stricmp((char *) ab->FilePath, (char *) bb->FilePath);
|
||||
}
|
||||
void HomebrewFiles::SortList()
|
||||
{
|
||||
qsort(FileInfo, filecount, sizeof(FileInfos), ListCompare);
|
||||
}
|
45
source/homebrewboot/HomebrewFiles.h
Normal file
45
source/homebrewboot/HomebrewFiles.h
Normal file
@ -0,0 +1,45 @@
|
||||
/****************************************************************************
|
||||
* HomebrewFiles Class
|
||||
* for USB Loader GX
|
||||
***************************************************************************/
|
||||
#ifndef ___HOMEBREWFILES_H_
|
||||
#define ___HOMEBREWFILES_H_
|
||||
|
||||
#define MAXHOMEBREWS 300
|
||||
|
||||
typedef struct {
|
||||
char FileName[100];
|
||||
char FilePath[150];
|
||||
unsigned int FileSize;
|
||||
} FileInfos;
|
||||
|
||||
class HomebrewFiles
|
||||
{
|
||||
public:
|
||||
//!Constructor
|
||||
//!\param path Path where to check for homebrew files
|
||||
HomebrewFiles(const char * path);
|
||||
//!Destructor
|
||||
~HomebrewFiles();
|
||||
//! Load the dol/elf list of a path
|
||||
//!\param path Path where to check for homebrew files
|
||||
bool LoadPath(const char * path);
|
||||
//! Get the a filename of the list
|
||||
//!\param list index
|
||||
char * GetFilename(int index);
|
||||
//! Get the a filepath of the list
|
||||
//!\param list index
|
||||
char * GetFilepath(int index);
|
||||
//! Get the a filesize of the list
|
||||
//!\param list index
|
||||
unsigned int GetFilesize(int index);
|
||||
//! Get the filecount of the whole list
|
||||
int GetFilecount();
|
||||
//! Sort list by filepath
|
||||
void SortList();
|
||||
protected:
|
||||
int filecount;
|
||||
FileInfos FileInfo[MAXHOMEBREWS];
|
||||
};
|
||||
|
||||
#endif
|
55
source/homebrewboot/dolloader.c
Normal file
55
source/homebrewboot/dolloader.c
Normal file
@ -0,0 +1,55 @@
|
||||
#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(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;
|
||||
}
|
19
source/homebrewboot/dolloader.h
Normal file
19
source/homebrewboot/dolloader.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _DOLLOADER_H_
|
||||
#define _DOLLOADER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void __exception_closeall();
|
||||
typedef void (*entrypoint) (void);
|
||||
|
||||
u32 load_dol(void *dolstart, struct __argv *argv);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
594
source/homebrewboot/elf_abi.h
Normal file
594
source/homebrewboot/elf_abi.h
Normal file
@ -0,0 +1,594 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 2001, 2002
|
||||
* Erik Theisen. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the ELF ABI header file
|
||||
* formerly known as "elf_abi.h".
|
||||
*/
|
||||
|
||||
#ifndef _ELF_ABI_H
|
||||
#define _ELF_ABI_H
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
/*
|
||||
* This version doesn't work for 64-bit ABIs - Erik.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These typedefs need to be handled better.
|
||||
*/
|
||||
typedef u32 Elf32_Addr; /* Unsigned program address */
|
||||
typedef u32 Elf32_Off; /* Unsigned file offset */
|
||||
typedef s32 Elf32_Sword; /* Signed large integer */
|
||||
typedef u32 Elf32_Word; /* Unsigned large integer */
|
||||
typedef u16 Elf32_Half; /* Unsigned medium integer */
|
||||
|
||||
/* e_ident[] identification indexes */
|
||||
#define EI_MAG0 0 /* file ID */
|
||||
#define EI_MAG1 1 /* file ID */
|
||||
#define EI_MAG2 2 /* file ID */
|
||||
#define EI_MAG3 3 /* file ID */
|
||||
#define EI_CLASS 4 /* file class */
|
||||
#define EI_DATA 5 /* data encoding */
|
||||
#define EI_VERSION 6 /* ELF header version */
|
||||
#define EI_OSABI 7 /* OS/ABI specific ELF extensions */
|
||||
#define EI_ABIVERSION 8 /* ABI target version */
|
||||
#define EI_PAD 9 /* start of pad bytes */
|
||||
#define EI_NIDENT 16 /* Size of e_ident[] */
|
||||
|
||||
/* e_ident[] magic number */
|
||||
#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
|
||||
#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
|
||||
#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
|
||||
#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
|
||||
#define ELFMAG "\177ELF" /* magic */
|
||||
#define SELFMAG 4 /* size of magic */
|
||||
|
||||
/* e_ident[] file class */
|
||||
#define ELFCLASSNONE 0 /* invalid */
|
||||
#define ELFCLASS32 1 /* 32-bit objs */
|
||||
#define ELFCLASS64 2 /* 64-bit objs */
|
||||
#define ELFCLASSNUM 3 /* number of classes */
|
||||
|
||||
/* e_ident[] data encoding */
|
||||
#define ELFDATANONE 0 /* invalid */
|
||||
#define ELFDATA2LSB 1 /* Little-Endian */
|
||||
#define ELFDATA2MSB 2 /* Big-Endian */
|
||||
#define ELFDATANUM 3 /* number of data encode defines */
|
||||
|
||||
/* e_ident[] OS/ABI specific ELF extensions */
|
||||
#define ELFOSABI_NONE 0 /* No extension specified */
|
||||
#define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
|
||||
#define ELFOSABI_NETBSD 2 /* NetBSD */
|
||||
#define ELFOSABI_LINUX 3 /* Linux */
|
||||
#define ELFOSABI_SOLARIS 6 /* Sun Solaris */
|
||||
#define ELFOSABI_AIX 7 /* AIX */
|
||||
#define ELFOSABI_IRIX 8 /* IRIX */
|
||||
#define ELFOSABI_FREEBSD 9 /* FreeBSD */
|
||||
#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
|
||||
#define ELFOSABI_MODESTO 11 /* Novell Modesto */
|
||||
#define ELFOSABI_OPENBSD 12 /* OpenBSD */
|
||||
/* 64-255 Architecture-specific value range */
|
||||
|
||||
/* e_ident[] ABI Version */
|
||||
#define ELFABIVERSION 0
|
||||
|
||||
/* e_ident */
|
||||
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
|
||||
(ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
|
||||
(ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
|
||||
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
|
||||
|
||||
/* ELF Header */
|
||||
typedef struct elfhdr{
|
||||
unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
|
||||
Elf32_Half e_type; /* object file type */
|
||||
Elf32_Half e_machine; /* machine */
|
||||
Elf32_Word e_version; /* object file version */
|
||||
Elf32_Addr e_entry; /* virtual entry point */
|
||||
Elf32_Off e_phoff; /* program header table offset */
|
||||
Elf32_Off e_shoff; /* section header table offset */
|
||||
Elf32_Word e_flags; /* processor-specific flags */
|
||||
Elf32_Half e_ehsize; /* ELF header size */
|
||||
Elf32_Half e_phentsize; /* program header entry size */
|
||||
Elf32_Half e_phnum; /* number of program header entries */
|
||||
Elf32_Half e_shentsize; /* section header entry size */
|
||||
Elf32_Half e_shnum; /* number of section header entries */
|
||||
Elf32_Half e_shstrndx; /* section header table's "section
|
||||
header string table" entry offset */
|
||||
} Elf32_Ehdr;
|
||||
|
||||
/* e_type */
|
||||
#define ET_NONE 0 /* No file type */
|
||||
#define ET_REL 1 /* relocatable file */
|
||||
#define ET_EXEC 2 /* executable file */
|
||||
#define ET_DYN 3 /* shared object file */
|
||||
#define ET_CORE 4 /* core file */
|
||||
#define ET_NUM 5 /* number of types */
|
||||
#define ET_LOOS 0xfe00 /* reserved range for operating */
|
||||
#define ET_HIOS 0xfeff /* system specific e_type */
|
||||
#define ET_LOPROC 0xff00 /* reserved range for processor */
|
||||
#define ET_HIPROC 0xffff /* specific e_type */
|
||||
|
||||
/* e_machine */
|
||||
#define EM_NONE 0 /* No Machine */
|
||||
#define EM_M32 1 /* AT&T WE 32100 */
|
||||
#define EM_SPARC 2 /* SPARC */
|
||||
#define EM_386 3 /* Intel 80386 */
|
||||
#define EM_68K 4 /* Motorola 68000 */
|
||||
#define EM_88K 5 /* Motorola 88000 */
|
||||
#if 0
|
||||
#define EM_486 6 /* RESERVED - was Intel 80486 */
|
||||
#endif
|
||||
#define EM_860 7 /* Intel 80860 */
|
||||
#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
|
||||
#define EM_S370 9 /* IBM System/370 Processor */
|
||||
#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
|
||||
#if 0
|
||||
#define EM_SPARC64 11 /* RESERVED - was SPARC v9
|
||||
64-bit unoffical */
|
||||
#endif
|
||||
/* RESERVED 11-14 for future use */
|
||||
#define EM_PARISC 15 /* HPPA */
|
||||
/* RESERVED 16 for future use */
|
||||
#define EM_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
|
||||
#define EM_960 19 /* Intel 80960 */
|
||||
#define EM_PPC 20 /* PowerPC */
|
||||
#define EM_PPC64 21 /* 64-bit PowerPC */
|
||||
#define EM_S390 22 /* IBM System/390 Processor */
|
||||
/* RESERVED 23-35 for future use */
|
||||
#define EM_V800 36 /* NEC V800 */
|
||||
#define EM_FR20 37 /* Fujitsu FR20 */
|
||||
#define EM_RH32 38 /* TRW RH-32 */
|
||||
#define EM_RCE 39 /* Motorola RCE */
|
||||
#define EM_ARM 40 /* Advanced Risc Machines ARM */
|
||||
#define EM_ALPHA 41 /* Digital Alpha */
|
||||
#define EM_SH 42 /* Hitachi SH */
|
||||
#define EM_SPARCV9 43 /* SPARC Version 9 */
|
||||
#define EM_TRICORE 44 /* Siemens TriCore embedded processor */
|
||||
#define EM_ARC 45 /* Argonaut RISC Core */
|
||||
#define EM_H8_300 46 /* Hitachi H8/300 */
|
||||
#define EM_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define EM_H8S 48 /* Hitachi H8S */
|
||||
#define EM_H8_500 49 /* Hitachi H8/500 */
|
||||
#define EM_IA_64 50 /* Intel Merced */
|
||||
#define EM_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define EM_COLDFIRE 52 /* Motorola Coldfire */
|
||||
#define EM_68HC12 53 /* Motorola M68HC12 */
|
||||
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
|
||||
#define EM_PCP 55 /* Siemens PCP */
|
||||
#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
|
||||
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
|
||||
#define EM_STARCORE 58 /* Motorola Start*Core processor */
|
||||
#define EM_ME16 59 /* Toyota ME16 processor */
|
||||
#define EM_ST100 60 /* STMicroelectronic ST100 processor */
|
||||
#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
|
||||
#define EM_X86_64 62 /* AMD x86-64 */
|
||||
#define EM_PDSP 63 /* Sony DSP Processor */
|
||||
/* RESERVED 64,65 for future use */
|
||||
#define EM_FX66 66 /* Siemens FX66 microcontroller */
|
||||
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
|
||||
#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
|
||||
#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
|
||||
#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
|
||||
#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
|
||||
#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
|
||||
#define EM_SVX 73 /* Silicon Graphics SVx */
|
||||
#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
|
||||
#define EM_VAX 75 /* Digital VAX */
|
||||
#define EM_CHRIS 76 /* Axis Communications embedded proc. */
|
||||
#define EM_JAVELIN 77 /* Infineon Technologies emb. proc. */
|
||||
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
|
||||
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
|
||||
#define EM_MMIX 80 /* Donald Knuth's edu 64-bit proc. */
|
||||
#define EM_HUANY 81 /* Harvard University mach-indep objs */
|
||||
#define EM_PRISM 82 /* SiTera Prism */
|
||||
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
|
||||
#define EM_FR30 84 /* Fujitsu FR30 */
|
||||
#define EM_D10V 85 /* Mitsubishi DV10V */
|
||||
#define EM_D30V 86 /* Mitsubishi DV30V */
|
||||
#define EM_V850 87 /* NEC v850 */
|
||||
#define EM_M32R 88 /* Mitsubishi M32R */
|
||||
#define EM_MN10300 89 /* Matsushita MN10200 */
|
||||
#define EM_MN10200 90 /* Matsushita MN10200 */
|
||||
#define EM_PJ 91 /* picoJava */
|
||||
#define EM_NUM 92 /* number of machine types */
|
||||
|
||||
/* Version */
|
||||
#define EV_NONE 0 /* Invalid */
|
||||
#define EV_CURRENT 1 /* Current */
|
||||
#define EV_NUM 2 /* number of versions */
|
||||
|
||||
/* Section Header */
|
||||
typedef struct {
|
||||
Elf32_Word sh_name; /* name - index into section header
|
||||
string table section */
|
||||
Elf32_Word sh_type; /* type */
|
||||
Elf32_Word sh_flags; /* flags */
|
||||
Elf32_Addr sh_addr; /* address */
|
||||
Elf32_Off sh_offset; /* file offset */
|
||||
Elf32_Word sh_size; /* section size */
|
||||
Elf32_Word sh_link; /* section header table index link */
|
||||
Elf32_Word sh_info; /* extra information */
|
||||
Elf32_Word sh_addralign; /* address alignment */
|
||||
Elf32_Word sh_entsize; /* section entry size */
|
||||
} Elf32_Shdr;
|
||||
|
||||
/* Special Section Indexes */
|
||||
#define SHN_UNDEF 0 /* undefined */
|
||||
#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
|
||||
#define SHN_LOPROC 0xff00 /* reserved range for processor */
|
||||
#define SHN_HIPROC 0xff1f /* specific section indexes */
|
||||
#define SHN_LOOS 0xff20 /* reserved range for operating */
|
||||
#define SHN_HIOS 0xff3f /* specific semantics */
|
||||
#define SHN_ABS 0xfff1 /* absolute value */
|
||||
#define SHN_COMMON 0xfff2 /* common symbol */
|
||||
#define SHN_XINDEX 0xffff /* Index is an extra table */
|
||||
#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
|
||||
|
||||
/* sh_type */
|
||||
#define SHT_NULL 0 /* inactive */
|
||||
#define SHT_PROGBITS 1 /* program defined information */
|
||||
#define SHT_SYMTAB 2 /* symbol table section */
|
||||
#define SHT_STRTAB 3 /* string table section */
|
||||
#define SHT_RELA 4 /* relocation section with addends*/
|
||||
#define SHT_HASH 5 /* symbol hash table section */
|
||||
#define SHT_DYNAMIC 6 /* dynamic section */
|
||||
#define SHT_NOTE 7 /* note section */
|
||||
#define SHT_NOBITS 8 /* no space section */
|
||||
#define SHT_REL 9 /* relation section without addends */
|
||||
#define SHT_SHLIB 10 /* reserved - purpose unknown */
|
||||
#define SHT_DYNSYM 11 /* dynamic symbol table section */
|
||||
#define SHT_INIT_ARRAY 14 /* Array of constructors */
|
||||
#define SHT_FINI_ARRAY 15 /* Array of destructors */
|
||||
#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
|
||||
#define SHT_GROUP 17 /* Section group */
|
||||
#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
|
||||
#define SHT_NUM 19 /* number of section types */
|
||||
#define SHT_LOOS 0x60000000 /* Start OS-specific */
|
||||
#define SHT_HIOS 0x6fffffff /* End OS-specific */
|
||||
#define SHT_LOPROC 0x70000000 /* reserved range for processor */
|
||||
#define SHT_HIPROC 0x7fffffff /* specific section header types */
|
||||
#define SHT_LOUSER 0x80000000 /* reserved range for application */
|
||||
#define SHT_HIUSER 0xffffffff /* specific indexes */
|
||||
|
||||
/* Section names */
|
||||
#define ELF_BSS ".bss" /* uninitialized data */
|
||||
#define ELF_COMMENT ".comment" /* version control information */
|
||||
#define ELF_DATA ".data" /* initialized data */
|
||||
#define ELF_DATA1 ".data1" /* initialized data */
|
||||
#define ELF_DEBUG ".debug" /* debug */
|
||||
#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
|
||||
#define ELF_DYNSTR ".dynstr" /* dynamic string table */
|
||||
#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
|
||||
#define ELF_FINI ".fini" /* termination code */
|
||||
#define ELF_FINI_ARRAY ".fini_array" /* Array of destructors */
|
||||
#define ELF_GOT ".got" /* global offset table */
|
||||
#define ELF_HASH ".hash" /* symbol hash table */
|
||||
#define ELF_INIT ".init" /* initialization code */
|
||||
#define ELF_INIT_ARRAY ".init_array" /* Array of constuctors */
|
||||
#define ELF_INTERP ".interp" /* Pathname of program interpreter */
|
||||
#define ELF_LINE ".line" /* Symbolic line numnber information */
|
||||
#define ELF_NOTE ".note" /* Contains note section */
|
||||
#define ELF_PLT ".plt" /* Procedure linkage table */
|
||||
#define ELF_PREINIT_ARRAY ".preinit_array" /* Array of pre-constructors */
|
||||
#define ELF_REL_DATA ".rel.data" /* relocation data */
|
||||
#define ELF_REL_FINI ".rel.fini" /* relocation termination code */
|
||||
#define ELF_REL_INIT ".rel.init" /* relocation initialization code */
|
||||
#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
|
||||
#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
|
||||
#define ELF_REL_TEXT ".rel.text" /* relocation code */
|
||||
#define ELF_RODATA ".rodata" /* read-only data */
|
||||
#define ELF_RODATA1 ".rodata1" /* read-only data */
|
||||
#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
|
||||
#define ELF_STRTAB ".strtab" /* string table */
|
||||
#define ELF_SYMTAB ".symtab" /* symbol table */
|
||||
#define ELF_SYMTAB_SHNDX ".symtab_shndx"/* symbol table section index */
|
||||
#define ELF_TBSS ".tbss" /* thread local uninit data */
|
||||
#define ELF_TDATA ".tdata" /* thread local init data */
|
||||
#define ELF_TDATA1 ".tdata1" /* thread local init data */
|
||||
#define ELF_TEXT ".text" /* code */
|
||||
|
||||
/* Section Attribute Flags - sh_flags */
|
||||
#define SHF_WRITE 0x1 /* Writable */
|
||||
#define SHF_ALLOC 0x2 /* occupies memory */
|
||||
#define SHF_EXECINSTR 0x4 /* executable */
|
||||
#define SHF_MERGE 0x10 /* Might be merged */
|
||||
#define SHF_STRINGS 0x20 /* Contains NULL terminated strings */
|
||||
#define SHF_INFO_LINK 0x40 /* sh_info contains SHT index */
|
||||
#define SHF_LINK_ORDER 0x80 /* Preserve order after combining*/
|
||||
#define SHF_OS_NONCONFORMING 0x100 /* Non-standard OS specific handling */
|
||||
#define SHF_GROUP 0x200 /* Member of section group */
|
||||
#define SHF_TLS 0x400 /* Thread local storage */
|
||||
#define SHF_MASKOS 0x0ff00000 /* OS specific */
|
||||
#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
|
||||
/* specific section attributes */
|
||||
|
||||
/* Section Group Flags */
|
||||
#define GRP_COMDAT 0x1 /* COMDAT group */
|
||||
#define GRP_MASKOS 0x0ff00000 /* Mask OS specific flags */
|
||||
#define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags */
|
||||
|
||||
/* Symbol Table Entry */
|
||||
typedef struct elf32_sym {
|
||||
Elf32_Word st_name; /* name - index into string table */
|
||||
Elf32_Addr st_value; /* symbol value */
|
||||
Elf32_Word st_size; /* symbol size */
|
||||
unsigned char st_info; /* type and binding */
|
||||
unsigned char st_other; /* 0 - no defined meaning */
|
||||
Elf32_Half st_shndx; /* section header index */
|
||||
} Elf32_Sym;
|
||||
|
||||
/* Symbol table index */
|
||||
#define STN_UNDEF 0 /* undefined */
|
||||
|
||||
/* Extract symbol info - st_info */
|
||||
#define ELF32_ST_BIND(x) ((x) >> 4)
|
||||
#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
|
||||
#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
|
||||
#define ELF32_ST_VISIBILITY(x) ((x) & 0x3)
|
||||
|
||||
/* Symbol Binding - ELF32_ST_BIND - st_info */
|
||||
#define STB_LOCAL 0 /* Local symbol */
|
||||
#define STB_GLOBAL 1 /* Global symbol */
|
||||
#define STB_WEAK 2 /* like global - lower precedence */
|
||||
#define STB_NUM 3 /* number of symbol bindings */
|
||||
#define STB_LOOS 10 /* reserved range for operating */
|
||||
#define STB_HIOS 12 /* system specific symbol bindings */
|
||||
#define STB_LOPROC 13 /* reserved range for processor */
|
||||
#define STB_HIPROC 15 /* specific symbol bindings */
|
||||
|
||||
/* Symbol type - ELF32_ST_TYPE - st_info */
|
||||
#define STT_NOTYPE 0 /* not specified */
|
||||
#define STT_OBJECT 1 /* data object */
|
||||
#define STT_FUNC 2 /* function */
|
||||
#define STT_SECTION 3 /* section */
|
||||
#define STT_FILE 4 /* file */
|
||||
#define STT_NUM 5 /* number of symbol types */
|
||||
#define STT_TLS 6 /* Thread local storage symbol */
|
||||
#define STT_LOOS 10 /* reserved range for operating */
|
||||
#define STT_HIOS 12 /* system specific symbol types */
|
||||
#define STT_LOPROC 13 /* reserved range for processor */
|
||||
#define STT_HIPROC 15 /* specific symbol types */
|
||||
|
||||
/* Symbol visibility - ELF32_ST_VISIBILITY - st_other */
|
||||
#define STV_DEFAULT 0 /* Normal visibility rules */
|
||||
#define STV_INTERNAL 1 /* Processor specific hidden class */
|
||||
#define STV_HIDDEN 2 /* Symbol unavailable in other mods */
|
||||
#define STV_PROTECTED 3 /* Not preemptible, not exported */
|
||||
|
||||
|
||||
/* Relocation entry with implicit addend */
|
||||
typedef struct
|
||||
{
|
||||
Elf32_Addr r_offset; /* offset of relocation */
|
||||
Elf32_Word r_info; /* symbol table index and type */
|
||||
} Elf32_Rel;
|
||||
|
||||
/* Relocation entry with explicit addend */
|
||||
typedef struct
|
||||
{
|
||||
Elf32_Addr r_offset; /* offset of relocation */
|
||||
Elf32_Word r_info; /* symbol table index and type */
|
||||
Elf32_Sword r_addend;
|
||||
} Elf32_Rela;
|
||||
|
||||
/* Extract relocation info - r_info */
|
||||
#define ELF32_R_SYM(i) ((i) >> 8)
|
||||
#define ELF32_R_TYPE(i) ((unsigned char) (i))
|
||||
#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
|
||||
|
||||
/* Program Header */
|
||||
typedef struct {
|
||||
Elf32_Word p_type; /* segment type */
|
||||
Elf32_Off p_offset; /* segment offset */
|
||||
Elf32_Addr p_vaddr; /* virtual address of segment */
|
||||
Elf32_Addr p_paddr; /* physical address - ignored? */
|
||||
Elf32_Word p_filesz; /* number of bytes in file for seg. */
|
||||
Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
|
||||
Elf32_Word p_flags; /* flags */
|
||||
Elf32_Word p_align; /* memory alignment */
|
||||
} Elf32_Phdr;
|
||||
|
||||
/* Segment types - p_type */
|
||||
#define PT_NULL 0 /* unused */
|
||||
#define PT_LOAD 1 /* loadable segment */
|
||||
#define PT_DYNAMIC 2 /* dynamic linking section */
|
||||
#define PT_INTERP 3 /* the RTLD */
|
||||
#define PT_NOTE 4 /* auxiliary information */
|
||||
#define PT_SHLIB 5 /* reserved - purpose undefined */
|
||||
#define PT_PHDR 6 /* program header */
|
||||
#define PT_TLS 7 /* Thread local storage template */
|
||||
#define PT_NUM 8 /* Number of segment types */
|
||||
#define PT_LOOS 0x60000000 /* reserved range for operating */
|
||||
#define PT_HIOS 0x6fffffff /* system specific segment types */
|
||||
#define PT_LOPROC 0x70000000 /* reserved range for processor */
|
||||
#define PT_HIPROC 0x7fffffff /* specific segment types */
|
||||
|
||||
/* Segment flags - p_flags */
|
||||
#define PF_X 0x1 /* Executable */
|
||||
#define PF_W 0x2 /* Writable */
|
||||
#define PF_R 0x4 /* Readable */
|
||||
#define PF_MASKOS 0x0ff00000 /* OS specific segment flags */
|
||||
#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
|
||||
/* specific segment flags */
|
||||
/* Dynamic structure */
|
||||
typedef struct
|
||||
{
|
||||
Elf32_Sword d_tag; /* controls meaning of d_val */
|
||||
union
|
||||
{
|
||||
Elf32_Word d_val; /* Multiple meanings - see d_tag */
|
||||
Elf32_Addr d_ptr; /* program virtual address */
|
||||
} d_un;
|
||||
} Elf32_Dyn;
|
||||
|
||||
extern Elf32_Dyn _DYNAMIC[];
|
||||
|
||||
/* Dynamic Array Tags - d_tag */
|
||||
#define DT_NULL 0 /* marks end of _DYNAMIC array */
|
||||
#define DT_NEEDED 1 /* string table offset of needed lib */
|
||||
#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
|
||||
#define DT_PLTGOT 3 /* address PLT/GOT */
|
||||
#define DT_HASH 4 /* address of symbol hash table */
|
||||
#define DT_STRTAB 5 /* address of string table */
|
||||
#define DT_SYMTAB 6 /* address of symbol table */
|
||||
#define DT_RELA 7 /* address of relocation table */
|
||||
#define DT_RELASZ 8 /* size of relocation table */
|
||||
#define DT_RELAENT 9 /* size of relocation entry */
|
||||
#define DT_STRSZ 10 /* size of string table */
|
||||
#define DT_SYMENT 11 /* size of symbol table entry */
|
||||
#define DT_INIT 12 /* address of initialization func. */
|
||||
#define DT_FINI 13 /* address of termination function */
|
||||
#define DT_SONAME 14 /* string table offset of shared obj */
|
||||
#define DT_RPATH 15 /* string table offset of library
|
||||
search path */
|
||||
#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
|
||||
#define DT_REL 17 /* address of rel. tbl. w addends */
|
||||
#define DT_RELSZ 18 /* size of DT_REL relocation table */
|
||||
#define DT_RELENT 19 /* size of DT_REL relocation entry */
|
||||
#define DT_PLTREL 20 /* PLT referenced relocation entry */
|
||||
#define DT_DEBUG 21 /* bugger */
|
||||
#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
|
||||
#define DT_JMPREL 23 /* add. of PLT's relocation entries */
|
||||
#define DT_BIND_NOW 24 /* Process relocations of object */
|
||||
#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
|
||||
#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
|
||||
#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
|
||||
#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
|
||||
#define DT_RUNPATH 29 /* Library search path */
|
||||
#define DT_FLAGS 30 /* Flags for the object being loaded */
|
||||
#define DT_ENCODING 32 /* Start of encoded range */
|
||||
#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
|
||||
#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
|
||||
#define DT_NUM 34 /* Number used. */
|
||||
#define DT_LOOS 0x60000000 /* reserved range for OS */
|
||||
#define DT_HIOS 0x6fffffff /* specific dynamic array tags */
|
||||
#define DT_LOPROC 0x70000000 /* reserved range for processor */
|
||||
#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
|
||||
|
||||
/* Dynamic Tag Flags - d_un.d_val */
|
||||
#define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */
|
||||
#define DF_SYMBOLIC 0x02 /* Symbol resolutions starts here */
|
||||
#define DF_TEXTREL 0x04 /* Object contains text relocations */
|
||||
#define DF_BIND_NOW 0x08 /* No lazy binding for this object */
|
||||
#define DF_STATIC_TLS 0x10 /* Static thread local storage */
|
||||
|
||||
/* Standard ELF hashing function */
|
||||
unsigned long elf_hash(const unsigned char *name);
|
||||
|
||||
#define ELF_TARG_VER 1 /* The ver for which this code is intended */
|
||||
|
||||
/*
|
||||
* XXX - PowerPC defines really don't belong in here,
|
||||
* but we'll put them in for simplicity.
|
||||
*/
|
||||
|
||||
/* Values for Elf32/64_Ehdr.e_flags. */
|
||||
#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
|
||||
|
||||
/* Cygnus local bits below */
|
||||
#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
|
||||
#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
|
||||
flag */
|
||||
|
||||
/* PowerPC relocations defined by the ABIs */
|
||||
#define R_PPC_NONE 0
|
||||
#define R_PPC_ADDR32 1 /* 32bit absolute address */
|
||||
#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
|
||||
#define R_PPC_ADDR16 3 /* 16bit absolute address */
|
||||
#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
|
||||
#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
|
||||
#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
|
||||
#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
|
||||
#define R_PPC_ADDR14_BRTAKEN 8
|
||||
#define R_PPC_ADDR14_BRNTAKEN 9
|
||||
#define R_PPC_REL24 10 /* PC relative 26 bit */
|
||||
#define R_PPC_REL14 11 /* PC relative 16 bit */
|
||||
#define R_PPC_REL14_BRTAKEN 12
|
||||
#define R_PPC_REL14_BRNTAKEN 13
|
||||
#define R_PPC_GOT16 14
|
||||
#define R_PPC_GOT16_LO 15
|
||||
#define R_PPC_GOT16_HI 16
|
||||
#define R_PPC_GOT16_HA 17
|
||||
#define R_PPC_PLTREL24 18
|
||||
#define R_PPC_COPY 19
|
||||
#define R_PPC_GLOB_DAT 20
|
||||
#define R_PPC_JMP_SLOT 21
|
||||
#define R_PPC_RELATIVE 22
|
||||
#define R_PPC_LOCAL24PC 23
|
||||
#define R_PPC_UADDR32 24
|
||||
#define R_PPC_UADDR16 25
|
||||
#define R_PPC_REL32 26
|
||||
#define R_PPC_PLT32 27
|
||||
#define R_PPC_PLTREL32 28
|
||||
#define R_PPC_PLT16_LO 29
|
||||
#define R_PPC_PLT16_HI 30
|
||||
#define R_PPC_PLT16_HA 31
|
||||
#define R_PPC_SDAREL16 32
|
||||
#define R_PPC_SECTOFF 33
|
||||
#define R_PPC_SECTOFF_LO 34
|
||||
#define R_PPC_SECTOFF_HI 35
|
||||
#define R_PPC_SECTOFF_HA 36
|
||||
/* Keep this the last entry. */
|
||||
#define R_PPC_NUM 37
|
||||
|
||||
/* The remaining relocs are from the Embedded ELF ABI, and are not
|
||||
in the SVR4 ELF ABI. */
|
||||
#define R_PPC_EMB_NADDR32 101
|
||||
#define R_PPC_EMB_NADDR16 102
|
||||
#define R_PPC_EMB_NADDR16_LO 103
|
||||
#define R_PPC_EMB_NADDR16_HI 104
|
||||
#define R_PPC_EMB_NADDR16_HA 105
|
||||
#define R_PPC_EMB_SDAI16 106
|
||||
#define R_PPC_EMB_SDA2I16 107
|
||||
#define R_PPC_EMB_SDA2REL 108
|
||||
#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
|
||||
#define R_PPC_EMB_MRKREF 110
|
||||
#define R_PPC_EMB_RELSEC16 111
|
||||
#define R_PPC_EMB_RELST_LO 112
|
||||
#define R_PPC_EMB_RELST_HI 113
|
||||
#define R_PPC_EMB_RELST_HA 114
|
||||
#define R_PPC_EMB_BIT_FLD 115
|
||||
#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
|
||||
|
||||
/* Diab tool relocations. */
|
||||
#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
|
||||
#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
|
||||
#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
|
||||
#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
|
||||
#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
|
||||
#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
|
||||
|
||||
/* This is a phony reloc to handle any old fashioned TOC16 references
|
||||
that may still be in object files. */
|
||||
#define R_PPC_TOC16 255
|
||||
|
||||
#endif /* _ELF_H */
|
||||
|
103
source/homebrewboot/elfloader.c
Normal file
103
source/homebrewboot/elfloader.c
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2001 William L. Pitts
|
||||
* Modifications (c) 2004 Felix Domke
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are freely
|
||||
* permitted provided that the above copyright notice and this
|
||||
* paragraph and the following disclaimer are duplicated in all
|
||||
* such forms.
|
||||
*
|
||||
* This software is provided "AS IS" and without any express or
|
||||
* implied warranties, including, without limitation, the implied
|
||||
* warranties of merchantability and fitness for a particular
|
||||
* purpose.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gccore.h>
|
||||
|
||||
#include "elf_abi.h"
|
||||
|
||||
/* ======================================================================
|
||||
* Determine if a valid ELF image exists at the given memory location.
|
||||
* First looks at the ELF header magic field, the makes sure that it is
|
||||
* executable and makes sure that it is for a PowerPC.
|
||||
* ====================================================================== */
|
||||
s32 valid_elf_image (void *addr)
|
||||
{
|
||||
Elf32_Ehdr *ehdr; /* Elf header structure pointer */
|
||||
|
||||
ehdr = (Elf32_Ehdr *) addr;
|
||||
|
||||
if (!IS_ELF (*ehdr))
|
||||
return 0;
|
||||
|
||||
if (ehdr->e_type != ET_EXEC)
|
||||
return -1;
|
||||
|
||||
if (ehdr->e_machine != EM_PPC)
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* ======================================================================
|
||||
* A very simple elf loader, assumes the image is valid, returns the
|
||||
* entry point address.
|
||||
* ====================================================================== */
|
||||
u32 load_elf_image (void *addr)
|
||||
{
|
||||
Elf32_Ehdr *ehdr;
|
||||
Elf32_Shdr *shdr;
|
||||
u8 *strtab = 0;
|
||||
u8 *image;
|
||||
int i;
|
||||
|
||||
ehdr = (Elf32_Ehdr *) addr;
|
||||
/* Find the section header string table for output info */
|
||||
shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff +
|
||||
(ehdr->e_shstrndx * sizeof (Elf32_Shdr)));
|
||||
|
||||
if (shdr->sh_type == SHT_STRTAB)
|
||||
strtab = (u8 *) (addr + shdr->sh_offset);
|
||||
|
||||
/* Load each appropriate section */
|
||||
for (i = 0; i < ehdr->e_shnum; ++i) {
|
||||
shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff +
|
||||
(i * sizeof (Elf32_Shdr)));
|
||||
|
||||
if (!(shdr->sh_flags & SHF_ALLOC)
|
||||
|| shdr->sh_addr == 0 || shdr->sh_size == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
shdr->sh_addr &= 0x3FFFFFFF;
|
||||
shdr->sh_addr |= 0x80000000;
|
||||
|
||||
if (strtab) {
|
||||
/*printf ("%sing section %s @ 0x%08x (0x%08x bytes)\n",
|
||||
(shdr->sh_type == SHT_NOBITS) ?
|
||||
"clear" : "load",
|
||||
&strtab[shdr->sh_name],
|
||||
(u32) shdr->sh_addr,
|
||||
(u32) shdr->sh_size);*/
|
||||
}
|
||||
|
||||
if (shdr->sh_type == SHT_NOBITS) {
|
||||
memset ((void *) shdr->sh_addr, 0, shdr->sh_size);
|
||||
} else {
|
||||
image = (u8 *) addr + shdr->sh_offset;
|
||||
memcpy ((void *) shdr->sh_addr,
|
||||
(const void *) image,
|
||||
shdr->sh_size);
|
||||
}
|
||||
DCFlushRangeNoSync ((void *) shdr->sh_addr, shdr->sh_size);
|
||||
}
|
||||
|
||||
return (ehdr->e_entry & 0x3FFFFFFF) | 0x80000000;
|
||||
}
|
||||
|
18
source/homebrewboot/elfloader.h
Normal file
18
source/homebrewboot/elfloader.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _ELFLOADER_H_
|
||||
#define _ELFLOADER_H_
|
||||
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
s32 valid_elf_image (void *addr);
|
||||
u32 load_elf_image (void *addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -22,6 +22,8 @@
|
||||
#include "usbloader/getentries.h"
|
||||
#include "language/gettext.h"
|
||||
#include "settings/Settings.h"
|
||||
#include "homebrewboot/HomebrewBrowse.h"
|
||||
#include "homebrewboot/BootHomebrew.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "prompts/ProgressWindow.h"
|
||||
#include "prompts/gameinfo.h"
|
||||
@ -75,6 +77,7 @@ extern struct discHdr * gameList;
|
||||
extern u32 gameCnt;
|
||||
extern s32 gameSelected, gameStart;
|
||||
extern const u8 data1;
|
||||
extern bool boothomebrew;
|
||||
|
||||
/****************************************************************************
|
||||
* ResumeGui
|
||||
@ -441,6 +444,17 @@ int MenuDiscList()
|
||||
GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, 2, 3, THEME.carousel_x, THEME.carousel_y, &trigA, &btnSoundOver, &btnClick,1);
|
||||
carouselBtn.SetAlpha(180);
|
||||
|
||||
GuiImage homebrewBtnImg(&imgarrangeList);
|
||||
homebrewBtnImg.SetWidescreen(CFG.widescreen);
|
||||
GuiButton homebrewBtn(homebrewBtnImg.GetWidth(), homebrewBtnImg.GetHeight());
|
||||
homebrewBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
homebrewBtn.SetPosition(430, 410);
|
||||
homebrewBtn.SetImage(&homebrewBtnImg);
|
||||
homebrewBtn.SetSoundOver(&btnSoundOver);
|
||||
homebrewBtn.SetSoundClick(&btnClick);
|
||||
homebrewBtn.SetEffectGrow();
|
||||
homebrewBtn.SetTrigger(&trigA);
|
||||
|
||||
if (Settings.fave)
|
||||
{
|
||||
favoriteBtn.SetImage(&favoriteBtnImg);
|
||||
@ -595,6 +609,7 @@ int MenuDiscList()
|
||||
w.Append(&listBtn);
|
||||
w.Append(&gridBtn);
|
||||
w.Append(&carouselBtn);
|
||||
w.Append(&homebrewBtn);
|
||||
|
||||
if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24))
|
||||
{
|
||||
@ -924,18 +939,21 @@ int MenuDiscList()
|
||||
}
|
||||
|
||||
else if (carouselBtn.GetState() == STATE_CLICKED) {
|
||||
if (Settings.gameDisplay!=carousel) {
|
||||
|
||||
Settings.gameDisplay=carousel;
|
||||
menu = MENU_DISCLIST;
|
||||
if(isInserted(bootDevice)) {
|
||||
if (Settings.gameDisplay!=carousel) {
|
||||
Settings.gameDisplay=carousel;
|
||||
menu = MENU_DISCLIST;
|
||||
if(isInserted(bootDevice)) {
|
||||
cfg_save_global();
|
||||
}
|
||||
carouselBtn.ResetState();
|
||||
break;
|
||||
} else {
|
||||
carouselBtn.ResetState();
|
||||
}
|
||||
carouselBtn.ResetState();
|
||||
break;
|
||||
} else {
|
||||
carouselBtn.ResetState();
|
||||
}
|
||||
}
|
||||
else if (homebrewBtn.GetState() == STATE_CLICKED) {
|
||||
menu = MENU_HOMEBREWBROWSE;
|
||||
break;
|
||||
}
|
||||
else if (gameInfo.GetState() == STATE_CLICKED) {
|
||||
struct discHdr *header = &gameList[selectImg1];
|
||||
@ -1120,7 +1138,7 @@ int MenuDiscList()
|
||||
/* Open gct File and check exist */
|
||||
sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull);
|
||||
exeFile = fopen (nipple ,"rb");
|
||||
|
||||
|
||||
if (exeFile==NULL)
|
||||
{
|
||||
sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats."));
|
||||
@ -1136,7 +1154,7 @@ int MenuDiscList()
|
||||
WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
SDCard_deInit();
|
||||
wiilight(0);
|
||||
@ -1204,7 +1222,7 @@ int MenuDiscList()
|
||||
WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
SDCard_deInit();
|
||||
wiilight(0);
|
||||
@ -1273,7 +1291,7 @@ int MenuDiscList()
|
||||
covertOld=covert;
|
||||
}
|
||||
|
||||
HaltGui();
|
||||
HaltGui();
|
||||
mainWindow->RemoveAll();
|
||||
mainWindow->Append(bgImg);
|
||||
delete gameBrowser;
|
||||
@ -1731,6 +1749,9 @@ int MainMenu(int menu)
|
||||
case MENU_SETTINGS:
|
||||
currentMenu = MenuSettings();
|
||||
break;
|
||||
case MENU_HOMEBREWBROWSE:
|
||||
currentMenu = MenuHomebrewBrowse();
|
||||
break;
|
||||
case MENU_DISCLIST:
|
||||
currentMenu = MenuDiscList();
|
||||
break;
|
||||
@ -1738,8 +1759,6 @@ int MainMenu(int menu)
|
||||
currentMenu = MenuCheck();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
CloseXMLDatabase();
|
||||
ExitGUIThreads();
|
||||
@ -1758,6 +1777,10 @@ int MainMenu(int menu)
|
||||
ShutdownAudio();
|
||||
StopGX();
|
||||
|
||||
if(boothomebrew == true) {
|
||||
BootHomebrew(Settings.selected_homebrew);
|
||||
} else {
|
||||
|
||||
int ret = 0;
|
||||
struct discHdr *header = &gameList[gameSelected];
|
||||
|
||||
@ -1963,6 +1986,7 @@ int MainMenu(int menu)
|
||||
if (ret < 0) {
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ enum
|
||||
MENU_FORMAT,
|
||||
MENU_INSTALL,
|
||||
MENU_CHECK,
|
||||
MENU_GAME_SETTINGS
|
||||
MENU_GAME_SETTINGS,
|
||||
MENU_HOMEBREWBROWSE,
|
||||
BOOTHOMEBREW
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1196,6 +1196,7 @@ int MenuSettings()
|
||||
options2.SetName(5, "%s", tr("Cheatcodes Path"));
|
||||
options2.SetName(6, "%s", tr("TXTCheatcodes Path"));
|
||||
options2.SetName(7, "%s", tr("Dol Path"));
|
||||
options2.SetName(8, "%s", tr("Homebrew Apps Path"));
|
||||
for(int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL);
|
||||
w.Append(&optionBrowser2);
|
||||
optionBrowser2.SetClickable(true);
|
||||
@ -1219,6 +1220,7 @@ int MenuSettings()
|
||||
options2.SetValue(5, "%s", Settings.Cheatcodespath);
|
||||
options2.SetValue(6, "%s", Settings.TxtCheatcodespath);
|
||||
options2.SetValue(7, "%s", Settings.dolpath);
|
||||
options2.SetValue(8, "%s", Settings.homebrewapps_path);
|
||||
|
||||
if(backBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
@ -1493,6 +1495,32 @@ int MenuSettings()
|
||||
WindowPrompt(tr("Dolpath change"),tr("Console should be unlocked to modify it."),tr("OK"));
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if ( Settings.godmode == 1)
|
||||
{
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.homebrewapps_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
{
|
||||
int len = (strlen(entered)-1);
|
||||
if(entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.homebrewapps_path, entered, sizeof(Settings.homebrewapps_path));
|
||||
WindowPrompt(tr("Homebrew Appspath changed"),0,tr("OK"));
|
||||
// if(!isSdInserted()) {
|
||||
if(!isInserted(bootDevice)) {
|
||||
WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
WindowPrompt(tr("Homebrew Appspath change"),tr("Console should be unlocked to modify it."),tr("OK"));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@ -1982,7 +2010,7 @@ int GameSettings(struct discHdr * header)
|
||||
int dolchoice =0;
|
||||
//check to see if we already know the offset of the correct dol
|
||||
int autodol = autoSelectDol(filename);
|
||||
|
||||
|
||||
//if we do know that offset ask if they want to use it
|
||||
if (autodol>0){
|
||||
dolchoice = WindowPrompt(0,tr("Do you want to use the alt dol that is known to be correct?"),tr("Yes"),tr("Pick from a list"));
|
||||
|
@ -220,6 +220,7 @@ void CFG_Default(int widescreen) // -1 = non forced Mode
|
||||
snprintf(Settings.languagefiles_path, sizeof(Settings.languagefiles_path), "%s/config/language/", bootDevice);
|
||||
snprintf(Settings.oggload_path, sizeof(Settings.oggload_path), "%s/config/backgroundmusic/", bootDevice);
|
||||
snprintf(Settings.update_path, sizeof(Settings.update_path), "%s/apps/usbloader_gx/", bootDevice);
|
||||
snprintf(Settings.homebrewapps_path, sizeof(Settings.homebrewapps_path), "%s/apps/", bootDevice);
|
||||
snprintf(Settings.Cheatcodespath, sizeof(Settings.Cheatcodespath), "%s/codes/", bootDevice);
|
||||
snprintf(Settings.TxtCheatcodespath, sizeof(Settings.TxtCheatcodespath), "%s/txtcodes/", bootDevice);
|
||||
snprintf(Settings.dolpath, sizeof(Settings.dolpath), "%s/", bootDevice);
|
||||
@ -487,6 +488,10 @@ void path_set(char *name, char *val)
|
||||
strcopy(Settings.update_path, val, sizeof(Settings.update_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "homebrewapps_path") == 0) {
|
||||
strcopy(Settings.homebrewapps_path, val, sizeof(Settings.homebrewapps_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "Cheatcodespath") == 0) {
|
||||
strcopy(Settings.Cheatcodespath, val, sizeof(Settings.Cheatcodespath));
|
||||
return;
|
||||
@ -1253,6 +1258,7 @@ bool cfg_save_global()// save global settings
|
||||
fprintf(f, "wiilight = %d\n ", Settings.wiilight);
|
||||
fprintf(f, "gameDisplay = %d\n ", Settings.gameDisplay);
|
||||
fprintf(f, "update_path = %s\n ", Settings.update_path);
|
||||
fprintf(f, "homebrewapps_path = %s\n ", Settings.homebrewapps_path);
|
||||
fprintf(f, "Cheatcodespath = %s\n ", Settings.Cheatcodespath);
|
||||
fprintf(f, "titlesOverride = %d\n ", Settings.titlesOverride);
|
||||
//fprintf(f, "db_url = %s\n ", Settings.db_url);
|
||||
|
@ -355,6 +355,8 @@ struct SSettings {
|
||||
char ogg_path[150];
|
||||
char dolpath[150];
|
||||
char update_path[150];
|
||||
char homebrewapps_path[150];
|
||||
char selected_homebrew[200];
|
||||
char Cheatcodespath[100];
|
||||
char TxtCheatcodespath[100];
|
||||
short error002;
|
||||
|
Loading…
Reference in New Issue
Block a user