mirror of
https://github.com/modmii/Any-Region-Changer-ModMii-Edition.git
synced 2024-11-22 16:19:19 +01:00
SetAttr :thumbs_down:
This commit is contained in:
parent
f1053f0ecb
commit
97e971d3a3
4
Makefile
4
Makefile
@ -18,7 +18,7 @@ include $(DEVKITPPC)/wii_rules
|
||||
TARGET := boot
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
DATA := data
|
||||
INCLUDES :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
@ -39,7 +39,7 @@ LIBS := -lwiiuse -lbte -logc -lm -lruntimeiospatch
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS :=
|
||||
LIBDIRS := $(CURDIR)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
|
BIN
data/certs.dat
BIN
data/certs.dat
Binary file not shown.
BIN
data/haxx.certs
BIN
data/haxx.certs
Binary file not shown.
@ -21,6 +21,9 @@ documentation would be appreciated but is not required.
|
||||
2.Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
Hi i made some changes
|
||||
- thepikachugamer
|
||||
|
||||
3.This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
@ -29,15 +32,17 @@ distribution.
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <gccore.h>
|
||||
|
||||
#include "id.h"
|
||||
#include "wiibasics.h"
|
||||
#include "detect_settings.h"
|
||||
#include "wiibasics.h"
|
||||
|
||||
u16 get_installed_title_version(u64 title)
|
||||
/* (gdb) print (unsigned short)-1
|
||||
* $1 = 65535
|
||||
* This is a valid version number */
|
||||
// u16 get_installed_title_version(u64 title)
|
||||
s32 get_installed_title_version(u64 title)
|
||||
{
|
||||
s32 ret, fd;
|
||||
static char filepath[256] ATTRIBUTE_ALIGN(32);
|
||||
static char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
// Check to see if title exists
|
||||
if (ES_GetDataDir(title, filepath) >= 0)
|
||||
@ -56,37 +61,29 @@ u16 get_installed_title_version(u64 title)
|
||||
|
||||
sprintf(filepath, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title));
|
||||
|
||||
ret = ISFS_Open(filepath, ISFS_OPEN_READ);
|
||||
if (ret <= 0)
|
||||
fd = ret = ISFS_Open(filepath, ISFS_OPEN_READ);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ISFS_Open (ret = %d)\n", ret);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
fd = ret;
|
||||
|
||||
ret = ISFS_Seek(fd, 0x1dc, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ISFS_Seek (ret = %d)\n", ret);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ISFS_Read(fd, tmd_buf, 2);
|
||||
ISFS_Close(fd);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ISFS_Read (ret = %d)\n", ret);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ISFS_Close(fd);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ISFS_Close (ret = %d)\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return be16(tmd_buf);
|
||||
return *(u16*)tmd_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -98,13 +95,14 @@ u16 get_installed_title_version(u64 title)
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_GetStoredTMD: %d\n", ret);
|
||||
return -1;
|
||||
// return -1;
|
||||
return ret;
|
||||
}
|
||||
tmd *t = SIGNATURE_PAYLOAD(s_tmd);
|
||||
return t->title_version;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return -106;
|
||||
}
|
||||
|
||||
u64 get_title_ios(u64 title)
|
||||
@ -159,7 +157,8 @@ u64 get_title_ios(u64 title)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return be64(tmd_buf);
|
||||
// it's very nicely aligned i don't think the broadway will crash with this one
|
||||
return *(u64*)tmd_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -181,122 +180,93 @@ u64 get_title_ios(u64 title)
|
||||
}
|
||||
|
||||
/* Get Sysmenu Region identifies the region of the system menu (not your Wii)
|
||||
by looking into it's resource content file for region information. */
|
||||
by looking into it's resource content file for region information. */ // <-- Semibricked Wiis:
|
||||
char get_sysmenu_region(void)
|
||||
{
|
||||
s32 ret, cfd;
|
||||
static u8 fbuffer[0x500] ATTRIBUTE_ALIGN(32);
|
||||
static tikview viewdata[0x10] ATTRIBUTE_ALIGN(32);
|
||||
u32 views;
|
||||
static u64 tid ATTRIBUTE_ALIGN(32) = TITLE_ID(1, 2);
|
||||
u8 region, match[] = "FINAL";
|
||||
s32 ret;
|
||||
u16 version;
|
||||
|
||||
/*ret = ES_SetUID(TITLE_ID(1,2));
|
||||
if (ret){
|
||||
printf("Error! ES_GetSetUID %d\n", ret);
|
||||
wait_anyKey();
|
||||
version = get_installed_title_version(TITLE_ID(1, 2));
|
||||
if (version <= 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ES_GetTitleID(&tid);
|
||||
if (ret){
|
||||
printf("Error! ES_GetTitleID %d\n", ret);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
if (tid != TITLE_ID(1,2)){
|
||||
printf("Error! Not System Menu! %016llx\n", tid);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
ret = ES_OpenContent(1);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_OpenContent (ret = %d)\n", ret);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}*/
|
||||
/* "mauifrog's 4.1 mod"(?) */
|
||||
if ((version / 1000) == 54)
|
||||
version %= 1000;
|
||||
|
||||
ret = ES_GetNumTicketViews(tid, &views);
|
||||
if (ret < 0)
|
||||
switch (version & 0b0000000000001111)
|
||||
{
|
||||
printf(" Error! ES_GetNumTickets (ret = %d)\n", ret);
|
||||
wait_anyKey();
|
||||
return ret;
|
||||
}
|
||||
case 0:
|
||||
return 'J';
|
||||
case 1:
|
||||
return 'U';
|
||||
case 2:
|
||||
return 'E';
|
||||
case 6:
|
||||
return 'K';
|
||||
|
||||
if (!views)
|
||||
{
|
||||
printf(" No tickets found!\n");
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
else if (views > 16)
|
||||
{
|
||||
printf(" Too many ticket views! (views = %d)\n", views);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ES_GetTicketViews(tid, viewdata, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_OpenTitleContent (ret = %d)\n", ret);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ES_OpenTitleContent(tid, viewdata, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_OpenTitleContent (ret = %d)\n", ret);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
|
||||
cfd = ret;
|
||||
region = 0;
|
||||
while (!region)
|
||||
{
|
||||
int i;
|
||||
ret = ES_ReadContent(cfd, fbuffer, 0x500);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_ReadContent (ret = %d)\n", ret);
|
||||
default:
|
||||
printf("Infected system menu (version number is %hu)\n", version);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < 0x500; i++)
|
||||
// Plan B
|
||||
tikview view ATTRIBUTE_ALIGN(32) = {};
|
||||
s32 cfd;
|
||||
char region = 0;
|
||||
unsigned char buffer[0x1000] = {};
|
||||
const char search[] = "\\ipl\\bin\\RVL\\Final_";
|
||||
|
||||
ret = ES_GetTicketViews(TITLE_ID(1, 2), &view, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_GetTicketViews (ret = %i)\n", ret);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// .......right, this isn't a vWii with Priiloader installed lol
|
||||
cfd = ret = ES_OpenTitleContent(TITLE_ID(1, 2), &view, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_OpenTitleContent (ret = %i)\n", ret);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
ret = ES_ReadContent(cfd, buffer, sizeof(buffer));
|
||||
if (ret <= 0)
|
||||
break;
|
||||
|
||||
for (int i = 0; i < (ret - sizeof(search)); i++)
|
||||
{
|
||||
if (fbuffer[i] == 'F')
|
||||
// Not looking for the null byte!!!!
|
||||
if (memcmp(buffer, search, sizeof(search) - 1) == 0)
|
||||
{
|
||||
if (!memcmp(&fbuffer[i], match, 6))
|
||||
{
|
||||
region = fbuffer[i + 6];
|
||||
break;
|
||||
}
|
||||
region = *(buffer + i + strlen(search));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = ES_CloseContent(cfd);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Error! ES_CloseContent (ret = %d)\n", ret);
|
||||
wait_anyKey();
|
||||
return 0;
|
||||
|
||||
if (region)
|
||||
break;
|
||||
}
|
||||
|
||||
switch (region)
|
||||
ES_CloseContent(cfd);
|
||||
if (ret < 0)
|
||||
{
|
||||
case 'U':
|
||||
case 'E':
|
||||
case 'J':
|
||||
case 'K':
|
||||
return region;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
printf("Error! ES_ReadContent (ret = %i)\n", ret);
|
||||
wait_anyKey();
|
||||
}
|
||||
}
|
||||
else if (!region)
|
||||
{
|
||||
printf("Unable to identify system menu region!!\n");
|
||||
wait_anyKey();
|
||||
}
|
||||
|
||||
return region;
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ documentation would be appreciated but is not required.
|
||||
2.Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
Hi i made some changes
|
||||
- thepikachugamer
|
||||
|
||||
3.This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
@ -30,7 +33,7 @@ distribution.
|
||||
#define __SYSMENU_DETECT_H_
|
||||
|
||||
// Get the title version of a given title
|
||||
u16 get_installed_title_version(u64 title);
|
||||
s32 get_installed_title_version(u64 title);
|
||||
|
||||
// Get the IOS version of a given title
|
||||
u64 get_title_ios(u64 title);
|
||||
|
250
source/id.c
250
source/id.c
@ -1,250 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
id.c -- ES Identification code
|
||||
|
||||
Copyright (C) 2008 tona
|
||||
Unless other credit specified
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1.The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2.Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3.This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gccore.h>
|
||||
|
||||
#include "wiibasics.h"
|
||||
#include "id.h"
|
||||
#include "gecko.h"
|
||||
#include "sha1.h"
|
||||
#include "certs_dat.h"
|
||||
|
||||
/* Debug functions adapted from libogc's es.c */
|
||||
//#define DEBUG_ES
|
||||
//#define DEBUG_IDENT
|
||||
#define ISALIGNED(x) ((((u32)x) & 0x1F) == 0)
|
||||
|
||||
static u8 su_tmd[0x208] ATTRIBUTE_ALIGN(32);
|
||||
static u8 su_tik[STD_SIGNED_TIK_SIZE] ATTRIBUTE_ALIGN(32);
|
||||
int su_id_filled = 0;
|
||||
|
||||
#ifdef DEBUG_IDENT
|
||||
s32 __sanity_check_certlist(const signed_blob *certs, u32 certsize)
|
||||
{
|
||||
int count = 0;
|
||||
signed_blob *end;
|
||||
|
||||
if (!certs || !certsize)
|
||||
return 0;
|
||||
|
||||
end = (signed_blob *)(((u8 *)certs) + certsize);
|
||||
while (certs != end)
|
||||
{
|
||||
#ifdef DEBUG_ES
|
||||
printf("Checking certificate at %p\n", certs);
|
||||
#endif
|
||||
certs = ES_NextCert(certs);
|
||||
if (!certs)
|
||||
return 0;
|
||||
count++;
|
||||
}
|
||||
#ifdef DEBUG_ES
|
||||
printf("Num of certificates: %d\n", count);
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
void zero_sig(signed_blob *sig)
|
||||
{
|
||||
u8 *sig_ptr = (u8 *)sig;
|
||||
memset(sig_ptr + 4, 0, SIGNATURE_SIZE(sig) - 4);
|
||||
}
|
||||
|
||||
void brute_tmd(tmd *p_tmd)
|
||||
{
|
||||
u16 fill;
|
||||
for (fill = 0; fill < 65535; fill++)
|
||||
{
|
||||
p_tmd->fill2 = fill;
|
||||
sha1 hash;
|
||||
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);
|
||||
SHA1((u8 *)p_tmd, TMD_SIZE(p_tmd), hash);
|
||||
;
|
||||
|
||||
if (hash[0] == 0)
|
||||
{
|
||||
// debug_printf("setting fill3 to %04hx\n", fill);
|
||||
return;
|
||||
}
|
||||
}
|
||||
printf("Unable to fix tmd :(\n");
|
||||
exit(4);
|
||||
}
|
||||
|
||||
void brute_tik(tik *p_tik)
|
||||
{
|
||||
u16 fill;
|
||||
for (fill = 0; fill < 65535; fill++)
|
||||
{
|
||||
p_tik->padding = fill;
|
||||
sha1 hash;
|
||||
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);
|
||||
SHA1((u8 *)p_tik, sizeof(tik), hash);
|
||||
|
||||
if (hash[0] == 0)
|
||||
return;
|
||||
}
|
||||
printf("Unable to fix tik :(\n");
|
||||
exit(5);
|
||||
}
|
||||
|
||||
void forge_tmd(signed_blob *s_tmd)
|
||||
{
|
||||
// debug_printf("forging tmd sig");
|
||||
zero_sig(s_tmd);
|
||||
brute_tmd(SIGNATURE_PAYLOAD(s_tmd));
|
||||
}
|
||||
|
||||
void forge_tik(signed_blob *s_tik)
|
||||
{
|
||||
// debug_printf("forging tik sig");
|
||||
zero_sig(s_tik);
|
||||
brute_tik(SIGNATURE_PAYLOAD(s_tik));
|
||||
}
|
||||
|
||||
void Make_SUID(void)
|
||||
{
|
||||
signed_blob *s_tmd, *s_tik;
|
||||
tmd *p_tmd;
|
||||
tik *p_tik;
|
||||
|
||||
memset(su_tmd, 0, sizeof su_tmd);
|
||||
memset(su_tik, 0, sizeof su_tik);
|
||||
s_tmd = (signed_blob *)&su_tmd[0];
|
||||
s_tik = (signed_blob *)&su_tik[0];
|
||||
*s_tmd = *s_tik = 0x10001;
|
||||
p_tmd = (tmd *)SIGNATURE_PAYLOAD(s_tmd);
|
||||
p_tik = (tik *)SIGNATURE_PAYLOAD(s_tik);
|
||||
|
||||
strcpy(p_tmd->issuer, "Root-CA00000001-CP00000004");
|
||||
p_tmd->title_id = TITLE_ID(1, 2);
|
||||
|
||||
p_tmd->num_contents = 1;
|
||||
|
||||
forge_tmd(s_tmd);
|
||||
|
||||
strcpy(p_tik->issuer, "Root-CA00000001-XS00000003");
|
||||
p_tik->ticketid = 0x000038A45236EE5FLL;
|
||||
p_tik->titleid = TITLE_ID(1, 2);
|
||||
|
||||
memset(p_tik->cidx_mask, 0xFF, 0x20);
|
||||
forge_tik(s_tik);
|
||||
|
||||
su_id_filled = 1;
|
||||
}
|
||||
|
||||
s32 Identify(const u8 *certs, u32 certs_size, const u8 *idtmd, u32 idtmd_size, const u8 *idticket, u32 idticket_size)
|
||||
{
|
||||
s32 ret;
|
||||
u32 keyid = 0;
|
||||
ret = ES_Identify((signed_blob *)certs, certs_size, (signed_blob *)idtmd, idtmd_size, (signed_blob *)idticket, idticket_size, &keyid);
|
||||
if (ret < 0)
|
||||
{
|
||||
switch (ret)
|
||||
{
|
||||
case ES_EINVAL:
|
||||
printf("Error! ES_Identify (ret = %d;) Data invalid!\n", ret);
|
||||
break;
|
||||
case ES_EALIGN:
|
||||
printf("Error! ES_Identify (ret = %d;) Data not aligned!\n", ret);
|
||||
break;
|
||||
case ES_ENOTINIT:
|
||||
printf("Error! ES_Identify (ret = %d;) ES not initialized!\n", ret);
|
||||
break;
|
||||
case ES_ENOMEM:
|
||||
printf("Error! ES_Identify (ret = %d;) No memory!\n", ret);
|
||||
break;
|
||||
default:
|
||||
printf("Error! ES_Identify (ret = %d)\n", ret);
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG_IDENT
|
||||
printf("\tTicket: %u Std: %u Max: %u\n", idticket_size, STD_SIGNED_TIK_SIZE, MAX_SIGNED_TMD_SIZE);
|
||||
printf("\tTMD invalid? %d %d %d Tik invalid? %d %d\n", !(signed_blob *)idtmd, !idtmd_size, !IS_VALID_SIGNATURE((signed_blob *)idtmd), !(signed_blob *)idticket, !IS_VALID_SIGNATURE((signed_blob *)idticket));
|
||||
printf("\tCerts: Sane? %d\n", __sanity_check_certlist((signed_blob *)certs, certs_size));
|
||||
if (!ISALIGNED(certs))
|
||||
printf("\tCertificate data is not aligned!\n");
|
||||
if (!ISALIGNED(idtmd))
|
||||
printf("\tTMD data is not aligned!\n");
|
||||
if (!ISALIGNED(idticket))
|
||||
printf("\tTicket data is not aligned!\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
printf("OK!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 Identify_SU(void)
|
||||
{
|
||||
if (!su_id_filled)
|
||||
Make_SUID();
|
||||
|
||||
gprintf("\nIdentifying as SU...");
|
||||
fflush(stdout);
|
||||
return Identify(certs_dat, certs_dat_size, su_tmd, sizeof su_tmd, su_tik, sizeof su_tik);
|
||||
}
|
||||
|
||||
s32 Identify_SysMenu(void)
|
||||
{
|
||||
s32 ret;
|
||||
u32 sysmenu_tmd_size, sysmenu_ticket_size;
|
||||
// static u8 certs[0xA00] ATTRIBUTE_ALIGN(32);
|
||||
static u8 sysmenu_tmd[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
||||
static u8 sysmenu_ticket[STD_SIGNED_TIK_SIZE] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
/*printf("\nPulling Certs...");
|
||||
ret = ISFS_ReadFileToArray ("/sys/certs.sys", certs, 0xA00, &certs_size);
|
||||
if (ret < 0) {
|
||||
printf("\tReading Certs failed!\n");
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
printf("\nPulling Sysmenu TMD...");
|
||||
ret = ISFS_ReadFileToArray("/title/00000001/00000002/content/title.tmd", sysmenu_tmd, MAX_SIGNED_TMD_SIZE, &sysmenu_tmd_size);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("\tReading TMD failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\nPulling Sysmenu Ticket...");
|
||||
ret = ISFS_ReadFileToArray("/ticket/00000001/00000002.tik", sysmenu_ticket, STD_SIGNED_TIK_SIZE, &sysmenu_ticket_size);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("\tReading TMD failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\nIdentifying as SysMenu...");
|
||||
fflush(stdout);
|
||||
return Identify(certs_dat, certs_dat_size, sysmenu_tmd, sysmenu_tmd_size, sysmenu_ticket, sysmenu_ticket_size);
|
||||
}
|
38
source/id.h
38
source/id.h
@ -1,38 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
id.h -- ES Identification code
|
||||
|
||||
Copyright (C) 2008 tona
|
||||
Unless other credit specified
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1.The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2.Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3.This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#ifndef _ID_H_
|
||||
#define _ID_H_
|
||||
|
||||
// Identify as the "super user"
|
||||
s32 Identify_SU(void);
|
||||
|
||||
// Identify as the system menu
|
||||
s32 Identify_SysMenu(void);
|
||||
|
||||
#endif
|
165
source/main.c
165
source/main.c
@ -38,7 +38,6 @@ distribution.
|
||||
#include "wiibasics.h"
|
||||
#include "runtimeiospatch.h"
|
||||
#include "sysconf.h"
|
||||
#include "id.h"
|
||||
#include "detect_settings.h"
|
||||
#include "gecko.h"
|
||||
|
||||
@ -47,17 +46,19 @@ distribution.
|
||||
#define WARNING_SIGN "\x1b[30;1m\x1b[43;1m/!\\\x1b[37;1m\x1b[40m"
|
||||
#define maxdata 256
|
||||
|
||||
u32 selected = 8;
|
||||
// Why was this unsigned? Lol
|
||||
int selected = 8;
|
||||
char page_contents[ITEMS][64];
|
||||
|
||||
int lang, area, game, video, region, country, countrystr, eula;
|
||||
u8 sadr[SADR_LENGTH];
|
||||
|
||||
char languages[][ITEMS] = {"Japanese ", "English ", "German ", "French ", "Spanish ", "Italian ", "Dutch "};
|
||||
char areas[][ITEMS] = {"Japan ", "USA ", "Europe ", "Australia", "Brazil ", "Taiwan ", "China ", "Korea ", "Hong Kong", "Asia ", "Latin Am.", "S. Africa"};
|
||||
char regions[][ITEMS] = {"Japan ", "USA ", "Europe ", "Korea "};
|
||||
char vmodes[][ITEMS] = {"NTSC ", "PAL ", "MPAL "};
|
||||
char eulas[][ITEMS] = {"Unread ", "Read "};
|
||||
static const char
|
||||
*languages[] = {"Japanese", "English", "German", "French", "Spanish", "Italian", "Dutch"}, // 9
|
||||
*areas[] = {"Japan", "USA", "Europe", "Australia", "Brazil", "Taiwan", "China", "Korea", "Hong Kong", "Asia", "Latin Am.", "S. Africa"}, // ?
|
||||
*regions[] = {"Japan", "USA", "Europe", "Korea"}, // 8
|
||||
*vmodes[] = {"NTSC", "PAL", "MPAL"}, // 8
|
||||
*eulas[] = {"Unread", "Read"}; // 8
|
||||
|
||||
void draw_credits()
|
||||
{
|
||||
@ -122,16 +123,23 @@ void getSettings(void)
|
||||
eula = SYSCONF_GetEULA();
|
||||
if (lang < 0 || area < 0 || game < 0 || video < 0 || (eula != SYSCONF_ENOENT && eula < 0))
|
||||
{
|
||||
printf("Error getting settings! %d, %d, %d, %d, %d\n", lang, area, game, video, eula);
|
||||
printf("Error getting settings!\n"
|
||||
"lang=%d\t"
|
||||
"area=%d\t"
|
||||
"game=%d\n"
|
||||
"video=%d\t"
|
||||
"eula=%d\t\n" , lang, area, game, video, eula);
|
||||
wait_anyKey();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (SYSCONF_GetLength("IPL.SADR") != SADR_LENGTH)
|
||||
handleError("IPL.SADR Length Incorrect", SYSCONF_GetLength("IPL.SADR"));
|
||||
|
||||
ret = SYSCONF_Get("IPL.SADR", sadr, SADR_LENGTH);
|
||||
if (ret < 0)
|
||||
handleError("SYSCONF_Get IPL.SADR", ret);
|
||||
|
||||
country = sadr[0];
|
||||
gprintf("\n\ncountry[%i] \n\n", country);
|
||||
}
|
||||
@ -144,18 +152,22 @@ void saveSettings(void)
|
||||
ret = SYSCONF_SetLanguage(lang);
|
||||
if (ret)
|
||||
handleError("SYSCONF_SetLanguage", ret);
|
||||
|
||||
if (area != SYSCONF_GetArea())
|
||||
ret = SYSCONF_SetArea(area);
|
||||
if (ret)
|
||||
handleError("SYSCONF_SetArea", ret);
|
||||
|
||||
if (game != SYSCONF_GetRegion())
|
||||
ret = SYSCONF_SetRegion(game);
|
||||
if (ret)
|
||||
handleError("SYSCONF_SetRegion", ret);
|
||||
|
||||
if (video != SYSCONF_GetVideo())
|
||||
ret = SYSCONF_SetVideo(video);
|
||||
if (ret)
|
||||
handleError("SYSCONF_SetVideo", ret);
|
||||
|
||||
if (eula != SYSCONF_GetEULA())
|
||||
ret = SYSCONF_SetEULA(eula);
|
||||
if (ret)
|
||||
@ -180,42 +192,45 @@ void saveSettings(void)
|
||||
wait_anyKey();
|
||||
}
|
||||
|
||||
void updateSelected(int delta)
|
||||
{
|
||||
if (selected + delta >= ITEMS || selected + delta < 0)
|
||||
return;
|
||||
static char* itos(int i) {
|
||||
static char buffer[12];
|
||||
sprintf(buffer, "%d", i);
|
||||
|
||||
if (delta != 0)
|
||||
{
|
||||
// Remove the cursor from the last selected item
|
||||
page_contents[selected][1] = ' ';
|
||||
page_contents[selected][45] = ' ';
|
||||
page_contents[selected][57] = ' ';
|
||||
// Set new cursor location
|
||||
selected += delta;
|
||||
}
|
||||
|
||||
// Add the cursor to the now-selected item
|
||||
page_contents[selected][1] = '>';
|
||||
page_contents[selected][45] = '<';
|
||||
page_contents[selected][57] = '>';
|
||||
return buffer;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
const char* value;
|
||||
} page_item;
|
||||
|
||||
void updatePage(void)
|
||||
{
|
||||
const page_item page_items[] =
|
||||
{
|
||||
{ "Language Setting", languages[lang] },
|
||||
{ "Console Area Setting", areas[area] },
|
||||
{ "Game Region setting", regions[game] },
|
||||
{ "Console Video Mode", vmodes[video] },
|
||||
{ "Shop Country Code", itos(country) },
|
||||
{ "End-User License Agreement", (eula == SYSCONF_ENOENT) ? "Disabled" : eulas[eula]},
|
||||
|
||||
sprintf(page_contents[0], " %-40s %10s \n", "Language Setting:", languages[lang]);
|
||||
sprintf(page_contents[1], " %-40s %10s \n", "Console Area Setting:", areas[area]);
|
||||
sprintf(page_contents[2], " %-40s %10s \n", "Game Region Setting:", regions[game]);
|
||||
sprintf(page_contents[3], " %-40s %10s \n", "Console Video Mode:", vmodes[video]);
|
||||
sprintf(page_contents[4], " %-40s %10d \n", "Shop Country Code:", country);
|
||||
sprintf(page_contents[5], " %-40s %10s \n", "Services EULA:", (eula == SYSCONF_ENOENT) ? "Disabled" : eulas[eula]);
|
||||
sprintf(page_contents[6], " %-40s %10s \n", "Revert Settings", "Revert ");
|
||||
sprintf(page_contents[7], " %-40s %10s \n", "Save Settings", "Save ");
|
||||
sprintf(page_contents[8], " %-40s %10s \n", "Auto Fix Settings ", "Fix ");
|
||||
sprintf(page_contents[9], " %-40s %10s \n", "Exit to the Homebrew Channel", "Exit ");
|
||||
{ "Revert Settings", "Revert" },
|
||||
{ "Save Settings", "Save" },
|
||||
{ "Auto Fix Settings", "Fix" },
|
||||
|
||||
updateSelected(0);
|
||||
{ "Return to the Homebrew Channel", "Exit" },
|
||||
{}
|
||||
};
|
||||
const char* s_selected = " %-40s < %s >";
|
||||
const char* s_deselected = " %-40s %s ";
|
||||
|
||||
for (int i = 0; page_items[i].name != NULL; i++)
|
||||
{
|
||||
sprintf(page_contents[i], (i == selected) ? s_selected : s_deselected,
|
||||
page_items[i].name, page_items[i].value);
|
||||
}
|
||||
}
|
||||
char AREAtoSysMenuRegion(int area)
|
||||
{
|
||||
@ -254,20 +269,30 @@ int main(int argc, char **argv)
|
||||
u32 buttons;
|
||||
int Current_Ios = 0;
|
||||
|
||||
ret = IOS_ReloadIOS(236);
|
||||
if (ret != 0)
|
||||
videoInit();
|
||||
ret = IosPatch_FULL(true, true, false, false, IOS_GetVersion());
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = IOS_ReloadIOS(249);
|
||||
if (ret != 0)
|
||||
ret = IOS_ReloadIOS(236);
|
||||
if (ret < 0)
|
||||
{
|
||||
IosPatch_FULL(true, true, false, false, 58);
|
||||
ret = IOS_ReloadIOS(249);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("\n\n\nUnable to find a suitable IOS to use. Consider updating the Homebrew Channel!\n");
|
||||
printf("Exiting in 5 seconds...\n");
|
||||
sleep(5);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
basicInit();
|
||||
|
||||
miscInit();
|
||||
ISFS_Initialize();
|
||||
WPAD_Init();
|
||||
|
||||
if (InitGecko())
|
||||
USBGeckoOutput();
|
||||
|
||||
Current_Ios = IOS_GetVersion();
|
||||
gprintf("\n\ncurrent_ios [%i] \n\n", Current_Ios);
|
||||
|
||||
@ -288,40 +313,40 @@ int main(int argc, char **argv)
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
PrintBanner();
|
||||
printf("\n------------------------------------------------------------------------");
|
||||
printf("Edit Region Settings");
|
||||
if (sysmenu_region != 0 && sysmenu_region != AREAtoSysMenuRegion(area))
|
||||
printf(" " WARNING_SIGN " \x1b[41;1mWARNING: AREA/SysMenu MISMATCH!\x1b[40m " WARNING_SIGN);
|
||||
printf("\n------------------------------------------------------------------------");
|
||||
for (i = 0; i < 4; i++)
|
||||
printf(page_contents[i]);
|
||||
|
||||
printf("\t Country Codes: \t1[JPN] 49[USA] 110[UK] 136[KOR]\n");
|
||||
for (i = 0; i < 8; i++)
|
||||
printf("%s\n", page_contents[i]);
|
||||
|
||||
printf("\n\t Country Codes: \t1[JPN] 49[USA] 110[UK] 136[KOR]\n");
|
||||
|
||||
for (i = i; i < 8; i++)
|
||||
printf(page_contents[i]);
|
||||
printf("------------------------------------------------------------------------");
|
||||
printf("Auto Fix - SysMenu Region: %c (v%u)\n", sysmenu_region, sysmenu_version);
|
||||
printf("------------------------------------------------------------------------");
|
||||
for (i = i; i < 9; i++)
|
||||
printf(page_contents[i]);
|
||||
printf("%s\n", page_contents[i]);
|
||||
printf("------------------------------------------------------------------------");
|
||||
printf("Exiting Options\n");
|
||||
printf("------------------------------------------------------------------------");
|
||||
for (i = i; i < ITEMS; i++)
|
||||
printf(page_contents[i]);
|
||||
printf("%s\n", page_contents[i]);
|
||||
printf("------------------------------------------------------------------------");
|
||||
Console_SetPosition(26, 0);
|
||||
printf("Change Selection: [%s%s %s%s]\t\t\t\t\t\tSelect: [A]\tCredits: [1]", LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW);
|
||||
buttons = wait_anyKey();
|
||||
gprintf("\n\nselected [%i] \n\n", selected);
|
||||
if (buttons & WPAD_BUTTON_DOWN)
|
||||
updateSelected(1);
|
||||
if (++selected > 9)
|
||||
selected = 0;
|
||||
|
||||
if (buttons & WPAD_BUTTON_UP)
|
||||
updateSelected(-1);
|
||||
if (--selected < 0)
|
||||
selected = 9;
|
||||
|
||||
if (buttons & WPAD_BUTTON_LEFT)
|
||||
{
|
||||
@ -412,15 +437,7 @@ int main(int argc, char **argv)
|
||||
saveSettings();
|
||||
break;
|
||||
case 8:
|
||||
if (sysmenu_region == 85)
|
||||
{ // usa
|
||||
lang = 1;
|
||||
area = 1;
|
||||
game = 1;
|
||||
video = 0;
|
||||
country = 49;
|
||||
}
|
||||
else if (sysmenu_region == 74)
|
||||
if (sysmenu_region == 'J')
|
||||
{ // jpn
|
||||
lang = 0;
|
||||
area = 0;
|
||||
@ -428,7 +445,15 @@ int main(int argc, char **argv)
|
||||
video = 0;
|
||||
country = 1;
|
||||
}
|
||||
else if (sysmenu_region == 69)
|
||||
else if (sysmenu_region == 'U')
|
||||
{ // usa
|
||||
lang = 1;
|
||||
area = 1;
|
||||
game = 1;
|
||||
video = 0;
|
||||
country = 49;
|
||||
}
|
||||
else if (sysmenu_region == 'E')
|
||||
{ // EUR/PAL
|
||||
lang = 1;
|
||||
area = 2;
|
||||
@ -436,7 +461,7 @@ int main(int argc, char **argv)
|
||||
video = 1;
|
||||
country = 110;
|
||||
}
|
||||
else if (sysmenu_region == 75)
|
||||
else if (sysmenu_region == 'K')
|
||||
{ // KOR
|
||||
lang = 1;
|
||||
area = 7;
|
||||
@ -446,12 +471,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nUnknown System Menu region \"%u\".\n", sysmenu_region);
|
||||
printf("\nUnknown System Menu region '%c' (v%hu).\n", sysmenu_region ? sysmenu_region : ' ', sysmenu_version);
|
||||
printf("Press any key to quit\n");
|
||||
wait_anyKey();
|
||||
exit(0);
|
||||
}
|
||||
saveSettings();
|
||||
selected--;
|
||||
// saveSettings();
|
||||
break;
|
||||
case 9:
|
||||
needbreak = true;
|
||||
@ -479,7 +505,8 @@ int main(int argc, char **argv)
|
||||
Console_SetPosition(26, 30);
|
||||
Console_SetColors(BLACK, 0, GREEN, 0);
|
||||
printf("Exiting");
|
||||
miscDeInit();
|
||||
ISFS_Deinitialize();
|
||||
WPAD_Shutdown();
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,141 +0,0 @@
|
||||
// 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
|
@ -45,15 +45,15 @@ distribution.
|
||||
#include "wiibasics.h"
|
||||
#endif
|
||||
|
||||
static int __sysconf_inited = 0;
|
||||
static int __sysconf_buffer_txt_decrypted = 0;
|
||||
static u8 __sysconf_buffer[0x4000] ATTRIBUTE_ALIGN(32);
|
||||
static char __sysconf_txt_buffer[0x101] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
static int __sysconf_inited = 0;
|
||||
static int __sysconf_buffer_txt_decrypted = 0;
|
||||
static int __sysconf_buffer_updated = 0;
|
||||
static int __sysconf_txt_buffer_updated = 0;
|
||||
|
||||
static const char __sysconf_file[] ATTRIBUTE_ALIGN(32) = "/shared2/sys/SYSCONF";
|
||||
// static const char __sysconf_txt_file[] ATTRIBUTE_ALIGN(32) = "/title/00000001/00000002/data/setting.txt";
|
||||
static const char __sysconf_txt_file[] ATTRIBUTE_ALIGN(32) = "/title/00000001/00000002/data/setting.txt";
|
||||
|
||||
int __SYSCONF_EndOfTextOffset(void)
|
||||
@ -173,24 +173,24 @@ s32 SYSCONF_Init(void)
|
||||
if (__sysconf_inited)
|
||||
return 0;
|
||||
|
||||
fd = IOS_Open(__sysconf_file, 1);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
ret = fd = ISFS_Open(__sysconf_file, ISFS_OPEN_READ);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
memset(__sysconf_buffer, 0, 0x4000);
|
||||
memset(__sysconf_txt_buffer, 0, 0x101);
|
||||
|
||||
ret = IOS_Read(fd, __sysconf_buffer, 0x4000);
|
||||
ret = ISFS_Read(fd, __sysconf_buffer, 0x4000);
|
||||
IOS_Close(fd);
|
||||
if (ret != 0x4000)
|
||||
return SYSCONF_EBADFILE;
|
||||
|
||||
fd = IOS_Open(__sysconf_txt_file, 1);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
ret = fd = ISFS_Open(__sysconf_txt_file, ISFS_OPEN_READ);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = IOS_Read(fd, __sysconf_txt_buffer, 0x100);
|
||||
IOS_Close(fd);
|
||||
ret = ISFS_Read(fd, __sysconf_txt_buffer, 0x100);
|
||||
ISFS_Close(fd);
|
||||
if (ret != 0x100)
|
||||
return SYSCONF_EBADFILE;
|
||||
|
||||
@ -205,7 +205,6 @@ s32 SYSCONF_Init(void)
|
||||
|
||||
int __SYSCONF_WriteTxtBuffer(void)
|
||||
{
|
||||
u64 tid;
|
||||
int ret, fd;
|
||||
|
||||
if (!__sysconf_inited)
|
||||
@ -214,6 +213,7 @@ int __SYSCONF_WriteTxtBuffer(void)
|
||||
if (!__sysconf_txt_buffer_updated)
|
||||
return 0;
|
||||
|
||||
/* guys just use libruntimeiospatch or a cios for nand perms
|
||||
ret = ES_GetTitleID(&tid);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -227,21 +227,24 @@ int __SYSCONF_WriteTxtBuffer(void)
|
||||
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 3, 3, 3);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*/
|
||||
|
||||
fd = IOS_Open(__sysconf_txt_file, 2);
|
||||
fd = ISFS_Open(__sysconf_txt_file, ISFS_OPEN_WRITE);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
ret = IOS_Write(fd, __sysconf_txt_buffer, 0x100);
|
||||
IOS_Close(fd);
|
||||
ret = ISFS_Write(fd, __sysconf_txt_buffer, 0x100);
|
||||
ISFS_Close(fd);
|
||||
if (ret != 0x100)
|
||||
return SYSCONF_EBADWRITE;
|
||||
|
||||
/*
|
||||
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 1, 1, 1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*/
|
||||
|
||||
__sysconf_buffer_updated = 0;
|
||||
__sysconf_txt_buffer_updated = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -263,7 +266,7 @@ int __SYSCONF_WriteBuffer(void)
|
||||
ret = IOS_Write(fd, __sysconf_buffer, 0x4000);
|
||||
IOS_Close(fd);
|
||||
if (ret != 0x4000)
|
||||
return SYSCONF_EBADFILE;
|
||||
return SYSCONF_EBADWRITE;
|
||||
|
||||
__sysconf_buffer_updated = 0;
|
||||
return 0;
|
||||
|
@ -21,6 +21,9 @@ documentation would be appreciated but is not required.
|
||||
2.Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
i modified it a ton sorry tona
|
||||
- thepikachugamer
|
||||
|
||||
3.This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
@ -33,7 +36,6 @@ distribution.
|
||||
#include <string.h>
|
||||
|
||||
#include "wiibasics.h"
|
||||
#include "id.h"
|
||||
#include "gecko.h"
|
||||
|
||||
#define MAX_WIIMOTES 4
|
||||
@ -42,54 +44,50 @@ static void *xfb = NULL;
|
||||
static GXRModeObj *rmode = NULL;
|
||||
int ConsoleRows;
|
||||
int ConsoleCols;
|
||||
u16 be16(const u8 *p)
|
||||
{
|
||||
return (p[0] << 8) | p[1];
|
||||
}
|
||||
|
||||
u32 be32(const u8 *p)
|
||||
/* What are these for anyways
|
||||
typedef struct
|
||||
{
|
||||
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
}
|
||||
u64 titleID;
|
||||
u32 uid;
|
||||
} uidEntry;
|
||||
|
||||
u64 be64(const u8 *p)
|
||||
uidEntry findUIDEntry(u64 titleID, u32 uid)
|
||||
{
|
||||
return ((u64)be32(p) << 32) | be32(p + 4);
|
||||
}
|
||||
s32 ret, fd;
|
||||
uidEntry entry ATTRIBUTE_ALIGN(0x20);
|
||||
|
||||
u32 getTitleIDUID(u64 titleID)
|
||||
{
|
||||
s32 ret, i;
|
||||
static u8 uid_buffer[0x1000] ATTRIBUTE_ALIGN(32);
|
||||
u32 size;
|
||||
ret = ISFS_ReadFileToArray("/sys/uid.sys", uid_buffer, 0x1000, &size);
|
||||
if (titleID && uid)
|
||||
return 0;
|
||||
|
||||
fd = ret = ISFS_Open("/sys/uid.sys", ISFS_OPEN_READ);
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < size; i += 12)
|
||||
if (be64(&uid_buffer[i]) == titleID)
|
||||
return be32(&uid_buffer[i + 8]);
|
||||
while (true)
|
||||
{
|
||||
ret = ISFS_Read(fd, &entry, sizeof(uidEntry));
|
||||
if (ret < sizeof(uidEntry))
|
||||
break;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u64 getUIDTitleID(u32 uid)
|
||||
{
|
||||
s32 ret, i;
|
||||
static u8 uid_buffer[0x1000] ATTRIBUTE_ALIGN(32);
|
||||
u32 size;
|
||||
ret = ISFS_ReadFileToArray("/sys/uid.sys", uid_buffer, 0x1000, &size);
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
|
||||
for (i = 8; i < size; i += 12)
|
||||
if (be32(&uid_buffer[i]) == uid)
|
||||
return be64(&uid_buffer[i - 8]);
|
||||
return 0;
|
||||
if (entry.titleID == titleID)
|
||||
{
|
||||
uid = entry.uid;
|
||||
break;
|
||||
}
|
||||
else if (entry.uid == uid)
|
||||
{
|
||||
titleID = entry.titleID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ISFS_Close(fd);
|
||||
return (uidEntry){ titleID, uid };
|
||||
}
|
||||
*/
|
||||
|
||||
/* Basic init taken pretty directly from the libOGC examples */
|
||||
void basicInit(void)
|
||||
void videoInit(void)
|
||||
{
|
||||
// Initialise the video system
|
||||
VIDEO_Init();
|
||||
@ -182,6 +180,7 @@ void PrintBanner()
|
||||
PrintCenter(text, ConsoleCols);
|
||||
Console_SetColors(BLACK, 0, WHITE, 2);
|
||||
}
|
||||
/*
|
||||
void miscInit(void)
|
||||
{
|
||||
int ret;
|
||||
@ -189,7 +188,8 @@ void miscInit(void)
|
||||
// This function initialises the attached controllers
|
||||
WPAD_Init();
|
||||
|
||||
Identify_SU();
|
||||
// NO
|
||||
// Identify_SU();
|
||||
|
||||
gprintf("Initializing Filesystem driver...");
|
||||
fflush(stdout);
|
||||
@ -198,7 +198,7 @@ void miscInit(void)
|
||||
if (ret < 0)
|
||||
{
|
||||
gprintf("\nError! ISFS_Initialize (ret = %d)\n", ret);
|
||||
wait_anyKey();
|
||||
// wait_anyKey();
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
@ -244,6 +244,7 @@ void miscDeInit(void)
|
||||
fflush(stdout);
|
||||
ISFS_Deinitialize();
|
||||
}
|
||||
*/
|
||||
|
||||
u32 getButtons(void)
|
||||
{
|
||||
@ -275,17 +276,7 @@ u32 wait_key(u32 button)
|
||||
u32 pressed;
|
||||
do
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
pressed = getButtons();
|
||||
if (pressed & WPAD_BUTTON_HOME)
|
||||
{
|
||||
Console_SetPosition(26, 0);
|
||||
ClearLine();
|
||||
Console_SetPosition(26, 30);
|
||||
Console_SetColors(BLACK, 0, GREEN, 0);
|
||||
printf("Exiting");
|
||||
exit(0);
|
||||
}
|
||||
pressed = wait_anyKey();
|
||||
} while (!(pressed & button));
|
||||
|
||||
return pressed;
|
||||
@ -352,9 +343,13 @@ bool yes_or_no(void)
|
||||
return yes;
|
||||
}
|
||||
|
||||
/* Reads a file from ISFS to an array in memory */
|
||||
/* Reads a file from ISFS to an array in memory
|
||||
s32 ISFS_ReadFileToArray(const char *filepath, u8 *filearray, u32 max_size, u32 *file_size)
|
||||
{
|
||||
printf("Stubbed. We have libruntimeiospatch!!");
|
||||
wait_anyKey();
|
||||
return -1;
|
||||
|
||||
s32 ret, fd;
|
||||
static fstats filestats ATTRIBUTE_ALIGN(32);
|
||||
|
||||
@ -405,9 +400,13 @@ s32 ISFS_ReadFileToArray(const char *filepath, u8 *filearray, u32 max_size, u32
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Writes from an array in memory to a file with ISFS */
|
||||
// Writes from an array in memory to a file with ISFS
|
||||
s32 ISFS_WriteFileFromArray(const char *filepath, const u8 *filearray, u32 array_size, u32 ownerID, u16 groupID, u8 attr, u8 own_perm, u8 group_perm, u8 other_perm)
|
||||
{
|
||||
printf("Stubbed. We have libruntimeiospatch!!");
|
||||
wait_anyKey();
|
||||
return -1;
|
||||
|
||||
s32 ret, fd = 0, out;
|
||||
u64 currentTid;
|
||||
u32 realownid;
|
||||
@ -509,7 +508,7 @@ s32 ISFS_WriteFileFromArray(const char *filepath, const u8 *filearray, u32 array
|
||||
return -1;
|
||||
}
|
||||
fd = 0;
|
||||
*/
|
||||
*//*
|
||||
ret = ISFS_GetAttr(filepath, &realownid, &realgroupid, &realattr, &realownperm, &realgroupperm, &realotherperm);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -567,3 +566,4 @@ cleanup:
|
||||
}
|
||||
return out;
|
||||
}
|
||||
*/
|
||||
|
@ -21,6 +21,8 @@ documentation would be appreciated but is not required.
|
||||
2.Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
See the source file
|
||||
|
||||
3.This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
@ -54,21 +56,31 @@ distribution.
|
||||
#define RIGHT_ARROW "\x10"
|
||||
|
||||
#define ARCME_VERSION 1.0
|
||||
#define ARCME_REV 6
|
||||
#define ARCME_REV 7
|
||||
|
||||
// be functions from segher's wii.git
|
||||
u16 be16(const u8 *p);
|
||||
u32 be32(const u8 *p);
|
||||
u64 be64(const u8 *p);
|
||||
u64 be34(const u8 *p);
|
||||
static inline u16 be16(const u8 *p)
|
||||
{
|
||||
return (p[0] << 8) | p[1];
|
||||
}
|
||||
|
||||
// Do basic Wii init: Video, console, WPAD
|
||||
void basicInit(void);
|
||||
static inline u32 be32(const u8 *p)
|
||||
{
|
||||
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
}
|
||||
|
||||
static inline u64 be64(const u8 *p)
|
||||
{
|
||||
return ((u64)be32(p) << 32) | be32(p + 4);
|
||||
}
|
||||
// u64 be34(const u8 *p); // < ???
|
||||
|
||||
void videoInit(void);
|
||||
|
||||
// Do our custom init: Identify and initialized ISFS driver
|
||||
void miscInit(void);
|
||||
// void miscInit(void);
|
||||
|
||||
void IdentSysMenu(void);
|
||||
// void IdentSysMenu(void);
|
||||
|
||||
// Clean up after ourselves (Deinit ISFS)
|
||||
void miscDeInit(void);
|
||||
@ -83,10 +95,10 @@ u32 wait_key(u32 button);
|
||||
void hex_print_array16(const u8 *array, u32 size);
|
||||
|
||||
/* Reads a file from ISFS to an array in memory */
|
||||
s32 ISFS_ReadFileToArray(const char *filepath, u8 *filearray, u32 max_size, u32 *file_size);
|
||||
// s32 ISFS_ReadFileToArray(const char *filepath, u8 *filearray, u32 max_size, u32 *file_size);
|
||||
|
||||
/* Writes from an array in memory to a file with ISFS */
|
||||
s32 ISFS_WriteFileFromArray(const char *filepath, const u8 *filearray, u32 array_size, u32 ownerID, u16 groupID, u8 attr, u8 own_perm, u8 group_perm, u8 other_perm);
|
||||
// s32 ISFS_WriteFileFromArray(const char *filepath, const u8 *filearray, u32 array_size, u32 ownerID, u16 groupID, u8 attr, u8 own_perm, u8 group_perm, u8 other_perm);
|
||||
|
||||
bool yes_or_no();
|
||||
void ClearScreen();
|
||||
|
Loading…
Reference in New Issue
Block a user