Compare commits

...

3 Commits

Author SHA1 Message Date
thepikachugamer 8b81077516
Merge 2456595f8b into f1053f0ecb 2023-12-20 18:41:42 -06:00
Naim2000 2456595f8b mm scrap that 2023-12-20 15:20:49 -05:00
Naim2000 d7df66655f fix emergency region detection 2023-12-20 14:23:21 -05:00
4 changed files with 176 additions and 27 deletions

143
include/runtimeiospatch.h Normal file
View File

@ -0,0 +1,143 @@
// 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, version 2.0.
// 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 2.0 for more details.
// Copyright (C) 2010 Joseph Jordan <joe.ftpii@psychlaw.com.au>
// Copyright (C) 2012-2013 damysteryman
// Copyright (C) 2012-2015 Christopher Bratusek <nano@jpberlin.de>
// Copyright (C) 2013 DarkMatterCore
// Copyright (C) 2014 megazig
// Copyright (C) 2015 FIX94
#ifndef __RUNTIMEIOSPATCH_H__
#define __RUNTIMEIOSPATCH_H__
/**
* Version information for Libruntimeiospatch.
*/
#define LIB_RUNTIMEIOSPATCH_VERSION "1.5.4"
//==============================================================================
// HW_RVL header
//==============================================================================
#if defined(HW_RVL) /* defined(HW_RVL) */
/**
*Returns true when HW_AHBPROT access can be applied
*/
#define AHBPROT_DISABLED (*(vu32*)0xcd800064 == 0xFFFFFFFF)
//==============================================================================
// Error code definitions:
//==============================================================================
#define ERROR_AHBPROT -5
#define ERROR_PATCH -7
//==============================================================================
// C++ header
//==============================================================================
#ifdef __cplusplus
extern "C" {
#endif
/* __cplusplus */
//==============================================================================
// Patchsets:
//==============================================================================
/*
Wii:
* DI Readlimit
* ISFS Permissions
* ES SetUID
* ES SetIdentify
* Hash Check (aka Trucha)
* New Hash Check (aka New Trucha)
* SSL patches
Sciifii:
* MEM2 Prot
* ES OpenTitleContent 1 & 2
* ES ReadContent Prot
* ES CloseContent
* ES TitleVersionCheck
* ES TitleDeleteCheck
vWii:
* Kill Anti-SystemTitle-Install 1, 2, 3, 4 & 5
*/
//==============================================================================
// Functions:
//==============================================================================
/**
* This function can be used to keep HW_AHBPROT access when going to reload IOS
* @param verbose Flag determing whether or not to print messages on-screen
* @example
* if(AHBPROT_DISABLED) {
* s32 ret;
* ret = IosPatch_AHBPROT(false);
* if (ret) {
* IOS_ReloadIOS(36);
* } else {
* printf("IosPatch_AHBPROT failed.");
* }
* }
* @return Signed 32bit integer representing code
* > 0 : Success - return equals to number of applied patches
* ERROR_AHBPROT : Error - No HW_AHBPROT access
*/
s32 IosPatch_AHBPROT(bool verbose);
/**
* This function applies patches on current IOS
* @see Patchsets
* @param wii Flag determing whether or not to apply Wii patches.
* @param sciifii Flag determing whether or not to apply extra Sciifii patches.
* @param vwii Flag determing whether or not to apply extra vWii patches.
* @param verbose Flag determing whether or not to print messages on-screen.
* @example if(AHBPROT_DISABLED) IosPatch_FULL(true, false, false, false);
* @return Signed 32bit integer representing code
* > 0 : Success - return equals to number of applied patches
* ERROR_AHBPROT : Error - No HW_AHBPROT access
* ERROR_PATCH : Error - Patching HW_AHBPROT access failed
*/
s32 IosPatch_RUNTIME(bool wii, bool sciifii, bool vwii, bool verbose);
/**
* This function combines IosPatch_AHBPROT + IOS_ReloadIOS + IosPatch_RUNTIME
* @see Patchsets
* @param wii Flag determing whether or not to apply Wii patches.
* @param sciifii Flag determing whether or not to apply extra Sciifii patches.
* @param vwii Flag determing whether or not to apply extra vWii patches.
* @param verbose Flag determing whether or not to print messages on-screen.
* @param IOS Which IOS to reload into.
* @example if(AHBPROT_DISABLED) IosPatch_FULL(true, false, false, false, 58);
* @return Signed 32bit integer representing code
* > 0 : Success - return equals to number of applied patches
* ERROR_AHBPROT : Error - No HW_AHBPROT access
* ERROR_PATCH : Error - Patching HW_AHBPROT access failed
*/
s32 IosPatch_FULL(bool wii, bool sciifii, bool vwii, bool verbose, int IOS);
//==============================================================================
// C++ footer
//==============================================================================
#ifdef __cplusplus
}
#endif /* __cplusplus */
//==============================================================================
// HW_RVL footer
//==============================================================================
#endif /* defined(HW_RVL) */
#endif

BIN
lib/libruntimeiospatch.a Normal file

Binary file not shown.

View File

@ -32,6 +32,7 @@ distribution.
#include <stdio.h>
#include <string.h>
#include <gccore.h>
#include <sys/param.h>
#include "detect_settings.h"
#include "wiibasics.h"
@ -207,23 +208,24 @@ char get_sysmenu_region(void)
default:
printf("Infected system menu (version number is %hu)\n", version);
printf("Press HOME to exit, any other button to try plan B.\n");
wait_anyKey();
break;
}
// Plan B
tikview view ATTRIBUTE_ALIGN(32) = {};
tikview view ATTRIBUTE_ALIGN(0x20) = {};
s32 cfd;
char region = 0;
unsigned char buffer[0x1000] = {};
const char search[] = "\\ipl\\bin\\RVL\\Final_";
const char search[] = "ipl\\bin\\RVL\\Final_";
unsigned char* buffer = NULL;
ret = ES_GetTicketViews(TITLE_ID(1, 2), &view, 1);
if (ret < 0)
{
printf("Error! ES_GetTicketViews (ret = %i)\n", ret);
wait_anyKey();
return 0;
return '?';
}
// .......right, this isn't a vWii with Priiloader installed lol
@ -232,41 +234,45 @@ char get_sysmenu_region(void)
{
printf("Error! ES_OpenTitleContent (ret = %i)\n", ret);
wait_anyKey();
return 0;
return '?';
}
while (true)
size_t size = ret = ES_SeekContent(cfd, 0, SEEK_END);
ES_SeekContent(cfd, 0, SEEK_SET);
buffer = memalign(0x20, size);
if (!buffer)
{
ret = ES_ReadContent(cfd, buffer, sizeof(buffer));
if (ret <= 0)
break;
for (int i = 0; i < (ret - sizeof(search)); i++)
{
// Not looking for the null byte!!!!
if (memcmp(buffer, search, sizeof(search) - 1) == 0)
{
region = *(buffer + i + strlen(search));
break;
}
}
if (region)
break;
printf("Out of memory!\n");
wait_anyKey();
exit(1);
}
ret = ES_ReadContent(cfd, buffer, size);
ES_CloseContent(cfd);
if (ret < 0)
{
printf("Error! ES_ReadContent (ret = %i)\n", ret);
wait_anyKey();
}
else if (!region)
for (int i = 0; i < size; i++)
{
printf("Unable to identify system menu region!!\n");
wait_anyKey();
if (memcmp(buffer + i, search, sizeof(search) - 1) == 0)
{
printf("Found you!!! offset=%08x\n%s\n", i, buffer + i);
region = *(buffer + i + strlen(search));
break;
}
}
return region;
free(buffer);
if (!region)
{
printf("Unable to identify system menu region!!\n");
sleep(2);
}
return region ? region : '?';
}

View File

@ -270,7 +270,7 @@ int main(int argc, char **argv)
int Current_Ios = 0;
videoInit();
ret = IosPatch_FULL(true, true, false, false, IOS_GetVersion());
ret = 0; // IosPatch_FULL(true, true, false, false, IOS_GetVersion());
if (ret < 0)
{
ret = IOS_ReloadIOS(236);