-removed alot of unneeded cIOS checks, saving the info about our

currently loaded cIOS instead
-fixed bug of missing remount if no games are found with enabled
NAND emulation which made wiiflow hang
-added information for neek2o
-removed ios reload on boot when wiiflow is in neek2o mode
-made NAND file extraction MEM2 only
-fixed two not free'd memory allocations which could fill the
memory with unused stuff
This commit is contained in:
fix94.1 2012-08-11 12:27:38 +00:00
parent 5cd988fe23
commit 2b32db857a
21 changed files with 185 additions and 173 deletions

View File

@ -24,7 +24,6 @@ if [ $GENERATE -eq 1 ];
then then
cat <<EOF > $FILENAME cat <<EOF > $FILENAME
#include "alt_ios.h"
int mainIOS = $VERSION; int mainIOS = $VERSION;
EOF EOF
fi fi

View File

@ -34,7 +34,7 @@
#include "ext2.h" #include "ext2.h"
#include "sdhc.h" #include "sdhc.h"
#include "usbstorage.h" #include "usbstorage.h"
#include "loader/cios.h" #include "loader/nk.h"
#include "loader/utils.h" #include "loader/utils.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"

View File

@ -4,6 +4,7 @@
#include "alt_ios.h" #include "alt_ios.h"
#include "cios.h" #include "cios.h"
#include "disc.h" #include "disc.h"
#include "nk.h"
#include "sys.h" #include "sys.h"
#include "wbfs.h" #include "wbfs.h"
#include "wdvd.h" #include "wdvd.h"
@ -81,7 +82,16 @@ void load_dip_249()
bool loadIOS(int ios, bool launch_game, bool emu_channel) bool loadIOS(int ios, bool launch_game, bool emu_channel)
{ {
#ifndef DOLPHIN #ifndef DOLPHIN
gprintf("Reloading into IOS %i from %i (AHBPROT: %u)...\n", ios, IOS_GetVersion(), HAVE_AHBPROT); if(neek2o())
{
memset(&CurrentIOS, 0, sizeof(IOS_Info));
CurrentIOS.Version = 254;
CurrentIOS.Type = IOS_TYPE_D2X;
CurrentIOS.Base = 254;
CurrentIOS.Revision = 999;
DCFlushRange(&CurrentIOS, sizeof(IOS_Info));
return true;
}
Close_Inputs(); Close_Inputs();
DeviceHandler::Instance()->UnMountAll(); DeviceHandler::Instance()->UnMountAll();
@ -89,21 +99,17 @@ bool loadIOS(int ios, bool launch_game, bool emu_channel)
USBStorage2_Deinit(); USBStorage2_Deinit();
mload_close(); mload_close();
gprintf("Reloading into IOS %i from %i (AHBPROT: %u)...\n", ios, IOS_GetVersion(), HAVE_AHBPROT);
ISFS_Deinitialize(); ISFS_Deinitialize();
bool iosOK = IOS_ReloadIOS(ios) == 0; bool iosOK = IOS_ReloadIOS(ios) == 0;
ISFS_Initialize(); ISFS_Initialize();
gprintf("%s, Current IOS: %i\n", iosOK ? "OK" : "FAILED!", IOS_GetVersion()); IOS_GetCurrentIOSInfo();
if(is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion())) if(CurrentIOS.Type == IOS_TYPE_HERMES)
{
load_ehc_module_ex(); load_ehc_module_ex();
gprintf("Hermes cIOS Base IOS%i\n", get_ios_base()); else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
}
else if(is_ios_type(IOS_TYPE_WANIN, IOS_GetVersion()) && IOS_GetRevision() >= 18)
{
load_dip_249(); load_dip_249();
gprintf("Waninkoko cIOS Base IOS%i\n", get_ios_base());
}
if(!emu_channel) if(!emu_channel)
{ {
if(launch_game) if(launch_game)
@ -121,15 +127,3 @@ bool loadIOS(int ios, bool launch_game, bool emu_channel)
return true; return true;
#endif #endif
} }
u32 get_ios_base()
{
u32 revision = IOS_GetRevision();
if (is_ios_type(IOS_TYPE_WANIN, IOS_GetVersion()) && revision >= 17)
return wanin_mload_get_IOS_base();
else if (is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion()) && revision >= 4)
return mload_get_IOS_base();
return 0;
}

View File

@ -8,9 +8,6 @@ extern "C" {
#endif #endif
bool loadIOS(int ios, bool launch_game, bool emu_channel); bool loadIOS(int ios, bool launch_game, bool emu_channel);
u32 get_ios_base();
extern int mainIOS;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -108,7 +108,7 @@ void maindolpatches(void *dst, int len, u8 vidMode, GXRModeObj *vmode, bool vipa
PrinceOfPersiaPatch(); PrinceOfPersiaPatch();
NewSuperMarioBrosPatch(); NewSuperMarioBrosPatch();
// Patch NoDiscInDrive only for IOS 249 < rev13 or IOS 222/223/224 // Patch NoDiscInDrive only for IOS 249 < rev13 or IOS 222/223/224
if((is_ios_type(IOS_TYPE_WANIN, IOS_GetVersion()) && IOS_GetRevision() < 13) || (is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion()))) if((CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision < 13) || CurrentIOS.Type == IOS_TYPE_HERMES)
patch_NoDiscinDrive(dst, len); patch_NoDiscinDrive(dst, len);
patchVideoModes(dst, len, vidMode, vmode, patchVidModes); patchVideoModes(dst, len, vidMode, vmode, patchVidModes);
if(hooktype != 0 && dogamehooks(dst, len, false)) if(hooktype != 0 && dogamehooks(dst, len, false))
@ -117,7 +117,7 @@ void maindolpatches(void *dst, int len, u8 vidMode, GXRModeObj *vmode, bool vipa
vidolpatcher(dst, len); vidolpatcher(dst, len);
if(configbytes[0] != 0xCD) if(configbytes[0] != 0xCD)
langpatcher(dst, len); langpatcher(dst, len);
if(is_ios_type(IOS_TYPE_WANIN, IOS_GetVersion()) && IOS_GetRevision() < 13) if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision < 13)
Anti_002_fix(dst, len); Anti_002_fix(dst, len);
if(countryString) if(countryString)
PatchCountryStrings(dst, len); // Country Patch by WiiPower PatchCountryStrings(dst, len); // Country Patch by WiiPower

View File

@ -3,6 +3,7 @@
* by Dimok * by Dimok
* Modifications by xFede * Modifications by xFede
* Wiiflowized and heavily improved by Miigotu * Wiiflowized and heavily improved by Miigotu
* 2012 Converted, corrected and extended by FIX94
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any * warranty. In no event will the authors be held liable for any
@ -24,60 +25,19 @@
* distribution. * distribution.
***************************************************************************/ ***************************************************************************/
#include <gctypes.h> #include <gctypes.h>
#include <malloc.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "cios.h" #include "cios.h"
#include "alt_ios.h"
#include "utils.h" #include "utils.h"
#include "fs.h" #include "fs.h"
#include "nk.h"
#include "mload.h" #include "mload.h"
#include "gecko/gecko.h" #include "gecko/gecko.h"
#include "memory/mem2.hpp" #include "memory/mem2.hpp"
static bool checked = false; IOS_Info CurrentIOS;
static bool neek = false;
extern u32 get_ios_base();
bool neek2o(void)
{
if(!checked)
{
u32 num = 0;
neek = !(ISFS_ReadDir("/sneek", NULL, &num));
gprintf("WiiFlow is in %s mode\n", neek ? "neek2o" : "real nand");
checked = true;
}
return neek;
}
/* Check if the cIOS is a D2X. */
bool D2X(u8 ios, u8 *base)
{
if(neek2o())
{
*base = (u8)IOS_GetVersion();
return true;
}
iosinfo_t *info = GetInfo(ios);
if(!info)
return false;
if(info->magicword != 0x1ee7c105 /* Magic Word */
|| info->magicversion != 1 /* Magic Version */
|| info->version < 6 /* Version */
|| strncasecmp(info->name, "d2x", 3) != 0) /* Name */
{
free(info);
return false;
}
*base = (u8)info->baseios;
free(info);
return true;
}
signed_blob *GetTMD(u8 ios, u32 *TMD_Length) signed_blob *GetTMD(u8 ios, u32 *TMD_Length)
{ {
if(ES_GetStoredTMDSize(TITLE_ID(1, ios), TMD_Length) < 0) if(ES_GetStoredTMDSize(TITLE_ID(1, ios), TMD_Length) < 0)
@ -88,7 +48,7 @@ signed_blob *GetTMD(u8 ios, u32 *TMD_Length)
return NULL; return NULL;
if(ES_GetStoredTMD(TITLE_ID(1, ios), TMD, *TMD_Length) < 0) if(ES_GetStoredTMD(TITLE_ID(1, ios), TMD, *TMD_Length) < 0)
{ {
free(TMD); MEM2_free(TMD);
return NULL; return NULL;
} }
return TMD; return TMD;
@ -99,17 +59,15 @@ signed_blob *GetTMD(u8 ios, u32 *TMD_Length)
* @return pointer to iosinfo_t on success else NULL. The user is responsible for freeing the buffer. * @return pointer to iosinfo_t on success else NULL. The user is responsible for freeing the buffer.
*/ */
iosinfo_t *GetInfo(u8 ios) iosinfo_t *IOS_GetInfo(u8 ios)
{ {
u32 TMD_Length; u32 TMD_Length;
signed_blob *TMD = GetTMD(ios, &TMD_Length); signed_blob *TMD = GetTMD(ios, &TMD_Length);
if(TMD == NULL) if(TMD == NULL)
return NULL; return NULL;
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7)); sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7));
MEM2_free(TMD);
free(TMD);
u32 size = 0; u32 size = 0;
u8 *buffer = ISFS_GetFile((u8 *)filepath, &size, sizeof(iosinfo_t)); u8 *buffer = ISFS_GetFile((u8 *)filepath, &size, sizeof(iosinfo_t));
@ -125,9 +83,9 @@ u32 Title_GetSize_FromTMD(tmd *tmd_data)
u32 cnt, size = 0; u32 cnt, size = 0;
/* Calculate title size */ /* Calculate title size */
for (cnt = 0; cnt < tmd_data->num_contents; cnt++) { for(cnt = 0; cnt < tmd_data->num_contents; cnt++)
{
tmd_content *content = &tmd_data->contents[cnt]; tmd_content *content = &tmd_data->contents[cnt];
/* Add content size */ /* Add content size */
size += content->size; size += content->size;
} }
@ -135,7 +93,34 @@ u32 Title_GetSize_FromTMD(tmd *tmd_data)
return size; return size;
} }
int get_ios_type(u8 slot) /* Check if the cIOS is a D2X. */
bool IOS_D2X(u8 ios, u8 *base)
{
if(neek2o())
{
*base = (u8)IOS_GetVersion();
return true;
}
iosinfo_t *info = IOS_GetInfo(ios);
if(!info)
return false;
if(info->magicword != 0x1ee7c105 /* Magic Word */
|| info->magicversion != 1 /* Magic Version */
|| info->version < 6 /* Version */
|| strncasecmp(info->name, "d2x", 3) != 0) /* Name */
{
MEM2_free(info);
return false;
}
*base = (u8)info->baseios;
MEM2_free(info);
return true;
}
u8 IOS_GetType(u8 slot)
{ {
u32 TMD_Length; u32 TMD_Length;
signed_blob *TMD_Buffer = GetTMD(slot, &TMD_Length); signed_blob *TMD_Buffer = GetTMD(slot, &TMD_Length);
@ -145,18 +130,13 @@ int get_ios_type(u8 slot)
tmd *iosTMD = (tmd*)SIGNATURE_PAYLOAD(TMD_Buffer); tmd *iosTMD = (tmd*)SIGNATURE_PAYLOAD(TMD_Buffer);
if(Title_GetSize_FromTMD(iosTMD) < 0x100000 || iosTMD->title_version == 65280) if(Title_GetSize_FromTMD(iosTMD) < 0x100000 || iosTMD->title_version == 65280)
{ {
free(TMD_Buffer); MEM2_free(TMD_Buffer);
return IOS_TYPE_NO_CIOS; return IOS_TYPE_NO_CIOS;
} }
u32 title_rev = iosTMD->title_version; u32 title_rev = iosTMD->title_version;
free(TMD_Buffer); MEM2_free(TMD_Buffer);
iosTMD = NULL; iosTMD = NULL;
iosinfo_t *info = GetInfo(slot);
if(info == NULL)
return IOS_TYPE_NO_CIOS;
free(info);
u8 base = 0; u8 base = 0;
switch(slot) switch(slot)
{ {
@ -175,35 +155,61 @@ int get_ios_type(u8 slot)
case 249: case 249:
case 250: case 250:
case 251: case 251:
if(D2X(slot, &base)) if(IOS_D2X(slot, &base))
return IOS_TYPE_D2X; return IOS_TYPE_D2X;
else else
return IOS_TYPE_WANIN; return IOS_TYPE_WANIN;
default: default:
if(D2X(slot, &base)) if(IOS_D2X(slot, &base))
return IOS_TYPE_D2X; return IOS_TYPE_D2X;
else else
return IOS_TYPE_NO_CIOS; return IOS_TYPE_NO_CIOS;
} }
} }
int is_ios_type(int type, u8 slot) void IOS_GetCurrentIOSInfo()
{ {
return (get_ios_type(slot) == type); memset(&CurrentIOS, 0, sizeof(IOS_Info));
CurrentIOS.Revision = IOS_GetRevision();
CurrentIOS.Version = IOS_GetVersion();
CurrentIOS.Type = IOS_GetType(CurrentIOS.Version);
if(CurrentIOS.Type == IOS_TYPE_D2X)
{
iosinfo_t *iosInfo = IOS_GetInfo(CurrentIOS.Version);
CurrentIOS.Revision = iosInfo->version;
CurrentIOS.Base = iosInfo->baseios;
gprintf("D2X cIOS Base IOS%i\n", CurrentIOS.Base);
MEM2_free(iosInfo);
}
else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
{
CurrentIOS.Base = wanin_mload_get_IOS_base();
gprintf("Waninkoko cIOS Base IOS%i\n", CurrentIOS.Base);
}
else if(CurrentIOS.Type == IOS_TYPE_HERMES && CurrentIOS.Revision >= 4)
{
CurrentIOS.Base = mload_get_IOS_base();
gprintf("Hermes cIOS Base IOS%i\n", CurrentIOS.Base);
}
else
CurrentIOS.Base = CurrentIOS.Version;
DCFlushRange(&CurrentIOS, sizeof(IOS_Info));
} }
bool shadow_mload() bool Hermes_shadow_mload()
{ {
if(!is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion()))
return false;
int v51 = (5 << 4) & 1; int v51 = (5 << 4) & 1;
if(mload_get_version() >= v51) if(mload_get_version() >= v51)
{ {
// shadow /dev/mload supported in hermes cios v5.1 IOS_Open("/dev/mload/OFF",0); // shadow /dev/mload supported in hermes cios v5.1
//IOS_Open("/dev/usb123/OFF",0);// this disables ehc completely
IOS_Open("/dev/mload/OFF",0);
gprintf("Shadow mload\n"); gprintf("Shadow mload\n");
return true; return true;
} }
return false; return false;
} }
void Hermes_Disable_EHC()
{
IOS_Open("/dev/usb123/OFF", 0);// this disables ehc completely
gprintf("Hermes EHC Disabled\n");
}

View File

@ -1,3 +1,4 @@
#ifndef _CIOSINFO_H_ #ifndef _CIOSINFO_H_
#define _CIOSINFO_H_ #define _CIOSINFO_H_
@ -8,23 +9,30 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
typedef struct _iosinfo_t typedef struct _iosinfo_t {
{
u32 magicword; //0x1ee7c105 u32 magicword; //0x1ee7c105
u32 magicversion; // 1 u32 magicversion; // 1
u32 version; // Example: 5 u32 version; // Example: 5
u32 baseios; // Example: 56 u32 baseios; // Example: 56
char name[0x10]; // Example: d2x char name[0x10]; // Example: d2x
char versionstring[0x10]; // Example: beta2 char versionstring[0x10]; // Example: beta2
} __attribute__((packed)) iosinfo_t; } iosinfo_t;
bool neek2o(void); typedef struct _IOS_Info {
bool D2X(u8 ios, u8 *base); u32 Revision;
iosinfo_t *GetInfo(u8 ios); u8 Version;
signed_blob *GetTMD(u8 ios, u32 *TMD_Length); u8 Type;
int is_ios_type(int type, u8 slot); u8 Base;
int get_ios_type(u8 slot); } IOS_Info;
bool shadow_mload();
extern IOS_Info CurrentIOS;
void IOS_GetCurrentIOSInfo();
bool IOS_D2X(u8 ios, u8 *base);
u8 IOS_GetType(u8 slot);
bool Hermes_shadow_mload();
void Hermes_Disable_EHC();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -59,7 +59,7 @@ void __Disc_SetLowMem()
*(vu32*)0xCD00643C = 0x00000000; // 32Mhz on Bus *(vu32*)0xCD00643C = 0x00000000; // 32Mhz on Bus
/* Fix for Sam & Max (WiiPower) */ /* Fix for Sam & Max (WiiPower) */
if (!is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion())) if(CurrentIOS.Type != IOS_TYPE_HERMES)
*GameID_Address = 0x80000000; *GameID_Address = 0x80000000;
/* Copy disc ID */ /* Copy disc ID */
@ -309,7 +309,7 @@ s32 Disc_SetUSB(const u8 *id, bool frag)
if(frag) if(frag)
return set_frag_list(); return set_frag_list();
s32 part = -1; s32 part = -1;
if(is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion())) if(CurrentIOS.Type == IOS_TYPE_HERMES)
part = wbfs_part_idx ? wbfs_part_idx - 1 : 0; part = wbfs_part_idx ? wbfs_part_idx - 1 : 0;
return WDVD_SetUSBMode(wbfsDev, (u8*)id, part); return WDVD_SetUSBMode(wbfsDev, (u8*)id, part);
} }

View File

@ -1,9 +1,14 @@
#include <ogcsys.h> #include <ogcsys.h>
#include <locale.h> #include <locale.h>
#include <ogc/isfs.h> #include <ogc/isfs.h>
#include <malloc.h> #include <string.h>
#include "utils.h"
#include "fs.h" #include "fs.h"
#include "utils.h"
#include "memory/mem2.hpp"
static fstats stats ATTRIBUTE_ALIGN(32);
u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length) u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
{ {
@ -11,24 +16,23 @@ u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
s32 fd = ISFS_Open((const char *)path, ISFS_OPEN_READ); s32 fd = ISFS_Open((const char *)path, ISFS_OPEN_READ);
u8 *buf = NULL; u8 *buf = NULL;
static fstats stats ATTRIBUTE_ALIGN(32);
if(fd >= 0) if(fd >= 0)
{ {
memset(&stats, 0, sizeof(fstats));
if(ISFS_GetFileStats(fd, &stats) >= 0) if(ISFS_GetFileStats(fd, &stats) >= 0)
{ {
if(length <= 0) if(length <= 0)
length = stats.file_length; length = stats.file_length;
if(length > 0) if(length > 0)
buf = (u8 *)memalign(32, ALIGN32(length)); buf = (u8 *)MEM2_memalign(32, ALIGN32(length));
if(buf) if(buf)
{ {
*size = stats.file_length; *size = stats.file_length;
if(ISFS_Read(fd, (char*)buf, length) != length) if(ISFS_Read(fd, (char*)buf, length) != length)
{ {
*size = 0; *size = 0;
free(buf); MEM2_free(buf);
} }
} }
} }

View File

@ -29,9 +29,24 @@
#include <malloc.h> #include <malloc.h>
#include "nk.h" #include "nk.h"
#include "cios.h"
#include "armboot.h" #include "armboot.h"
#include "memory/mem2.hpp" #include "memory/mem2.hpp"
#include "gecko/gecko.h"
bool checked = false;
bool neek = false;
bool neek2o(void)
{
if(!checked)
{
u32 num = 0;
neek = !(ISFS_ReadDir("/sneek", NULL, &num));
gprintf("WiiFlow is in %s mode\n", neek ? "neek2o" : "real nand");
checked = true;
}
return neek;
}
s32 Launch_nk(u64 TitleID, const char *nandpath) s32 Launch_nk(u64 TitleID, const char *nandpath)
{ {

View File

@ -25,6 +25,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
s32 Launch_nk(u64 TitleID, const char *nandpath); s32 Launch_nk(u64 TitleID, const char *nandpath);
bool neek2o(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -24,6 +24,7 @@ CMenu *mainMenu;
extern "C" extern "C"
{ {
extern void __exception_setreload(int t); extern void __exception_setreload(int t);
extern int mainIOS;
void ShowError(const wstringEx &error) { mainMenu->error(error); } void ShowError(const wstringEx &error) { mainMenu->error(error); }
void HideWaitMessage() { mainMenu->_hideWaitMessage(); } void HideWaitMessage() { mainMenu->_hideWaitMessage(); }
@ -69,13 +70,7 @@ int main(int argc, char **argv)
// Load Custom IOS // Load Custom IOS
gprintf("Loading cIOS: %d\n", mainIOS); gprintf("Loading cIOS: %d\n", mainIOS);
bool iosOK = loadIOS(mainIOS, false, false); bool iosOK = loadIOS(mainIOS, false, false);
iosOK = iosOK && CurrentIOS.Type != IOS_TYPE_NO_CIOS;
u8 mainIOSBase = 0;
D2X(mainIOS, &mainIOSBase);
if(!mainIOSBase)
mainIOSBase = get_ios_base();
iosOK = iosOK && mainIOSBase > 0;
gprintf("Loaded cIOS: %u has base %u\n", mainIOS, mainIOSBase);
#else #else
bool iosOK = true; bool iosOK = true;
#endif #endif

View File

@ -19,6 +19,7 @@
#include "loader/alt_ios.h" #include "loader/alt_ios.h"
#include "loader/cios.h" #include "loader/cios.h"
#include "loader/fs.h" #include "loader/fs.h"
#include "loader/nk.h"
#include "loader/playlog.h" #include "loader/playlog.h"
#include "loader/sys.h" #include "loader/sys.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"
@ -280,10 +281,7 @@ void CMenu::init(void)
if(!neek2o()) if(!neek2o())
_load_installed_cioses(); _load_installed_cioses();
else else
{ _installed_cios[CurrentIOS.Version] = CurrentIOS.Version;
extern int mainIOS;
_installed_cios[mainIOS] = mainIOS;
}
snprintf(m_app_update_drive, sizeof(m_app_update_drive), "%s:/", drive); snprintf(m_app_update_drive, sizeof(m_app_update_drive), "%s:/", drive);
m_dataDir = sfmt("%s:/%s", drive, APPDATA_DIR); m_dataDir = sfmt("%s:/%s", drive, APPDATA_DIR);
@ -2307,12 +2305,12 @@ void CMenu::_load_installed_cioses()
for(u8 slot = 200; slot < 254; slot++) for(u8 slot = 200; slot < 254; slot++)
{ {
u8 base = 1; u8 base = 1;
if(D2X(slot, &base)) if(IOS_D2X(slot, &base))
{ {
gprintf("Found d2x base %u in slot %u\n", base, slot); gprintf("Found d2x base %u in slot %u\n", base, slot);
_installed_cios[slot] = base; _installed_cios[slot] = base;
} }
else if(!is_ios_type(IOS_TYPE_NO_CIOS, slot)) else if(IOS_GetType(slot) != IOS_TYPE_NO_CIOS)
{ {
gprintf("Found cIOS in slot %u\n", slot); gprintf("Found cIOS in slot %u\n", slot);
_installed_cios[slot] = slot; _installed_cios[slot] = slot;

View File

@ -158,11 +158,5 @@ void CMenu::_textAbout(void)
false false
); );
Nand::Instance()->Disable_Emu(); m_btnMgr.setText(m_aboutLblIOS, wfmt(_fmt("ios", L"IOS%i base %i v%i"), CurrentIOS.Version, CurrentIOS.Base, CurrentIOS.Revision), true);
iosinfo_t * iosInfo = GetInfo(mainIOS);
if(iosInfo != NULL)
{
m_btnMgr.setText(m_aboutLblIOS, wfmt(_fmt("ios", L"IOS%i base %i v%i"), mainIOS, iosInfo->baseios, iosInfo->version), true);
free(iosInfo);
}
} }

View File

@ -1,8 +1,7 @@
#include "menu.hpp" #include "menu.hpp"
#include "channel/nand.hpp" #include "channel/nand.hpp"
#include "loader/alt_ios.h" #include "loader/nk.h"
#include "loader/cios.h"
#include "loader/sys.h" #include "loader/sys.h"
const int CMenu::_nbCfgPages = 6; const int CMenu::_nbCfgPages = 6;

View File

@ -5,6 +5,7 @@
#include "channel/nand.hpp" #include "channel/nand.hpp"
#include "gecko/gecko.h" #include "gecko/gecko.h"
#include "loader/cios.h" #include "loader/cios.h"
#include "loader/nk.h"
#include "loader/sys.h" #include "loader/sys.h"
static const int g_curPage = 4; static const int g_curPage = 4;

View File

@ -56,7 +56,6 @@ extern const u8 gc_ogg[];
extern const u32 gc_ogg_size; extern const u32 gc_ogg_size;
extern u32 boot2version; extern u32 boot2version;
extern int mainIOS;
static u64 sm_title_id[8] ATTRIBUTE_ALIGN(32); static u64 sm_title_id[8] ATTRIBUTE_ALIGN(32);
bool m_zoom_banner = false; bool m_zoom_banner = false;
@ -934,7 +933,7 @@ int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id, bool emu_channel)
} }
} }
else if(gameIOS != 57) else if(gameIOS != 57)
gameIOS = mainIOS; gameIOS = CurrentIOS.Version;
gprintf("Changed requested IOS to %d.\n", gameIOS); gprintf("Changed requested IOS to %d.\n", gameIOS);
// remap IOS to CIOS // remap IOS to CIOS
@ -970,7 +969,7 @@ int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id, bool emu_channel)
return LOAD_IOS_FAILED; return LOAD_IOS_FAILED;
} }
if(gameIOS != mainIOS) if(gameIOS != CurrentIOS.Version)
{ {
gprintf("Reloading IOS into %d\n", gameIOS); gprintf("Reloading IOS into %d\n", gameIOS);
if(!loadIOS(gameIOS, true, false)) if(!loadIOS(gameIOS, true, false))
@ -1064,7 +1063,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
} }
while(1); while(1);
} }
else
cleanup(); cleanup();
if(!forwarder) if(!forwarder)
@ -1083,7 +1082,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
if(_loadIOS(gameIOS, userIOS, id, !emu_disabled) == LOAD_IOS_FAILED) if(_loadIOS(gameIOS, userIOS, id, !emu_disabled) == LOAD_IOS_FAILED)
return; return;
} }
if(rtrn != NULL && strlen(rtrn) == 4) if(CurrentIOS.Type == IOS_TYPE_D2X && rtrn != NULL && strlen(rtrn) == 4)
{ {
int rtrnID = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3]; int rtrnID = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3];
@ -1344,8 +1343,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
#else #else
bool iosLoaded = true; bool iosLoaded = true;
#endif #endif
u8 base; if(CurrentIOS.Type == IOS_TYPE_D2X)
if(D2X(IOS_GetVersion(), &base))
{ {
if(!m_directLaunch && returnTo) if(!m_directLaunch && returnTo)
{ {
@ -1358,7 +1356,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
IOS_Close(ESHandle); IOS_Close(ESHandle);
returnTo = 0; returnTo = 0;
} }
IOSReloadBlock(IOS_GetVersion(), true); IOSReloadBlock(CurrentIOS.Version, true);
} }
if(emulate_mode && !neek2o()) if(emulate_mode && !neek2o())
{ {
@ -1411,15 +1409,23 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
#ifndef DOLPHIN #ifndef DOLPHIN
USBStorage2_Deinit(); USBStorage2_Deinit();
USB_Deinitialize(); USB_Deinitialize();
shadow_mload(); if(CurrentIOS.Type == IOS_TYPE_HERMES)
{
if(dvd)
Hermes_Disable_EHC();
else
Hermes_shadow_mload();
}
#endif #endif
/* Last check if the Disc ID is correct */ /* Last check if the Disc ID is correct */
char discid[32] ATTRIBUTE_ALIGN(32); void *ReadBuffer = MEM2_memalign(32, 32);
memset(discid, 0, sizeof(discid)); WDVD_UnencryptedRead(ReadBuffer, 32, 0);
WDVD_UnencryptedRead(discid, 32, 0); string ReadedID((char*)ReadBuffer, 6);
gprintf("WDVD_UnencryptedRead ID: %s (expected: %s)\n", discid, id.c_str()); MEM2_free(ReadBuffer);
if(strncasecmp(id.c_str(), discid, 6) != 0)
gprintf("WDVD_UnencryptedRead ID: %s (expected: %s)\n", ReadedID.c_str(), id.c_str());
if(strncasecmp(id.c_str(), ReadedID.c_str(), 6) != 0)
return; return;
DisableMEM1allocR(); DisableMEM1allocR();

View File

@ -2,7 +2,6 @@
#include "menu.hpp" #include "menu.hpp"
#include "gui/GameTDB.hpp" #include "gui/GameTDB.hpp"
#include "loader/alt_ios.h"
#include "loader/sys.h" #include "loader/sys.h"
extern const u8 wifi1_png[]; extern const u8 wifi1_png[];

View File

@ -10,6 +10,7 @@
#include "loader/alt_ios.h" #include "loader/alt_ios.h"
#include "loader/cios.h" #include "loader/cios.h"
#include "loader/disc.h" #include "loader/disc.h"
#include "loader/nk.h"
#include "loader/sys.h" #include "loader/sys.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"
#include "loader/wdvd.h" #include "loader/wdvd.h"
@ -153,6 +154,7 @@ void CMenu::_showMain(void)
if(!m_cfg.getBool("NAND", "disable", true)) if(!m_cfg.getBool("NAND", "disable", true))
{ {
Nand::Instance()->Disable_Emu(); Nand::Instance()->Disable_Emu();
DeviceHandler::Instance()->MountAll();
_hideMain(); _hideMain();
if(!_AutoCreateNand()) if(!_AutoCreateNand())
m_cfg.setBool("NAND", "disable", true); m_cfg.setBool("NAND", "disable", true);
@ -633,10 +635,8 @@ int CMenu::main(void)
{ {
_showWaitMessage(); _showWaitMessage();
_hideMain(); _hideMain();
Nand::Instance()->Disable_Emu();
bool isD2XnewerThanV6 = false; bool isD2XnewerThanV6 = false;
iosinfo_t * iosInfo = GetInfo(mainIOS); if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X)
if (iosInfo->version > 6)
isD2XnewerThanV6 = true; isD2XnewerThanV6 = true;
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0)) if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0))
Nand::Instance()->Enable_Emu(); Nand::Instance()->Enable_Emu();

View File

@ -4,8 +4,8 @@
#include "lockMutex.hpp" #include "lockMutex.hpp"
#include "channel/nand.hpp" #include "channel/nand.hpp"
#include "fileOps/fileOps.h" #include "fileOps/fileOps.h"
#include "loader/alt_ios.h"
#include "loader/cios.h" #include "loader/cios.h"
#include "loader/nk.h"
#include "loader/sys.h" #include "loader/sys.h"
// NandEmulation menu // NandEmulation menu
@ -201,9 +201,7 @@ void CMenu::_enableNandEmu(bool fromconfig)
if(!disable) if(!disable)
{ {
bool isD2XnewerThanV6 = false; bool isD2XnewerThanV6 = false;
Nand::Instance()->Disable_Emu(); if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X)
iosinfo_t * iosInfo = GetInfo(mainIOS);
if(iosInfo->version > 6 || neek2o())
isD2XnewerThanV6 = true; isD2XnewerThanV6 = true;
if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true) && !neek2o() && !m_tempView) if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true) && !neek2o() && !m_tempView)
Nand::Instance()->Enable_Emu(); Nand::Instance()->Enable_Emu();

View File

@ -6,8 +6,6 @@
#include "loader/sys.h" #include "loader/sys.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"
extern int mainIOS;
int version_num = 0, num_versions = 0, i; int version_num = 0, num_versions = 0, i;
int CMenu::_version[9] = {0, atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV)}; int CMenu::_version[9] = {0, atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV)};