mirror of
https://github.com/modmii/YAWM-ModMii-Edition.git
synced 2024-11-25 09:36:53 +01:00
Commit
This commit is contained in:
parent
63890517c4
commit
dce3effdea
@ -1,8 +1,10 @@
|
|||||||
#ifndef _FAT_H_
|
#ifndef _FAT_H_
|
||||||
#define _FAT_H_
|
#define _FAT_H_
|
||||||
|
|
||||||
|
|
||||||
/* 'FAT File' structure */
|
/* 'FAT File' structure */
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
/* Filename */
|
/* Filename */
|
||||||
char filename[128];
|
char filename[128];
|
||||||
/* 1 = Batch Install, 2 = Batch Uninstall - Leathl */
|
/* 1 = Batch Install, 2 = Batch Uninstall - Leathl */
|
||||||
@ -18,9 +20,7 @@ typedef struct {
|
|||||||
size_t fsize;
|
size_t fsize;
|
||||||
} fatFile;
|
} fatFile;
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
|
|
||||||
void FatMount();
|
void FatMount();
|
||||||
void FatUnmount();
|
void FatUnmount();
|
||||||
char* FatGetDeviceName(u8 index);
|
char* FatGetDeviceName(u8 index);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "fileops.h"
|
#include "fileops.h"
|
||||||
|
|
||||||
@ -57,6 +58,22 @@ void FSOPMakeFolder(const char* path)
|
|||||||
if (FSOPFolderExists(path))
|
if (FSOPFolderExists(path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
char* pos = strchr(path, '/');
|
||||||
|
s32 current = pos - path;
|
||||||
|
current++;
|
||||||
|
pos = strchr(path + current, '/');
|
||||||
|
|
||||||
|
while (pos)
|
||||||
|
{
|
||||||
|
*pos = 0;
|
||||||
|
mkdir(path, S_IREAD | S_IWRITE);
|
||||||
|
*pos = '/';
|
||||||
|
|
||||||
|
current = pos - path;
|
||||||
|
current++;
|
||||||
|
pos = strchr(path + current, '/');
|
||||||
|
}
|
||||||
|
|
||||||
mkdir(path, S_IREAD | S_IWRITE);
|
mkdir(path, S_IREAD | S_IWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
264
source/menu.c
264
source/menu.c
@ -21,6 +21,7 @@
|
|||||||
#include "iospatch.h"
|
#include "iospatch.h"
|
||||||
#include "appboot.h"
|
#include "appboot.h"
|
||||||
#include "fileops.h"
|
#include "fileops.h"
|
||||||
|
#include "menu.h"
|
||||||
|
|
||||||
/* NAND device list */
|
/* NAND device list */
|
||||||
nandDevice ndevList[] =
|
nandDevice ndevList[] =
|
||||||
@ -42,6 +43,8 @@ static char gMenuRegion = '\0';
|
|||||||
static u16 gMenuVersion = 0;
|
static u16 gMenuVersion = 0;
|
||||||
static u8 gSelected = 0;
|
static u8 gSelected = 0;
|
||||||
|
|
||||||
|
static bool gNeedPriiloaderOption = false;
|
||||||
|
|
||||||
/* Macros */
|
/* Macros */
|
||||||
//#define NB_FAT_DEVICES (sizeof(fdevList) / sizeof(fatDevice))
|
//#define NB_FAT_DEVICES (sizeof(fdevList) / sizeof(fatDevice))
|
||||||
#define NB_NAND_DEVICES (sizeof(ndevList) / sizeof(nandDevice))
|
#define NB_NAND_DEVICES (sizeof(ndevList) / sizeof(nandDevice))
|
||||||
@ -106,14 +109,18 @@ s32 __Menu_RetrieveList(char *inPath, fatFile **outbuf, u32 *outlen)
|
|||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cnt > 0) {
|
if (cnt > 0)
|
||||||
|
{
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
buffer = malloc(sizeof(fatFile) * cnt);
|
buffer = malloc(sizeof(fatFile) * cnt);
|
||||||
if (!buffer) {
|
if (!buffer)
|
||||||
|
{
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(fatFile) * cnt);
|
||||||
|
|
||||||
/* Reset directory */
|
/* Reset directory */
|
||||||
rewinddir(dir);
|
rewinddir(dir);
|
||||||
|
|
||||||
@ -213,7 +220,9 @@ void Menu_SelectIOS(void)
|
|||||||
qsort(iosVersion, iosCnt, sizeof(u8), __Menu_IsGreater);
|
qsort(iosVersion, iosCnt, sizeof(u8), __Menu_IsGreater);
|
||||||
|
|
||||||
if (gConfig.cIOSVersion < 0)
|
if (gConfig.cIOSVersion < 0)
|
||||||
|
{
|
||||||
tmpVersion = CIOS_VERSION;
|
tmpVersion = CIOS_VERSION;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmpVersion = (u8)gConfig.cIOSVersion;
|
tmpVersion = (u8)gConfig.cIOSVersion;
|
||||||
@ -223,7 +232,8 @@ void Menu_SelectIOS(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set default version */
|
/* Set default version */
|
||||||
for (cnt = 0; cnt < iosCnt; cnt++) {
|
for (cnt = 0; cnt < iosCnt; cnt++)
|
||||||
|
{
|
||||||
u8 version = iosVersion[cnt];
|
u8 version = iosVersion[cnt];
|
||||||
|
|
||||||
/* Custom IOS available */
|
/* Custom IOS available */
|
||||||
@ -277,26 +287,32 @@ void Menu_SelectIOS(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u8 version = iosVersion[selected];
|
u8 version = iosVersion[selected];
|
||||||
|
|
||||||
if (IOS_GetVersion() != version) {
|
if (IOS_GetVersion() != version) {
|
||||||
/* Shutdown subsystems */
|
/* Shutdown subsystems */
|
||||||
|
FatUnmount();
|
||||||
Wpad_Disconnect();
|
Wpad_Disconnect();
|
||||||
//mload_close();
|
|
||||||
|
|
||||||
/* Load IOS */
|
/* Load IOS */
|
||||||
|
if (!loadIOS(version))
|
||||||
if(!loadIOS(version)) Wpad_Init(), Menu_SelectIOS();
|
{
|
||||||
|
Wpad_Init();
|
||||||
|
Menu_SelectIOS();
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize subsystems */
|
/* Initialize subsystems */
|
||||||
Wpad_Init();
|
Wpad_Init();
|
||||||
|
FatMount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu_FatDevice(void)
|
void Menu_FatDevice(void)
|
||||||
{
|
{
|
||||||
FatMount();
|
FatMount();
|
||||||
|
if (gSelected >= FatGetDeviceCount())
|
||||||
|
gSelected = 0;
|
||||||
|
|
||||||
const u16 konamiCode[] =
|
const u16 konamiCode[] =
|
||||||
{
|
{
|
||||||
@ -314,30 +330,34 @@ void Menu_FatDevice(void)
|
|||||||
{
|
{
|
||||||
/* Clear console */
|
/* Clear console */
|
||||||
Con_Clear();
|
Con_Clear();
|
||||||
|
bool deviceOk = (FatGetDeviceCount() > 0);
|
||||||
|
|
||||||
if (!FatGetDeviceCount())
|
if (!deviceOk)
|
||||||
{
|
{
|
||||||
printf("\t[+] No source device: < %s >\n\n", FatGetDeviceName(gSelected));
|
printf("\t[+] No source devices found\n\n");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Selected device */
|
{
|
||||||
//printf("\tWii menu version: %d, region: %s\n\n", gMenuVersion, GetSysMenuRegionString(&gMenuRegion));
|
|
||||||
printf("\t>> Select source device: < %s >\n\n", FatGetDeviceName(gSelected));
|
printf("\t>> Select source device: < %s >\n\n", FatGetDeviceName(gSelected));
|
||||||
printf("\t Press LEFT/RIGHT to change the selected device.\n\n");
|
printf("\t Press LEFT/RIGHT to change the selected device.\n\n");
|
||||||
printf("\t Press A button to continue.\n");
|
printf("\t Press A button to continue.\n");
|
||||||
printf("\t Press B button to remount source devices.\n");
|
}
|
||||||
|
/* Selected device */
|
||||||
|
//printf("\tWii menu version: %d, region: %s\n\n", gMenuVersion, GetSysMenuRegionString(&gMenuRegion));
|
||||||
|
|
||||||
|
printf("\t Press 1 button to remount source devices.\n");
|
||||||
printf("\t Press HOME button to restart.\n\n");
|
printf("\t Press HOME button to restart.\n\n");
|
||||||
|
|
||||||
if (skipRegionSafetyCheck)
|
if (skipRegionSafetyCheck)
|
||||||
{
|
{
|
||||||
printf("[+] WARNING: SM Region checks disabled!\n\n");
|
printf("[+] WARNING: SM Region checks disabled!\n\n");
|
||||||
printf("\t Press 1 button to reset.\n");
|
printf("\t Press 2 button to reset.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u32 buttons = WaitButtons();
|
u32 buttons = WaitButtons();
|
||||||
|
|
||||||
if (buttons & (WPAD_BUTTON_UP | WPAD_BUTTON_DOWN | WPAD_BUTTON_RIGHT | WPAD_BUTTON_LEFT | WPAD_BUTTON_A | WPAD_BUTTON_B))
|
if (deviceOk && buttons & (WPAD_BUTTON_UP | WPAD_BUTTON_DOWN | WPAD_BUTTON_RIGHT | WPAD_BUTTON_LEFT | WPAD_BUTTON_A | WPAD_BUTTON_B))
|
||||||
{
|
{
|
||||||
if (!skipRegionSafetyCheck)
|
if (!skipRegionSafetyCheck)
|
||||||
{
|
{
|
||||||
@ -347,16 +367,12 @@ void Menu_FatDevice(void)
|
|||||||
codePosition = 0;
|
codePosition = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buttons & WPAD_BUTTON_LEFT)
|
if (deviceOk && buttons & WPAD_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
if ((s8)(--gSelected) < 0)
|
if ((s8)(--gSelected) < 0)
|
||||||
gSelected = FatGetDeviceCount() - 1;
|
gSelected = FatGetDeviceCount() - 1;
|
||||||
}
|
}
|
||||||
else if (buttons & WPAD_BUTTON_1 && skipRegionSafetyCheck)
|
else if (deviceOk && buttons & WPAD_BUTTON_RIGHT)
|
||||||
{
|
|
||||||
skipRegionSafetyCheck = false;
|
|
||||||
}
|
|
||||||
else if (buttons & WPAD_BUTTON_RIGHT)
|
|
||||||
{
|
{
|
||||||
if ((++gSelected) >= FatGetDeviceCount())
|
if ((++gSelected) >= FatGetDeviceCount())
|
||||||
gSelected = 0;
|
gSelected = 0;
|
||||||
@ -365,7 +381,7 @@ void Menu_FatDevice(void)
|
|||||||
{
|
{
|
||||||
Restart();
|
Restart();
|
||||||
}
|
}
|
||||||
else if (buttons & WPAD_BUTTON_B && !codePosition)
|
else if (buttons & WPAD_BUTTON_1)
|
||||||
{
|
{
|
||||||
printf("\t\t[-] Mounting devices.");
|
printf("\t\t[-] Mounting devices.");
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
@ -380,7 +396,11 @@ void Menu_FatDevice(void)
|
|||||||
gSelected = 0;
|
gSelected = 0;
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
}
|
}
|
||||||
else if (buttons & WPAD_BUTTON_A)
|
else if (buttons & WPAD_BUTTON_2 && skipRegionSafetyCheck)
|
||||||
|
{
|
||||||
|
skipRegionSafetyCheck = false;
|
||||||
|
}
|
||||||
|
else if (deviceOk && buttons & WPAD_BUTTON_A)
|
||||||
{
|
{
|
||||||
if (codePosition == sizeof(konamiCode) / sizeof(konamiCode[0]))
|
if (codePosition == sizeof(konamiCode) / sizeof(konamiCode[0]))
|
||||||
{
|
{
|
||||||
@ -388,7 +408,6 @@ void Menu_FatDevice(void)
|
|||||||
printf("[+] Disabled SM region checks\n");
|
printf("[+] Disabled SM region checks\n");
|
||||||
sleep(3);
|
sleep(3);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,7 +528,8 @@ int Menu_BatchProcessWads(fatFile *files, int fileCount, char *inFilePath, int i
|
|||||||
printf(" Do you want to proceed?\n");
|
printf(" Do you want to proceed?\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("[+] %d file%s marked for installation and %d file%s for uninstallation.\n", installCnt, (installCnt == 1) ? "" : "s", uninstallCnt, (uninstallCnt == 1) ? "" : "s");
|
printf("[+] %d file%s marked for installation.\n", installCnt, (installCnt == 1) ? "" : "s");
|
||||||
|
printf("[+] %d file%s marked for uninstallation.\n", uninstallCnt, (uninstallCnt == 1) ? "" : "s");
|
||||||
printf(" Do you want to proceed?\n");
|
printf(" Do you want to proceed?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,30 +554,52 @@ int Menu_BatchProcessWads(fatFile *files, int fileCount, char *inFilePath, int i
|
|||||||
{
|
{
|
||||||
fatFile *thisFile = &files[count];
|
fatFile *thisFile = &files[count];
|
||||||
|
|
||||||
if ((thisFile->install == 1) | (thisFile->install == 2)) {
|
|
||||||
int mode = thisFile->install;
|
int mode = thisFile->install;
|
||||||
|
if (mode)
|
||||||
|
{
|
||||||
Con_Clear();
|
Con_Clear();
|
||||||
|
printf("[+] Processing WAD: %d/%d...\n\n", (errors + success + 1), (installCnt + uninstallCnt));
|
||||||
printf("[+] Opening \"%s\", please wait...\n\n", thisFile->filename);
|
printf("[+] Opening \"%s\", please wait...\n\n", thisFile->filename);
|
||||||
|
|
||||||
sprintf(gTmpFilePath, "%s/%s", inFilePath, thisFile->filename);
|
sprintf(gTmpFilePath, "%s/%s", inFilePath, thisFile->filename);
|
||||||
|
|
||||||
FILE *fp = fopen(gTmpFilePath, "rb");
|
FILE *fp = fopen(gTmpFilePath, "rb");
|
||||||
if (!fp) {
|
if (!fp)
|
||||||
|
{
|
||||||
printf(" ERROR!\n");
|
printf(" ERROR!\n");
|
||||||
errors += 1;
|
errors += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[+] %s WAD, please wait...\n", (mode == 2) ? "Uninstalling" : "Installing");
|
if (mode == 2)
|
||||||
if (mode == 2) {
|
{
|
||||||
|
printf(">> Uninstalling WAD, please wait...\n\n");
|
||||||
ret = Wad_Uninstall(fp);
|
ret = Wad_Uninstall(fp);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
|
printf(">> Installing WAD, please wait...\n\n");
|
||||||
ret = Wad_Install(fp);
|
ret = Wad_Install(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0) errors += 1;
|
if (ret < 0)
|
||||||
else success += 1;
|
{
|
||||||
|
if ((errors + success + 1) < (installCnt + uninstallCnt))
|
||||||
|
{
|
||||||
|
s32 i;
|
||||||
|
for (i = 5; i > 0; i--)
|
||||||
|
{
|
||||||
|
printf("\r Continue in: %d", i);
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
success++;
|
||||||
|
}
|
||||||
|
|
||||||
thisFile->installstate = ret;
|
thisFile->installstate = ret;
|
||||||
|
|
||||||
@ -566,7 +608,7 @@ int Menu_BatchProcessWads(fatFile *files, int fileCount, char *inFilePath, int i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WiiLightControl (WII_LIGHT_OFF);
|
WiiLightControl(WII_LIGHT_OFF);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" %d titles succeeded and %d failed...\n", success, errors);
|
printf(" %d titles succeeded and %d failed...\n", success, errors);
|
||||||
@ -583,24 +625,52 @@ int Menu_BatchProcessWads(fatFile *files, int fileCount, char *inFilePath, int i
|
|||||||
{
|
{
|
||||||
Con_Clear();
|
Con_Clear();
|
||||||
|
|
||||||
int i=0;
|
int i = 0;
|
||||||
for (count = 0; count < fileCount; count++)
|
for (count = 0; count < fileCount; count++)
|
||||||
{
|
{
|
||||||
fatFile *thisFile = &files[count];
|
fatFile *thisFile = &files[count];
|
||||||
|
|
||||||
if (thisFile->installstate <0)
|
if (thisFile->installstate < 0)
|
||||||
{
|
{
|
||||||
char str[41];
|
char str[41];
|
||||||
strncpy(str, thisFile->filename, 40); //Only 40 chars to fit the screen
|
strncpy(str, thisFile->filename, 40); //Only 40 chars to fit the screen
|
||||||
str[40]=0;
|
str[40]=0;
|
||||||
i++;
|
i++;
|
||||||
if(thisFile->installstate == -999) printf(" %s BRICK BLOCKED\n", str);
|
|
||||||
else if(thisFile->installstate == -998) printf(" %s Skipped\n", str);
|
|
||||||
else if(thisFile->installstate == -106) printf(" %s Not installed?\n", str);
|
switch (thisFile->installstate)
|
||||||
else if(thisFile->installstate == -1036 ) printf(" %s Needed IOS missing\n", str);
|
{
|
||||||
else if(thisFile->installstate == -4100 ) printf(" %s No trucha bug?\n", str);
|
case -106:
|
||||||
else printf(" %s error %d\n", str, thisFile->installstate);
|
{
|
||||||
if( i == 17 )
|
printf(" %s Not installed?\n", str);
|
||||||
|
} break;
|
||||||
|
case -996:
|
||||||
|
{
|
||||||
|
printf(" %s Read error\n", str);
|
||||||
|
} break;
|
||||||
|
case -998:
|
||||||
|
{
|
||||||
|
printf(" %s Skipped\n", str);
|
||||||
|
} break;
|
||||||
|
case -999:
|
||||||
|
{
|
||||||
|
printf(" %s BRICK BLOCKED\n", str);
|
||||||
|
} break;
|
||||||
|
case -1036:
|
||||||
|
{
|
||||||
|
printf(" %s Needed IOS missing\n", str);
|
||||||
|
} break;
|
||||||
|
case -4100:
|
||||||
|
{
|
||||||
|
printf(" %s No trucha bug?\n", str);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
printf(" %s error %d\n", str, thisFile->installstate);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 17)
|
||||||
{
|
{
|
||||||
printf("\n Press any button to continue\n");
|
printf("\n Press any button to continue\n");
|
||||||
WaitButtons();
|
WaitButtons();
|
||||||
@ -610,8 +680,30 @@ int Menu_BatchProcessWads(fatFile *files, int fileCount, char *inFilePath, int i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gNeedPriiloaderOption)
|
||||||
|
{
|
||||||
|
printf("\n Priiloader has been retained, but all hacks were reset.\n\n");
|
||||||
|
printf(" Press A launch Priiloader now.\n");
|
||||||
|
printf(" Press any other button to continue...\n");
|
||||||
|
|
||||||
|
u32 buttons = WaitButtons();
|
||||||
|
|
||||||
|
if (buttons & WPAD_BUTTON_A)
|
||||||
|
{
|
||||||
|
gNeedPriiloaderOption = false;
|
||||||
|
*(vu32*)0x8132FFFB = 0x4461636f;
|
||||||
|
DCFlushRange((void*)0x8132FFFB, 4);
|
||||||
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
gNeedPriiloaderOption = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf("\n Press any button to continue...\n");
|
printf("\n Press any button to continue...\n");
|
||||||
WaitButtons();
|
WaitButtons();
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -741,33 +833,71 @@ void Menu_WadManage(fatFile *file, char *inFilePath)
|
|||||||
/* Generate filepath */
|
/* Generate filepath */
|
||||||
// sprintf(filepath, "%s:" WAD_DIRECTORY "/%s", fdev->mount, file->filename);
|
// sprintf(filepath, "%s:" WAD_DIRECTORY "/%s", fdev->mount, file->filename);
|
||||||
sprintf(gTmpFilePath, "%s/%s", inFilePath, file->filename); // wiiNinja
|
sprintf(gTmpFilePath, "%s/%s", inFilePath, file->filename); // wiiNinja
|
||||||
if(file->iswad) {
|
if(file->iswad)
|
||||||
|
{
|
||||||
/* Open WAD */
|
/* Open WAD */
|
||||||
fp = fopen(gTmpFilePath, "rb");
|
fp = fopen(gTmpFilePath, "rb");
|
||||||
if (!fp) {
|
if (!fp)
|
||||||
|
{
|
||||||
printf(" ERROR!\n");
|
printf(" ERROR!\n");
|
||||||
goto out;
|
goto out;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf(" OK!\n\n");
|
printf(" OK!\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("[+] %s WAD, please wait...\n", (!mode) ? "Installing" : "Uninstalling");
|
printf("[+] %s WAD, please wait...\n", (!mode) ? "Installing" : "Uninstalling");
|
||||||
|
|
||||||
/* Do install/uninstall */
|
/* Do install/uninstall */
|
||||||
WiiLightControl (WII_LIGHT_ON);
|
WiiLightControl (WII_LIGHT_ON);
|
||||||
if (!mode)
|
|
||||||
Wad_Install(fp);
|
|
||||||
else
|
|
||||||
Wad_Uninstall(fp);
|
|
||||||
WiiLightControl (WII_LIGHT_OFF);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("launch dol/elf here \n");
|
|
||||||
|
|
||||||
if(LoadApp(inFilePath, file->filename)) {
|
if (!mode)
|
||||||
LaunchApp();
|
{
|
||||||
|
Wad_Install(fp);
|
||||||
|
WiiLightControl(WII_LIGHT_OFF);
|
||||||
|
|
||||||
|
if (gNeedPriiloaderOption)
|
||||||
|
{
|
||||||
|
printf("\n Priiloader has been retained, but all hacks were reset.\n\n");
|
||||||
|
printf(" Press A launch Priiloader now.\n");
|
||||||
|
printf(" Press any other button to continue...\n");
|
||||||
|
|
||||||
|
u32 buttons = WaitButtons();
|
||||||
|
|
||||||
|
if (fp)
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
if (buttons & WPAD_BUTTON_A)
|
||||||
|
{
|
||||||
|
gNeedPriiloaderOption = false;
|
||||||
|
*(vu32*)0x8132FFFB = 0x4461636f;
|
||||||
|
DCFlushRange((void*)0x8132FFFB, 4);
|
||||||
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gNeedPriiloaderOption = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Wad_Uninstall(fp);
|
||||||
|
WiiLightControl(WII_LIGHT_OFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("launch dol/elf here \n");
|
||||||
|
|
||||||
|
if(LoadApp(inFilePath, file->filename))
|
||||||
|
LaunchApp();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* Close file */
|
/* Close file */
|
||||||
if (fp)
|
if (fp)
|
||||||
@ -860,6 +990,7 @@ getList:
|
|||||||
{
|
{
|
||||||
fatFile *file = &fileList[counter];
|
fatFile *file = &fileList[counter];
|
||||||
file->install = 0;
|
file->install = 0;
|
||||||
|
file->installstate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -967,13 +1098,13 @@ getList:
|
|||||||
{
|
{
|
||||||
installCnt = 0;
|
installCnt = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while( i < fileCnt)
|
while(i < fileCnt)
|
||||||
{
|
{
|
||||||
fatFile *file = &fileList[i];
|
fatFile *file = &fileList[i];
|
||||||
if (((file->isdir) == false) && (file->install == 0))
|
if (((file->isdir) == false) && (file->install == 0))
|
||||||
{
|
{
|
||||||
file->install = 1;
|
file->install = 1;
|
||||||
installCnt += 1;
|
installCnt++;
|
||||||
}
|
}
|
||||||
else if (((file->isdir) == false) && (file->install == 1))
|
else if (((file->isdir) == false) && (file->install == 1))
|
||||||
{
|
{
|
||||||
@ -1026,7 +1157,7 @@ getList:
|
|||||||
installCnt = 0;
|
installCnt = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while( i < fileCnt)
|
while(i < fileCnt)
|
||||||
{
|
{
|
||||||
fatFile *file = &fileList[i];
|
fatFile *file = &fileList[i];
|
||||||
if (((file->isdir) == false) && (file->install == 0))
|
if (((file->isdir) == false) && (file->install == 0))
|
||||||
@ -1066,7 +1197,7 @@ getList:
|
|||||||
else if (((file->isdir) == false) && (file->install == 2))
|
else if (((file->isdir) == false) && (file->install == 2))
|
||||||
{
|
{
|
||||||
file->install = 0;
|
file->install = 0;
|
||||||
uninstallCnt -= 1;
|
uninstallCnt--;
|
||||||
}
|
}
|
||||||
|
|
||||||
selected++;
|
selected++;
|
||||||
@ -1155,6 +1286,7 @@ getList:
|
|||||||
{
|
{
|
||||||
fatFile *temp = &fileList[counter];
|
fatFile *temp = &fileList[counter];
|
||||||
temp->install = 0;
|
temp->install = 0;
|
||||||
|
temp->installstate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
installCnt = 0;
|
installCnt = 0;
|
||||||
@ -1165,7 +1297,7 @@ getList:
|
|||||||
//else use standard wadmanage menu - Leathl
|
//else use standard wadmanage menu - Leathl
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmpCurPath = PeekCurrentDir ();
|
tmpCurPath = PeekCurrentDir();
|
||||||
if (tmpCurPath != NULL)
|
if (tmpCurPath != NULL)
|
||||||
Menu_WadManage(tmpFile, tmpCurPath);
|
Menu_WadManage(tmpFile, tmpCurPath);
|
||||||
}
|
}
|
||||||
@ -1229,11 +1361,13 @@ void Menu_Loop(void)
|
|||||||
ndev = &ndevList[0];
|
ndev = &ndevList[0];
|
||||||
|
|
||||||
/* NAND device menu */
|
/* NAND device menu */
|
||||||
if ((iosVersion == CIOS_VERSION || iosVersion == 250) && IOS_GetRevision() >13)
|
if ((iosVersion == CIOS_VERSION || iosVersion == 250) && IOS_GetRevision() > 13)
|
||||||
{
|
{
|
||||||
Menu_NandDevice();
|
Menu_NandDevice();
|
||||||
}
|
}
|
||||||
for (;;) {
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
/* FAT device menu */
|
/* FAT device menu */
|
||||||
Menu_FatDevice();
|
Menu_FatDevice();
|
||||||
|
|
||||||
@ -1242,8 +1376,12 @@ void Menu_Loop(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start of wiiNinja's added routines
|
void SetPriiloaderOption(bool enabled)
|
||||||
|
{
|
||||||
|
gNeedPriiloaderOption = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start of wiiNinja's added routines
|
||||||
int PushCurrentDir (char *dirStr, int Selected, int Start)
|
int PushCurrentDir (char *dirStr, int Selected, int Start)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
void Menu_Loop(void);
|
void Menu_Loop(void);
|
||||||
|
void SetPriiloaderOption(bool enabled);
|
||||||
|
bool MenuTestDevice();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -354,6 +354,8 @@ s32 NANDGetNameList(const char* src, NameList** entries, s32* count)
|
|||||||
|
|
||||||
s32 NANDDumpFile(const char* src, const char* dst)
|
s32 NANDDumpFile(const char* src, const char* dst)
|
||||||
{
|
{
|
||||||
|
printf("Dump file: %s\n", src);
|
||||||
|
|
||||||
s32 fd = ISFS_Open(src, ISFS_OPEN_READ);
|
s32 fd = ISFS_Open(src, ISFS_OPEN_READ);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
@ -371,7 +373,6 @@ s32 NANDDumpFile(const char* src, const char* dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FSOPDeleteFile(dst);
|
FSOPDeleteFile(dst);
|
||||||
|
|
||||||
FILE* file = fopen(dst, "wb");
|
FILE* file = fopen(dst, "wb");
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "nand.h"
|
#include "nand.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "iospatch.h"
|
#include "iospatch.h"
|
||||||
|
#include "fileops.h"
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
CONFIG gConfig;
|
CONFIG gConfig;
|
||||||
@ -217,11 +218,14 @@ int ReadConfigFile(char* configFilePath)
|
|||||||
if (tmpStr == NULL)
|
if (tmpStr == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
// Just check if at least one device is available
|
|
||||||
for (i = 0; i < FatGetDeviceCount(); i++)
|
for (i = 0; i < FatGetDeviceCount(); i++)
|
||||||
{
|
{
|
||||||
snprintf(path, sizeof(path), "%s%s", FatGetDevicePrefix(i), configFilePath);
|
snprintf(path, sizeof(path), "%s%s", FatGetDevicePrefix(i), configFilePath);
|
||||||
|
if (FSOPFileExists(path))
|
||||||
|
{
|
||||||
found = true;
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
@ -282,7 +286,6 @@ int ReadConfigFile(char* configFilePath)
|
|||||||
GetStringParam (tmpOutStr, tmpStr, MAX_FAT_DEVICE_LENGTH);
|
GetStringParam (tmpOutStr, tmpStr, MAX_FAT_DEVICE_LENGTH);
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
//if (strncmp (fdevList[i].mount, tmpOutStr, 4) == 0)
|
|
||||||
if (strncmp(FatGetDevicePrefix(i), tmpOutStr, 4) == 0)
|
if (strncmp(FatGetDevicePrefix(i), tmpOutStr, 4) == 0)
|
||||||
{
|
{
|
||||||
gConfig.fatDeviceIndex = i;
|
gConfig.fatDeviceIndex = i;
|
||||||
|
61
source/wad.c
61
source/wad.c
@ -14,6 +14,8 @@
|
|||||||
#include "nand.h"
|
#include "nand.h"
|
||||||
#include "fileops.h"
|
#include "fileops.h"
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "iospatch.h"
|
||||||
|
|
||||||
// Turn upper and lower into a full title ID
|
// Turn upper and lower into a full title ID
|
||||||
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
|
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
|
||||||
@ -166,10 +168,10 @@ static char* GetTitleExec(u64 tId, bool tweaked)
|
|||||||
u32 size;
|
u32 size;
|
||||||
const u8 buffer[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
const u8 buffer[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
s32 ret = ES_GetStoredTMDSize(0x100000002, &size);
|
s32 ret = ES_GetStoredTMDSize(0x100000002LL, &size);
|
||||||
signed_blob* tmdRaw = (signed_blob*)buffer;
|
signed_blob* tmdRaw = (signed_blob*)buffer;
|
||||||
|
|
||||||
ret = ES_GetStoredTMD(0x100000002, tmdRaw, size);
|
ret = ES_GetStoredTMD(0x100000002LL, tmdRaw, size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
printf("Error! ES_GetStoredTMDSize: Failed! (Error: %d)\n", ret);
|
printf("Error! ES_GetStoredTMDSize: Failed! (Error: %d)\n", ret);
|
||||||
@ -479,6 +481,10 @@ bool skipRegionSafetyCheck = false;
|
|||||||
|
|
||||||
s32 Wad_Install(FILE *fp)
|
s32 Wad_Install(FILE *fp)
|
||||||
{
|
{
|
||||||
|
//fseek(fp, 0, SEEK_END);
|
||||||
|
//s32 wadSize = ftell(fp);
|
||||||
|
//fseek(fp, 0, SEEK_CUR);
|
||||||
|
|
||||||
SetPRButtons(false);
|
SetPRButtons(false);
|
||||||
wadHeader *header = NULL;
|
wadHeader *header = NULL;
|
||||||
signed_blob *p_certs = NULL, *p_crl = NULL, *p_tik = NULL, *p_tmd = NULL;
|
signed_blob *p_certs = NULL, *p_crl = NULL, *p_tik = NULL, *p_tmd = NULL;
|
||||||
@ -633,7 +639,13 @@ s32 Wad_Install(FILE *fp)
|
|||||||
}
|
}
|
||||||
if(region != RegionLookupList[(tmd_data->title_version & 0x0F)])
|
if(region != RegionLookupList[(tmd_data->title_version & 0x0F)])
|
||||||
{
|
{
|
||||||
printf("\n I won't install the wrong regions SM\n");
|
printf("\n I won't install the wrong regions SM by default.\n\n");
|
||||||
|
|
||||||
|
printf("\n Are you region changing?\n");
|
||||||
|
|
||||||
|
printf("\n If you're really sure what you're doing, next time\n");
|
||||||
|
printf(" select your device using Konami...\n\n");
|
||||||
|
|
||||||
ret = -999;
|
ret = -999;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -648,10 +660,14 @@ skipChecks:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gForcedInstall && IsPriiloaderInstalled())
|
if (!gForcedInstall && AHBPROT_DISABLED && IsPriiloaderInstalled())
|
||||||
{
|
{
|
||||||
cleanupPriiloader = true;
|
cleanupPriiloader = true;
|
||||||
printf("\n Priiloader is installed next to the system menu.\n\n");
|
printf("\n Priiloader is installed next to the system menu.\n\n");
|
||||||
|
printf(" It is recommended to retain Priiloader as it can\n");
|
||||||
|
printf(" protect your console from being bricked.\n\n");
|
||||||
|
|
||||||
|
|
||||||
printf(" Press A to retain Priiloader or B to remove.");
|
printf(" Press A to retain Priiloader or B to remove.");
|
||||||
|
|
||||||
u32 buttons = WaitButtons();
|
u32 buttons = WaitButtons();
|
||||||
@ -661,6 +677,7 @@ skipChecks:
|
|||||||
retainPriiloader = (BackUpPriiloader() && CompareHashes(true));
|
retainPriiloader = (BackUpPriiloader() && CompareHashes(true));
|
||||||
if (retainPriiloader)
|
if (retainPriiloader)
|
||||||
{
|
{
|
||||||
|
SetPriiloaderOption(true);
|
||||||
Con_ClearLine();
|
Con_ClearLine();
|
||||||
printf("\r[+] Priiloader will be retained.\n");
|
printf("\r[+] Priiloader will be retained.\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -685,11 +702,16 @@ skipChecks:
|
|||||||
|
|
||||||
if (!retainPriiloader)
|
if (!retainPriiloader)
|
||||||
{
|
{
|
||||||
|
SetPriiloaderOption(false);
|
||||||
Con_ClearLine();
|
Con_ClearLine();
|
||||||
printf("\r[+] Priiloader will be removed.\n");
|
printf("\r[+] Priiloader will be removed.\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetPriiloaderOption(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gForcedInstall)
|
if (gForcedInstall)
|
||||||
@ -701,6 +723,12 @@ skipChecks:
|
|||||||
/* Fix ticket */
|
/* Fix ticket */
|
||||||
__Wad_FixTicket(p_tik);
|
__Wad_FixTicket(p_tik);
|
||||||
|
|
||||||
|
//if (!MenuTestDevice())
|
||||||
|
//{
|
||||||
|
// ret = -996;
|
||||||
|
// goto err;
|
||||||
|
//}
|
||||||
|
|
||||||
printf("\t\t>> Installing ticket...");
|
printf("\t\t>> Installing ticket...");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
@ -720,7 +748,8 @@ skipChecks:
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
/* Install contents */
|
/* Install contents */
|
||||||
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];
|
||||||
|
|
||||||
u32 idx = 0, len;
|
u32 idx = 0, len;
|
||||||
@ -736,13 +765,15 @@ skipChecks:
|
|||||||
|
|
||||||
/* Install content */
|
/* Install content */
|
||||||
cfd = ES_AddContentStart(tmd_data->title_id, content->cid);
|
cfd = ES_AddContentStart(tmd_data->title_id, content->cid);
|
||||||
if (cfd < 0) {
|
if (cfd < 0)
|
||||||
|
{
|
||||||
ret = cfd;
|
ret = cfd;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Install content data */
|
/* Install content data */
|
||||||
while (idx < len) {
|
while (idx < len)
|
||||||
|
{
|
||||||
u32 size;
|
u32 size;
|
||||||
|
|
||||||
/* Data length */
|
/* Data length */
|
||||||
@ -750,15 +781,25 @@ skipChecks:
|
|||||||
if (size > BLOCK_SIZE)
|
if (size > BLOCK_SIZE)
|
||||||
size = BLOCK_SIZE;
|
size = BLOCK_SIZE;
|
||||||
|
|
||||||
|
//if (offset + size > wadSize)
|
||||||
|
// size = wadSize - offset;
|
||||||
|
|
||||||
|
//printf("\n>> Read Offset: %X (%d) Length: %d/%d", offset, size, idx, len);
|
||||||
/* Read data */
|
/* Read data */
|
||||||
ret = FSOPReadOpenFile(fp, &wadBuffer, offset, size);
|
ret = FSOPReadOpenFile(fp, &wadBuffer, offset, size);
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
|
{
|
||||||
|
ES_AddContentFinish(cfd);
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* Install data */
|
/* Install data */
|
||||||
ret = ES_AddContentData(cfd, wadBuffer, size);
|
ret = ES_AddContentData(cfd, wadBuffer, size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ret = ES_AddContentFinish(cfd);
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* Increase variables */
|
/* Increase variables */
|
||||||
idx += size;
|
idx += size;
|
||||||
@ -778,6 +819,7 @@ skipChecks:
|
|||||||
|
|
||||||
/* Finish title install */
|
/* Finish title install */
|
||||||
ret = ES_AddTitleFinish();
|
ret = ES_AddTitleFinish();
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
printf(" OK!\n");
|
printf(" OK!\n");
|
||||||
@ -879,6 +921,11 @@ skipChecks:
|
|||||||
err:
|
err:
|
||||||
printf("\n ERROR! (ret = %d)\n", ret);
|
printf("\n ERROR! (ret = %d)\n", ret);
|
||||||
|
|
||||||
|
if (retainPriiloader)
|
||||||
|
SetPriiloaderOption(false);
|
||||||
|
|
||||||
|
if (ret == 0)
|
||||||
|
ret = -996;
|
||||||
/* Cancel install */
|
/* Cancel install */
|
||||||
ES_AddTitleCancel();
|
ES_AddTitleCancel();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user