mirror of
https://gitlab.com/Nanolx/homebrewfilter.git
synced 2024-12-29 02:41:48 +01:00
merge changes from obcd
This commit is contained in:
parent
7c5db8beb7
commit
f022f66fa4
@ -26,6 +26,8 @@ SOURCES := source \
|
||||
source/Network \
|
||||
source/Tools \
|
||||
source/Neek \
|
||||
source/Neek/data \
|
||||
source/Neek/xml \
|
||||
../svnrev
|
||||
INCLUDES := source
|
||||
DATA := data/fonts \
|
||||
|
@ -38,6 +38,8 @@ static int wiiload_args = 0;
|
||||
static char temp_arg[1024];
|
||||
std::string filepath;
|
||||
|
||||
extern bool in_neek;
|
||||
|
||||
void arg_init()
|
||||
{
|
||||
memset(&args, 0, sizeof(args));
|
||||
@ -223,7 +225,6 @@ int BootHomebrew()
|
||||
arg_add(parser(Settings.forwarder_arg, "<arg>", "</arg>").c_str());
|
||||
Settings.forwarder_arg.erase(0, Settings.forwarder_arg.find("</arg>") +1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( valid_elf_image(homebrewbuffer) == 1 )
|
||||
@ -234,11 +235,26 @@ int BootHomebrew()
|
||||
if (!entry)
|
||||
return -1;
|
||||
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
//we can't use check_uneek_fs
|
||||
//as we already shut down the uneek_fs system
|
||||
//so it will always return false
|
||||
|
||||
if (in_neek == false)
|
||||
{
|
||||
if(Settings.force_reload != "")
|
||||
{
|
||||
//keep ahbprot rights in new ios
|
||||
Patch_ahbprot();
|
||||
}
|
||||
IOS_ReloadIOS(SelectedIOS());
|
||||
}
|
||||
wiiload_args = 0;
|
||||
|
||||
/*this will also be called when wiiloading an application
|
||||
will need to check if it's expected behavour? */
|
||||
|
||||
/*
|
||||
if(!wiiload_args)
|
||||
{
|
||||
|
||||
@ -249,9 +265,8 @@ int BootHomebrew()
|
||||
IOS_ReloadIOS(SelectedIOS());
|
||||
}
|
||||
}
|
||||
|
||||
wiiload_args = 0;
|
||||
|
||||
*/
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
_CPU_ISR_Disable (cpu_isr);
|
||||
__exception_closeall();
|
||||
|
@ -172,7 +172,7 @@ int MenuMain()
|
||||
LogoHomebrewFilterImg.SetPosition(30, 420);
|
||||
LogoHomebrewFilterImg.SetScale(0.65);
|
||||
|
||||
GuiText ownerTxt("Nano", 18, (GXColor){Theme.owner_1, Theme.owner_2, Theme.owner_3, 255});
|
||||
GuiText ownerTxt("Nano & Obcd", 18, (GXColor){Theme.owner_1, Theme.owner_2, Theme.owner_3, 255});
|
||||
ownerTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
ownerTxt.SetPosition(-35,430);
|
||||
|
||||
|
1837
main/source/Neek/armboot.c
Normal file
1837
main/source/Neek/armboot.c
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,205 +0,0 @@
|
||||
/******************************************************************************************
|
||||
*** ***
|
||||
*** nswitch - Simple neek/realnand switcher to embed in a channel ***
|
||||
*** ***
|
||||
*** Copyright (C) 2011 OverjoY ***
|
||||
*** ***
|
||||
*** 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 version 2. ***
|
||||
*** ***
|
||||
*** 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. ***
|
||||
*** ***
|
||||
*******************************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <fat.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "armboot.h"
|
||||
|
||||
#define le32(i) (((((u32) i) & 0xFF) << 24) | ((((u32) i) & 0xFF00) << 8) | \
|
||||
((((u32) i) & 0xFF0000) >> 8) | ((((u32) i) & 0xFF000000) >> 24))
|
||||
|
||||
enum
|
||||
{
|
||||
SD = 0,
|
||||
USB1,
|
||||
USB2,
|
||||
USB3,
|
||||
USB4,
|
||||
MAXDEV
|
||||
};
|
||||
|
||||
static const char dev[MAXDEV][6] =
|
||||
{
|
||||
"sd",
|
||||
"usb1",
|
||||
"usb2",
|
||||
"usb3",
|
||||
"usb4"
|
||||
};
|
||||
|
||||
typedef struct _PR
|
||||
{
|
||||
u8 state;
|
||||
u8 chs_st[3];
|
||||
u8 type;
|
||||
u8 chs_e[3];
|
||||
u32 lba;
|
||||
u32 bc;
|
||||
} __attribute__((__packed__)) _pr;
|
||||
|
||||
typedef struct _MBR
|
||||
{
|
||||
u8 ca[446];
|
||||
_pr part[4];
|
||||
u16 sig;
|
||||
} __attribute__((__packed__)) _mbr;
|
||||
|
||||
bool check_neek2o() {
|
||||
|
||||
if(fopen("sd1:/sneek/kernel.bin", "rb") || fopen("usb1:/sneek/kernel.bin", "rb"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
int boot_neek2o() {
|
||||
|
||||
u32 b2;
|
||||
ES_GetBoot2Version( &b2 );
|
||||
if( b2 < 5 )
|
||||
{
|
||||
int tr = 10;
|
||||
bool USBMounted = false, SDMounted = false;
|
||||
while( tr )
|
||||
{
|
||||
if( __io_usbstorage.startup() && __io_usbstorage.isInserted() )
|
||||
{
|
||||
_mbr mbr;
|
||||
char buffer[512];
|
||||
|
||||
__io_usbstorage.readSectors( 0, 1, &mbr );
|
||||
for( tr = 0; tr < 4; ++tr)
|
||||
{
|
||||
if(mbr.part[tr].type == 0)
|
||||
continue;
|
||||
|
||||
__io_usbstorage.readSectors( le32( mbr.part[tr].lba ), 1, buffer );
|
||||
|
||||
if( *( (u16 *)( buffer + 0x1FE ) ) == 0x55AA )
|
||||
{
|
||||
if( memcmp( buffer + 0x36, "FAT", 3 ) == 0 || memcmp( buffer + 0x52, "FAT", 3 ) == 0 )
|
||||
{
|
||||
fatMount( dev[USB1+tr], &__io_usbstorage, le32( mbr.part[tr].lba ), 8, 64 );
|
||||
USBMounted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
usleep( 150000 );
|
||||
}
|
||||
|
||||
if( __io_wiisd.startup() || !__io_wiisd.isInserted() )
|
||||
if( fatMount( dev[SD], &__io_wiisd, 0, 8, 64 ) )
|
||||
SDMounted = true;
|
||||
|
||||
|
||||
FILE *f = NULL;
|
||||
long fsize;
|
||||
size_t fres;
|
||||
char path[40];
|
||||
if( USBMounted )
|
||||
{
|
||||
for( tr = USB1; tr < MAXDEV; ++tr )
|
||||
{
|
||||
sprintf( path, "%s:/sneek/kernel.bin", dev[tr] );
|
||||
if( !f )
|
||||
f = fopen( path, "rb" );
|
||||
}
|
||||
}
|
||||
|
||||
if( !f && SDMounted )
|
||||
f = fopen( "sd:/sneek/kernel.bin", "rb" );
|
||||
|
||||
|
||||
if( f )
|
||||
{
|
||||
fseek( f , 0 , SEEK_END );
|
||||
fsize = ftell( f );
|
||||
rewind( f );
|
||||
fres = fread ( (void *)0x91000000, 1, fsize, f );
|
||||
DCFlushRange( (void *)0x91000000, fsize );
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose( f );
|
||||
|
||||
for( tr = SD; tr < MAXDEV; ++tr )
|
||||
{
|
||||
char d[40];
|
||||
sprintf( d, "%s:", dev[tr] );
|
||||
fatUnmount( d );
|
||||
}
|
||||
__io_usbstorage.shutdown();
|
||||
__io_wiisd.shutdown();
|
||||
SYS_ResetSystem( SYS_RETURNTOMENU, 0, 0 );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
|
||||
for( tr = SD; tr < MAXDEV; ++tr )
|
||||
{
|
||||
char d[40];
|
||||
sprintf( d, "%s:", dev[tr] );
|
||||
fatUnmount( d );
|
||||
}
|
||||
__io_usbstorage.shutdown();
|
||||
__io_wiisd.shutdown();
|
||||
|
||||
/*** Boot mini from mem code by giantpune ***/
|
||||
void *mini = memalign( 32, armboot_size );
|
||||
if( !mini )
|
||||
return 0;
|
||||
|
||||
memcpy( mini, armboot, armboot_size );
|
||||
DCFlushRange( mini, armboot_size );
|
||||
|
||||
*(u32*)0xc150f000 = 0x424d454d;
|
||||
asm volatile( "eieio" );
|
||||
|
||||
*(u32*)0xc150f004 = MEM_VIRTUAL_TO_PHYSICAL( mini );
|
||||
asm volatile( "eieio" );
|
||||
|
||||
IOS_ReloadIOS( 0xfe );
|
||||
|
||||
free( mini );
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SYS_ResetSystem( SYS_RESTART,0,0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
165
main/source/Neek/bootneek.cpp
Normal file
165
main/source/Neek/bootneek.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <sys/iosupport.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "uneek_fs.h"
|
||||
#include "../gecko.h"
|
||||
#include "common.h"
|
||||
|
||||
struct SSettingsNeek2o n2oSettings;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif //__cplusplus
|
||||
|
||||
bool IsNandFolder (char *path);
|
||||
void DoMini(u8* kbuf, size_t kernel_size);
|
||||
s32 get_nand_folder(char* nandpath);
|
||||
|
||||
// xml.cpp
|
||||
void CreateXmlFile(const char* filename, struct SSettingsNeek2o *Settings);
|
||||
int LoadXmlFile(const char* filename, struct SSettingsNeek2o *Settings);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //__cplusplus
|
||||
|
||||
|
||||
|
||||
void ExitApp();
|
||||
|
||||
|
||||
|
||||
int boot_neek2o()
|
||||
{
|
||||
int allfound = 0;
|
||||
s32 nresult;
|
||||
u32 kernel_size;
|
||||
int ferr;
|
||||
u8* kernel_buff;
|
||||
char filepath[1024];
|
||||
char kpath[1024] = { 0 };
|
||||
|
||||
xml_set_default();
|
||||
strcpy(filepath,"sd1:/sneek/kernel.bin");
|
||||
if (FileExist(filepath))
|
||||
{
|
||||
strcpy(kpath,filepath);
|
||||
strcpy(filepath,"sd1:/sneek/bootneek.xml");
|
||||
if (FileExist(filepath))
|
||||
{
|
||||
LoadXmlFile(filepath,&n2oSettings);
|
||||
allfound = 1;
|
||||
}
|
||||
}
|
||||
if (allfound == 0)
|
||||
{
|
||||
strcpy(filepath,"usb1:/sneek/kernel.bin");
|
||||
if (FileExist(filepath))
|
||||
{
|
||||
strcpy(kpath,filepath);
|
||||
strcpy(filepath,"usb1:/sneek/bootneek.xml");
|
||||
if (FileExist(filepath))
|
||||
{
|
||||
LoadXmlFile(filepath,&n2oSettings);
|
||||
allfound = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(kpath[0] != 0)
|
||||
{
|
||||
gprintf ("Booting neek...\n");
|
||||
//check if it's sneek or uneek
|
||||
if (n2oSettings.neeknandpath[0] == 0)
|
||||
{
|
||||
//no nandpath defined
|
||||
//their still could be a nandpath.bin and a nandcfg.bin
|
||||
//assume loading from where we found kernel.bin
|
||||
if ((kpath[0] == 's')||(kpath[0] == 'S'))
|
||||
{
|
||||
strcpy(n2oSettings.nanddisc,"sd1:/");
|
||||
strcpy(n2oSettings.nandfolder,"/");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(n2oSettings.nanddisc,"usb1:/");
|
||||
strcpy(n2oSettings.nandfolder,"/");
|
||||
}
|
||||
}
|
||||
nresult = adjust_nandpath();
|
||||
if((nresult == -2) || (nresult == -3))
|
||||
{
|
||||
if (n2oSettings.neeknandpath[0] == 0)
|
||||
{
|
||||
gprintf("Warning:bootneek.xml not found\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("Warning:bootneek.xml contains an invalid nandpath\n");
|
||||
}
|
||||
}
|
||||
if (nresult == -2)
|
||||
{
|
||||
gprintf("Will use nandcfg.bin nand or rootnand instead\n");
|
||||
}
|
||||
if (nresult == -3)
|
||||
{
|
||||
//we might still check if nandpath.bin contains a valid nandpath
|
||||
gprintf("Will use nandpath.bin instead\n");
|
||||
}
|
||||
//if a specific dipath is requested, let's generate the file
|
||||
if (n2oSettings.neekdipath[0] != 0)
|
||||
{
|
||||
create_dipath();
|
||||
}
|
||||
//if there is a request to boot a specific channel
|
||||
//let's make this possible as well
|
||||
//for future expansion
|
||||
nresult = set_neek_channel();
|
||||
if (nresult == -2)
|
||||
{
|
||||
gprintf("Error: could not create /sys/launch.sys\n");
|
||||
gprintf("Unable to boot the neek with the requested startup channel\n");
|
||||
}
|
||||
if (nresult == -3)
|
||||
{
|
||||
gprintf("Error: could not locate the requested neek startup channel on the nand\n");
|
||||
}
|
||||
if (nresult == 1)
|
||||
{
|
||||
kernel_buff = ReadFile2Buffer(kpath,&kernel_size,&ferr);
|
||||
ExitApp();
|
||||
//if it failed reading....
|
||||
//ferr = 1;
|
||||
if (ferr == 0)
|
||||
{
|
||||
//if the kernel should be patched
|
||||
//this is the place to do it.
|
||||
//I had it, let's go for it
|
||||
DoMini(kernel_buff,kernel_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("ERROR:unable to load kernel.bin\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("couldn't find sneek2o or uneek2o\n");
|
||||
ExitApp();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
extern "C" {
|
||||
#endif //__cplusplus
|
||||
|
||||
bool check_neek2o();
|
||||
int boot_neek2o();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //__cplusplus
|
||||
#endif //__cplusplus
|
||||
|
||||
int boot_neek2o();
|
35
main/source/Neek/common.h
Normal file
35
main/source/Neek/common.h
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
|
||||
struct SSettingsNeek2o {
|
||||
char type[8];
|
||||
char neeknandpath[64];
|
||||
char neekdipath[64];
|
||||
char nandbootdelay[4];
|
||||
char neekbootdelay[4];
|
||||
char nandbootapplication[64];
|
||||
char neekbootapplication[64];
|
||||
char neekbootchannel[24];
|
||||
char neekselection[2];
|
||||
char nanddisc[16];
|
||||
char nandfolder[64];
|
||||
char nandbootdescription[128];
|
||||
char neekbootdescription[128];
|
||||
char nandbootargument[128];
|
||||
char neekbootargument[128];
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif //__cplusplus
|
||||
|
||||
bool FileExist (char *fn);
|
||||
bool DirExist (char *path);
|
||||
u8 *ReadFile2Buffer (char *path, size_t *filesize, int *err);
|
||||
bool IsNandFolder (char *path);
|
||||
s32 adjust_nandpath (void);
|
||||
void create_dipath(void);
|
||||
s32 set_neek_channel(void);
|
||||
void xml_set_default(void);
|
||||
s32 get_nand_folder(char* nandpath);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //__cplusplus
|
BIN
main/source/Neek/data/armboot.bin
Normal file
BIN
main/source/Neek/data/armboot.bin
Normal file
Binary file not shown.
1837
main/source/Neek/data/armboot.c
Normal file
1837
main/source/Neek/data/armboot.c
Normal file
File diff suppressed because it is too large
Load Diff
14
main/source/Neek/data/armboot.h
Normal file
14
main/source/Neek/data/armboot.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
This file was autogenerated by raw2c.
|
||||
Visit http://www.devkitpro.org
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
#ifndef _armboot_h_
|
||||
#define _armboot_h_
|
||||
//---------------------------------------------------------------------------------
|
||||
extern const unsigned char armboot[];
|
||||
extern const int armboot_size;
|
||||
//---------------------------------------------------------------------------------
|
||||
#endif //_armboot_h_
|
||||
//---------------------------------------------------------------------------------
|
BIN
main/source/Neek/data/raw2c.exe
Normal file
BIN
main/source/Neek/data/raw2c.exe
Normal file
Binary file not shown.
81
main/source/Neek/mini.c
Normal file
81
main/source/Neek/mini.c
Normal file
@ -0,0 +1,81 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gccore.h>
|
||||
#include <dirent.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <malloc.h>
|
||||
#include "uneek_fs.h"
|
||||
#include "gecko.h"
|
||||
#include "armboot.h"
|
||||
//#include "../build/kernel_bin.h"
|
||||
|
||||
//#define KERNEL_SIZE 168920
|
||||
|
||||
void DoMini(u8* kbuf, size_t kernel_size)
|
||||
{
|
||||
//temporary test
|
||||
//copy kernel.bin
|
||||
|
||||
|
||||
kernel_size +=3;
|
||||
kernel_size &= 0xFFFFFFFC;
|
||||
//memcpy((void*)0x91000000,kernel_bin,KERNEL_SIZE);
|
||||
//DCFlushRange( (void *)0x91000000, KERNEL_SIZE );
|
||||
|
||||
|
||||
// char* mini = (char*) memalign( 32, armboot_bin_size +KERNEL_SIZE + 4 );
|
||||
u8* mini = (u8*) memalign( 32, armboot_size +kernel_size + 4 );
|
||||
|
||||
if( !mini )
|
||||
{
|
||||
return;
|
||||
}
|
||||
gprintf( "mini buffer: %p\n", mini );
|
||||
|
||||
|
||||
// memcpy( mini, kernel_bin,KERNEL_SIZE);
|
||||
// DCFlushRange( mini, KERNEL_SIZE );
|
||||
// memcpy( mini+KERNEL_SIZE+4, armboot_bin, armboot_bin_size );
|
||||
// DCFlushRange( mini+KERNEL_SIZE+4, armboot_bin_size );
|
||||
|
||||
memcpy( mini, kbuf,kernel_size);
|
||||
DCFlushRange( mini, kernel_size );
|
||||
free(kbuf);
|
||||
memcpy( mini+kernel_size+4, armboot, armboot_size );
|
||||
DCFlushRange( mini+kernel_size+4, armboot_size );
|
||||
|
||||
gprintf( "armboot.bin copied\n" );
|
||||
*(u32*)0xc150f000 = 0x424d454d;
|
||||
asm volatile( "eieio" );
|
||||
|
||||
// physical address for armboot.bin. ( virtualToPhysical() )
|
||||
// *(u32*)0xc150f004 = MEM_VIRTUAL_TO_PHYSICAL( mini+KERNEL_SIZE+4 );
|
||||
*(u32*)0xc150f004 = MEM_VIRTUAL_TO_PHYSICAL( mini+kernel_size+4 );
|
||||
|
||||
asm volatile( "eieio" );
|
||||
|
||||
gprintf( "physical memory address: %08x\n", MEM_VIRTUAL_TO_PHYSICAL( mini ) );
|
||||
gprintf( "loading bootmii IOS\n" );
|
||||
|
||||
|
||||
// pass position of kernel.bin to mini
|
||||
*(u32*)0x8132FFF0 = MEM_VIRTUAL_TO_PHYSICAL( mini );
|
||||
asm volatile( "eieio" );
|
||||
DCFlushRange((void*)0x8132FFF0,4);
|
||||
|
||||
// pass length of kernel.bin to mini
|
||||
*(u32*)0x8132FFF4 = kernel_size;
|
||||
asm volatile( "eieio" );
|
||||
DCFlushRange((void*)0x8132FFF4,4);
|
||||
|
||||
|
||||
|
||||
IOS_ReloadIOS( 0xfe );
|
||||
|
||||
gprintf( "well shit. this shouldnt happen\n" );
|
||||
|
||||
free( mini );
|
||||
}
|
||||
|
374
main/source/Neek/utils.c
Normal file
374
main/source/Neek/utils.c
Normal file
@ -0,0 +1,374 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <gccore.h>
|
||||
#include <unistd.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <dirent.h>
|
||||
#include <malloc.h>
|
||||
#include "common.h"
|
||||
#include "gecko.h"
|
||||
|
||||
|
||||
extern struct SSettingsNeek2o n2oSettings;
|
||||
|
||||
|
||||
bool FileExist (char *fn)
|
||||
{
|
||||
FILE * f;
|
||||
f = fopen(fn, "rb");
|
||||
if (!f) return false;
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DirExist (char *path)
|
||||
{
|
||||
DIR *dir;
|
||||
|
||||
dir=opendir(path);
|
||||
if (dir)
|
||||
{
|
||||
closedir(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
u8 *ReadFile2Buffer (char *path, size_t *filesize, int *err)
|
||||
{
|
||||
u8 *buff = NULL;
|
||||
int size;
|
||||
int bytes;
|
||||
int block = 65536;
|
||||
FILE* f = NULL;
|
||||
|
||||
if (filesize) *filesize = 0;
|
||||
if (err) *err = 0;
|
||||
|
||||
f = fopen(path, "rb");
|
||||
if (!f)
|
||||
{
|
||||
if (err != NULL) *err = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Get file size
|
||||
fseek( f, 0, SEEK_END);
|
||||
size = ftell(f);
|
||||
if (filesize) *filesize = size;
|
||||
|
||||
if (size <= 0)
|
||||
{
|
||||
if (err != NULL) *err = -2;
|
||||
fclose (f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Return to beginning....
|
||||
fseek( f, 0, SEEK_SET);
|
||||
|
||||
//buff = malloc (size);
|
||||
buff = memalign(32,size);
|
||||
|
||||
if (buff == NULL)
|
||||
{
|
||||
if (err != NULL) *err = -3;
|
||||
fclose (f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bytes = 0;
|
||||
do
|
||||
{
|
||||
bytes += fread(&buff[bytes], 1, block, f );
|
||||
}
|
||||
while (bytes < size);
|
||||
|
||||
fclose (f);
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
/*
|
||||
this function will check if a folder "may" contain a valid nand
|
||||
*/
|
||||
bool IsNandFolder (char *path)
|
||||
{
|
||||
char npath[300];
|
||||
|
||||
sprintf (npath, "%s/TITLE", path);
|
||||
if (!DirExist(npath)) return false;
|
||||
|
||||
sprintf (npath, "%s/TICKET", path);
|
||||
if (!DirExist(npath)) return false;
|
||||
|
||||
sprintf (npath, "%s/SHARED1", path);
|
||||
if (!DirExist(npath)) return false;
|
||||
|
||||
sprintf (npath, "%s/SYS", path);
|
||||
if (!DirExist(npath)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
s32 adjust_nandpath (void)
|
||||
{
|
||||
char nandpath[128];
|
||||
FILE *fp = NULL;
|
||||
s32 check_npbin = false;
|
||||
|
||||
// let's keep things simple:
|
||||
// 1. check if we point to a valid nandpath
|
||||
// 2. if this is the case, create a nandpath.bin with it's contents.
|
||||
// 3. delete the nandcfg.bin.
|
||||
// 4. if not 2, check for a valid nandpath in nandpath.bin
|
||||
// 5. if there is one, everything ok, delete nandcfg.bin
|
||||
// 6. if this all fails, maybe there is a nandcfg.bin or a nand in root.
|
||||
// 7. I don't feel like analysing that for the moment.
|
||||
strcpy(nandpath,n2oSettings.nanddisc);
|
||||
strcat(nandpath,n2oSettings.nandfolder);
|
||||
if (IsNandFolder(nandpath))
|
||||
{
|
||||
strcpy(nandpath,n2oSettings.nanddisc);
|
||||
strcat(nandpath,"/sneek/nandcfg.bin");
|
||||
if (FileExist(nandpath))
|
||||
{
|
||||
remove(nandpath);
|
||||
}
|
||||
//don't erase nandpath.bin if xml contents incorrect
|
||||
//nandpath.bin should have priority above root folder nand
|
||||
//isn't backwards compatibility fun?
|
||||
if(n2oSettings.neeknandpath[0] != 0)
|
||||
{
|
||||
strcpy(nandpath,n2oSettings.nanddisc);
|
||||
strcat(nandpath,"/sneek/nandpath.bin");
|
||||
if (FileExist(nandpath))
|
||||
{
|
||||
remove(nandpath);
|
||||
}
|
||||
fp = fopen(nandpath, "wb");
|
||||
if(fp)
|
||||
{
|
||||
int write = strlen(n2oSettings.nandfolder)+1;
|
||||
fwrite(n2oSettings.nandfolder, 1, write, fp);
|
||||
fclose (fp);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//unable to create nandpath.bin, how is that possible
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
check_npbin = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
check_npbin = true;
|
||||
}
|
||||
// path in bootneek.xml incorrect or non existent
|
||||
// so we check path in nandpath.bin
|
||||
if(check_npbin == true)
|
||||
{
|
||||
strcpy(nandpath,n2oSettings.nanddisc);
|
||||
if (get_nand_folder(nandpath))
|
||||
{
|
||||
//so, if we have a valid path in nandpath.bin,
|
||||
//use that for channel launch adjustment
|
||||
strcpy(n2oSettings.nandfolder,nandpath);
|
||||
//we have a nandpath.bin
|
||||
//so delete nandcfg.bin
|
||||
strcpy(nandpath,n2oSettings.nanddisc);
|
||||
strcat(nandpath,"/sneek/nandcfg.bin");
|
||||
if (FileExist(nandpath))
|
||||
{
|
||||
remove(nandpath);
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
//we could check for the path in nandcfg.bin.
|
||||
//or maybe check for a root nand
|
||||
return -2;
|
||||
}
|
||||
//will keep compiler happy
|
||||
//should never arrive here
|
||||
return -4;
|
||||
}
|
||||
|
||||
void create_dipath(void)
|
||||
{
|
||||
|
||||
char dipath[64];
|
||||
FILE *fp = NULL;
|
||||
|
||||
strcpy(dipath,n2oSettings.nanddisc);
|
||||
strcat(dipath,"/sneek/dipath.bin");
|
||||
if (FileExist(dipath))
|
||||
{
|
||||
remove(dipath);
|
||||
}
|
||||
fp = fopen(dipath, "wb");
|
||||
if(fp)
|
||||
{
|
||||
int write = strlen(n2oSettings.neekdipath)+1;
|
||||
fwrite(n2oSettings.neekdipath, 1, write, fp);
|
||||
fclose (fp);
|
||||
}
|
||||
}
|
||||
|
||||
s32 set_neek_channel(void)
|
||||
{
|
||||
char launchfile[128];
|
||||
char stitlexsb[32];
|
||||
char titlefolder[128];
|
||||
u64 title;
|
||||
int titlemsb, titlelsb;
|
||||
FILE *fp = NULL;
|
||||
|
||||
//strcpy(launchfile,n2oSettings.neeknandpath);
|
||||
strcpy(launchfile,n2oSettings.nanddisc);
|
||||
strcat(launchfile,n2oSettings.nandfolder);
|
||||
strcat(launchfile,"/sys/launch.sys");
|
||||
if(n2oSettings.neekbootchannel[0] == 0)
|
||||
{
|
||||
//seems like we don't need to boot a specific channel...
|
||||
if (FileExist(launchfile))
|
||||
{
|
||||
remove(launchfile);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//I think we should check if the channel exists
|
||||
//If it doesn't, remove a potential launchfile
|
||||
//And give a warning message
|
||||
//strcpy(titlefolder,n2oSettings.neeknandpath);
|
||||
strcpy(titlefolder,n2oSettings.nanddisc);
|
||||
strcat(titlefolder,n2oSettings.nandfolder);
|
||||
strcat(titlefolder,"/title/");
|
||||
strncpy(stitlexsb,n2oSettings.neekbootchannel,8);
|
||||
stitlexsb[8] = '/';
|
||||
strncpy(stitlexsb+9,n2oSettings.neekbootchannel+8,8);
|
||||
stitlexsb[17]= 0;
|
||||
strcat(titlefolder,stitlexsb);
|
||||
gprintf("Titlefolder = %s\n",titlefolder);
|
||||
if (DirExist(titlefolder))
|
||||
{
|
||||
//calculate the channel for storage in launch.sys
|
||||
strncpy(stitlexsb,n2oSettings.neekbootchannel,8);
|
||||
stitlexsb[8]=0;
|
||||
sscanf(stitlexsb,"%x",&titlemsb);
|
||||
strncpy(stitlexsb,n2oSettings.neekbootchannel+8,8);
|
||||
stitlexsb[8]=0;
|
||||
sscanf(stitlexsb,"%x",&titlelsb);
|
||||
title = (u64)(titlemsb) << 32;
|
||||
title = title + (u64)(titlelsb);
|
||||
gprintf( "titleid = %08x %08x\r\n", (u32)((title)>>32), (u32)(title) );
|
||||
fp = fopen(launchfile, "wb");
|
||||
if(fp)
|
||||
{
|
||||
fwrite((void*)(&title), 1, 8, fp);
|
||||
fclose (fp);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//unable to create /sys/launch.sys, how is that possible
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//the boot channel title folder doesn't exist
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void xml_set_default(void)
|
||||
{
|
||||
|
||||
n2oSettings.neeknandpath[0] = 0;
|
||||
strcpy(n2oSettings.nanddisc,"sd1:/");
|
||||
strcpy(n2oSettings.nandfolder,"/");
|
||||
n2oSettings.neekbootchannel[0]= 0;
|
||||
n2oSettings.neekdipath[0]= 0;
|
||||
|
||||
|
||||
// strcpy(n2oSettings.neeknandpath,"usb://nands/nand1");
|
||||
// strcpy(n2oSettings.nanddisc,"usb:/");
|
||||
// strcpy(n2oSettings.nandfolder,"/nands/nand1");
|
||||
|
||||
//strcpy(n2oSettings.neekdipath,"/sneek");
|
||||
strcpy(n2oSettings.nandbootdelay,"0");
|
||||
strcpy(n2oSettings.neekbootdelay,"0");
|
||||
strcpy(n2oSettings.nandbootapplication,"usb://apps/postloader/boot.dol");
|
||||
strcpy(n2oSettings.neekbootapplication,"usb://apps/postloader/boot.dol");
|
||||
strcpy(n2oSettings.nandbootdescription,"postloader");
|
||||
strcpy(n2oSettings.neekbootdescription,"postloader");
|
||||
strcpy(n2oSettings.nandbootargument,"priibooter");
|
||||
strcpy(n2oSettings.neekbootargument,"priibooter");
|
||||
//strcpy(n2oSettings.neekbootchannel,"00000000000000010000000000000002");
|
||||
strcpy(n2oSettings.neekselection,"0");
|
||||
}
|
||||
|
||||
|
||||
s32 get_nand_folder(char* nandpath)
|
||||
{
|
||||
char nandpathfile[128];
|
||||
char buffer[128];
|
||||
FILE *fp = NULL;
|
||||
u32 counter;
|
||||
|
||||
strcpy(nandpathfile, nandpath);
|
||||
strcat(nandpathfile,"/sneek/nandpath.bin");
|
||||
nandpath[0] = 0;
|
||||
fp = fopen(nandpathfile, "rb");
|
||||
if(fp)
|
||||
{
|
||||
fseek (fp, 0, SEEK_END);
|
||||
int len = ftell(fp);
|
||||
fseek (fp, 0, SEEK_SET);
|
||||
if (len > 80)
|
||||
len = 80;
|
||||
if (len > 0)
|
||||
{
|
||||
fread(buffer, 1, len, fp);
|
||||
fclose (fp);
|
||||
for (counter=0;counter<len;counter++)
|
||||
{
|
||||
if ((buffer[counter] == 13)||(buffer[counter] == 10)||(buffer[counter] == 32))
|
||||
{
|
||||
buffer[counter] = 0;
|
||||
}
|
||||
}
|
||||
if (buffer[0] != '/')
|
||||
{
|
||||
strcat(nandpath,"/");
|
||||
}
|
||||
strcat(nandpath,buffer);
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose (fp);
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
}
|
221
main/source/Neek/xml/xml.c
Normal file
221
main/source/Neek/xml/xml.c
Normal file
@ -0,0 +1,221 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gccore.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
/*Include these for mxml*/
|
||||
#include <fat.h>
|
||||
#include <mxml.h>
|
||||
#include "../common.h"
|
||||
|
||||
/*
|
||||
struct SSettingsNeek2o {
|
||||
char type[8];
|
||||
char dipath[64];
|
||||
char nandbootdelay[4];
|
||||
char neekbootdelay[4]
|
||||
char nandbootapplication[64];
|
||||
char neekbootapplication[64];
|
||||
char neekbootchannel[16];
|
||||
char neekselection[2];
|
||||
};
|
||||
*/
|
||||
|
||||
extern struct SSettingsNeek2o n2oSettings;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateXmlFile(const char* filename, struct SSettingsNeek2o *Settings)
|
||||
{
|
||||
mxml_node_t *xml;
|
||||
mxml_node_t *data;
|
||||
|
||||
xml = mxmlNewXML("1.0");
|
||||
|
||||
data = mxmlNewElement(xml, "neek2oconfig");
|
||||
|
||||
//Create config value
|
||||
//mxmlElementSetAttr(data, "type",Settings->type);
|
||||
mxmlElementSetAttr(data, "neeknandpath",Settings->neeknandpath);
|
||||
mxmlElementSetAttr(data, "neekdipath",Settings->neekdipath);
|
||||
mxmlElementSetAttr(data, "nandbootdelay",Settings->nandbootdelay);
|
||||
mxmlElementSetAttr(data, "neekbootdelay",Settings->neekbootdelay);
|
||||
|
||||
mxmlElementSetAttr(data, "nandbootapplication",Settings->nandbootapplication);
|
||||
mxmlElementSetAttr(data, "neekbootapplication",Settings->neekbootapplication);
|
||||
|
||||
mxmlElementSetAttr(data, "neekbootchannel",Settings->neekbootchannel);
|
||||
mxmlElementSetAttr(data, "neekselection",Settings->neekselection);
|
||||
|
||||
mxmlElementSetAttr(data, "nandbootdescription",Settings->nandbootdescription);
|
||||
mxmlElementSetAttr(data, "neekbootdescription",Settings->neekbootdescription);
|
||||
|
||||
mxmlElementSetAttr(data, "nandbootargument",Settings->nandbootargument);
|
||||
mxmlElementSetAttr(data, "neekbootargument",Settings->neekbootargument);
|
||||
|
||||
|
||||
/*save the xml file to a file*/
|
||||
FILE *fp;
|
||||
fp = fopen(filename, "w");
|
||||
|
||||
mxmlSaveFile(xml, fp, MXML_NO_CALLBACK);
|
||||
|
||||
/*clean up*/
|
||||
fclose(fp);
|
||||
mxmlDelete(data);
|
||||
mxmlDelete(xml);
|
||||
}
|
||||
|
||||
int LoadXmlFile(const char* filename, struct SSettingsNeek2o *Settings)
|
||||
{
|
||||
FILE *fp;
|
||||
mxml_node_t *tree;
|
||||
mxml_node_t *data;
|
||||
u32 counter, count2;
|
||||
u32 slashfound;
|
||||
char temppath[64];
|
||||
//u32 last,teller;
|
||||
/*Load our xml file! */
|
||||
fp = fopen(filename, "r");
|
||||
|
||||
if (fp==NULL)
|
||||
{
|
||||
//WindowPrompt(filename, "Fehler", "Back",0);
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
|
||||
fclose(fp);
|
||||
|
||||
/*Load and printf our values! */
|
||||
/* As a note, its a good idea to normally check if node* is NULL */
|
||||
data = mxmlFindElement(tree, tree, "neek2oconfig", NULL, NULL, MXML_DESCEND);
|
||||
|
||||
//snprintf(Settings->type,8,"%s",mxmlElementGetAttr(data,"type"));
|
||||
snprintf(Settings->neeknandpath,64,"%s",mxmlElementGetAttr(data,"neeknandpath"));
|
||||
snprintf(Settings->neekdipath,64,"%s",mxmlElementGetAttr(data,"neekdipath"));
|
||||
snprintf(Settings->nandbootdelay,4,"%s",mxmlElementGetAttr(data,"nandbootdelay"));
|
||||
snprintf(Settings->neekbootdelay,4,"%s",mxmlElementGetAttr(data,"neekbootdelay"));
|
||||
snprintf(Settings->nandbootapplication,64,"%s",mxmlElementGetAttr(data,"nandbootapplication"));
|
||||
snprintf(Settings->neekbootapplication,64,"%s",mxmlElementGetAttr(data,"neekbootapplication"));
|
||||
snprintf(Settings->neekbootchannel,24,"%s",mxmlElementGetAttr(data,"neekbootchannel"));
|
||||
snprintf(Settings->neekselection,2,"%s",mxmlElementGetAttr(data,"neekselection"));
|
||||
snprintf(Settings->nandbootdescription,80,"%s",mxmlElementGetAttr(data,"nandbootdescription"));
|
||||
snprintf(Settings->neekbootdescription,80,"%s",mxmlElementGetAttr(data,"neekbootdescription"));
|
||||
snprintf(Settings->nandbootargument,80,"%s",mxmlElementGetAttr(data,"nandbootargument"));
|
||||
snprintf(Settings->neekbootargument,80,"%s",mxmlElementGetAttr(data,"neekbootargument"));
|
||||
|
||||
//strcpy(Settings->SMB_PWD,mxmlElementGetAttr(data,"password"));
|
||||
//snprintf(Settings->SMB_PWD,64,"%s",mxmlElementGetAttr(data,"password"));
|
||||
//strcpy(Settings->SMB_SHARE,mxmlElementGetAttr(data,"smbsharename"));
|
||||
//snprintf(Settings->SMB_SHARE,64,"%s",mxmlElementGetAttr(data,"smbsharename"));
|
||||
//strcpy(Settings->SMB_IP,(char*)mxmlElementGetAttr(data,"smbip"));
|
||||
//snprintf(Settings->SMB_IP,20,"%s",mxmlElementGetAttr(data,"smbip"));
|
||||
|
||||
mxmlDelete(data);
|
||||
mxmlDelete(tree);
|
||||
|
||||
//we should convert neeknandpath in nanddisk and nandfolder
|
||||
if (Settings->neeknandpath[0] != 0)
|
||||
{
|
||||
strncpy(temppath,Settings->neeknandpath,3);
|
||||
temppath[3]=0;
|
||||
for (counter=0;counter<3;counter++)
|
||||
{
|
||||
temppath[counter] = toupper((int)(temppath[counter]));
|
||||
}
|
||||
if (strncmp(temppath,"USB",3)==0)
|
||||
{
|
||||
strcpy(Settings->nanddisc,"usb1:/");
|
||||
count2 = 3;
|
||||
slashfound = 0;
|
||||
while((count2 < strlen(Settings->neeknandpath))&&(slashfound ==0))
|
||||
{
|
||||
if (Settings->neeknandpath[count2] == '/')
|
||||
{
|
||||
slashfound = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
count2++;
|
||||
}
|
||||
|
||||
}
|
||||
if (slashfound != 0)
|
||||
{
|
||||
if (Settings->neeknandpath[count2+1]=='/')
|
||||
{
|
||||
count2++;
|
||||
}
|
||||
strcpy(Settings->nandfolder,Settings->neeknandpath+count2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//default to root
|
||||
strcpy(Settings->nandfolder,"/");
|
||||
}
|
||||
}
|
||||
else if (strncmp(temppath,"SD",2)==0)
|
||||
{
|
||||
strcpy(Settings->nanddisc,"sd1:/");
|
||||
count2 = 2;
|
||||
slashfound = 0;
|
||||
while((count2 < strlen(Settings->neeknandpath))&&(slashfound == 0))
|
||||
{
|
||||
if (Settings->neeknandpath[count2] == '/')
|
||||
{
|
||||
slashfound = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
count2++;
|
||||
}
|
||||
|
||||
}
|
||||
if (slashfound != 0)
|
||||
{
|
||||
if (Settings->neeknandpath[count2+1]=='/')
|
||||
{
|
||||
count2++;
|
||||
}
|
||||
strcpy(Settings->nandfolder,Settings->neeknandpath+count2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//default to root
|
||||
strcpy(Settings->nandfolder,"/");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//default to root of usb
|
||||
//not sure this is needed
|
||||
strcpy(Settings->nanddisc,"usb1:/");
|
||||
strcpy(Settings->nandfolder,"/");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//obcd
|
||||
//Somehow, the first dot from the ip adress is changed into a ,
|
||||
//This dirty hack ensures that only dots are present in the ip adress
|
||||
/*
|
||||
last = strlen(SMBSettings.SMB_IP);
|
||||
for (teller = 0;teller < last;teller++)
|
||||
{
|
||||
if (SMBSettings.SMB_IP[teller] == ',')
|
||||
{
|
||||
SMBSettings.SMB_IP[teller] = '.';
|
||||
}
|
||||
}
|
||||
*/
|
||||
return 1;
|
||||
}
|
120
main/source/Neek/xml/xml.epp
Normal file
120
main/source/Neek/xml/xml.epp
Normal file
@ -0,0 +1,120 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gccore.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
/*Include these for mxml*/
|
||||
#include <fat.h>
|
||||
#include <mxml.h>
|
||||
#include "../common.h"
|
||||
|
||||
/*
|
||||
struct SSettingsNeek2o {
|
||||
char type[8];
|
||||
char dipath[64];
|
||||
char nandbootdelay[4];
|
||||
char neekbootdelay[4]
|
||||
char nandbootapplication[64];
|
||||
char neekbootapplication[64];
|
||||
char neekbootchannel[16];
|
||||
char neekselection[2];
|
||||
};
|
||||
*/
|
||||
|
||||
extern struct SSettingsNeek2o n2oSettings;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateXmlFile(const char* filename, struct SSettingsNeek2o *Settings)
|
||||
{
|
||||
mxml_node_t *xml;
|
||||
mxml_node_t *data;
|
||||
|
||||
xml = mxmlNewXML("1.0");
|
||||
|
||||
data = mxmlNewElement(xml, "neek2oconfig");
|
||||
|
||||
//Create config value
|
||||
mxmlElementSetAttr(data, "type",Settings->type);
|
||||
mxmlElementSetAttr(data, "neeknandpath",Settings->neeknandpath);
|
||||
mxmlElementSetAttr(data, "neekdipath",Settings->neekdipath);
|
||||
mxmlElementSetAttr(data, "nandbootdelay",Settings->nandbootdelay);
|
||||
mxmlElementSetAttr(data, "neekbootdelay",Settings->neekbootdelay);
|
||||
|
||||
mxmlElementSetAttr(data, "nandbootapplication",Settings->nandbootapplication);
|
||||
mxmlElementSetAttr(data, "neekbootapplication",Settings->neekbootapplication);
|
||||
|
||||
mxmlElementSetAttr(data, "neekbootchannel",Settings->neekbootchannel);
|
||||
mxmlElementSetAttr(data, "neekselection",Settings->neekselection);
|
||||
|
||||
/*save the xml file to a file*/
|
||||
FILE *fp;
|
||||
fp = fopen(filename, "w");
|
||||
|
||||
mxmlSaveFile(xml, fp, MXML_NO_CALLBACK);
|
||||
|
||||
/*clean up*/
|
||||
fclose(fp);
|
||||
mxmlDelete(data);
|
||||
mxmlDelete(xml);
|
||||
}
|
||||
|
||||
int LoadXmlFile(const char* filename, struct SSettingsNeek2o *Settings)
|
||||
{
|
||||
FILE *fp;
|
||||
mxml_node_t *tree;
|
||||
mxml_node_t *data;
|
||||
//u32 last,teller;
|
||||
/*Load our xml file! */
|
||||
fp = fopen(filename, "r");
|
||||
|
||||
if (fp==NULL)
|
||||
{
|
||||
//WindowPrompt(filename, "Fehler", "Back",0);
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
|
||||
fclose(fp);
|
||||
|
||||
/*Load and printf our values! */
|
||||
/* As a note, its a good idea to normally check if node* is NULL */
|
||||
data = mxmlFindElement(tree, tree, "neek2oconfig", NULL, NULL, MXML_DESCEND);
|
||||
|
||||
snprintf(Settings->type,8,"%s",mxmlElementGetAttr(data,"type"));
|
||||
snprintf(Settings->neeknandpath,64,"%s",mxmlElementGetAttr(data,"neeknandpath"));
|
||||
snprintf(Settings->neekdipath,64,"%s",mxmlElementGetAttr(data,"neekdipath"));
|
||||
snprintf(Settings->nandbootdelay,4,"%s",mxmlElementGetAttr(data,"nandbootdelay"));
|
||||
snprintf(Settings->neekbootdelay,4,"%s",mxmlElementGetAttr(data,"neekbootdelay"));
|
||||
snprintf(Settings->nandbootapplication,64,"%s",mxmlElementGetAttr(data,"nandbootapplication"));
|
||||
snprintf(Settings->neekbootapplication,64,"%s",mxmlElementGetAttr(data,"neekbootapplication"));
|
||||
snprintf(Settings->neekbootchannel,16,"%s",mxmlElementGetAttr(data,"neekbootchannel"));
|
||||
snprintf(Settings->neekselection,2,"%s",mxmlElementGetAttr(data,"neekselection"));
|
||||
|
||||
//strcpy(Settings->SMB_PWD,mxmlElementGetAttr(data,"password"));
|
||||
//snprintf(Settings->SMB_PWD,64,"%s",mxmlElementGetAttr(data,"password"));
|
||||
//strcpy(Settings->SMB_SHARE,mxmlElementGetAttr(data,"smbsharename"));
|
||||
//snprintf(Settings->SMB_SHARE,64,"%s",mxmlElementGetAttr(data,"smbsharename"));
|
||||
//strcpy(Settings->SMB_IP,(char*)mxmlElementGetAttr(data,"smbip"));
|
||||
//snprintf(Settings->SMB_IP,20,"%s",mxmlElementGetAttr(data,"smbip"));
|
||||
|
||||
mxmlDelete(data);
|
||||
mxmlDelete(tree);
|
||||
|
||||
//obcd
|
||||
//Somehow, the first dot from the ip adress is changed into a ,
|
||||
//This dirty hack ensures that only dots are present in the ip adress
|
||||
/*
|
||||
last = strlen(SMBSettings.SMB_IP);
|
||||
for (teller = 0;teller < last;teller++)
|
||||
{
|
||||
if (SMBSettings.SMB_IP[teller] == ',')
|
||||
{
|
||||
SMBSettings.SMB_IP[teller] = '.';
|
||||
}
|
||||
}
|
||||
*/
|
||||
return 1;
|
||||
}
|
7
main/source/Neek/xml/xml.h
Normal file
7
main/source/Neek/xml/xml.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef _XML_H_
|
||||
#define _XML_H_
|
||||
|
||||
int LoadXmlFile(const char* filename, struct SSettingsSMB *Settings);
|
||||
void CreateXmlFile(const char* filename, struct SSettingsSMB *Settings);
|
||||
|
||||
#endif
|
@ -6,6 +6,8 @@
|
||||
#include "menu.h"
|
||||
#include "Tools/SelectIos.h"
|
||||
|
||||
extern bool runaway;
|
||||
|
||||
/*** Extern variables ***/
|
||||
extern GuiWindow * mainWindow;
|
||||
|
||||
@ -138,6 +140,10 @@ endPrompt()
|
||||
|
||||
if(back.GetState() == STATE_CLICKED || back2.GetState() == STATE_CLICKED)
|
||||
stop = true;
|
||||
if(runaway == true)
|
||||
{
|
||||
stop = true;
|
||||
}
|
||||
}
|
||||
|
||||
HaltGui();
|
||||
|
@ -46,12 +46,13 @@ infoPrompt()
|
||||
i++;
|
||||
y += 50;
|
||||
|
||||
Entrie[i] = new GuiText(tr("Developer:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
|
||||
Entrie[i] = new GuiText(tr("Developers:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
|
||||
Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
Entrie[i]->SetPosition(x, y);
|
||||
i++;
|
||||
|
||||
Entrie[i] = new GuiText("hamachi-mp / Christopher Roy Bratusek / obcd", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
|
||||
// Entrie[i] = new GuiText("hamachi-mp / Christopher Roy Bratusek / obcd", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
|
||||
Entrie[i] = new GuiText("hamachi-mp Nano Obcd", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
|
||||
Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
Entrie[i]->SetPosition(x+200, y);
|
||||
i++;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "Tools/SelectIos.h"
|
||||
#include "Neek/boot_neek2o.h"
|
||||
// #include "Neek/bootneek.h"
|
||||
#include "Neek/uneek_fs.h"
|
||||
|
||||
/*** Extern variables ***/
|
||||
@ -62,7 +62,7 @@ loaderPrompt()
|
||||
GuiImageData btn_over(Theme.button_focus);
|
||||
GuiImage nandemuImgOver(&btn_over);
|
||||
GuiImage neek2oImgOver(&btn_over);
|
||||
GuiImage realnandImgOver(&btn);
|
||||
GuiImage realnandImgOver(&btn_over);
|
||||
GuiImage priiloaderImgOver(&btn_over);
|
||||
GuiImage backImgOver(&btn_over);
|
||||
|
||||
@ -120,7 +120,11 @@ loaderPrompt()
|
||||
|
||||
if(!check_uneek_fs())
|
||||
{
|
||||
neek2o.SetPosition(0, 90);
|
||||
promptWindow.Append(&neek2o);
|
||||
|
||||
priiloader.SetPosition(0, 140);
|
||||
/*
|
||||
if(get_nandemu() && check_neek2o())
|
||||
{
|
||||
nandemu.SetPosition(0, 90);
|
||||
@ -145,6 +149,7 @@ loaderPrompt()
|
||||
|
||||
priiloader.SetPosition(0, 140);
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -31,6 +31,7 @@ void add(string device, string apps_path)
|
||||
char pathname[200];
|
||||
char pathmeta[200];
|
||||
string pathboot;
|
||||
int rel_ios = 0;
|
||||
|
||||
pdir=opendir((device + ":/" + apps_path).c_str());
|
||||
|
||||
@ -70,8 +71,34 @@ void add(string device, string apps_path)
|
||||
|
||||
arg = parser(quelltext, "<arguments>", "</arguments>");
|
||||
|
||||
force_reload = parser(quelltext, "<force_ios_reload", ">");
|
||||
//we have 3 ways in meta.xml to tell a launcher to keep ahbprot disabled
|
||||
//hbc always reloads the ios, so we will as well
|
||||
//unless we are in neek mode (it's just a waste of time there)
|
||||
|
||||
force_reload = parser(quelltext, "<force_ios_reload", ">");
|
||||
if (force_reload[0] != 0)
|
||||
{
|
||||
rel_ios = 1;
|
||||
force_reload[0] = 0;
|
||||
}
|
||||
force_reload = parser(quelltext, "<ahb_access", ">");
|
||||
if (force_reload[0] != 0)
|
||||
{
|
||||
rel_ios = 1;
|
||||
force_reload[0] = 0;
|
||||
}
|
||||
force_reload = parser(quelltext, "<no_ios_reload", ">");
|
||||
if (force_reload[0] != 0)
|
||||
{
|
||||
rel_ios = 1;
|
||||
}
|
||||
if (rel_ios == 1)
|
||||
{
|
||||
force_reload[0] = '/';
|
||||
force_reload[1] = 0;
|
||||
}
|
||||
|
||||
|
||||
size_t amount_read;
|
||||
FILE *fp = fopen(iconpath.c_str(),"r"); //open the png file
|
||||
if(fp) //make sure the file exists
|
||||
|
@ -51,7 +51,7 @@ s32 Patch_ahbprot(void)
|
||||
// patch HID4 write in HBC stub - this should be done when the extra HID4 bits are turned on
|
||||
*(u32*)0x80002174 = 0x60000000;
|
||||
|
||||
if (read32(CHECK_AHB) != -1)
|
||||
if (read32(CHECK_AHB) != 0xffffffff)
|
||||
{
|
||||
gprintf("AHBPROT doesn't seem to be disabled.\n");
|
||||
return false;
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "gecko.h"
|
||||
#include "Network/wiiload_gecko.h"
|
||||
#include "Neek/uneek_fs.h"
|
||||
#include "Neek/boot_neek2o.h"
|
||||
#include "Neek/bootneek.h"
|
||||
|
||||
#define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0)
|
||||
|
||||
@ -66,6 +66,7 @@ bool goneek2o = false;
|
||||
bool gorealnand = false;
|
||||
bool runaway = false;
|
||||
bool gecko_connected;
|
||||
bool in_neek;
|
||||
|
||||
// kopiere ios für app in einen vector
|
||||
void addAppIos(string foldername, int ios)
|
||||
@ -111,9 +112,12 @@ static void WiiResetPressed()
|
||||
|
||||
static void WiiPowerPressed()
|
||||
{
|
||||
gprintf("Power button pressed \n");
|
||||
runaway = true;
|
||||
PowerOff = SYS_POWEROFF_STANDBY;
|
||||
if(runaway == false)
|
||||
{
|
||||
gprintf("Power button pressed \n");
|
||||
runaway = true;
|
||||
PowerOff = SYS_POWEROFF_STANDBY;
|
||||
}
|
||||
}
|
||||
|
||||
static void WiimotePowerPressed(s32 chan)
|
||||
@ -171,7 +175,7 @@ main(int argc, char *argv[])
|
||||
SetupPads(); // Initialize input
|
||||
InitGUIThreads(); // Initialize GUI
|
||||
|
||||
init_uneek_fs(ISFS_OPEN_READ|ISFS_OPEN_WRITE);
|
||||
in_neek = init_uneek_fs(ISFS_OPEN_READ|ISFS_OPEN_WRITE);
|
||||
|
||||
MountAllDevices();
|
||||
InitNetworkThread(); // Initialize Network
|
||||
@ -214,15 +218,17 @@ main(int argc, char *argv[])
|
||||
ResumeGui();
|
||||
stretch(Settings.top, Settings.bottom, Settings.left, Settings.right);
|
||||
|
||||
if(HAVE_AHBPROT)
|
||||
if(!check_uneek_fs())
|
||||
{
|
||||
runtimePatchApply();
|
||||
if(HAVE_AHBPROT)
|
||||
{
|
||||
runtimePatchApply();
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("Warning: no AHBPROT\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("ERROR no AHBPROT\n");
|
||||
}
|
||||
|
||||
DI2_Init(); // Init DVD
|
||||
|
||||
if(strstr(Options.language, tr("STANDARD")))
|
||||
@ -246,7 +252,7 @@ main(int argc, char *argv[])
|
||||
else if(boot_buffer)
|
||||
if(wiiload)
|
||||
{
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
BootHomebrew();
|
||||
}
|
||||
|
||||
@ -254,12 +260,12 @@ main(int argc, char *argv[])
|
||||
{
|
||||
if(!check_uneek_fs())
|
||||
{
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
IOS_ReloadIOS(254);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
//we can't launch bootmii from within neek2o I assume
|
||||
//so we should do something else
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
@ -271,13 +277,13 @@ main(int argc, char *argv[])
|
||||
if (opendir(check_path("sd1:/apps/NANDEmu-Boot").c_str()) != NULL)
|
||||
{
|
||||
LoadHomebrew ("sd1:/apps/NANDEmu-Boot/boot.dol");
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
BootHomebrew ();
|
||||
}
|
||||
else if (opendir(check_path("usb1:/apps/NANDEmu-Boot").c_str()) != NULL)
|
||||
{
|
||||
LoadHomebrew ("usb1:/apps/NANDEmu-Boot/boot.dol");
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
BootHomebrew ();
|
||||
}
|
||||
}
|
||||
@ -286,19 +292,20 @@ main(int argc, char *argv[])
|
||||
{
|
||||
*(vu32*)0x8132FFFB = 0x4461636f;
|
||||
DCFlushRange((void*)0x8132FFFB, 4);
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
if(goneek2o)
|
||||
{
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
boot_neek2o();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
if(gorealnand)
|
||||
{
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
SYS_ResetSystem(SYS_RESTART, 0, 0);
|
||||
}
|
||||
|
||||
@ -306,11 +313,11 @@ main(int argc, char *argv[])
|
||||
{
|
||||
*(vu32*)0x8132FFFB = 0x50756E65;
|
||||
DCFlushRange((void*)0x8132FFFB, 4);
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
else if(PowerOff != -1)
|
||||
ExitApp();
|
||||
//ExitApp();
|
||||
SYS_ResetSystem(PowerOff, 0, 0);
|
||||
|
||||
return 0;
|
||||
|
@ -39,6 +39,7 @@ GuiWindow * mainWindow = NULL;
|
||||
GuiImageData * pointer = NULL;
|
||||
GuiImage * bgImg = NULL;
|
||||
extern bool boothomebrew;
|
||||
extern bool goneek2o;
|
||||
|
||||
static lwp_t guithread = LWP_THREAD_NULL;
|
||||
static bool guiHalt = true;
|
||||
@ -143,8 +144,8 @@ UpdateGUI (void *arg)
|
||||
if(IOS_GetVersion() != GetAppIOS(startingAppName))
|
||||
addAppIos(Settings.startingAppName, SelectedIOS());
|
||||
}
|
||||
|
||||
ExitApp();
|
||||
if (!goneek2o)
|
||||
ExitApp();
|
||||
}
|
||||
|
||||
// sd check
|
||||
|
Loading…
Reference in New Issue
Block a user