mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
-BETA wiiflow saves ios settings on the NAND from now on, so
loading up wiiflow is much faster if you use force cIOS load, you can actually delete, move, copy or whatever the save directly from the system menu like a normal game save (may more things will be done in the future this way)
This commit is contained in:
parent
903d3fba50
commit
45441ded06
@ -44,7 +44,8 @@ SOURCES := source \
|
||||
DATA := data \
|
||||
data/images \
|
||||
data/help \
|
||||
data/sounds
|
||||
data/sounds \
|
||||
data/save
|
||||
INCLUDES := source
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
BIN
data/save.bin
Normal file
BIN
data/save.bin
Normal file
Binary file not shown.
187
source/channel/nand_save.cpp
Normal file
187
source/channel/nand_save.cpp
Normal file
@ -0,0 +1,187 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <malloc.h>
|
||||
#include "nand_save.hpp"
|
||||
#include "nand.hpp"
|
||||
#include "identify.h"
|
||||
#include "gecko/gecko.hpp"
|
||||
#include "loader/fs.h"
|
||||
#include "loader/sys.h"
|
||||
#include "unzip/lz77.h"
|
||||
#include "unzip/U8Archive.h"
|
||||
|
||||
extern const u8 save_bin[];
|
||||
extern const u32 save_bin_size;
|
||||
|
||||
NandSave InternalSave;
|
||||
|
||||
#define BANNER_PATH "/title/00010000/57465346/data/banner.bin"
|
||||
#define IOS_SAVE_PATH "/title/00010000/57465346/data/ios"
|
||||
|
||||
NandSave::NandSave()
|
||||
{
|
||||
ret = 0;
|
||||
fd = 0;
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
bool NandSave::CheckSave()
|
||||
{
|
||||
/* 10 million variables */
|
||||
u32 u8_bin_size = 0;
|
||||
u8 *u8_bin = NULL;
|
||||
u32 certSize = 0;
|
||||
signed_blob *certBuffer = NULL;
|
||||
u32 tmd_bin_size = 0;
|
||||
const signed_blob *tmd_bin = NULL;
|
||||
u32 tik_bin_size = 0;
|
||||
const signed_blob *tik_bin = NULL;
|
||||
u32 banner_bin_size = 0;
|
||||
const u8 *banner_bin = NULL;
|
||||
u32 entries = 0;
|
||||
/* May our banner already exist */
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
strcpy(ISFS_Path, BANNER_PATH);
|
||||
fd = ISFS_Open(ISFS_Path, ISFS_OPEN_READ);
|
||||
if(fd >= 0)
|
||||
{
|
||||
ISFS_Close(fd);
|
||||
gprintf("Found WiiFlow Save\n");
|
||||
goto done;
|
||||
}
|
||||
/* extract our archive */
|
||||
decompressLZ77content(save_bin+4, save_bin_size-4, &u8_bin, &u8_bin_size);
|
||||
if(u8_bin == NULL || u8_bin_size == 0)
|
||||
goto error;
|
||||
/* grab cert.sys */
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
strcpy(ISFS_Path, "/sys/cert.sys");
|
||||
certBuffer = (signed_blob*)ISFS_GetFile(ISFS_Path, &certSize, -1);
|
||||
if(certBuffer == NULL || certSize == 0)
|
||||
goto error;
|
||||
/* Install tik and tmd */
|
||||
Patch_Channel_Boot();
|
||||
tik_bin = (const signed_blob*)u8_get_file(u8_bin, "tik.bin", &tik_bin_size);
|
||||
if(tik_bin == NULL || tik_bin_size == 0)
|
||||
goto error;
|
||||
ret = ES_AddTicket(tik_bin, tik_bin_size, certBuffer, certSize, NULL, 0);
|
||||
if(ret < 0)
|
||||
goto error;
|
||||
tmd_bin = (const signed_blob*)u8_get_file(u8_bin, "tmd.bin", &tmd_bin_size);
|
||||
if(tmd_bin == NULL || tmd_bin_size == 0)
|
||||
goto error;
|
||||
ret = ES_AddTitleStart(tmd_bin, tmd_bin_size, certBuffer, certSize, NULL, 0);
|
||||
if(ret < 0)
|
||||
goto error;
|
||||
ret = ES_AddTitleFinish();
|
||||
if(ret < 0)
|
||||
goto error;
|
||||
/* WARNING dirty, delete tik again */
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
strcpy(ISFS_Path, "/ticket/00010000/57465346.tik");
|
||||
ret = ISFS_Delete(ISFS_Path);
|
||||
if(ret < 0)
|
||||
goto error;
|
||||
/* Delete the unused ticket folder */
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
strcpy(ISFS_Path, "/ticket/00010000");
|
||||
ret = ISFS_ReadDir(ISFS_Path, NULL, &entries);
|
||||
if(ret < 0)
|
||||
goto error;
|
||||
if(entries == 0)
|
||||
{
|
||||
ret = ISFS_Delete(ISFS_Path);
|
||||
if(ret < 0)
|
||||
goto error;
|
||||
}
|
||||
banner_bin = u8_get_file(u8_bin, "banner.bin", &banner_bin_size);
|
||||
if(banner_bin == NULL || banner_bin_size == 0)
|
||||
goto error;
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
strcpy(ISFS_Path, BANNER_PATH);
|
||||
/* Write our banner */
|
||||
ISFS_CreateFile(ISFS_Path, 0, 3, 3, 3);
|
||||
fd = ISFS_Open(ISFS_Path, ISFS_OPEN_WRITE);
|
||||
if(fd < 0)
|
||||
goto error;
|
||||
ret = ISFS_Write(fd, banner_bin, banner_bin_size);
|
||||
ISFS_Close(fd);
|
||||
if(ret < 0)
|
||||
{
|
||||
ISFS_Delete(ISFS_Path);
|
||||
goto error;
|
||||
}
|
||||
free(certBuffer);
|
||||
free(u8_bin);
|
||||
gprintf("Created WiiFlow Save\n");
|
||||
done:
|
||||
loaded = true;
|
||||
return loaded;
|
||||
|
||||
error:
|
||||
gprintf("Error while creating WiiFlow Save\n");
|
||||
loaded = false;
|
||||
ES_AddTitleCancel();
|
||||
if(certBuffer != NULL)
|
||||
free(certBuffer);
|
||||
certBuffer = NULL;
|
||||
if(u8_bin != NULL)
|
||||
free(u8_bin);
|
||||
u8_bin = NULL;
|
||||
tik_bin = NULL;
|
||||
tmd_bin = NULL;
|
||||
banner_bin = NULL;
|
||||
return loaded;
|
||||
}
|
||||
|
||||
void NandSave::LoadIOS()
|
||||
{
|
||||
if(loaded == false)
|
||||
return;
|
||||
u32 size = 0;
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
strcpy(ISFS_Path, IOS_SAVE_PATH);
|
||||
ios_settings_t *file = (ios_settings_t*)ISFS_GetFile(ISFS_Path, &size, -1);
|
||||
if(file == NULL)
|
||||
return;
|
||||
gprintf("Loading IOS Settings from NAND\n");
|
||||
if(size == sizeof(ios_settings_t))
|
||||
{
|
||||
if(file->cios > 0)
|
||||
mainIOS = file->cios;
|
||||
useMainIOS = file->use_cios;
|
||||
}
|
||||
free(file);
|
||||
}
|
||||
|
||||
void NandSave::SaveIOS(const ios_settings_t settings)
|
||||
{
|
||||
if(loaded == false)
|
||||
return;
|
||||
gprintf("Saving IOS Settings to NAND\n");
|
||||
memset(&ISFS_Path, 0, ISFS_MAXPATH);
|
||||
strcpy(ISFS_Path, IOS_SAVE_PATH);
|
||||
ISFS_CreateFile(ISFS_Path, 0, 3, 3, 3);
|
||||
fd = ISFS_Open(ISFS_Path, ISFS_OPEN_WRITE);
|
||||
if(fd < 0)
|
||||
return;
|
||||
ret = ISFS_Write(fd, &settings, sizeof(ios_settings_t));
|
||||
ISFS_Close(fd);
|
||||
if(ret < 0)
|
||||
ISFS_Delete(ISFS_Path);
|
||||
}
|
44
source/channel/nand_save.hpp
Normal file
44
source/channel/nand_save.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#ifndef _NAND_SAVE_HPP_
|
||||
#define _NAND_SAVE_HPP_
|
||||
|
||||
#include <ogcsys.h>
|
||||
|
||||
typedef struct _ios_settings_t
|
||||
{
|
||||
u8 cios;
|
||||
bool use_cios;
|
||||
} __attribute__((packed)) ios_settings_t;
|
||||
|
||||
class NandSave
|
||||
{
|
||||
public:
|
||||
NandSave();
|
||||
bool CheckSave();
|
||||
void LoadIOS();
|
||||
void SaveIOS(const ios_settings_t settings);
|
||||
private:
|
||||
s32 fd;
|
||||
s32 ret;
|
||||
bool loaded;
|
||||
char ISFS_Path[ISFS_MAXPATH];
|
||||
};
|
||||
|
||||
extern NandSave InternalSave;
|
||||
|
||||
#endif
|
@ -1,83 +0,0 @@
|
||||
|
||||
|
||||
/* Condition Register Bit Fields */
|
||||
|
||||
#define cr0 0
|
||||
#define cr1 1
|
||||
#define cr2 2
|
||||
#define cr3 3
|
||||
#define cr4 4
|
||||
#define cr5 5
|
||||
#define cr6 6
|
||||
#define cr7 7
|
||||
|
||||
|
||||
/* General Purpose Registers */
|
||||
|
||||
#define r0 0
|
||||
#define r1 1
|
||||
#define r2 2
|
||||
#define r3 3
|
||||
#define r4 4
|
||||
#define r5 5
|
||||
#define r6 6
|
||||
#define r7 7
|
||||
#define r8 8
|
||||
#define r9 9
|
||||
#define r10 10
|
||||
#define r11 11
|
||||
#define r12 12
|
||||
#define r13 13
|
||||
#define r14 14
|
||||
#define r15 15
|
||||
#define r16 16
|
||||
#define r17 17
|
||||
#define r18 18
|
||||
#define r19 19
|
||||
#define r20 20
|
||||
#define r21 21
|
||||
#define r22 22
|
||||
#define r23 23
|
||||
#define r24 24
|
||||
#define r25 25
|
||||
#define r26 26
|
||||
#define r27 27
|
||||
#define r28 28
|
||||
#define r29 29
|
||||
#define r30 30
|
||||
#define r31 31
|
||||
|
||||
/* Define Floating Point Registers */
|
||||
|
||||
#define f0 0
|
||||
#define f1 1
|
||||
#define f2 2
|
||||
#define f3 3
|
||||
#define f4 4
|
||||
#define f5 5
|
||||
#define f6 6
|
||||
#define f7 7
|
||||
#define f8 8
|
||||
#define f9 9
|
||||
#define f10 10
|
||||
#define f11 11
|
||||
#define f12 12
|
||||
#define f13 13
|
||||
#define f14 14
|
||||
#define f15 15
|
||||
#define f16 16
|
||||
#define f17 17
|
||||
#define f18 18
|
||||
#define f19 19
|
||||
#define f20 20
|
||||
#define f21 21
|
||||
#define f22 22
|
||||
#define f23 23
|
||||
#define f24 24
|
||||
#define f25 25
|
||||
#define f26 26
|
||||
#define f27 27
|
||||
#define f28 28
|
||||
#define f29 29
|
||||
#define f30 30
|
||||
#define f31 31
|
@ -5,6 +5,7 @@
|
||||
#include "const_str.hpp"
|
||||
#include "booter/external_booter.hpp"
|
||||
#include "channel/nand.hpp"
|
||||
#include "channel/nand_save.hpp"
|
||||
#include "devicemounter/DeviceHandler.hpp"
|
||||
#include "gecko/gecko.hpp"
|
||||
#include "gui/video.hpp"
|
||||
@ -64,13 +65,15 @@ int main(int argc, char **argv)
|
||||
}
|
||||
/* Init ISFS */
|
||||
NandHandle.Init_ISFS();
|
||||
if(InternalSave.CheckSave()) /* Maybe new IOS settings */
|
||||
InternalSave.LoadIOS();
|
||||
/* Handle (c)IOS Loading */
|
||||
if(neek2o() || Sys_DolphinMode()) /* wont reload anythin */
|
||||
iosOK = loadIOS(IOS_GetVersion(), false);
|
||||
else if(!CustomIOS(IOS_GetType(mainIOS))) /* safe reload */
|
||||
iosOK = NandHandle.LoadDefaultIOS();
|
||||
else /* cIOS found and on real nand, so just use it */
|
||||
else if(useMainIOS && CustomIOS(IOS_GetType(mainIOS))) /* Requested */
|
||||
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);
|
||||
else /* safe reload to the default IOS */
|
||||
iosOK = NandHandle.LoadDefaultIOS();
|
||||
|
||||
// Init
|
||||
Sys_Init();
|
||||
|
@ -1,7 +1,23 @@
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include "menu.hpp"
|
||||
#include "const_str.hpp"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "channel/nand_save.hpp"
|
||||
|
||||
s16 m_bootLblTitle;
|
||||
s16 m_bootLblLoadCIOS;
|
||||
@ -12,6 +28,8 @@ s16 m_bootLblCurCIOSrev;
|
||||
s16 m_bootLblCIOSrevM;
|
||||
s16 m_bootLblCIOSrevP;
|
||||
|
||||
ios_settings_t settings;
|
||||
|
||||
static void showBoot(void)
|
||||
{
|
||||
m_btnMgr.show(m_bootLblTitle);
|
||||
@ -40,6 +58,8 @@ void CMenu::_Boot(void)
|
||||
{
|
||||
SetupInput();
|
||||
_refreshBoot();
|
||||
bool prev_load = m_cfg.getBool("GENERAL", "force_cios_load", false);
|
||||
u8 prev_ios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
|
||||
|
||||
while(!m_exit)
|
||||
{
|
||||
@ -75,6 +95,15 @@ void CMenu::_Boot(void)
|
||||
_refreshBoot();
|
||||
}
|
||||
}
|
||||
bool cur_load = m_cfg.getBool("GENERAL", "force_cios_load", false);
|
||||
u8 cur_ios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
|
||||
if(prev_load != cur_load || prev_ios != cur_ios)
|
||||
{
|
||||
memset(&settings, 0, sizeof(ios_settings_t));
|
||||
settings.cios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
|
||||
settings.use_cios = m_cfg.getBool("GENERAL", "force_cios_load", false);
|
||||
InternalSave.SaveIOS(settings);
|
||||
}
|
||||
hideBoot(false);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ u32 packBytes(int a, int b, int c, int d)
|
||||
return (d << 24) | (c << 16) | (b << 8) | (a);
|
||||
}
|
||||
|
||||
s32 __decompressLZ77_11(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
||||
s32 __decompressLZ77_11(const u8 *in, const u32 inputLen, u8 **output, u32 *outputLen)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@ -117,10 +117,9 @@ s32 __decompressLZ77_11(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 __decompressLZ77_10(u8 *in, u8 **output, u32 *outputLen)
|
||||
s32 __decompressLZ77_10(const u8 *in, u8 **output, u32 *outputLen)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
u8 *out = NULL;
|
||||
|
||||
u32 compressedPos = 0;
|
||||
@ -185,15 +184,12 @@ s32 __decompressLZ77_10(u8 *in, u8 **output, u32 *outputLen)
|
||||
|
||||
int isLZ77compressed(u8 *buffer)
|
||||
{
|
||||
if ((buffer[0] == LZ77_0x10_FLAG) || (buffer[0] == LZ77_0x11_FLAG))
|
||||
{
|
||||
if((buffer[0] == LZ77_0x10_FLAG) || (buffer[0] == LZ77_0x11_FLAG))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int decompressLZ77content(u8 *buffer, u32 length, u8 **output, u32 *outputLen)
|
||||
int decompressLZ77content(const u8 *buffer, const u32 length, u8 **output, u32 *outputLen)
|
||||
{
|
||||
int ret;
|
||||
switch (buffer[0])
|
||||
|
@ -24,7 +24,7 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int isLZ77compressed(u8 *buffer);
|
||||
int decompressLZ77content(u8 *buffer, u32 length, u8 **output, u32 *outputLen);
|
||||
int decompressLZ77content(const u8 *buffer, const u32 length, u8 **output, u32 *outputLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user