mirror of
https://github.com/modmii/SysCheck-ModMii-Edition.git
synced 2024-11-21 23:59:19 +01:00
-App now exits properly on error, and textures are freed
-Fixed loading bar and cogs not appearing during upload -More work on rewriting IOS_ReloadIOS() so that cogs pause less -Cogs disappear if there is an error -A little more code cleanup
This commit is contained in:
parent
bb7dcdf19d
commit
4a2bbe92ae
@ -8,4 +8,5 @@ void InitThread(void);
|
||||
void * DrawCogThread(void *arg);
|
||||
s32 PauseThread(void);
|
||||
s32 ResumeThread(void);
|
||||
s32 StopThread(void);
|
||||
#endif
|
11
source/gui.c
11
source/gui.c
@ -168,8 +168,7 @@ int initGUI(void) {
|
||||
}
|
||||
|
||||
void deinitGUI(void) {
|
||||
//StopThread();
|
||||
done = 1;
|
||||
StopThread();
|
||||
GRRLIB_FreeTTF(myFont);
|
||||
GRRLIB_FreeTexture(tex_background_png);
|
||||
GRRLIB_FreeTexture(tex_Checkicon_png);
|
||||
@ -203,7 +202,7 @@ void DrawDuringSort(void) {
|
||||
|
||||
int printError(const char* msg) {
|
||||
int i;
|
||||
//PauseThread();
|
||||
PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Deleteicon_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_PrintfTTF((640-strlen(msg)*9)/2, 256, myFont, msg, 20, HEX_WHITE);
|
||||
@ -218,7 +217,7 @@ int printError(const char* msg) {
|
||||
|
||||
int printSuccess(const char* msg) {
|
||||
int i;
|
||||
//PauseThread();
|
||||
PauseThread();
|
||||
//GRRLIB_ClearTex(tex_ScreenBuf);
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Checkicon_png, 0, 1, 1, HEX_WHITE);
|
||||
@ -334,7 +333,7 @@ inline void DrawCog(void) {
|
||||
|
||||
int printEndError(const char* msg) {
|
||||
int i;
|
||||
//PauseThread();
|
||||
PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Deleteicon_png, 0, 1, 1, HEX_WHITE);
|
||||
|
||||
@ -398,6 +397,7 @@ int printReport(char report[200][100], int firstLine, bool completeReport) {
|
||||
|
||||
int printUploadSuccess(const char* msg) {
|
||||
int i;
|
||||
PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Checkicon_png, 0, 1, 1, HEX_WHITE);
|
||||
|
||||
@ -417,6 +417,7 @@ int printUploadSuccess(const char* msg) {
|
||||
|
||||
int printUploadError(const char* msg) {
|
||||
int i;
|
||||
PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Deleteicon_png, 0, 1, 1, HEX_WHITE);
|
||||
|
||||
|
@ -32,6 +32,10 @@ distribution.
|
||||
// This is just stripped down code from ios.c.
|
||||
// I didn't do any extra work, I'm just making it faster for this one situation
|
||||
|
||||
#if defined(HW_RVL)
|
||||
#include <gctypes.h>
|
||||
#include <gcutil.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <ogc/machine/asm.h>
|
||||
@ -43,34 +47,83 @@ distribution.
|
||||
#include <ogc/ios.h>
|
||||
#include <ogc/irq.h>
|
||||
|
||||
#define IOS_HEAP_SIZE 0x1000
|
||||
#define MAX_IPC_RETRIES 400
|
||||
|
||||
extern void udelay(int us);
|
||||
|
||||
void ReloadIOS(int version) {
|
||||
__STM_Close();
|
||||
// These two functions deal with the "internal" IOS subsystems that are used by default by libogc
|
||||
// Other stuff should be inited by the user and deinited by the exit callbacks. The user is also responsible
|
||||
// for deiniting other stuff before an IOS reload and reiniting them after.
|
||||
/*static s32 __IOS_InitializeSubsystems(void)
|
||||
{
|
||||
s32 res;
|
||||
s32 ret = 0;
|
||||
res = __ES_Init();
|
||||
if(res < 0) {
|
||||
ret = res;
|
||||
}
|
||||
res = __STM_Init();
|
||||
if(res < 0) {
|
||||
ret = res;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static s32 __IOS_ShutdownSubsystems(void)
|
||||
{
|
||||
s32 res;
|
||||
s32 ret = 0;
|
||||
res = __STM_Close();
|
||||
if(res < 0) ret = res;
|
||||
res = __ES_Close();
|
||||
if(res < 0) ret = res;
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
static s32 LaunchNewIOS(int version)
|
||||
{
|
||||
u32 numviews;
|
||||
s32 res;
|
||||
u64 titleID = 0x100000000LL;
|
||||
raw_irq_handler_t irq_handler;
|
||||
//raw_irq_handler_t irq_handler;
|
||||
u32 counter;
|
||||
|
||||
STACK_ALIGN(tikview,views,4,32);
|
||||
s32 newversion;
|
||||
|
||||
if(version < 3 || version > 0xFF) {
|
||||
return IOS_EBADVERSION;
|
||||
}
|
||||
|
||||
titleID |= version;
|
||||
|
||||
ES_GetNumTicketViews(titleID, &numviews);
|
||||
|
||||
ES_GetTicketViews(titleID, views, numviews);
|
||||
res = ES_GetNumTicketViews(titleID, &numviews);
|
||||
if(res < 0) {
|
||||
return res;
|
||||
}
|
||||
if(numviews > 4) {
|
||||
printf(" GetNumTicketViews too many views: %u\n",numviews);
|
||||
return IOS_ETOOMANYVIEWS;
|
||||
}
|
||||
res = ES_GetTicketViews(titleID, views, numviews);
|
||||
if(res < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
write32(0x80003140, 0);
|
||||
|
||||
ES_LaunchTitleBackground(titleID, &views[0]);
|
||||
res = ES_LaunchTitleBackground(titleID, &views[0]);
|
||||
if(res < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
__ES_Reset();
|
||||
|
||||
// Mask IPC IRQ while we're busy reloading
|
||||
__MaskIrq(IRQ_PI_ACR);
|
||||
irq_handler = IRQ_Free(IRQ_PI_ACR);
|
||||
//__MaskIrq(IRQ_PI_ACR);
|
||||
//irq_handler = IRQ_Free(IRQ_PI_ACR);
|
||||
|
||||
while ((read32(0x80003140) >> 16) == 0)
|
||||
udelay(1000);
|
||||
|
||||
@ -81,10 +134,48 @@ void ReloadIOS(int version) {
|
||||
break;
|
||||
}
|
||||
|
||||
IRQ_Request(IRQ_PI_ACR, irq_handler, NULL);
|
||||
__UnmaskIrq(IRQ_PI_ACR);
|
||||
//IRQ_Request(IRQ_PI_ACR, irq_handler, NULL);
|
||||
//__UnmaskIrq(IRQ_PI_ACR);
|
||||
|
||||
__IPC_Reinitialize();
|
||||
__ES_Init();
|
||||
__STM_Init();
|
||||
}
|
||||
|
||||
newversion = IOS_GetVersion();
|
||||
|
||||
if(newversion != version) {
|
||||
return IOS_EMISMATCH;
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
s32 ReloadIOS(int version)
|
||||
{
|
||||
int ret = 0;
|
||||
int res = 0;
|
||||
|
||||
//res = __IOS_ShutdownSubsystems();
|
||||
if(res < 0) {
|
||||
ret = res;
|
||||
}
|
||||
|
||||
res = __ES_Init();
|
||||
if(res < 0) {
|
||||
ret = res;
|
||||
} else {
|
||||
res = LaunchNewIOS(version);
|
||||
if(res < 0) {
|
||||
ret = res;
|
||||
__ES_Close();
|
||||
}
|
||||
}
|
||||
|
||||
res = __IOS_InitializeSubsystems();
|
||||
if(res < 0) {
|
||||
ret = res;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* defined(HW_RVL) */
|
||||
|
17
source/sys.c
17
source/sys.c
@ -28,6 +28,7 @@
|
||||
#include "gui.h"
|
||||
#include "languages.h"
|
||||
#include "fatMounter.h"
|
||||
#include "thread.h"
|
||||
|
||||
|
||||
// Constants
|
||||
@ -478,7 +479,7 @@ char GetSysMenuRegion(u32 sysVersion) {
|
||||
case 54449: // mauifrog 4.1U
|
||||
case 481: //4.2U
|
||||
case 513: //4.3U
|
||||
//case 545:
|
||||
case 545:
|
||||
SysMenuRegion = 'U';
|
||||
break;
|
||||
case 130: //2.0E
|
||||
@ -521,7 +522,6 @@ char GetSysMenuRegion(u32 sysVersion) {
|
||||
SysMenuRegion = 'K';
|
||||
break;
|
||||
default:
|
||||
//SysMenuRegion = 'X';
|
||||
SysMenuRegion = getSystemMenuRegionFromContent();
|
||||
break;
|
||||
}
|
||||
@ -536,23 +536,19 @@ void zero_sig(signed_blob *sig)
|
||||
|
||||
|
||||
// Get the boot2 version
|
||||
u32 GetBoot2Version(void)
|
||||
inline u32 GetBoot2Version(void)
|
||||
{
|
||||
u32 boot2version = 0;
|
||||
|
||||
if (ES_GetBoot2Version(&boot2version) < 0) boot2version = 0;
|
||||
|
||||
return boot2version;
|
||||
}
|
||||
|
||||
|
||||
// Get the console ID
|
||||
u32 GetDeviceID(void)
|
||||
inline u32 GetDeviceID(void)
|
||||
{
|
||||
u32 deviceId = 0;
|
||||
|
||||
if (ES_GetDeviceID(&deviceId) < 0) deviceId = 0;
|
||||
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
@ -631,7 +627,7 @@ bool CheckVersionPatch(void)
|
||||
|
||||
//RemoveBogusTicket();
|
||||
|
||||
/*gpritnf();
|
||||
/*gprintf();
|
||||
|
||||
int ret2 = ES_AddTitleStart((signed_blob *)v1_tmd, v1_tmd_size, (signed_blob *)v1_cert, v1_cert_size, 0, 0);
|
||||
if (ret2 >= 0) ES_AddTitleCancel();
|
||||
@ -854,7 +850,7 @@ char *url_encode(char *str) {
|
||||
}
|
||||
|
||||
void transmitSyscheck(char ReportBuffer[200][100], int *lines) {
|
||||
|
||||
ResumeThread();
|
||||
printLoadingBar(TXT_Upload, 0);
|
||||
gprintf("TempReport bauen\n");
|
||||
|
||||
@ -899,6 +895,7 @@ void transmitSyscheck(char ReportBuffer[200][100], int *lines) {
|
||||
|
||||
http_get_result(&http_status, &outbuf, &lenght);
|
||||
printLoadingBar(TXT_Upload, 100);
|
||||
PauseThread();
|
||||
|
||||
(*lines)++;
|
||||
memset(ReportBuffer[*lines], 0, 100);
|
||||
|
@ -44,13 +44,13 @@ char miosInfo[128] = {0};
|
||||
extern void __exception_setreload(int t);
|
||||
|
||||
// Stripped down version of IOS_ReloadIOS, run inline
|
||||
//inline void ReloadIOS(int version) {
|
||||
// //__IOS_ShutdownSubsystems();
|
||||
// __ES_Init();
|
||||
// __IOS_LaunchNewIOS(version);
|
||||
// __IOS_InitializeSubsystems();
|
||||
// //WII_LaunchTitle(TITLE_ID(0x00000001,version));
|
||||
//}
|
||||
inline void ReloadIOS2(int version) {
|
||||
//__IOS_ShutdownSubsystems();
|
||||
__ES_Init();
|
||||
__IOS_LaunchNewIOS(version);
|
||||
__IOS_InitializeSubsystems();
|
||||
//WII_LaunchTitle(TITLE_ID(0x00000001,version));
|
||||
}
|
||||
|
||||
int get_title_ios(u64 title) {
|
||||
s32 ret, fd;
|
||||
@ -366,9 +366,12 @@ int main(int argc, char **argv)
|
||||
|
||||
u32 tempTitles;
|
||||
if (ES_GetNumTitles(&tempTitles) < 0) {
|
||||
PauseThread();
|
||||
printError(ERR_GetNrOfTitles);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
//return false;
|
||||
}
|
||||
|
||||
s32 nbTitles = tempTitles;
|
||||
@ -379,7 +382,8 @@ int main(int argc, char **argv)
|
||||
sprintf(MSG_Buffer, ERR_AllocateMemory, titles);
|
||||
printError(MSG_Buffer);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Get list of titles
|
||||
@ -388,7 +392,8 @@ int main(int argc, char **argv)
|
||||
if (ES_GetTitles(titles, nbTitles) < 0) {
|
||||
printError(ERR_GetTitleList);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int i;
|
||||
@ -489,7 +494,8 @@ int main(int argc, char **argv)
|
||||
sprintf(MSG_Buffer, ERR_GetIosTMDSize, ios[i].titleID);
|
||||
printError(MSG_Buffer);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
iosTMDBuffer = (signed_blob*)memalign(32, (tmdSize+31)&(~31));
|
||||
@ -503,7 +509,8 @@ int main(int argc, char **argv)
|
||||
sprintf(MSG_Buffer, ERR_GetIosTMD, ios[i].titleID);
|
||||
printError(MSG_Buffer);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
iosTMD = (tmd*)SIGNATURE_PAYLOAD(iosTMDBuffer);
|
||||
@ -578,7 +585,8 @@ int main(int argc, char **argv)
|
||||
sprintf(MSG_Buffer, ERR_GetIosTMDSize, 2);
|
||||
printError(MSG_Buffer);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
iosTMDBuffer = (signed_blob*)memalign(32, (tmdSize+31)&(~31));
|
||||
@ -590,7 +598,8 @@ int main(int argc, char **argv)
|
||||
sprintf(MSG_Buffer, ERR_GetIosTMD, 2);
|
||||
printError(MSG_Buffer);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(0x20);
|
||||
@ -630,7 +639,8 @@ int main(int argc, char **argv)
|
||||
if (!GetCertificates()) {
|
||||
printError(ERR_GetCertificates);
|
||||
sleep(5);
|
||||
return false;
|
||||
deinitGUI();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//Select an IOS to test
|
||||
@ -758,8 +768,8 @@ int main(int argc, char **argv)
|
||||
// Reload IOS
|
||||
gprintf("// IOS_ReloadIOS(%d)\n", ios[i].titleID);
|
||||
logfile("// IOS_ReloadIOS(%d)\r\n", ios[i].titleID);
|
||||
IOS_ReloadIOS(ios[i].titleID);
|
||||
//ReloadIOS(ios[i].titleID);
|
||||
//IOS_ReloadIOS(ios[i].titleID);
|
||||
ReloadIOS(ios[i].titleID);
|
||||
|
||||
// Test fake signature
|
||||
gprintf("// Test fake signature\n");
|
||||
@ -825,7 +835,8 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
// Reload the running IOS
|
||||
IOS_ReloadIOS(runningIOS);
|
||||
//IOS_ReloadIOS(runningIOS);
|
||||
ReloadIOS(runningIOS);
|
||||
sprintf(MSG_Buffer, MSG_ReloadIOS, runningIOS, runningIOSRevision);
|
||||
printLoading(MSG_Buffer);
|
||||
//usleep(250000);
|
||||
@ -1179,7 +1190,8 @@ int main(int argc, char **argv)
|
||||
if (wpressed & WPAD_BUTTON_HOME) {
|
||||
// Unmount the SD Card
|
||||
UnmountSD();
|
||||
if(*LOADER_STUB) return true;
|
||||
deinitGUI();
|
||||
if(*LOADER_STUB) exit(0);;
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
@ -1187,6 +1199,7 @@ int main(int argc, char **argv)
|
||||
if (wpressed & WPAD_BUTTON_PLUS) {
|
||||
// Unmount the SD Card
|
||||
UnmountSD();
|
||||
deinitGUI();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
@ -1194,6 +1207,7 @@ int main(int argc, char **argv)
|
||||
if (wpressed & WPAD_BUTTON_MINUS) {
|
||||
// Unmount the SD Card
|
||||
UnmountSD();
|
||||
deinitGUI();
|
||||
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
#include <ogc/lwp.h>
|
||||
|
||||
@ -29,6 +30,7 @@ void * DrawCogThread(void *arg) {
|
||||
inline void InitThread(void) {
|
||||
memset (&stack, 0, STACKSIZE);
|
||||
LWP_CreateThread (&Cog_Thread, DrawCogThread, NULL, stack, STACKSIZE, PRIORITY);
|
||||
usleep(200);
|
||||
}
|
||||
|
||||
inline s32 PauseThread(void) {
|
||||
@ -41,6 +43,8 @@ inline s32 ResumeThread(void) {
|
||||
return LWP_ResumeThread(Cog_Thread);
|
||||
}
|
||||
|
||||
//inline s32 StopThread(void) {
|
||||
// return LWP_JoinThread(Cog_Thread, NULL);
|
||||
//}
|
||||
inline s32 StopThread(void) {
|
||||
done = 1;
|
||||
ResumeThread();
|
||||
return LWP_JoinThread(Cog_Thread, NULL);
|
||||
}
|
Loading…
Reference in New Issue
Block a user