mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
-recompiled libntfs with -O2 as it was before the update
-changed the IOS patching system, should be much more safe now
This commit is contained in:
parent
0c703207ea
commit
eb24ebf76f
Binary file not shown.
@ -78,7 +78,7 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat
|
||||
normalCFG.wip_list = get_wip_list();
|
||||
normalCFG.wip_count = get_wip_count();
|
||||
|
||||
ShutdownBeforeExit(BootType == TYPE_CHANNEL);
|
||||
ShutdownBeforeExit();
|
||||
/* Copy CFG into new memory region */
|
||||
memcpy(BooterConfig, &normalCFG, sizeof(the_CFG));
|
||||
DCFlushRange(BooterConfig, sizeof(the_CFG));
|
||||
@ -111,10 +111,10 @@ void ExternalBooter_ChannelSetup(u64 title, bool dol)
|
||||
normalCFG.use_dol = dol;
|
||||
}
|
||||
|
||||
void ShutdownBeforeExit(bool KeepPatches)
|
||||
void ShutdownBeforeExit(void)
|
||||
{
|
||||
DeviceHandle.UnMountAll();
|
||||
NandHandle.DeInit_ISFS(KeepPatches);
|
||||
NandHandle.DeInit_ISFS();
|
||||
WDVD_Close();
|
||||
Close_Inputs();
|
||||
/* Deinit network */
|
||||
|
@ -32,6 +32,6 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat
|
||||
int aspectRatio, u32 returnTo, u8 BootType, bool use_led);
|
||||
void ExternalBooter_ChannelSetup(u64 title, bool dol);
|
||||
void ExternalBooter_WiiGameSetup(bool wbfs, bool dvd, const char *ID);
|
||||
void ShutdownBeforeExit(bool KeepPatches = false);
|
||||
void ShutdownBeforeExit(void);
|
||||
|
||||
#endif
|
||||
|
@ -4,77 +4,60 @@
|
||||
#include <gccore.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include "gecko/gecko.hpp"
|
||||
#include "memory/memory.h"
|
||||
#include "identify.h"
|
||||
|
||||
static bool apply_patch(char *name, const u8 *old, u32 old_size, const u8 *patch, u32 patch_size, u32 patch_offset)
|
||||
static inline bool apply_patch(char *name, const u8 *old, const u8 *patch, u32 size)
|
||||
{
|
||||
u8 *ptr = (u8*)0x93400000;
|
||||
bool found = false;
|
||||
u8 *location = NULL;
|
||||
while((u32)ptr < (0x94000000 - patch_size))
|
||||
u8 i;
|
||||
u32 found = 0;
|
||||
u8 *ptr = (u8*)IOS_Patch_Start;
|
||||
|
||||
u32 level = IRQ_Disable();
|
||||
while((u32)ptr < (u32)IOS_Patch_End)
|
||||
{
|
||||
if(memcmp(ptr, old, old_size) == 0)
|
||||
if(memcmp(ptr, old, size) == 0)
|
||||
{
|
||||
found = true;
|
||||
location = ptr + patch_offset;
|
||||
u32 i;
|
||||
for(i = 0; i < patch_size; i++)
|
||||
location[i] = patch[i];
|
||||
DCFlushRange(location, patch_size);
|
||||
break;
|
||||
for(i = 0; i < size; ++i)
|
||||
*(vu8*)(ptr+i) = *(vu8*)(patch+i);
|
||||
found++;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
if(found)
|
||||
gprintf("apply_patch '%s': found at %08x\n", name, ptr);
|
||||
else
|
||||
gprintf("apply_patch '%s': not found\n", name);
|
||||
return found;
|
||||
IRQ_Restore(level);
|
||||
usleep(1000);
|
||||
|
||||
gprintf("patched %s %u times.\n", name, found);
|
||||
return (found > 0);
|
||||
}
|
||||
|
||||
const u8 isfs_permissions_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 };
|
||||
const u8 isfs_permissions_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 };
|
||||
static const u8 isfs_perm_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 };
|
||||
static const u8 isfs_perm_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 };
|
||||
static const u8 setuid_old[] = { 0xD1, 0x2A, 0x1C, 0x39 };
|
||||
static const u8 setuid_patch[] = { 0x46, 0xC0 };
|
||||
const u8 es_identify_old[] = { 0x28, 0x03, 0xD1, 0x23 };
|
||||
const u8 es_identify_patch[] = { 0x00, 0x00 };
|
||||
const u8 hash_old[] = { 0x20, 0x07, 0x23, 0xA2 };
|
||||
const u8 hash_patch[] = { 0x00 };
|
||||
const u8 new_hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
|
||||
static const u8 setuid_patch[] = { 0x46, 0xC0, 0x1C, 0x39 };
|
||||
static const u8 es_identify_old[] = { 0x28, 0x03, 0xD1, 0x23 };
|
||||
static const u8 es_identify_patch[] = { 0x28, 0x03, 0x00, 0x00 };
|
||||
static const u8 hash_old[] = { 0x20, 0x07, 0x23, 0xA2 };
|
||||
static const u8 hash_patch[] = { 0x20, 0x00, 0x23, 0xA2 };
|
||||
static const u8 new_hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
|
||||
static const u8 new_hash_patch[] = { 0x20, 0x00, 0x4B, 0x0B };
|
||||
|
||||
bool Patch_ISFS_Permission(bool enable)
|
||||
{
|
||||
/* Disable memory protection */
|
||||
write16(MEM_PROT, 0);
|
||||
/* Do Patches */
|
||||
bool ret = false;
|
||||
if(enable)
|
||||
{
|
||||
gprintf("Enabling ISFS Patches...\n");
|
||||
ret = apply_patch("isfs_permissions", isfs_permissions_old, sizeof(isfs_permissions_old), isfs_permissions_patch, sizeof(isfs_permissions_patch), 0);
|
||||
}
|
||||
else /* Just revert it */
|
||||
{
|
||||
gprintf("Disabling ISFS Patches...\n");
|
||||
ret = apply_patch("isfs_permissions", isfs_permissions_patch, sizeof(isfs_permissions_patch), isfs_permissions_old, sizeof(isfs_permissions_old), 0);
|
||||
}
|
||||
/* Enable memory protection */
|
||||
write16(MEM_PROT, 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Patch_Channel_Boot(void)
|
||||
void PatchIOS(void)
|
||||
{
|
||||
/* Stop IOS from blocking shit */
|
||||
__IOS_ShutdownSubsystems();
|
||||
/* Disable memory protection */
|
||||
write16(MEM_PROT, 0);
|
||||
/* Do Patching */
|
||||
apply_patch("es_setuid", setuid_old, sizeof(setuid_old), setuid_patch, sizeof(setuid_patch), 0);
|
||||
apply_patch("es_identify", es_identify_old, sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch), 2);
|
||||
apply_patch("hash_check", hash_old, sizeof(hash_old), hash_patch, sizeof(hash_patch), 1);
|
||||
apply_patch("new_hash_check", new_hash_old, sizeof(new_hash_old), hash_patch, sizeof(hash_patch), 1);
|
||||
apply_patch("isfs_permissions", isfs_perm_old, isfs_perm_patch, sizeof(isfs_perm_patch));
|
||||
apply_patch("es_setuid", setuid_old, setuid_patch, sizeof(setuid_patch));
|
||||
apply_patch("es_identify", es_identify_old, es_identify_patch, sizeof(es_identify_patch));
|
||||
apply_patch("hash_check", hash_old, hash_patch, sizeof(hash_patch));
|
||||
apply_patch("new_hash_check", new_hash_old, new_hash_patch, sizeof(new_hash_patch));
|
||||
/* Enable memory protection */
|
||||
write16(MEM_PROT, 1);
|
||||
/* Restart our IOS stuff */
|
||||
__IOS_InitializeSubsystems();
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ extern "C"
|
||||
#ifndef _PATCHER_H_
|
||||
#define _PATCHER_H_
|
||||
|
||||
bool Patch_ISFS_Permission(bool enable);
|
||||
void Patch_Channel_Boot(void);
|
||||
void PatchIOS(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -72,10 +72,10 @@ void Nand::Init()
|
||||
{
|
||||
MountedDevice = 0;
|
||||
EmuDevice = REAL_NAND;
|
||||
AccessPatched = false;
|
||||
Partition = 0;
|
||||
FullMode = 0x100;
|
||||
memset(NandPath, 0, sizeof(NandPath));
|
||||
isfs_inited = false;
|
||||
}
|
||||
|
||||
bool Nand::LoadDefaultIOS(void)
|
||||
@ -1040,26 +1040,22 @@ s32 Nand::Do_Region_Change(string id)
|
||||
|
||||
void Nand::Init_ISFS()
|
||||
{
|
||||
if(isfs_inited)
|
||||
return;
|
||||
if(IOS_GetVersion() < 222)
|
||||
{
|
||||
Patch_ISFS_Permission(true);
|
||||
AccessPatched = true;
|
||||
}
|
||||
PatchIOS();
|
||||
usleep(1000);
|
||||
gprintf("Init ISFS\n");
|
||||
ISFS_Initialize();
|
||||
isfs_inited = true;
|
||||
}
|
||||
|
||||
void Nand::DeInit_ISFS(bool KeepPatches)
|
||||
void Nand::DeInit_ISFS()
|
||||
{
|
||||
gprintf("Deinit ISFS\n");
|
||||
ISFS_Deinitialize();
|
||||
isfs_inited = false;
|
||||
usleep(1000);
|
||||
if(AccessPatched && !KeepPatches)
|
||||
{
|
||||
Patch_ISFS_Permission(false);
|
||||
AccessPatched = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Thanks to postloader for that patch */
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
|
||||
void Patch_AHB();
|
||||
void Init_ISFS();
|
||||
void DeInit_ISFS(bool KeepPatches = false);
|
||||
void DeInit_ISFS();
|
||||
|
||||
const char *Get_NandPath(void) { return NandPath; };
|
||||
u32 Get_Partition(void) { return Partition; };
|
||||
@ -134,7 +134,7 @@ private:
|
||||
u32 FoldersDone;
|
||||
bool fake;
|
||||
bool showprogress;
|
||||
bool AccessPatched;
|
||||
bool isfs_inited;
|
||||
|
||||
void *data;
|
||||
dump_callback_t dumper;
|
||||
|
@ -75,7 +75,6 @@ bool NandSave::CheckSave()
|
||||
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;
|
||||
|
@ -80,9 +80,9 @@ bool loadIOS(int ios, bool MountDevices)
|
||||
if(ios != CurIOS && IOS_GetType(ios) != IOS_TYPE_STUB)
|
||||
{
|
||||
WDVD_Close();
|
||||
NandHandle.Patch_AHB(); //No AHBPROT for the next IOS
|
||||
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
|
||||
ShutdownBeforeExit();
|
||||
NandHandle.Patch_AHB(); //No AHBPROT for the next IOS
|
||||
ret = IOS_ReloadIOS(ios) == 0;
|
||||
gprintf("AHBPROT after IOS Reload: %u\n", AHBRPOT_Patched());
|
||||
NandHandle.Init_ISFS();
|
||||
|
@ -72,8 +72,8 @@ int main(int argc, char **argv)
|
||||
iosOK = loadIOS(IOS_GetVersion(), false);
|
||||
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();
|
||||
else /* Keep our current IOS */
|
||||
iosOK = loadIOS(IOS_GetVersion(), false);
|
||||
|
||||
// Init
|
||||
Sys_Init();
|
||||
|
@ -28,6 +28,9 @@
|
||||
#define Priiloader_CFG1 ((vu32*)0x8132FFFB)
|
||||
#define Priiloader_CFG2 ((vu32*)0x817FEFF0)
|
||||
|
||||
#define IOS_Patch_Start ((vu32*)0x93400000)
|
||||
#define IOS_Patch_End ((vu32*)0x94000000)
|
||||
|
||||
#define HW_GPIO_OUT ((vu32*)0xCD8000E0)
|
||||
#define HW_GPIOB_OUT ((vu32*)0xCD8000C0)
|
||||
#define HW_AHBPROT ((vu32*)0xCD800064)
|
||||
|
@ -1168,8 +1168,8 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
|
||||
{
|
||||
setLanguage(language);
|
||||
ocarina_load_code(cheatFile, cheatSize);
|
||||
Patch_Channel_Boot(); /* Patch for everything */
|
||||
NandHandle.Patch_AHB(); /* Identify may takes it */
|
||||
PatchIOS(); /* Patch for everything */
|
||||
Identify(gameTitle);
|
||||
ExternalBooter_ChannelSetup(gameTitle, use_dol);
|
||||
WiiFlow_ExternalBooter(videoMode, vipatch, countryPatch, patchVidMode, aspectRatio, 0, TYPE_CHANNEL, use_led);
|
||||
|
Loading…
Reference in New Issue
Block a user