mirror of
https://github.com/modmii/Any-Region-Changer-ModMii-Edition.git
synced 2024-11-25 17:46:53 +01:00
Run automattic code formatting
This commit is contained in:
parent
ccbdddd2f2
commit
08c9eb7710
@ -34,17 +34,20 @@ distribution.
|
|||||||
#include "wiibasics.h"
|
#include "wiibasics.h"
|
||||||
#include "detect_settings.h"
|
#include "detect_settings.h"
|
||||||
|
|
||||||
u16 get_installed_title_version(u64 title) {
|
u16 get_installed_title_version(u64 title)
|
||||||
|
{
|
||||||
s32 ret, fd;
|
s32 ret, fd;
|
||||||
static char filepath[256] ATTRIBUTE_ALIGN(32);
|
static char filepath[256] ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
// Check to see if title exists
|
// Check to see if title exists
|
||||||
if (ES_GetDataDir(title, filepath) >= 0 ) {
|
if (ES_GetDataDir(title, filepath) >= 0)
|
||||||
|
{
|
||||||
u32 tmd_size;
|
u32 tmd_size;
|
||||||
static u8 tmd_buf[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
static u8 tmd_buf[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
ret = ES_GetStoredTMDSize(title, &tmd_size);
|
ret = ES_GetStoredTMDSize(title, &tmd_size);
|
||||||
if (ret < 0){
|
if (ret < 0)
|
||||||
|
{
|
||||||
// If we fail to use the ES function, try reading manually
|
// If we fail to use the ES function, try reading manually
|
||||||
// This is a workaround added since some IOS (like 21) don't like our
|
// This is a workaround added since some IOS (like 21) don't like our
|
||||||
// call to ES_GetStoredTMDSize
|
// call to ES_GetStoredTMDSize
|
||||||
@ -84,36 +87,40 @@ u16 get_installed_title_version(u64 title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return be16(tmd_buf);
|
return be16(tmd_buf);
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
// Normal versions of IOS won't have a problem, so we do things the "right" way.
|
// Normal versions of IOS won't have a problem, so we do things the "right" way.
|
||||||
|
|
||||||
// Some of this code adapted from bushing's title_lister.c
|
// Some of this code adapted from bushing's title_lister.c
|
||||||
signed_blob *s_tmd = (signed_blob *)tmd_buf;
|
signed_blob *s_tmd = (signed_blob *)tmd_buf;
|
||||||
ret = ES_GetStoredTMD(title, s_tmd, tmd_size);
|
ret = ES_GetStoredTMD(title, s_tmd, tmd_size);
|
||||||
if (ret < 0){
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("Error! ES_GetStoredTMD: %ld\n", ret);
|
printf("Error! ES_GetStoredTMD: %ld\n", ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tmd *t = SIGNATURE_PAYLOAD(s_tmd);
|
tmd *t = SIGNATURE_PAYLOAD(s_tmd);
|
||||||
return t->title_version;
|
return t->title_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 get_title_ios(u64 title) {
|
u64 get_title_ios(u64 title)
|
||||||
|
{
|
||||||
s32 ret, fd;
|
s32 ret, fd;
|
||||||
static char filepath[256] ATTRIBUTE_ALIGN(32);
|
static char filepath[256] ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
// Check to see if title exists
|
// Check to see if title exists
|
||||||
if (ES_GetDataDir(title, filepath) >= 0 ) {
|
if (ES_GetDataDir(title, filepath) >= 0)
|
||||||
|
{
|
||||||
u32 tmd_size;
|
u32 tmd_size;
|
||||||
static u8 tmd_buf[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
static u8 tmd_buf[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
ret = ES_GetStoredTMDSize(title, &tmd_size);
|
ret = ES_GetStoredTMDSize(title, &tmd_size);
|
||||||
if (ret < 0){
|
if (ret < 0)
|
||||||
|
{
|
||||||
// If we fail to use the ES function, try reading manually
|
// If we fail to use the ES function, try reading manually
|
||||||
// This is a workaround added since some IOS (like 21) don't like our
|
// This is a workaround added since some IOS (like 21) don't like our
|
||||||
// call to ES_GetStoredTMDSize
|
// call to ES_GetStoredTMDSize
|
||||||
@ -153,21 +160,22 @@ u64 get_title_ios(u64 title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return be64(tmd_buf);
|
return be64(tmd_buf);
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
// Normal versions of IOS won't have a problem, so we do things the "right" way.
|
// Normal versions of IOS won't have a problem, so we do things the "right" way.
|
||||||
|
|
||||||
// Some of this code adapted from bushing's title_lister.c
|
// Some of this code adapted from bushing's title_lister.c
|
||||||
signed_blob *s_tmd = (signed_blob *)tmd_buf;
|
signed_blob *s_tmd = (signed_blob *)tmd_buf;
|
||||||
ret = ES_GetStoredTMD(title, s_tmd, tmd_size);
|
ret = ES_GetStoredTMD(title, s_tmd, tmd_size);
|
||||||
if (ret < 0){
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("Error! ES_GetStoredTMD: %ld\n", ret);
|
printf("Error! ES_GetStoredTMD: %ld\n", ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tmd *t = SIGNATURE_PAYLOAD(s_tmd);
|
tmd *t = SIGNATURE_PAYLOAD(s_tmd);
|
||||||
return t->sys_version;
|
return t->sys_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -183,7 +191,6 @@ char get_sysmenu_region(void)
|
|||||||
static u64 tid ATTRIBUTE_ALIGN(32) = TITLE_ID(1, 2);
|
static u64 tid ATTRIBUTE_ALIGN(32) = TITLE_ID(1, 2);
|
||||||
u8 region, match[] = "FINAL";
|
u8 region, match[] = "FINAL";
|
||||||
|
|
||||||
|
|
||||||
/*ret = ES_SetUID(TITLE_ID(1,2));
|
/*ret = ES_SetUID(TITLE_ID(1,2));
|
||||||
if (ret){
|
if (ret){
|
||||||
printf("Error! ES_GetSetUID %d\n", ret);
|
printf("Error! ES_GetSetUID %d\n", ret);
|
||||||
@ -211,17 +218,21 @@ char get_sysmenu_region(void)
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
ret = ES_GetNumTicketViews(tid, &views);
|
ret = ES_GetNumTicketViews(tid, &views);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf(" Error! ES_GetNumTickets (ret = %ld)\n", ret);
|
printf(" Error! ES_GetNumTickets (ret = %ld)\n", ret);
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!views) {
|
if (!views)
|
||||||
|
{
|
||||||
printf(" No tickets found!\n");
|
printf(" No tickets found!\n");
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (views > 16) {
|
}
|
||||||
|
else if (views > 16)
|
||||||
|
{
|
||||||
printf(" Too many ticket views! (views = %ld)\n", views);
|
printf(" Too many ticket views! (views = %ld)\n", views);
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
return 0;
|
return 0;
|
||||||
@ -245,7 +256,8 @@ char get_sysmenu_region(void)
|
|||||||
|
|
||||||
cfd = ret;
|
cfd = ret;
|
||||||
region = 0;
|
region = 0;
|
||||||
while (!region){
|
while (!region)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
ret = ES_ReadContent(cfd, fbuffer, 0x500);
|
ret = ES_ReadContent(cfd, fbuffer, 0x500);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -255,15 +267,17 @@ char get_sysmenu_region(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0;i<0x500;i++) {
|
for (i = 0; i < 0x500; i++)
|
||||||
if (fbuffer[i] == 'F'){
|
{
|
||||||
if (!memcmp(&fbuffer[i], match, 6)){
|
if (fbuffer[i] == 'F')
|
||||||
|
{
|
||||||
|
if (!memcmp(&fbuffer[i], match, 6))
|
||||||
|
{
|
||||||
region = fbuffer[i + 6];
|
region = fbuffer[i + 6];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ret = ES_CloseContent(cfd);
|
ret = ES_CloseContent(cfd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -273,7 +287,8 @@ char get_sysmenu_region(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (region){
|
switch (region)
|
||||||
|
{
|
||||||
case 'U':
|
case 'U':
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'J':
|
case 'J':
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
//#include "fat2.h"
|
//#include "fat2.h"
|
||||||
//#include "install.h"
|
//#include "install.h"
|
||||||
|
|
||||||
|
|
||||||
/* init-globals */
|
/* init-globals */
|
||||||
static bool geckoinit = false;
|
static bool geckoinit = false;
|
||||||
char DirPath[64] = "Fat:/debug";
|
char DirPath[64] = "Fat:/debug";
|
||||||
@ -51,7 +50,8 @@ bool InitGecko()
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void gecko_log(const char *format, ...) {
|
void gecko_log(const char *format, ...)
|
||||||
|
{
|
||||||
// ret = Fat_MakeDir(DirPath);
|
// ret = Fat_MakeDir(DirPath);
|
||||||
// void *f = NULL;
|
// void *f = NULL;
|
||||||
gprintf("\n\n Fat Make Dir ret[%i] \n\n", ret);
|
gprintf("\n\n Fat Make Dir ret[%i] \n\n", ret);
|
||||||
@ -78,8 +78,10 @@ void gecko_log(const char *format, ...) {
|
|||||||
|
|
||||||
char ascii2(char s)
|
char ascii2(char s)
|
||||||
{
|
{
|
||||||
if (s < 0x20) return '.';
|
if (s < 0x20)
|
||||||
if (s > 0x7E) return '.';
|
return '.';
|
||||||
|
if (s > 0x7E)
|
||||||
|
return '.';
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,13 +100,15 @@ void hexdump2(void *d, int len)
|
|||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
if ((i + off) >= len)
|
if ((i + off) >= len)
|
||||||
gprintf(" ");
|
gprintf(" ");
|
||||||
else gprintf("%02x ", data[off + i]);
|
else
|
||||||
|
gprintf("%02x ", data[off + i]);
|
||||||
|
|
||||||
gprintf(" ");
|
gprintf(" ");
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
if ((i + off) >= len)
|
if ((i + off) >= len)
|
||||||
gprintf(" ");
|
gprintf(" ");
|
||||||
else gprintf("%c", ascii2(data[off + i]));
|
else
|
||||||
|
gprintf("%c", ascii2(data[off + i]));
|
||||||
gprintf("\n");
|
gprintf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,3 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
78
source/id.c
78
source/id.c
@ -37,8 +37,6 @@ distribution.
|
|||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
#include "certs_dat.h"
|
#include "certs_dat.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Debug functions adapted from libogc's es.c */
|
/* Debug functions adapted from libogc's es.c */
|
||||||
//#define DEBUG_ES
|
//#define DEBUG_ES
|
||||||
//#define DEBUG_IDENT
|
//#define DEBUG_IDENT
|
||||||
@ -54,15 +52,18 @@ s32 __sanity_check_certlist(const signed_blob *certs, u32 certsize)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
signed_blob *end;
|
signed_blob *end;
|
||||||
|
|
||||||
if(!certs || !certsize) return 0;
|
if (!certs || !certsize)
|
||||||
|
return 0;
|
||||||
|
|
||||||
end = (signed_blob *)(((u8 *)certs) + certsize);
|
end = (signed_blob *)(((u8 *)certs) + certsize);
|
||||||
while(certs != end) {
|
while (certs != end)
|
||||||
|
{
|
||||||
#ifdef DEBUG_ES
|
#ifdef DEBUG_ES
|
||||||
printf("Checking certificate at %p\n", certs);
|
printf("Checking certificate at %p\n", certs);
|
||||||
#endif
|
#endif
|
||||||
certs = ES_NextCert(certs);
|
certs = ES_NextCert(certs);
|
||||||
if(!certs) return 0;
|
if (!certs)
|
||||||
|
return 0;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_ES
|
#ifdef DEBUG_ES
|
||||||
@ -71,20 +72,25 @@ s32 __sanity_check_certlist(const signed_blob *certs, u32 certsize)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
void zero_sig(signed_blob *sig) {
|
void zero_sig(signed_blob *sig)
|
||||||
|
{
|
||||||
u8 *sig_ptr = (u8 *)sig;
|
u8 *sig_ptr = (u8 *)sig;
|
||||||
memset(sig_ptr + 4, 0, SIGNATURE_SIZE(sig) - 4);
|
memset(sig_ptr + 4, 0, SIGNATURE_SIZE(sig) - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void brute_tmd(tmd *p_tmd) {
|
void brute_tmd(tmd *p_tmd)
|
||||||
|
{
|
||||||
u16 fill;
|
u16 fill;
|
||||||
for(fill=0; fill<65535; fill++) {
|
for (fill = 0; fill < 65535; fill++)
|
||||||
|
{
|
||||||
p_tmd->fill2 = fill;
|
p_tmd->fill2 = fill;
|
||||||
sha1 hash;
|
sha1 hash;
|
||||||
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);
|
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);
|
||||||
SHA1((u8 *)p_tmd, TMD_SIZE(p_tmd), hash);;
|
SHA1((u8 *)p_tmd, TMD_SIZE(p_tmd), hash);
|
||||||
|
;
|
||||||
|
|
||||||
if (hash[0]==0) {
|
if (hash[0] == 0)
|
||||||
|
{
|
||||||
// debug_printf("setting fill3 to %04hx\n", fill);
|
// debug_printf("setting fill3 to %04hx\n", fill);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,34 +99,39 @@ void brute_tmd(tmd *p_tmd) {
|
|||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void brute_tik(tik *p_tik) {
|
void brute_tik(tik *p_tik)
|
||||||
|
{
|
||||||
u16 fill;
|
u16 fill;
|
||||||
for(fill=0; fill<65535; fill++) {
|
for (fill = 0; fill < 65535; fill++)
|
||||||
|
{
|
||||||
p_tik->padding = fill;
|
p_tik->padding = fill;
|
||||||
sha1 hash;
|
sha1 hash;
|
||||||
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);
|
// debug_printf("SHA1(%p, %x, %p)\n", p_tmd, TMD_SIZE(p_tmd), hash);
|
||||||
SHA1((u8 *)p_tik, sizeof(tik), hash);
|
SHA1((u8 *)p_tik, sizeof(tik), hash);
|
||||||
|
|
||||||
if (hash[0]==0) return;
|
if (hash[0] == 0)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
printf("Unable to fix tik :(\n");
|
printf("Unable to fix tik :(\n");
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void forge_tmd(signed_blob *s_tmd) {
|
void forge_tmd(signed_blob *s_tmd)
|
||||||
|
{
|
||||||
// debug_printf("forging tmd sig");
|
// debug_printf("forging tmd sig");
|
||||||
zero_sig(s_tmd);
|
zero_sig(s_tmd);
|
||||||
brute_tmd(SIGNATURE_PAYLOAD(s_tmd));
|
brute_tmd(SIGNATURE_PAYLOAD(s_tmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
void forge_tik(signed_blob *s_tik) {
|
void forge_tik(signed_blob *s_tik)
|
||||||
|
{
|
||||||
// debug_printf("forging tik sig");
|
// debug_printf("forging tik sig");
|
||||||
zero_sig(s_tik);
|
zero_sig(s_tik);
|
||||||
brute_tik(SIGNATURE_PAYLOAD(s_tik));
|
brute_tik(SIGNATURE_PAYLOAD(s_tik));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Make_SUID(void)
|
||||||
void Make_SUID(void) {
|
{
|
||||||
signed_blob *s_tmd, *s_tik;
|
signed_blob *s_tmd, *s_tik;
|
||||||
tmd *p_tmd;
|
tmd *p_tmd;
|
||||||
tik *p_tik;
|
tik *p_tik;
|
||||||
@ -133,7 +144,6 @@ void Make_SUID(void) {
|
|||||||
p_tmd = (tmd *)SIGNATURE_PAYLOAD(s_tmd);
|
p_tmd = (tmd *)SIGNATURE_PAYLOAD(s_tmd);
|
||||||
p_tik = (tik *)SIGNATURE_PAYLOAD(s_tik);
|
p_tik = (tik *)SIGNATURE_PAYLOAD(s_tik);
|
||||||
|
|
||||||
|
|
||||||
strcpy(p_tmd->issuer, "Root-CA00000001-CP00000004");
|
strcpy(p_tmd->issuer, "Root-CA00000001-CP00000004");
|
||||||
p_tmd->title_id = TITLE_ID(1, 2);
|
p_tmd->title_id = TITLE_ID(1, 2);
|
||||||
|
|
||||||
@ -149,15 +159,17 @@ void Make_SUID(void) {
|
|||||||
forge_tik(s_tik);
|
forge_tik(s_tik);
|
||||||
|
|
||||||
su_id_filled = 1;
|
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 Identify(const u8 *certs, u32 certs_size, const u8 *idtmd, u32 idtmd_size, const u8 *idticket, u32 idticket_size)
|
||||||
|
{
|
||||||
s32 ret;
|
s32 ret;
|
||||||
u32 keyid = 0;
|
u32 keyid = 0;
|
||||||
ret = ES_Identify((signed_blob *)certs, certs_size, (signed_blob *)idtmd, idtmd_size, (signed_blob *)idticket, idticket_size, &keyid);
|
ret = ES_Identify((signed_blob *)certs, certs_size, (signed_blob *)idtmd, idtmd_size, (signed_blob *)idticket, idticket_size, &keyid);
|
||||||
if (ret < 0){
|
if (ret < 0)
|
||||||
switch(ret){
|
{
|
||||||
|
switch (ret)
|
||||||
|
{
|
||||||
case ES_EINVAL:
|
case ES_EINVAL:
|
||||||
printf("Error! ES_Identify (ret = %ld;) Data invalid!\n", ret);
|
printf("Error! ES_Identify (ret = %ld;) Data invalid!\n", ret);
|
||||||
break;
|
break;
|
||||||
@ -178,9 +190,12 @@ s32 Identify(const u8 *certs, u32 certs_size, const u8 *idtmd, u32 idtmd_size, c
|
|||||||
printf("\tTicket: %u Std: %u Max: %u\n", idticket_size, STD_SIGNED_TIK_SIZE, MAX_SIGNED_TMD_SIZE);
|
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("\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));
|
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(certs))
|
||||||
if (!ISALIGNED(idtmd)) printf("\tTMD data is not aligned!\n");
|
printf("\tCertificate data is not aligned!\n");
|
||||||
if (!ISALIGNED(idticket)) printf("\tTicket 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
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -188,8 +203,8 @@ s32 Identify(const u8 *certs, u32 certs_size, const u8 *idtmd, u32 idtmd_size, c
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 Identify_SU(void)
|
||||||
s32 Identify_SU(void) {
|
{
|
||||||
if (!su_id_filled)
|
if (!su_id_filled)
|
||||||
Make_SUID();
|
Make_SUID();
|
||||||
|
|
||||||
@ -198,7 +213,8 @@ s32 Identify_SU(void) {
|
|||||||
return Identify(certs_dat, certs_dat_size, su_tmd, sizeof su_tmd, su_tik, sizeof su_tik);
|
return Identify(certs_dat, certs_dat_size, su_tmd, sizeof su_tmd, su_tik, sizeof su_tik);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Identify_SysMenu(void) {
|
s32 Identify_SysMenu(void)
|
||||||
|
{
|
||||||
s32 ret;
|
s32 ret;
|
||||||
u32 sysmenu_tmd_size, sysmenu_ticket_size;
|
u32 sysmenu_tmd_size, sysmenu_ticket_size;
|
||||||
// static u8 certs[0xA00] ATTRIBUTE_ALIGN(32);
|
// static u8 certs[0xA00] ATTRIBUTE_ALIGN(32);
|
||||||
@ -214,14 +230,16 @@ s32 Identify_SysMenu(void) {
|
|||||||
|
|
||||||
printf("\nPulling Sysmenu TMD...");
|
printf("\nPulling Sysmenu TMD...");
|
||||||
ret = ISFS_ReadFileToArray("/title/00000001/00000002/content/title.tmd", sysmenu_tmd, MAX_SIGNED_TMD_SIZE, &sysmenu_tmd_size);
|
ret = ISFS_ReadFileToArray("/title/00000001/00000002/content/title.tmd", sysmenu_tmd, MAX_SIGNED_TMD_SIZE, &sysmenu_tmd_size);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("\tReading TMD failed!\n");
|
printf("\tReading TMD failed!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nPulling Sysmenu Ticket...");
|
printf("\nPulling Sysmenu Ticket...");
|
||||||
ret = ISFS_ReadFileToArray("/ticket/00000001/00000002.tik", sysmenu_ticket, STD_SIGNED_TIK_SIZE, &sysmenu_ticket_size);
|
ret = ISFS_ReadFileToArray("/ticket/00000001/00000002.tik", sysmenu_ticket, STD_SIGNED_TIK_SIZE, &sysmenu_ticket_size);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("\tReading TMD failed!\n");
|
printf("\tReading TMD failed!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
199
source/main.c
199
source/main.c
@ -59,7 +59,8 @@ char regions[][ITEMS] = {"Japan ", "USA ", "Europe ", "Korea "};
|
|||||||
char vmodes[][ITEMS] = {"NTSC ", "PAL ", "MPAL "};
|
char vmodes[][ITEMS] = {"NTSC ", "PAL ", "MPAL "};
|
||||||
char eulas[][ITEMS] = {"Unread ", "Read "};
|
char eulas[][ITEMS] = {"Unread ", "Read "};
|
||||||
|
|
||||||
void draw_credits() {
|
void draw_credits()
|
||||||
|
{
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
PrintBanner();
|
PrintBanner();
|
||||||
Console_SetPosition(3, 0);
|
Console_SetPosition(3, 0);
|
||||||
@ -80,7 +81,8 @@ void draw_credits() {
|
|||||||
Console_SetPosition(26, 20);
|
Console_SetPosition(26, 20);
|
||||||
printf("Press Any Button To Return ..... ");
|
printf("Press Any Button To Return ..... ");
|
||||||
}
|
}
|
||||||
void Draw_Disclaimer() {
|
void Draw_Disclaimer()
|
||||||
|
{
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
PrintBanner();
|
PrintBanner();
|
||||||
printf("\n\t This software comes supplied with absolutely no warranty.\n");
|
printf("\n\t This software comes supplied with absolutely no warranty.\n");
|
||||||
@ -100,67 +102,89 @@ void Draw_Disclaimer() {
|
|||||||
printf("\n\n\n\n\t\t\t\t[A] Continue [Home] Exit\n");
|
printf("\n\n\n\n\t\t\t\t[A] Continue [Home] Exit\n");
|
||||||
wait_key(WPAD_BUTTON_A);
|
wait_key(WPAD_BUTTON_A);
|
||||||
}
|
}
|
||||||
void handleError(const char* string, int errorval){
|
void handleError(const char *string, int errorval)
|
||||||
|
{
|
||||||
printf("Unexpected Error: %s Value: %d\n", string, errorval);
|
printf("Unexpected Error: %s Value: %d\n", string, errorval);
|
||||||
printf("Press any key to quit\n");
|
printf("Press any key to quit\n");
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getSettings(void){
|
void getSettings(void)
|
||||||
|
{
|
||||||
int ret;
|
int ret;
|
||||||
lang = SYSCONF_GetLanguage();
|
lang = SYSCONF_GetLanguage();
|
||||||
area = SYSCONF_GetArea();
|
area = SYSCONF_GetArea();
|
||||||
game = SYSCONF_GetRegion();
|
game = SYSCONF_GetRegion();
|
||||||
video = SYSCONF_GetVideo();
|
video = SYSCONF_GetVideo();
|
||||||
eula = SYSCONF_GetEULA();
|
eula = SYSCONF_GetEULA();
|
||||||
if (lang < 0 || area < 0 || game < 0 || video < 0 || (eula != SYSCONF_ENOENT && eula < 0)){
|
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! %d, %d, %d, %d, %d\n", lang, area, game, video, eula);
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SYSCONF_GetLength("IPL.SADR") != SADR_LENGTH) handleError("IPL.SADR Length Incorrect", SYSCONF_GetLength("IPL.SADR"));
|
if (SYSCONF_GetLength("IPL.SADR") != SADR_LENGTH)
|
||||||
|
handleError("IPL.SADR Length Incorrect", SYSCONF_GetLength("IPL.SADR"));
|
||||||
ret = SYSCONF_Get("IPL.SADR", sadr, SADR_LENGTH);
|
ret = SYSCONF_Get("IPL.SADR", sadr, SADR_LENGTH);
|
||||||
if (ret < 0 ) handleError("SYSCONF_Get IPL.SADR", ret);
|
if (ret < 0)
|
||||||
|
handleError("SYSCONF_Get IPL.SADR", ret);
|
||||||
country = sadr[0];
|
country = sadr[0];
|
||||||
gprintf("\n\ncountry[%i] \n\n", country);
|
gprintf("\n\ncountry[%i] \n\n", country);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveSettings(void){
|
void saveSettings(void)
|
||||||
|
{
|
||||||
Console_SetPosition(24, 0);
|
Console_SetPosition(24, 0);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (lang != SYSCONF_GetLanguage()) ret = SYSCONF_SetLanguage(lang);
|
if (lang != SYSCONF_GetLanguage())
|
||||||
if (ret) handleError("SYSCONF_SetLanguage", ret);
|
ret = SYSCONF_SetLanguage(lang);
|
||||||
if (area != SYSCONF_GetArea()) ret = SYSCONF_SetArea(area);
|
if (ret)
|
||||||
if (ret) handleError("SYSCONF_SetArea", ret);
|
handleError("SYSCONF_SetLanguage", ret);
|
||||||
if(game != SYSCONF_GetRegion()) ret = SYSCONF_SetRegion(game);
|
if (area != SYSCONF_GetArea())
|
||||||
if (ret) handleError("SYSCONF_SetRegion", ret);
|
ret = SYSCONF_SetArea(area);
|
||||||
if (video != SYSCONF_GetVideo()) ret = SYSCONF_SetVideo(video);
|
if (ret)
|
||||||
if (ret) handleError("SYSCONF_SetVideo", ret);
|
handleError("SYSCONF_SetArea", ret);
|
||||||
if (eula != SYSCONF_GetEULA()) ret = SYSCONF_SetEULA(eula);
|
if (game != SYSCONF_GetRegion())
|
||||||
if (ret) handleError("SYSCONF_SetEULA", ret);
|
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)
|
||||||
|
handleError("SYSCONF_SetEULA", ret);
|
||||||
|
|
||||||
if (country != sadr[0]){
|
if (country != sadr[0])
|
||||||
|
{
|
||||||
memset(sadr, 0, SADR_LENGTH);
|
memset(sadr, 0, SADR_LENGTH);
|
||||||
sadr[0] = country;
|
sadr[0] = country;
|
||||||
ret = SYSCONF_Set("IPL.SADR", sadr, SADR_LENGTH);
|
ret = SYSCONF_Set("IPL.SADR", sadr, SADR_LENGTH);
|
||||||
if (ret) handleError("SYSCONF_Set IPL.SADR", ret);
|
if (ret)
|
||||||
|
handleError("SYSCONF_Set IPL.SADR", ret);
|
||||||
}
|
}
|
||||||
// wait_anyKey();
|
// wait_anyKey();
|
||||||
printf("Saving...");
|
printf("Saving...");
|
||||||
ret = SYSCONF_SaveChanges();
|
ret = SYSCONF_SaveChanges();
|
||||||
if (ret < 0) handleError("SYSCONF_SaveChanges", ret);
|
if (ret < 0)
|
||||||
else printf("OK!\n");
|
handleError("SYSCONF_SaveChanges", ret);
|
||||||
|
else
|
||||||
|
printf("OK!\n");
|
||||||
printf("Press any key to continue .....");
|
printf("Press any key to continue .....");
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSelected(int delta){
|
void updateSelected(int delta)
|
||||||
if (selected + delta >= ITEMS || selected + delta < 0) return;
|
{
|
||||||
|
if (selected + delta >= ITEMS || selected + delta < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (delta != 0){
|
if (delta != 0)
|
||||||
|
{
|
||||||
// Remove the cursor from the last selected item
|
// Remove the cursor from the last selected item
|
||||||
page_contents[selected][1] = ' ';
|
page_contents[selected][1] = ' ';
|
||||||
page_contents[selected][45] = ' ';
|
page_contents[selected][45] = ' ';
|
||||||
@ -175,7 +199,8 @@ void updateSelected(int delta){
|
|||||||
page_contents[selected][57] = '>';
|
page_contents[selected][57] = '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
void updatePage(void){
|
void updatePage(void)
|
||||||
|
{
|
||||||
|
|
||||||
sprintf(page_contents[0], " %-40s %10s \n", "Language Setting:", languages[lang]);
|
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[1], " %-40s %10s \n", "Console Area Setting:", areas[area]);
|
||||||
@ -191,9 +216,11 @@ void updatePage(void){
|
|||||||
|
|
||||||
updateSelected(0);
|
updateSelected(0);
|
||||||
}
|
}
|
||||||
char AREAtoSysMenuRegion(int area){
|
char AREAtoSysMenuRegion(int area)
|
||||||
|
{
|
||||||
// Data based on my own tests with AREA/Sysmenu
|
// Data based on my own tests with AREA/Sysmenu
|
||||||
switch (area){
|
switch (area)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
@ -215,7 +242,8 @@ char AREAtoSysMenuRegion(int area){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
int ret = 0, i;
|
int ret = 0, i;
|
||||||
u16 sysmenu_version;
|
u16 sysmenu_version;
|
||||||
@ -225,9 +253,11 @@ int main(int argc, char **argv) {
|
|||||||
int Current_Ios = 0;
|
int Current_Ios = 0;
|
||||||
|
|
||||||
ret = IOS_ReloadIOS(236);
|
ret = IOS_ReloadIOS(236);
|
||||||
if(ret != 0) {
|
if (ret != 0)
|
||||||
|
{
|
||||||
ret = IOS_ReloadIOS(249);
|
ret = IOS_ReloadIOS(249);
|
||||||
if(ret != 0) {
|
if (ret != 0)
|
||||||
|
{
|
||||||
IosPatch_FULL(true, true, false, false, 58);
|
IosPatch_FULL(true, true, false, false, 58);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,15 +274,18 @@ int main(int argc, char **argv) {
|
|||||||
gprintf("\n\nsysmenu_version[%u] sysmenu_region[%c] \n\n", sysmenu_version, sysmenu_region);
|
gprintf("\n\nsysmenu_version[%u] sysmenu_region[%c] \n\n", sysmenu_version, sysmenu_region);
|
||||||
gprintf("Init SYSCONF...");
|
gprintf("Init SYSCONF...");
|
||||||
ret = SYSCONF_Init();
|
ret = SYSCONF_Init();
|
||||||
if (ret < 0) handleError("SYSCONF_Init", ret);
|
if (ret < 0)
|
||||||
else gprintf("OK!\n");
|
handleError("SYSCONF_Init", ret);
|
||||||
|
else
|
||||||
|
gprintf("OK!\n");
|
||||||
|
|
||||||
getSettings();
|
getSettings();
|
||||||
region = game;
|
region = game;
|
||||||
Draw_Disclaimer();
|
Draw_Disclaimer();
|
||||||
updatePage();
|
updatePage();
|
||||||
|
|
||||||
while(1) {
|
while (1)
|
||||||
|
{
|
||||||
|
|
||||||
PrintBanner();
|
PrintBanner();
|
||||||
printf("\n------------------------------------------------------------------------");
|
printf("\n------------------------------------------------------------------------");
|
||||||
@ -288,62 +321,88 @@ int main(int argc, char **argv) {
|
|||||||
if (buttons & WPAD_BUTTON_UP)
|
if (buttons & WPAD_BUTTON_UP)
|
||||||
updateSelected(-1);
|
updateSelected(-1);
|
||||||
|
|
||||||
if (buttons & WPAD_BUTTON_LEFT){
|
if (buttons & WPAD_BUTTON_LEFT)
|
||||||
switch(selected){
|
{
|
||||||
|
switch (selected)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (--lang < 0) lang = 6;
|
if (--lang < 0)
|
||||||
|
lang = 6;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (--area < 0) area = 11;
|
if (--area < 0)
|
||||||
|
area = 11;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (--game < 0) game = 3;
|
if (--game < 0)
|
||||||
|
game = 3;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (--video < 0) video = 2;
|
if (--video < 0)
|
||||||
|
video = 2;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (country == 1) country = 136;
|
if (country == 1)
|
||||||
else if (country == 49) country = 1;
|
country = 136;
|
||||||
else if (country == 110) country = 49;
|
else if (country == 49)
|
||||||
else if (country == 136) country = 110;
|
country = 1;
|
||||||
if (eula >= 0) eula = 0;
|
else if (country == 110)
|
||||||
|
country = 49;
|
||||||
|
else if (country == 136)
|
||||||
|
country = 110;
|
||||||
|
if (eula >= 0)
|
||||||
|
eula = 0;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (eula >= 0) eula = !eula;
|
if (eula >= 0)
|
||||||
|
eula = !eula;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons & WPAD_BUTTON_RIGHT){
|
if (buttons & WPAD_BUTTON_RIGHT)
|
||||||
switch(selected){
|
{
|
||||||
|
switch (selected)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (++lang == 7) lang = 0;
|
if (++lang == 7)
|
||||||
|
lang = 0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (++area == 12) area = 0;
|
if (++area == 12)
|
||||||
|
area = 0;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (++game == 4) game = 0;
|
if (++game == 4)
|
||||||
|
game = 0;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (++video == 3) video = 0;
|
if (++video == 3)
|
||||||
|
video = 0;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (country == 1) country = 49;
|
if (country == 1)
|
||||||
else if (country == 49) country = 110;
|
country = 49;
|
||||||
else if (country == 110) country = 136;
|
else if (country == 49)
|
||||||
else if (country == 136) country = 1;
|
country = 110;
|
||||||
if (eula >= 0) eula = 0;
|
else if (country == 110)
|
||||||
|
country = 136;
|
||||||
|
else if (country == 136)
|
||||||
|
country = 1;
|
||||||
|
if (eula >= 0)
|
||||||
|
eula = 0;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (eula >= 0) eula = !eula;
|
if (eula >= 0)
|
||||||
|
eula = !eula;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons & WPAD_BUTTON_A){
|
if (buttons & WPAD_BUTTON_A)
|
||||||
switch(selected){
|
{
|
||||||
|
switch (selected)
|
||||||
|
{
|
||||||
case 6:
|
case 6:
|
||||||
getSettings();
|
getSettings();
|
||||||
break;
|
break;
|
||||||
@ -351,28 +410,32 @@ int main(int argc, char **argv) {
|
|||||||
saveSettings();
|
saveSettings();
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
if(sysmenu_region == 85) { // usa
|
if (sysmenu_region == 85)
|
||||||
|
{ // usa
|
||||||
lang = 1;
|
lang = 1;
|
||||||
area = 1;
|
area = 1;
|
||||||
game = 1;
|
game = 1;
|
||||||
video = 0;
|
video = 0;
|
||||||
country = 49;
|
country = 49;
|
||||||
}
|
}
|
||||||
else if(sysmenu_region == 74) { // jpn
|
else if (sysmenu_region == 74)
|
||||||
|
{ // jpn
|
||||||
lang = 0;
|
lang = 0;
|
||||||
area = 0;
|
area = 0;
|
||||||
game = 0;
|
game = 0;
|
||||||
video = 0;
|
video = 0;
|
||||||
country = 1;
|
country = 1;
|
||||||
}
|
}
|
||||||
else if(sysmenu_region == 69) { // EUR/PAL
|
else if (sysmenu_region == 69)
|
||||||
|
{ // EUR/PAL
|
||||||
lang = 1;
|
lang = 1;
|
||||||
area = 2;
|
area = 2;
|
||||||
game = 2;
|
game = 2;
|
||||||
video = 1;
|
video = 1;
|
||||||
country = 110;
|
country = 110;
|
||||||
}
|
}
|
||||||
else if(sysmenu_region == 255) { // KOR
|
else if (sysmenu_region == 255)
|
||||||
|
{ // KOR
|
||||||
lang = 1;
|
lang = 1;
|
||||||
area = 7;
|
area = 7;
|
||||||
game = 3;
|
game = 3;
|
||||||
@ -390,10 +453,12 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons & WPAD_BUTTON_B) {
|
if (buttons & WPAD_BUTTON_B)
|
||||||
|
{
|
||||||
selected = 9;
|
selected = 9;
|
||||||
}
|
}
|
||||||
if (buttons & WPAD_BUTTON_1) {
|
if (buttons & WPAD_BUTTON_1)
|
||||||
|
{
|
||||||
draw_credits();
|
draw_credits();
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,8 @@
|
|||||||
// C++ header
|
// C++ header
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
/* __cplusplus */
|
/* __cplusplus */
|
||||||
|
|
||||||
@ -71,7 +72,6 @@ vWii:
|
|||||||
* Kill Anti-SystemTitle-Install 1, 2, 3, 4 & 5
|
* Kill Anti-SystemTitle-Install 1, 2, 3, 4 & 5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// Functions:
|
// Functions:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
@ -95,7 +95,6 @@ vWii:
|
|||||||
*/
|
*/
|
||||||
s32 IosPatch_AHBPROT(bool verbose);
|
s32 IosPatch_AHBPROT(bool verbose);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function applies patches on current IOS
|
* This function applies patches on current IOS
|
||||||
* @see Patchsets
|
* @see Patchsets
|
||||||
@ -111,7 +110,6 @@ s32 IosPatch_AHBPROT(bool verbose);
|
|||||||
*/
|
*/
|
||||||
s32 IosPatch_RUNTIME(bool wii, bool sciifii, bool vwii, bool verbose);
|
s32 IosPatch_RUNTIME(bool wii, bool sciifii, bool vwii, bool verbose);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function combines IosPatch_AHBPROT + IOS_ReloadIOS + IosPatch_RUNTIME
|
* This function combines IosPatch_AHBPROT + IOS_ReloadIOS + IosPatch_RUNTIME
|
||||||
* @see Patchsets
|
* @see Patchsets
|
||||||
|
164
source/sha1.c
164
source/sha1.c
@ -24,28 +24,36 @@ A million repetitions of "a"
|
|||||||
/* blk0() and blk() perform the initial expand. */
|
/* blk0() and blk() perform the initial expand. */
|
||||||
/* I got the idea of expanding during the round function from SSLeay */
|
/* I got the idea of expanding during the round function from SSLeay */
|
||||||
#ifdef LITTLE_ENDIAN
|
#ifdef LITTLE_ENDIAN
|
||||||
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
#define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | (rol(block->l[i], 8) & 0x00FF00FF))
|
||||||
|(rol(block->l[i],8)&0x00FF00FF))
|
|
||||||
#else
|
#else
|
||||||
#define blk0(i) block->l[i]
|
#define blk0(i) block->l[i]
|
||||||
#endif
|
#endif
|
||||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
#define blk(i) (block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ block->l[(i + 8) & 15] ^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1))
|
||||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
|
||||||
|
|
||||||
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
|
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
|
||||||
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
|
#define R0(v, w, x, y, z, i) \
|
||||||
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
|
z += ((w & (x ^ y)) ^ y) + blk0(i) + 0x5A827999 + rol(v, 5); \
|
||||||
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
|
w = rol(w, 30);
|
||||||
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
|
#define R1(v, w, x, y, z, i) \
|
||||||
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
|
z += ((w & (x ^ y)) ^ y) + blk(i) + 0x5A827999 + rol(v, 5); \
|
||||||
|
w = rol(w, 30);
|
||||||
|
#define R2(v, w, x, y, z, i) \
|
||||||
|
z += (w ^ x ^ y) + blk(i) + 0x6ED9EBA1 + rol(v, 5); \
|
||||||
|
w = rol(w, 30);
|
||||||
|
#define R3(v, w, x, y, z, i) \
|
||||||
|
z += (((w | x) & y) | (w & x)) + blk(i) + 0x8F1BBCDC + rol(v, 5); \
|
||||||
|
w = rol(w, 30);
|
||||||
|
#define R4(v, w, x, y, z, i) \
|
||||||
|
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
|
||||||
|
w = rol(w, 30);
|
||||||
|
|
||||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||||
|
|
||||||
void SHA1Transform(unsigned long state[5], unsigned char buffer[64])
|
void SHA1Transform(unsigned long state[5], unsigned char buffer[64])
|
||||||
{
|
{
|
||||||
unsigned long a, b, c, d, e;
|
unsigned long a, b, c, d, e;
|
||||||
typedef union {
|
typedef union
|
||||||
|
{
|
||||||
unsigned char c[64];
|
unsigned char c[64];
|
||||||
unsigned long l[16];
|
unsigned long l[16];
|
||||||
} CHAR64LONG16;
|
} CHAR64LONG16;
|
||||||
@ -64,26 +72,86 @@ static unsigned char workspace[64];
|
|||||||
d = state[3];
|
d = state[3];
|
||||||
e = state[4];
|
e = state[4];
|
||||||
/* 4 rounds of 20 operations each. Loop unrolled. */
|
/* 4 rounds of 20 operations each. Loop unrolled. */
|
||||||
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
|
R0(a, b, c, d, e, 0);
|
||||||
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
|
R0(e, a, b, c, d, 1);
|
||||||
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
|
R0(d, e, a, b, c, 2);
|
||||||
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
|
R0(c, d, e, a, b, 3);
|
||||||
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
|
R0(b, c, d, e, a, 4);
|
||||||
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
|
R0(a, b, c, d, e, 5);
|
||||||
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
|
R0(e, a, b, c, d, 6);
|
||||||
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
|
R0(d, e, a, b, c, 7);
|
||||||
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
|
R0(c, d, e, a, b, 8);
|
||||||
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
|
R0(b, c, d, e, a, 9);
|
||||||
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
|
R0(a, b, c, d, e, 10);
|
||||||
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
|
R0(e, a, b, c, d, 11);
|
||||||
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
|
R0(d, e, a, b, c, 12);
|
||||||
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
|
R0(c, d, e, a, b, 13);
|
||||||
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
|
R0(b, c, d, e, a, 14);
|
||||||
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
|
R0(a, b, c, d, e, 15);
|
||||||
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
|
R1(e, a, b, c, d, 16);
|
||||||
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
|
R1(d, e, a, b, c, 17);
|
||||||
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
|
R1(c, d, e, a, b, 18);
|
||||||
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
|
R1(b, c, d, e, a, 19);
|
||||||
|
R2(a, b, c, d, e, 20);
|
||||||
|
R2(e, a, b, c, d, 21);
|
||||||
|
R2(d, e, a, b, c, 22);
|
||||||
|
R2(c, d, e, a, b, 23);
|
||||||
|
R2(b, c, d, e, a, 24);
|
||||||
|
R2(a, b, c, d, e, 25);
|
||||||
|
R2(e, a, b, c, d, 26);
|
||||||
|
R2(d, e, a, b, c, 27);
|
||||||
|
R2(c, d, e, a, b, 28);
|
||||||
|
R2(b, c, d, e, a, 29);
|
||||||
|
R2(a, b, c, d, e, 30);
|
||||||
|
R2(e, a, b, c, d, 31);
|
||||||
|
R2(d, e, a, b, c, 32);
|
||||||
|
R2(c, d, e, a, b, 33);
|
||||||
|
R2(b, c, d, e, a, 34);
|
||||||
|
R2(a, b, c, d, e, 35);
|
||||||
|
R2(e, a, b, c, d, 36);
|
||||||
|
R2(d, e, a, b, c, 37);
|
||||||
|
R2(c, d, e, a, b, 38);
|
||||||
|
R2(b, c, d, e, a, 39);
|
||||||
|
R3(a, b, c, d, e, 40);
|
||||||
|
R3(e, a, b, c, d, 41);
|
||||||
|
R3(d, e, a, b, c, 42);
|
||||||
|
R3(c, d, e, a, b, 43);
|
||||||
|
R3(b, c, d, e, a, 44);
|
||||||
|
R3(a, b, c, d, e, 45);
|
||||||
|
R3(e, a, b, c, d, 46);
|
||||||
|
R3(d, e, a, b, c, 47);
|
||||||
|
R3(c, d, e, a, b, 48);
|
||||||
|
R3(b, c, d, e, a, 49);
|
||||||
|
R3(a, b, c, d, e, 50);
|
||||||
|
R3(e, a, b, c, d, 51);
|
||||||
|
R3(d, e, a, b, c, 52);
|
||||||
|
R3(c, d, e, a, b, 53);
|
||||||
|
R3(b, c, d, e, a, 54);
|
||||||
|
R3(a, b, c, d, e, 55);
|
||||||
|
R3(e, a, b, c, d, 56);
|
||||||
|
R3(d, e, a, b, c, 57);
|
||||||
|
R3(c, d, e, a, b, 58);
|
||||||
|
R3(b, c, d, e, a, 59);
|
||||||
|
R4(a, b, c, d, e, 60);
|
||||||
|
R4(e, a, b, c, d, 61);
|
||||||
|
R4(d, e, a, b, c, 62);
|
||||||
|
R4(c, d, e, a, b, 63);
|
||||||
|
R4(b, c, d, e, a, 64);
|
||||||
|
R4(a, b, c, d, e, 65);
|
||||||
|
R4(e, a, b, c, d, 66);
|
||||||
|
R4(d, e, a, b, c, 67);
|
||||||
|
R4(c, d, e, a, b, 68);
|
||||||
|
R4(b, c, d, e, a, 69);
|
||||||
|
R4(a, b, c, d, e, 70);
|
||||||
|
R4(e, a, b, c, d, 71);
|
||||||
|
R4(d, e, a, b, c, 72);
|
||||||
|
R4(c, d, e, a, b, 73);
|
||||||
|
R4(b, c, d, e, a, 74);
|
||||||
|
R4(a, b, c, d, e, 75);
|
||||||
|
R4(e, a, b, c, d, 76);
|
||||||
|
R4(d, e, a, b, c, 77);
|
||||||
|
R4(c, d, e, a, b, 78);
|
||||||
|
R4(b, c, d, e, a, 79);
|
||||||
/* Add the working vars back into context.state[] */
|
/* Add the working vars back into context.state[] */
|
||||||
state[0] += a;
|
state[0] += a;
|
||||||
state[1] += b;
|
state[1] += b;
|
||||||
@ -94,7 +162,6 @@ static unsigned char workspace[64];
|
|||||||
a = b = c = d = e = 0;
|
a = b = c = d = e = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* SHA1Init - Initialize new context */
|
/* SHA1Init - Initialize new context */
|
||||||
|
|
||||||
void SHA1Init(SHA1_CTX *context)
|
void SHA1Init(SHA1_CTX *context)
|
||||||
@ -108,7 +175,6 @@ void SHA1Init(SHA1_CTX* context)
|
|||||||
context->count[0] = context->count[1] = 0;
|
context->count[0] = context->count[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Run your data through this. */
|
/* Run your data through this. */
|
||||||
|
|
||||||
void SHA1Update(SHA1_CTX *context, unsigned char *data, unsigned int len)
|
void SHA1Update(SHA1_CTX *context, unsigned char *data, unsigned int len)
|
||||||
@ -116,21 +182,24 @@ void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len)
|
|||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
j = (context->count[0] >> 3) & 63;
|
j = (context->count[0] >> 3) & 63;
|
||||||
if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
|
if ((context->count[0] += len << 3) < (len << 3))
|
||||||
|
context->count[1]++;
|
||||||
context->count[1] += (len >> 29);
|
context->count[1] += (len >> 29);
|
||||||
if ((j + len) > 63) {
|
if ((j + len) > 63)
|
||||||
|
{
|
||||||
memcpy(&context->buffer[j], data, (i = 64 - j));
|
memcpy(&context->buffer[j], data, (i = 64 - j));
|
||||||
SHA1Transform(context->state, context->buffer);
|
SHA1Transform(context->state, context->buffer);
|
||||||
for ( ; i + 63 < len; i += 64) {
|
for (; i + 63 < len; i += 64)
|
||||||
|
{
|
||||||
SHA1Transform(context->state, &data[i]);
|
SHA1Transform(context->state, &data[i]);
|
||||||
}
|
}
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
else i = 0;
|
else
|
||||||
|
i = 0;
|
||||||
memcpy(&context->buffer[j], &data[i], len - i);
|
memcpy(&context->buffer[j], &data[i], len - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Add padding and return the message digest. */
|
/* Add padding and return the message digest. */
|
||||||
|
|
||||||
void SHA1Final(unsigned char digest[20], SHA1_CTX *context)
|
void SHA1Final(unsigned char digest[20], SHA1_CTX *context)
|
||||||
@ -138,18 +207,19 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
|
|||||||
unsigned long i, j;
|
unsigned long i, j;
|
||||||
unsigned char finalcount[8];
|
unsigned char finalcount[8];
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++)
|
||||||
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
|
{
|
||||||
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
|
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */
|
||||||
}
|
}
|
||||||
SHA1Update(context, (unsigned char *)"\200", 1);
|
SHA1Update(context, (unsigned char *)"\200", 1);
|
||||||
while ((context->count[0] & 504) != 448) {
|
while ((context->count[0] & 504) != 448)
|
||||||
|
{
|
||||||
SHA1Update(context, (unsigned char *)"\0", 1);
|
SHA1Update(context, (unsigned char *)"\0", 1);
|
||||||
}
|
}
|
||||||
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
|
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
|
||||||
for (i = 0; i < 20; i++) {
|
for (i = 0; i < 20; i++)
|
||||||
digest[i] = (unsigned char)
|
{
|
||||||
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
digest[i] = (unsigned char)((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
|
||||||
}
|
}
|
||||||
/* Wipe variables */
|
/* Wipe variables */
|
||||||
i = j = 0;
|
i = j = 0;
|
||||||
@ -162,11 +232,11 @@ unsigned char finalcount[8];
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA1(unsigned char *ptr, unsigned int size, unsigned char *outbuf) {
|
void SHA1(unsigned char *ptr, unsigned int size, unsigned char *outbuf)
|
||||||
|
{
|
||||||
SHA1_CTX ctx;
|
SHA1_CTX ctx;
|
||||||
|
|
||||||
SHA1Init(&ctx);
|
SHA1Init(&ctx);
|
||||||
SHA1Update(&ctx, ptr, size);
|
SHA1Update(&ctx, ptr, size);
|
||||||
SHA1Final(outbuf, &ctx);
|
SHA1Final(outbuf, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
unsigned long state[5];
|
unsigned long state[5];
|
||||||
unsigned long count[2];
|
unsigned long count[2];
|
||||||
unsigned char buffer[64];
|
unsigned char buffer[64];
|
||||||
|
465
source/sysconf.c
465
source/sysconf.c
@ -56,7 +56,8 @@ 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";
|
||||||
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){
|
int __SYSCONF_EndOfTextOffset(void)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
@ -77,7 +78,8 @@ void __SYSCONF_DecryptEncryptTextBuffer(void)
|
|||||||
if (__sysconf_buffer_txt_decrypted)
|
if (__sysconf_buffer_txt_decrypted)
|
||||||
end += __SYSCONF_EndOfTextOffset();
|
end += __SYSCONF_EndOfTextOffset();
|
||||||
|
|
||||||
for(i=0; i<0x100; i++) {
|
for (i = 0; i < 0x100; i++)
|
||||||
|
{
|
||||||
__sysconf_txt_buffer[i] ^= key & 0xff;
|
__sysconf_txt_buffer[i] ^= key & 0xff;
|
||||||
key = (key << 1) | (key >> 31);
|
key = (key << 1) | (key >> 31);
|
||||||
}
|
}
|
||||||
@ -87,25 +89,29 @@ void __SYSCONF_DecryptEncryptTextBuffer(void)
|
|||||||
if (__sysconf_buffer_txt_decrypted)
|
if (__sysconf_buffer_txt_decrypted)
|
||||||
end += __SYSCONF_EndOfTextOffset();
|
end += __SYSCONF_EndOfTextOffset();
|
||||||
|
|
||||||
|
|
||||||
memset(end, 0, (__sysconf_txt_buffer + 0x100) - end);
|
memset(end, 0, (__sysconf_txt_buffer + 0x100) - end);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_SYSCONF
|
#ifdef DEBUG_SYSCONF
|
||||||
|
|
||||||
void SYSCONF_DumpBuffer(void){
|
void SYSCONF_DumpBuffer(void)
|
||||||
if(!__sysconf_inited) return;
|
{
|
||||||
|
if (!__sysconf_inited)
|
||||||
|
return;
|
||||||
hex_print_array16(__sysconf_buffer, 0x4000);
|
hex_print_array16(__sysconf_buffer, 0x4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SYSCONF_DumpTxtBuffer(void){
|
void SYSCONF_DumpTxtBuffer(void)
|
||||||
if(!__sysconf_inited) return;
|
{
|
||||||
|
if (!__sysconf_inited)
|
||||||
|
return;
|
||||||
hex_print_array16((u8 *)__sysconf_txt_buffer, 0x101);
|
hex_print_array16((u8 *)__sysconf_txt_buffer, 0x101);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SYSCONF_DumpEncryptedTxtBuffer(void){
|
void SYSCONF_DumpEncryptedTxtBuffer(void)
|
||||||
if(!__sysconf_inited) return;
|
{
|
||||||
|
if (!__sysconf_inited)
|
||||||
|
return;
|
||||||
int was = __sysconf_buffer_txt_decrypted;
|
int was = __sysconf_buffer_txt_decrypted;
|
||||||
if (__sysconf_buffer_txt_decrypted)
|
if (__sysconf_buffer_txt_decrypted)
|
||||||
__SYSCONF_DecryptEncryptTextBuffer();
|
__SYSCONF_DecryptEncryptTextBuffer();
|
||||||
@ -114,9 +120,10 @@ void SYSCONF_DumpEncryptedTxtBuffer(void){
|
|||||||
__SYSCONF_DecryptEncryptTextBuffer();
|
__SYSCONF_DecryptEncryptTextBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SYSCONF_PrintAllSettings(void)
|
||||||
void SYSCONF_PrintAllSettings(void){
|
{
|
||||||
if(!__sysconf_inited) return;
|
if (!__sysconf_inited)
|
||||||
|
return;
|
||||||
u16 i, count;
|
u16 i, count;
|
||||||
u16 *offset;
|
u16 *offset;
|
||||||
char temp[33], typestring[20];
|
char temp[33], typestring[20];
|
||||||
@ -124,11 +131,13 @@ void SYSCONF_PrintAllSettings(void){
|
|||||||
offset = (u16 *)&__sysconf_buffer[6];
|
offset = (u16 *)&__sysconf_buffer[6];
|
||||||
count = *((u16 *)(&__sysconf_buffer[4]));
|
count = *((u16 *)(&__sysconf_buffer[4]));
|
||||||
printf("Total: %u settings.\n", count);
|
printf("Total: %u settings.\n", count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
nlen = (__sysconf_buffer[*offset] & 0x0F) + 1;
|
nlen = (__sysconf_buffer[*offset] & 0x0F) + 1;
|
||||||
memcpy(temp, &__sysconf_buffer[(*offset) + 1], nlen);
|
memcpy(temp, &__sysconf_buffer[(*offset) + 1], nlen);
|
||||||
temp[nlen] = 0;
|
temp[nlen] = 0;
|
||||||
switch(__sysconf_buffer[*offset] >> 5){
|
switch (__sysconf_buffer[*offset] >> 5)
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
sprintf(typestring, "BIGARRAY[0x%X]", *((u16 *)&__sysconf_buffer[(*offset) + nlen + 1]) + 1);
|
sprintf(typestring, "BIGARRAY[0x%X]", *((u16 *)&__sysconf_buffer[(*offset) + nlen + 1]) + 1);
|
||||||
break;
|
break;
|
||||||
@ -153,7 +162,6 @@ void SYSCONF_PrintAllSettings(void){
|
|||||||
printf("%3u. 0x%04X: %-10s Type: %s\n", i + 1, *offset, temp, typestring);
|
printf("%3u. 0x%04X: %-10s Type: %s\n", i + 1, *offset, temp, typestring);
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* DEBUG_SYSCONF */
|
#endif /* DEBUG_SYSCONF */
|
||||||
|
|
||||||
@ -162,26 +170,32 @@ s32 SYSCONF_Init(void)
|
|||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if(__sysconf_inited) return 0;
|
if (__sysconf_inited)
|
||||||
|
return 0;
|
||||||
|
|
||||||
fd = IOS_Open(__sysconf_file, 1);
|
fd = IOS_Open(__sysconf_file, 1);
|
||||||
if(fd < 0) return fd;
|
if (fd < 0)
|
||||||
|
return fd;
|
||||||
|
|
||||||
memset(__sysconf_buffer, 0, 0x4000);
|
memset(__sysconf_buffer, 0, 0x4000);
|
||||||
memset(__sysconf_txt_buffer, 0, 0x101);
|
memset(__sysconf_txt_buffer, 0, 0x101);
|
||||||
|
|
||||||
ret = IOS_Read(fd, __sysconf_buffer, 0x4000);
|
ret = IOS_Read(fd, __sysconf_buffer, 0x4000);
|
||||||
IOS_Close(fd);
|
IOS_Close(fd);
|
||||||
if(ret != 0x4000) return SYSCONF_EBADFILE;
|
if (ret != 0x4000)
|
||||||
|
return SYSCONF_EBADFILE;
|
||||||
|
|
||||||
fd = IOS_Open(__sysconf_txt_file, 1);
|
fd = IOS_Open(__sysconf_txt_file, 1);
|
||||||
if(fd < 0) return fd;
|
if (fd < 0)
|
||||||
|
return fd;
|
||||||
|
|
||||||
ret = IOS_Read(fd, __sysconf_txt_buffer, 0x100);
|
ret = IOS_Read(fd, __sysconf_txt_buffer, 0x100);
|
||||||
IOS_Close(fd);
|
IOS_Close(fd);
|
||||||
if(ret != 0x100) return SYSCONF_EBADFILE;
|
if (ret != 0x100)
|
||||||
|
return SYSCONF_EBADFILE;
|
||||||
|
|
||||||
if(memcmp(__sysconf_buffer, "SCv0", 4)) return SYSCONF_EBADFILE;
|
if (memcmp(__sysconf_buffer, "SCv0", 4))
|
||||||
|
return SYSCONF_EBADFILE;
|
||||||
|
|
||||||
__SYSCONF_DecryptEncryptTextBuffer();
|
__SYSCONF_DecryptEncryptTextBuffer();
|
||||||
|
|
||||||
@ -194,52 +208,62 @@ int __SYSCONF_WriteTxtBuffer(void)
|
|||||||
u64 tid;
|
u64 tid;
|
||||||
int ret, fd;
|
int ret, fd;
|
||||||
|
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
if (!__sysconf_txt_buffer_updated) return 0;
|
if (!__sysconf_txt_buffer_updated)
|
||||||
|
return 0;
|
||||||
|
|
||||||
ret = ES_GetTitleID(&tid);
|
ret = ES_GetTitleID(&tid);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (tid != 0x100000002LL) return SYSCONF_EPERMS;
|
if (tid != 0x100000002LL)
|
||||||
|
return SYSCONF_EPERMS;
|
||||||
|
|
||||||
if (__sysconf_buffer_txt_decrypted)
|
if (__sysconf_buffer_txt_decrypted)
|
||||||
__SYSCONF_DecryptEncryptTextBuffer();
|
__SYSCONF_DecryptEncryptTextBuffer();
|
||||||
|
|
||||||
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 3, 3, 3);
|
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 3, 3, 3);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
fd = IOS_Open(__sysconf_txt_file, 2);
|
fd = IOS_Open(__sysconf_txt_file, 2);
|
||||||
if(fd < 0) return fd;
|
if (fd < 0)
|
||||||
|
return fd;
|
||||||
|
|
||||||
ret = IOS_Write(fd, __sysconf_txt_buffer, 0x100);
|
ret = IOS_Write(fd, __sysconf_txt_buffer, 0x100);
|
||||||
IOS_Close(fd);
|
IOS_Close(fd);
|
||||||
if(ret != 0x100) return SYSCONF_EBADWRITE;
|
if (ret != 0x100)
|
||||||
|
return SYSCONF_EBADWRITE;
|
||||||
|
|
||||||
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 1, 1, 1);
|
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 1, 1, 1);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
__sysconf_buffer_updated = 0;
|
__sysconf_buffer_updated = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int __SYSCONF_WriteBuffer(void)
|
int __SYSCONF_WriteBuffer(void)
|
||||||
{
|
{
|
||||||
int ret, fd;
|
int ret, fd;
|
||||||
|
|
||||||
if (!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
if (!__sysconf_buffer_updated) return 0;
|
if (!__sysconf_buffer_updated)
|
||||||
|
return 0;
|
||||||
|
|
||||||
fd = IOS_Open(__sysconf_file, 2);
|
fd = IOS_Open(__sysconf_file, 2);
|
||||||
if(fd < 0) return fd;
|
if (fd < 0)
|
||||||
|
return fd;
|
||||||
|
|
||||||
ret = IOS_Write(fd, __sysconf_buffer, 0x4000);
|
ret = IOS_Write(fd, __sysconf_buffer, 0x4000);
|
||||||
IOS_Close(fd);
|
IOS_Close(fd);
|
||||||
if(ret != 0x4000) return SYSCONF_EBADFILE;
|
if (ret != 0x4000)
|
||||||
|
return SYSCONF_EBADFILE;
|
||||||
|
|
||||||
__sysconf_buffer_updated = 0;
|
__sysconf_buffer_updated = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@ -248,7 +272,8 @@ int __SYSCONF_WriteBuffer(void)
|
|||||||
s32 SYSCONF_SaveChanges(void)
|
s32 SYSCONF_SaveChanges(void)
|
||||||
{
|
{
|
||||||
s32 ret;
|
s32 ret;
|
||||||
if (!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
ret = __SYSCONF_WriteBuffer();
|
ret = __SYSCONF_WriteBuffer();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -269,7 +294,8 @@ int __SYSCONF_ShiftTxt(char *start, s32 delta)
|
|||||||
__SYSCONF_DecryptEncryptTextBuffer();
|
__SYSCONF_DecryptEncryptTextBuffer();
|
||||||
|
|
||||||
end = strchr((char *)__sysconf_txt_buffer, 0);
|
end = strchr((char *)__sysconf_txt_buffer, 0);
|
||||||
if (end == NULL || end > __sysconf_txt_buffer+0x100) return SYSCONF_EBADFILE;
|
if (end == NULL || end > __sysconf_txt_buffer + 0x100)
|
||||||
|
return SYSCONF_EBADFILE;
|
||||||
|
|
||||||
if (start < __sysconf_txt_buffer || start >= end)
|
if (start < __sysconf_txt_buffer || start >= end)
|
||||||
return SYSCONF_EBADVALUE;
|
return SYSCONF_EBADVALUE;
|
||||||
@ -279,7 +305,6 @@ int __SYSCONF_ShiftTxt(char *start, s32 delta)
|
|||||||
// free (temp);
|
// free (temp);
|
||||||
*(end + delta) = 0;
|
*(end + delta) = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int __SYSCONF_GetTxt(const char *name, char *buf, int length)
|
int __SYSCONF_GetTxt(const char *name, char *buf, int length)
|
||||||
@ -289,23 +314,30 @@ int __SYSCONF_GetTxt(const char *name, char *buf, int length)
|
|||||||
int slen;
|
int slen;
|
||||||
int nlen = strlen(name);
|
int nlen = strlen(name);
|
||||||
|
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
if (!__sysconf_buffer_txt_decrypted)
|
if (!__sysconf_buffer_txt_decrypted)
|
||||||
__SYSCONF_DecryptEncryptTextBuffer();
|
__SYSCONF_DecryptEncryptTextBuffer();
|
||||||
|
|
||||||
while(line < (__sysconf_txt_buffer+0x100) ) {
|
while (line < (__sysconf_txt_buffer + 0x100))
|
||||||
|
{
|
||||||
delim = strchr(line, '=');
|
delim = strchr(line, '=');
|
||||||
if(delim && ((delim - line) == nlen) && !memcmp(name, line, nlen)) {
|
if (delim && ((delim - line) == nlen) && !memcmp(name, line, nlen))
|
||||||
|
{
|
||||||
delim++;
|
delim++;
|
||||||
end = strchr(line, '\r');
|
end = strchr(line, '\r');
|
||||||
if(end) {
|
if (end)
|
||||||
|
{
|
||||||
slen = end - delim;
|
slen = end - delim;
|
||||||
if(slen < length) {
|
if (slen < length)
|
||||||
|
{
|
||||||
memcpy(buf, delim, slen);
|
memcpy(buf, delim, slen);
|
||||||
buf[slen] = 0;
|
buf[slen] = 0;
|
||||||
return slen;
|
return slen;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// printf("Should be %u is %u", slen, length);
|
// printf("Should be %u is %u", slen, length);
|
||||||
return SYSCONF_ETOOBIG;
|
return SYSCONF_ETOOBIG;
|
||||||
}
|
}
|
||||||
@ -313,7 +345,8 @@ int __SYSCONF_GetTxt(const char *name, char *buf, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip to line end
|
// skip to line end
|
||||||
while(line < (__sysconf_txt_buffer+0x100) && *line++ != '\n');
|
while (line < (__sysconf_txt_buffer + 0x100) && *line++ != '\n')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
return SYSCONF_ENOENT;
|
return SYSCONF_ENOENT;
|
||||||
}
|
}
|
||||||
@ -326,14 +359,16 @@ int __SYSCONF_AddTxt(const char *name, const char *value)
|
|||||||
char endline[10];
|
char endline[10];
|
||||||
u32 length;
|
u32 length;
|
||||||
|
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
newline = strchr((char *)__sysconf_txt_buffer, 0);
|
newline = strchr((char *)__sysconf_txt_buffer, 0);
|
||||||
if (newline == NULL || newline > __sysconf_txt_buffer+0x100) return SYSCONF_EBADFILE;
|
if (newline == NULL || newline > __sysconf_txt_buffer + 0x100)
|
||||||
|
return SYSCONF_EBADFILE;
|
||||||
|
|
||||||
newline--;
|
newline--;
|
||||||
while (*--newline == '\r');
|
while (*--newline == '\r')
|
||||||
|
;
|
||||||
newline++;
|
newline++;
|
||||||
|
|
||||||
strcpy(endline, newline);
|
strcpy(endline, newline);
|
||||||
@ -342,11 +377,14 @@ int __SYSCONF_AddTxt(const char *name, const char *value)
|
|||||||
|
|
||||||
length = strlen(name) + strlen(value) + strlen(endline) + 1;
|
length = strlen(name) + strlen(value) + strlen(endline) + 1;
|
||||||
|
|
||||||
if (newline+length < __sysconf_txt_buffer+0x100){
|
if (newline + length < __sysconf_txt_buffer + 0x100)
|
||||||
|
{
|
||||||
temp = malloc(length + 1);
|
temp = malloc(length + 1);
|
||||||
sprintf(temp, "%s=%s%s", name, value, endline);
|
sprintf(temp, "%s=%s%s", name, value, endline);
|
||||||
strcpy(newline, temp);
|
strcpy(newline, temp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf("Not worth it!");
|
printf("Not worth it!");
|
||||||
return SYSCONF_EBADFILE;
|
return SYSCONF_EBADFILE;
|
||||||
}
|
}
|
||||||
@ -362,45 +400,54 @@ int __SYSCONF_SetTxt(const char *name, const char *value)
|
|||||||
int nlen = strlen(name);
|
int nlen = strlen(name);
|
||||||
int vlen = strlen(value);
|
int vlen = strlen(value);
|
||||||
|
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
if (!__sysconf_buffer_txt_decrypted)
|
if (!__sysconf_buffer_txt_decrypted)
|
||||||
__SYSCONF_DecryptEncryptTextBuffer();
|
__SYSCONF_DecryptEncryptTextBuffer();
|
||||||
|
|
||||||
while(line < (__sysconf_txt_buffer+0x100) ) {
|
while (line < (__sysconf_txt_buffer + 0x100))
|
||||||
|
{
|
||||||
delim = strchr(line, '=');
|
delim = strchr(line, '=');
|
||||||
if(delim && ((delim - line) == nlen) && !memcmp(name, line, nlen)) {
|
if (delim && ((delim - line) == nlen) && !memcmp(name, line, nlen))
|
||||||
|
{
|
||||||
delim++;
|
delim++;
|
||||||
end = strchr(line, '\r');
|
end = strchr(line, '\r');
|
||||||
if(end) {
|
if (end)
|
||||||
|
{
|
||||||
slen = end - delim;
|
slen = end - delim;
|
||||||
if(slen == vlen) {
|
if (slen == vlen)
|
||||||
|
{
|
||||||
// printf("vlen: %u slen: %u\n", vlen, slen);
|
// printf("vlen: %u slen: %u\n", vlen, slen);
|
||||||
memcpy(delim, value, vlen);
|
memcpy(delim, value, vlen);
|
||||||
__sysconf_txt_buffer_updated = 1;
|
__sysconf_txt_buffer_updated = 1;
|
||||||
return 0;
|
return 0;
|
||||||
} else if(vlen && (vlen < slen ||
|
}
|
||||||
(strchr(end, '\n') + (vlen-slen)) < __sysconf_txt_buffer+0x100)){
|
else if (vlen && (vlen < slen ||
|
||||||
|
(strchr(end, '\n') + (vlen - slen)) < __sysconf_txt_buffer + 0x100))
|
||||||
|
{
|
||||||
// printf("vlen: %u slen: %u\n", vlen, slen);
|
// printf("vlen: %u slen: %u\n", vlen, slen);
|
||||||
if (__SYSCONF_ShiftTxt(end, vlen-slen)) return -1;
|
if (__SYSCONF_ShiftTxt(end, vlen - slen))
|
||||||
|
return -1;
|
||||||
memcpy(delim, value, vlen);
|
memcpy(delim, value, vlen);
|
||||||
__sysconf_txt_buffer_updated = 1;
|
__sysconf_txt_buffer_updated = 1;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return SYSCONF_EBADVALUE;
|
return SYSCONF_EBADVALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip to line end
|
// skip to line end
|
||||||
while(line < (__sysconf_txt_buffer+0x100) && *line++ != '\n');
|
while (line < (__sysconf_txt_buffer + 0x100) && *line++ != '\n')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SYSCONF_ENOENT;
|
return SYSCONF_ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
u8 *__SYSCONF_Find(const char *name)
|
u8 *__SYSCONF_Find(const char *name)
|
||||||
{
|
{
|
||||||
u16 count;
|
u16 count;
|
||||||
@ -409,7 +456,8 @@ u8 *__SYSCONF_Find(const char *name)
|
|||||||
count = *((u16 *)(&__sysconf_buffer[4]));
|
count = *((u16 *)(&__sysconf_buffer[4]));
|
||||||
offset = (u16 *)&__sysconf_buffer[6];
|
offset = (u16 *)&__sysconf_buffer[6];
|
||||||
|
|
||||||
while(count--) {
|
while (count--)
|
||||||
|
{
|
||||||
if ((nlen == ((__sysconf_buffer[*offset] & 0x0F) + 1)) && !memcmp(name, &__sysconf_buffer[*offset + 1], nlen))
|
if ((nlen == ((__sysconf_buffer[*offset] & 0x0F) + 1)) && !memcmp(name, &__sysconf_buffer[*offset + 1], nlen))
|
||||||
return &__sysconf_buffer[*offset];
|
return &__sysconf_buffer[*offset];
|
||||||
offset++;
|
offset++;
|
||||||
@ -421,12 +469,15 @@ s32 SYSCONF_GetLength(const char *name)
|
|||||||
{
|
{
|
||||||
u8 *entry;
|
u8 *entry;
|
||||||
|
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
entry = __SYSCONF_Find(name);
|
entry = __SYSCONF_Find(name);
|
||||||
if(!entry) return SYSCONF_ENOENT;
|
if (!entry)
|
||||||
|
return SYSCONF_ENOENT;
|
||||||
|
|
||||||
switch(*entry>>5) {
|
switch (*entry >> 5)
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return *((u16 *)&entry[strlen(name) + 1]) + 1;
|
return *((u16 *)&entry[strlen(name) + 1]) + 1;
|
||||||
case 2:
|
case 2:
|
||||||
@ -447,10 +498,12 @@ s32 SYSCONF_GetLength(const char *name)
|
|||||||
s32 SYSCONF_GetType(const char *name)
|
s32 SYSCONF_GetType(const char *name)
|
||||||
{
|
{
|
||||||
u8 *entry;
|
u8 *entry;
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
entry = __SYSCONF_Find(name);
|
entry = __SYSCONF_Find(name);
|
||||||
if(!entry) return SYSCONF_ENOENT;
|
if (!entry)
|
||||||
|
return SYSCONF_ENOENT;
|
||||||
|
|
||||||
return *entry >> 5;
|
return *entry >> 5;
|
||||||
}
|
}
|
||||||
@ -459,16 +512,21 @@ s32 SYSCONF_Get(const char *name, void *buffer, u32 length)
|
|||||||
{
|
{
|
||||||
u8 *entry;
|
u8 *entry;
|
||||||
s32 len;
|
s32 len;
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
entry = __SYSCONF_Find(name);
|
entry = __SYSCONF_Find(name);
|
||||||
if(!entry) return SYSCONF_ENOENT;
|
if (!entry)
|
||||||
|
return SYSCONF_ENOENT;
|
||||||
|
|
||||||
len = SYSCONF_GetLength(name);
|
len = SYSCONF_GetLength(name);
|
||||||
if(len<0) return len;
|
if (len < 0)
|
||||||
if(len>length) return SYSCONF_ETOOBIG;
|
return len;
|
||||||
|
if (len > length)
|
||||||
|
return SYSCONF_ETOOBIG;
|
||||||
|
|
||||||
switch(*entry>>5) {
|
switch (*entry >> 5)
|
||||||
|
{
|
||||||
case SYSCONF_BIGARRAY:
|
case SYSCONF_BIGARRAY:
|
||||||
memcpy(buffer, &entry[strlen(name) + 3], len);
|
memcpy(buffer, &entry[strlen(name) + 3], len);
|
||||||
break;
|
break;
|
||||||
@ -492,16 +550,21 @@ s32 SYSCONF_Set(const char *name, const void *value, u32 length)
|
|||||||
{
|
{
|
||||||
u8 *entry;
|
u8 *entry;
|
||||||
s32 len;
|
s32 len;
|
||||||
if(!__sysconf_inited) return SYSCONF_ENOTINIT;
|
if (!__sysconf_inited)
|
||||||
|
return SYSCONF_ENOTINIT;
|
||||||
|
|
||||||
entry = __SYSCONF_Find(name);
|
entry = __SYSCONF_Find(name);
|
||||||
if(!entry) return SYSCONF_ENOENT;
|
if (!entry)
|
||||||
|
return SYSCONF_ENOENT;
|
||||||
|
|
||||||
len = SYSCONF_GetLength(name);
|
len = SYSCONF_GetLength(name);
|
||||||
if(len<0) return len;
|
if (len < 0)
|
||||||
if(length!=len) return SYSCONF_EBADVALUE;
|
return len;
|
||||||
|
if (length != len)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
switch(*entry>>5) {
|
switch (*entry >> 5)
|
||||||
|
{
|
||||||
case SYSCONF_BIGARRAY:
|
case SYSCONF_BIGARRAY:
|
||||||
memcpy(&entry[strlen(name) + 3], value, len);
|
memcpy(&entry[strlen(name) + 3], value, len);
|
||||||
break;
|
break;
|
||||||
@ -528,8 +591,10 @@ s32 SYSCONF_GetShutdownMode(void)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=2) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 2)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return idlesysconf[0];
|
return idlesysconf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,8 +603,10 @@ s32 SYSCONF_GetIdleLedMode(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 idlesysconf[2] = {0, 0};
|
u8 idlesysconf[2] = {0, 0};
|
||||||
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=2) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 2)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return idlesysconf[1];
|
return idlesysconf[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,8 +615,10 @@ s32 SYSCONF_GetProgressiveScan(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("IPL.PGS", &val, 1);
|
res = SYSCONF_Get("IPL.PGS", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,8 +627,10 @@ s32 SYSCONF_GetEuRGB60(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("IPL.E60", &val, 1);
|
res = SYSCONF_Get("IPL.E60", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,8 +639,10 @@ s32 SYSCONF_GetIRSensitivity(void)
|
|||||||
int res;
|
int res;
|
||||||
u32 val = 0;
|
u32 val = 0;
|
||||||
res = SYSCONF_Get("BT.SENS", &val, 4);
|
res = SYSCONF_Get("BT.SENS", &val, 4);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=4) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 4)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,8 +651,10 @@ s32 SYSCONF_GetSensorBarPosition(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("BT.BAR", &val, 1);
|
res = SYSCONF_Get("BT.BAR", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,8 +663,10 @@ s32 SYSCONF_GetPadSpeakerVolume(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("BT.SPKV", &val, 1);
|
res = SYSCONF_Get("BT.SPKV", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,8 +675,10 @@ s32 SYSCONF_GetPadMotorMode(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("BT.MOT", &val, 1);
|
res = SYSCONF_Get("BT.MOT", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,8 +687,10 @@ s32 SYSCONF_GetSoundMode(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("IPL.SND", &val, 1);
|
res = SYSCONF_Get("IPL.SND", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,8 +699,10 @@ s32 SYSCONF_GetLanguage(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("IPL.LNG", &val, 1);
|
res = SYSCONF_Get("IPL.LNG", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,8 +710,10 @@ s32 SYSCONF_GetCounterBias(u32 *bias)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
res = SYSCONF_Get("IPL.CB", bias, 4);
|
res = SYSCONF_Get("IPL.CB", bias, 4);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=4) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 4)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return SYSCONF_ERR_OK;
|
return SYSCONF_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,8 +722,10 @@ s32 SYSCONF_GetScreenSaverMode(void)
|
|||||||
int res;
|
int res;
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
res = SYSCONF_Get("IPL.SSV", &val, 1);
|
res = SYSCONF_Get("IPL.SSV", &val, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,8 +733,10 @@ s32 SYSCONF_GetDisplayOffsetH(s8 *offset)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
res = SYSCONF_Get("IPL.DH", offset, 1);
|
res = SYSCONF_Get("IPL.DH", offset, 1);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,10 +746,13 @@ s32 SYSCONF_GetPadDevices(sysconf_pad_device *devs, int count)
|
|||||||
u8 buf[0x461];
|
u8 buf[0x461];
|
||||||
|
|
||||||
res = SYSCONF_Get("BT.DINF", buf, 0x461);
|
res = SYSCONF_Get("BT.DINF", buf, 0x461);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if((res < 1) || (buf[0] > 0x10)) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if ((res < 1) || (buf[0] > 0x10))
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
if(count && devs) {
|
if (count && devs)
|
||||||
|
{
|
||||||
memset(devs, 0, count * sizeof(sysconf_pad_device));
|
memset(devs, 0, count * sizeof(sysconf_pad_device));
|
||||||
if (count < buf[0])
|
if (count < buf[0])
|
||||||
memcpy(devs, &buf[1], count * sizeof(sysconf_pad_device));
|
memcpy(devs, &buf[1], count * sizeof(sysconf_pad_device));
|
||||||
@ -678,8 +770,10 @@ s32 SYSCONF_GetNickName(u8 *nickname)
|
|||||||
u16 buf[11];
|
u16 buf[11];
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.NIK", buf, 0x16);
|
res = SYSCONF_Get("IPL.NIK", buf, 0x16);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if((res != 0x16) || (!buf[0])) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if ((res != 0x16) || (!buf[0]))
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
nickname[i] = buf[i];
|
nickname[i] = buf[i];
|
||||||
@ -694,8 +788,10 @@ s32 SYSCONF_GetAspectRatio(void)
|
|||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.AR", &val, 1);
|
res = SYSCONF_Get("IPL.AR", &val, 1);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,8 +801,10 @@ s32 SYSCONF_GetEULA(void)
|
|||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.EULA", &val, 1);
|
res = SYSCONF_Get("IPL.EULA", &val, 1);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,8 +814,10 @@ s32 SYSCONF_GetParentalPassword(s8 *password)
|
|||||||
u8 buf[0x4A];
|
u8 buf[0x4A];
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
memcpy(password, buf + 3, 4);
|
memcpy(password, buf + 3, 4);
|
||||||
password[4] = 0;
|
password[4] = 0;
|
||||||
@ -731,8 +831,10 @@ s32 SYSCONF_GetParentalAnswer(s8 *answer)
|
|||||||
u8 buf[0x4A];
|
u8 buf[0x4A];
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
memcpy(answer, buf + 8, 32);
|
memcpy(answer, buf + 8, 32);
|
||||||
answer[32] = 0;
|
answer[32] = 0;
|
||||||
@ -746,8 +848,10 @@ s32 SYSCONF_GetWiiConnect24(void)
|
|||||||
u32 val = 0;
|
u32 val = 0;
|
||||||
|
|
||||||
res = SYSCONF_Get("NET.WCFG", &val, 4);
|
res = SYSCONF_Get("NET.WCFG", &val, 4);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(res!=4) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 4)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,12 +861,18 @@ s32 SYSCONF_GetRegion(void)
|
|||||||
char buf[3];
|
char buf[3];
|
||||||
|
|
||||||
res = __SYSCONF_GetTxt("GAME", buf, 3);
|
res = __SYSCONF_GetTxt("GAME", buf, 3);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(!strcmp(buf, "JP")) return SYSCONF_REGION_JP;
|
return res;
|
||||||
if(!strcmp(buf, "US")) return SYSCONF_REGION_US;
|
if (!strcmp(buf, "JP"))
|
||||||
if(!strcmp(buf, "EU")) return SYSCONF_REGION_EU;
|
return SYSCONF_REGION_JP;
|
||||||
if(!strcmp(buf, "KR")) return SYSCONF_REGION_KR;
|
if (!strcmp(buf, "US"))
|
||||||
if(!strcmp(buf, "CN")) return SYSCONF_REGION_CN;
|
return SYSCONF_REGION_US;
|
||||||
|
if (!strcmp(buf, "EU"))
|
||||||
|
return SYSCONF_REGION_EU;
|
||||||
|
if (!strcmp(buf, "KR"))
|
||||||
|
return SYSCONF_REGION_KR;
|
||||||
|
if (!strcmp(buf, "CN"))
|
||||||
|
return SYSCONF_REGION_CN;
|
||||||
return SYSCONF_EBADVALUE;
|
return SYSCONF_EBADVALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,19 +882,32 @@ s32 SYSCONF_GetArea(void)
|
|||||||
char buf[4];
|
char buf[4];
|
||||||
|
|
||||||
res = __SYSCONF_GetTxt("AREA", buf, 4);
|
res = __SYSCONF_GetTxt("AREA", buf, 4);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(!strcmp(buf, "JPN")) return SYSCONF_AREA_JPN;
|
return res;
|
||||||
if(!strcmp(buf, "USA")) return SYSCONF_AREA_USA;
|
if (!strcmp(buf, "JPN"))
|
||||||
if(!strcmp(buf, "EUR")) return SYSCONF_AREA_EUR;
|
return SYSCONF_AREA_JPN;
|
||||||
if(!strcmp(buf, "AUS")) return SYSCONF_AREA_AUS;
|
if (!strcmp(buf, "USA"))
|
||||||
if(!strcmp(buf, "BRA")) return SYSCONF_AREA_BRA;
|
return SYSCONF_AREA_USA;
|
||||||
if(!strcmp(buf, "TWN")) return SYSCONF_AREA_TWN;
|
if (!strcmp(buf, "EUR"))
|
||||||
if(!strcmp(buf, "ROC")) return SYSCONF_AREA_ROC;
|
return SYSCONF_AREA_EUR;
|
||||||
if(!strcmp(buf, "KOR")) return SYSCONF_AREA_KOR;
|
if (!strcmp(buf, "AUS"))
|
||||||
if(!strcmp(buf, "HKG")) return SYSCONF_AREA_HKG;
|
return SYSCONF_AREA_AUS;
|
||||||
if(!strcmp(buf, "ASI")) return SYSCONF_AREA_ASI;
|
if (!strcmp(buf, "BRA"))
|
||||||
if(!strcmp(buf, "LTN")) return SYSCONF_AREA_LTN;
|
return SYSCONF_AREA_BRA;
|
||||||
if(!strcmp(buf, "SAF")) return SYSCONF_AREA_SAF;
|
if (!strcmp(buf, "TWN"))
|
||||||
|
return SYSCONF_AREA_TWN;
|
||||||
|
if (!strcmp(buf, "ROC"))
|
||||||
|
return SYSCONF_AREA_ROC;
|
||||||
|
if (!strcmp(buf, "KOR"))
|
||||||
|
return SYSCONF_AREA_KOR;
|
||||||
|
if (!strcmp(buf, "HKG"))
|
||||||
|
return SYSCONF_AREA_HKG;
|
||||||
|
if (!strcmp(buf, "ASI"))
|
||||||
|
return SYSCONF_AREA_ASI;
|
||||||
|
if (!strcmp(buf, "LTN"))
|
||||||
|
return SYSCONF_AREA_LTN;
|
||||||
|
if (!strcmp(buf, "SAF"))
|
||||||
|
return SYSCONF_AREA_SAF;
|
||||||
return SYSCONF_EBADVALUE;
|
return SYSCONF_EBADVALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,10 +917,14 @@ s32 SYSCONF_GetVideo(void)
|
|||||||
char buf[5];
|
char buf[5];
|
||||||
|
|
||||||
res = __SYSCONF_GetTxt("VIDEO", buf, 5);
|
res = __SYSCONF_GetTxt("VIDEO", buf, 5);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(!strcmp(buf, "NTSC")) return SYSCONF_VIDEO_NTSC;
|
return res;
|
||||||
if(!strcmp(buf, "PAL")) return SYSCONF_VIDEO_PAL;
|
if (!strcmp(buf, "NTSC"))
|
||||||
if(!strcmp(buf, "MPAL")) return SYSCONF_VIDEO_MPAL;
|
return SYSCONF_VIDEO_NTSC;
|
||||||
|
if (!strcmp(buf, "PAL"))
|
||||||
|
return SYSCONF_VIDEO_PAL;
|
||||||
|
if (!strcmp(buf, "MPAL"))
|
||||||
|
return SYSCONF_VIDEO_MPAL;
|
||||||
return SYSCONF_EBADVALUE;
|
return SYSCONF_EBADVALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -806,8 +933,10 @@ s32 SYSCONF_SetShutdownMode(u8 value)
|
|||||||
u8 idlesysconf[2] = {0, 0};
|
u8 idlesysconf[2] = {0, 0};
|
||||||
int res;
|
int res;
|
||||||
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=2) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 2)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
idlesysconf[0] = value;
|
idlesysconf[0] = value;
|
||||||
|
|
||||||
@ -819,15 +948,16 @@ s32 SYSCONF_SetIdleLedMode(u8 value)
|
|||||||
u8 idlesysconf[2] = {0, 0};
|
u8 idlesysconf[2] = {0, 0};
|
||||||
int res;
|
int res;
|
||||||
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
||||||
if(res<0) return res;
|
if (res < 0)
|
||||||
if(res!=2) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 2)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
idlesysconf[1] = value;
|
idlesysconf[1] = value;
|
||||||
|
|
||||||
return SYSCONF_Set("IPL.IDL", idlesysconf, 2);
|
return SYSCONF_Set("IPL.IDL", idlesysconf, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s32 SYSCONF_SetProgressiveScan(u8 value)
|
s32 SYSCONF_SetProgressiveScan(u8 value)
|
||||||
{
|
{
|
||||||
return SYSCONF_Set("IPL.PGS", &value, 1);
|
return SYSCONF_Set("IPL.PGS", &value, 1);
|
||||||
@ -838,7 +968,6 @@ s32 SYSCONF_SetEuRGB60(u8 value)
|
|||||||
return SYSCONF_Set("IPL.E60", &value, 1);
|
return SYSCONF_Set("IPL.E60", &value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s32 SYSCONF_SetIRSensitivity(u32 value)
|
s32 SYSCONF_SetIRSensitivity(u32 value)
|
||||||
{
|
{
|
||||||
return SYSCONF_Set("BT.SENS", &value, 4);
|
return SYSCONF_Set("BT.SENS", &value, 4);
|
||||||
@ -888,7 +1017,8 @@ s32 SYSCONF_SetPadDevices(const sysconf_pad_device *devs, u8 count)
|
|||||||
{
|
{
|
||||||
u8 buf[0x461] = {0};
|
u8 buf[0x461] = {0};
|
||||||
|
|
||||||
if(count > 0x10) return SYSCONF_EBADVALUE;
|
if (count > 0x10)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
buf[0] = count;
|
buf[0] = count;
|
||||||
|
|
||||||
if (devs)
|
if (devs)
|
||||||
@ -901,7 +1031,8 @@ s32 SYSCONF_SetNickName(const u8 *nickname, u16 length)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u16 buf[11] = {0};
|
u16 buf[11] = {0};
|
||||||
if (length >10) return SYSCONF_EBADVALUE;
|
if (length > 10)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
buf[i] = nickname[i];
|
buf[i] = nickname[i];
|
||||||
@ -917,7 +1048,8 @@ s32 SYSCONF_SetAspectRatio(u8 value)
|
|||||||
|
|
||||||
s32 SYSCONF_SetEULA(u8 value)
|
s32 SYSCONF_SetEULA(u8 value)
|
||||||
{
|
{
|
||||||
if (value > 1) return SYSCONF_EBADVALUE;
|
if (value > 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
return SYSCONF_Set("IPL.EULA", &value, 1);
|
return SYSCONF_Set("IPL.EULA", &value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -925,11 +1057,14 @@ s32 SYSCONF_SetParentalPassword(const s8 *password, u32 length)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
u8 buf[0x4A] = {0};
|
u8 buf[0x4A] = {0};
|
||||||
if (length != 4) return SYSCONF_EBADVALUE;
|
if (length != 4)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
memcpy(buf + 3, password, 4);
|
memcpy(buf + 3, password, 4);
|
||||||
|
|
||||||
@ -940,11 +1075,14 @@ s32 SYSCONF_SetParentalAnswer(const s8 *answer, u32 length)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
u8 buf[0x4A] = {0};
|
u8 buf[0x4A] = {0};
|
||||||
if (length != 32) return SYSCONF_EBADVALUE;
|
if (length != 32)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
||||||
if(res < 0) return res;
|
if (res < 0)
|
||||||
if(res!=1) return SYSCONF_EBADVALUE;
|
return res;
|
||||||
|
if (res != 1)
|
||||||
|
return SYSCONF_EBADVALUE;
|
||||||
|
|
||||||
memcpy(buf + 8, answer, length);
|
memcpy(buf + 8, answer, length);
|
||||||
|
|
||||||
@ -958,7 +1096,8 @@ s32 SYSCONF_SetWiiConnect24(u32 value)
|
|||||||
|
|
||||||
s32 SYSCONF_SetRegion(s32 value)
|
s32 SYSCONF_SetRegion(s32 value)
|
||||||
{
|
{
|
||||||
switch(value){
|
switch (value)
|
||||||
|
{
|
||||||
case SYSCONF_REGION_JP:
|
case SYSCONF_REGION_JP:
|
||||||
return __SYSCONF_SetTxt("GAME", "JP");
|
return __SYSCONF_SetTxt("GAME", "JP");
|
||||||
case SYSCONF_REGION_US:
|
case SYSCONF_REGION_US:
|
||||||
@ -976,7 +1115,8 @@ s32 SYSCONF_SetRegion(s32 value)
|
|||||||
|
|
||||||
s32 SYSCONF_SetArea(s32 value)
|
s32 SYSCONF_SetArea(s32 value)
|
||||||
{
|
{
|
||||||
switch(value){
|
switch (value)
|
||||||
|
{
|
||||||
case SYSCONF_AREA_JPN:
|
case SYSCONF_AREA_JPN:
|
||||||
return __SYSCONF_SetTxt("AREA", "JPN");
|
return __SYSCONF_SetTxt("AREA", "JPN");
|
||||||
break;
|
break;
|
||||||
@ -1020,7 +1160,8 @@ s32 SYSCONF_SetArea(s32 value)
|
|||||||
|
|
||||||
s32 SYSCONF_SetVideo(s32 value)
|
s32 SYSCONF_SetVideo(s32 value)
|
||||||
{
|
{
|
||||||
switch(value){
|
switch (value)
|
||||||
|
{
|
||||||
case SYSCONF_VIDEO_NTSC:
|
case SYSCONF_VIDEO_NTSC:
|
||||||
return __SYSCONF_SetTxt("VIDEO", "NTSC");
|
return __SYSCONF_SetTxt("VIDEO", "NTSC");
|
||||||
break;
|
break;
|
||||||
|
@ -50,10 +50,12 @@ distribution.
|
|||||||
//#define DEBUG_SYSCONF
|
//#define DEBUG_SYSCONF
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_BIGARRAY = 1,
|
SYSCONF_BIGARRAY = 1,
|
||||||
SYSCONF_SMALLARRAY,
|
SYSCONF_SMALLARRAY,
|
||||||
SYSCONF_BYTE,
|
SYSCONF_BYTE,
|
||||||
@ -62,13 +64,15 @@ enum {
|
|||||||
SYSCONF_BOOL = 7
|
SYSCONF_BOOL = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_VIDEO_NTSC = 0,
|
SYSCONF_VIDEO_NTSC = 0,
|
||||||
SYSCONF_VIDEO_PAL,
|
SYSCONF_VIDEO_PAL,
|
||||||
SYSCONF_VIDEO_MPAL
|
SYSCONF_VIDEO_MPAL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_REGION_JP = 0,
|
SYSCONF_REGION_JP = 0,
|
||||||
SYSCONF_REGION_US,
|
SYSCONF_REGION_US,
|
||||||
SYSCONF_REGION_EU,
|
SYSCONF_REGION_EU,
|
||||||
@ -76,7 +80,8 @@ enum {
|
|||||||
SYSCONF_REGION_CN
|
SYSCONF_REGION_CN
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_AREA_JPN = 0,
|
SYSCONF_AREA_JPN = 0,
|
||||||
SYSCONF_AREA_USA,
|
SYSCONF_AREA_USA,
|
||||||
SYSCONF_AREA_EUR,
|
SYSCONF_AREA_EUR,
|
||||||
@ -91,24 +96,28 @@ enum {
|
|||||||
SYSCONF_AREA_SAF
|
SYSCONF_AREA_SAF
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_SHUTDOWN_STANDBY = 0,
|
SYSCONF_SHUTDOWN_STANDBY = 0,
|
||||||
SYSCONF_SHUTDOWN_IDLE
|
SYSCONF_SHUTDOWN_IDLE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_LED_OFF = 0,
|
SYSCONF_LED_OFF = 0,
|
||||||
SYSCONF_LED_DIM,
|
SYSCONF_LED_DIM,
|
||||||
SYSCONF_LED_BRIGHT
|
SYSCONF_LED_BRIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_SOUND_MONO = 0,
|
SYSCONF_SOUND_MONO = 0,
|
||||||
SYSCONF_SOUND_STEREO,
|
SYSCONF_SOUND_STEREO,
|
||||||
SYSCONF_SOUND_SURROUND
|
SYSCONF_SOUND_SURROUND
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_LANG_JAPANESE = 0,
|
SYSCONF_LANG_JAPANESE = 0,
|
||||||
SYSCONF_LANG_ENGLISH,
|
SYSCONF_LANG_ENGLISH,
|
||||||
SYSCONF_LANG_GERMAN,
|
SYSCONF_LANG_GERMAN,
|
||||||
@ -118,19 +127,22 @@ enum {
|
|||||||
SYSCONF_LANG_DUTCH
|
SYSCONF_LANG_DUTCH
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_ASPECT_4_3 = 0,
|
SYSCONF_ASPECT_4_3 = 0,
|
||||||
SYSCONF_ASPECT_16_9
|
SYSCONF_ASPECT_16_9
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SYSCONF_SENSORBAR_BOTTOM = 0,
|
SYSCONF_SENSORBAR_BOTTOM = 0,
|
||||||
SYSCONF_SENSORBAR_TOP
|
SYSCONF_SENSORBAR_TOP
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _sysconf_pad_device sysconf_pad_device;
|
typedef struct _sysconf_pad_device sysconf_pad_device;
|
||||||
|
|
||||||
struct _sysconf_pad_device {
|
struct _sysconf_pad_device
|
||||||
|
{
|
||||||
u8 bdaddr[6];
|
u8 bdaddr[6];
|
||||||
char name[0x40];
|
char name[0x40];
|
||||||
} ATTRIBUTE_PACKED;
|
} ATTRIBUTE_PACKED;
|
||||||
@ -172,12 +184,10 @@ s32 SYSCONF_GetRegion(void);
|
|||||||
s32 SYSCONF_GetArea(void);
|
s32 SYSCONF_GetArea(void);
|
||||||
s32 SYSCONF_GetVideo(void);
|
s32 SYSCONF_GetVideo(void);
|
||||||
|
|
||||||
|
|
||||||
/* Set functions */
|
/* Set functions */
|
||||||
s32 SYSCONF_SaveChanges(void);
|
s32 SYSCONF_SaveChanges(void);
|
||||||
s32 SYSCONF_Set(const char *name, const void *value, u32 length);
|
s32 SYSCONF_Set(const char *name, const void *value, u32 length);
|
||||||
|
|
||||||
|
|
||||||
s32 SYSCONF_SetShutdownMode(u8 value);
|
s32 SYSCONF_SetShutdownMode(u8 value);
|
||||||
s32 SYSCONF_SetIdleLedMode(u8 value);
|
s32 SYSCONF_SetIdleLedMode(u8 value);
|
||||||
s32 SYSCONF_SetProgressiveScan(u8 value);
|
s32 SYSCONF_SetProgressiveScan(u8 value);
|
||||||
@ -204,7 +214,6 @@ s32 SYSCONF_SetRegion(s32 value);
|
|||||||
s32 SYSCONF_SetArea(s32 value);
|
s32 SYSCONF_SetArea(s32 value);
|
||||||
s32 SYSCONF_SetVideo(s32 value);
|
s32 SYSCONF_SetVideo(s32 value);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -38,7 +38,6 @@ distribution.
|
|||||||
|
|
||||||
#define MAX_WIIMOTES 4
|
#define MAX_WIIMOTES 4
|
||||||
|
|
||||||
|
|
||||||
static void *xfb = NULL;
|
static void *xfb = NULL;
|
||||||
static GXRModeObj *rmode = NULL;
|
static GXRModeObj *rmode = NULL;
|
||||||
int ConsoleRows;
|
int ConsoleRows;
|
||||||
@ -58,7 +57,8 @@ u64 be64(const u8 *p)
|
|||||||
return ((u64)be32(p) << 32) | be32(p + 4);
|
return ((u64)be32(p) << 32) | be32(p + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getTitleIDUID(u64 titleID){
|
u32 getTitleIDUID(u64 titleID)
|
||||||
|
{
|
||||||
s32 ret, i;
|
s32 ret, i;
|
||||||
static u8 uid_buffer[0x1000] ATTRIBUTE_ALIGN(32);
|
static u8 uid_buffer[0x1000] ATTRIBUTE_ALIGN(32);
|
||||||
u32 size;
|
u32 size;
|
||||||
@ -73,7 +73,8 @@ u32 getTitleIDUID(u64 titleID){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 getUIDTitleID(u32 uid){
|
u64 getUIDTitleID(u32 uid)
|
||||||
|
{
|
||||||
s32 ret, i;
|
s32 ret, i;
|
||||||
static u8 uid_buffer[0x1000] ATTRIBUTE_ALIGN(32);
|
static u8 uid_buffer[0x1000] ATTRIBUTE_ALIGN(32);
|
||||||
u32 size;
|
u32 size;
|
||||||
@ -87,7 +88,6 @@ u64 getUIDTitleID(u32 uid){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Basic init taken pretty directly from the libOGC examples */
|
/* Basic init taken pretty directly from the libOGC examples */
|
||||||
void basicInit(void)
|
void basicInit(void)
|
||||||
{
|
{
|
||||||
@ -106,11 +106,9 @@ void basicInit(void)
|
|||||||
// Allocate memory for the display in the uncached region
|
// Allocate memory for the display in the uncached region
|
||||||
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
||||||
|
|
||||||
|
|
||||||
// Initialise the console, required for printf
|
// Initialise the console, required for printf
|
||||||
console_init(xfb, 0, 0, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
|
console_init(xfb, 0, 0, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
|
||||||
|
|
||||||
|
|
||||||
// Set up the video registers with the chosen mode
|
// Set up the video registers with the chosen mode
|
||||||
VIDEO_Configure(rmode);
|
VIDEO_Configure(rmode);
|
||||||
|
|
||||||
@ -125,10 +123,8 @@ void basicInit(void)
|
|||||||
|
|
||||||
// Wait for Video setup to complete
|
// Wait for Video setup to complete
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
if (rmode->viTVMode & VI_NON_INTERLACE)
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The console understands VT terminal escape codes
|
// The console understands VT terminal escape codes
|
||||||
// This positions the cursor on row 2, column 0
|
// This positions the cursor on row 2, column 0
|
||||||
@ -138,39 +134,47 @@ void basicInit(void)
|
|||||||
CON_GetMetrics(&ConsoleCols, &ConsoleRows);
|
CON_GetMetrics(&ConsoleCols, &ConsoleRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearScreen() {
|
void ClearScreen()
|
||||||
|
{
|
||||||
/* Clear console */
|
/* Clear console */
|
||||||
printf("\x1b[2J");
|
printf("\x1b[2J");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
void ClearLine() {
|
void ClearLine()
|
||||||
|
{
|
||||||
printf("\r\x1b[2K\r");
|
printf("\r\x1b[2K\r");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
void PrintCenter(char *text, int width) {
|
void PrintCenter(char *text, int width)
|
||||||
|
{
|
||||||
int textLen = strlen(text);
|
int textLen = strlen(text);
|
||||||
int leftPad = (width - textLen) / 2;
|
int leftPad = (width - textLen) / 2;
|
||||||
int rightPad = (width - textLen) - leftPad;
|
int rightPad = (width - textLen) - leftPad;
|
||||||
printf("%*s%s%*s", leftPad, " ", text, rightPad, " ");
|
printf("%*s%s%*s", leftPad, " ", text, rightPad, " ");
|
||||||
}
|
}
|
||||||
void Console_SetFgColor(u8 color, u8 bold) {
|
void Console_SetFgColor(u8 color, u8 bold)
|
||||||
|
{
|
||||||
printf("\x1b[%u;%dm", color + 30, bold);
|
printf("\x1b[%u;%dm", color + 30, bold);
|
||||||
}
|
}
|
||||||
void Console_SetBgColor(u8 color, u8 bold) {
|
void Console_SetBgColor(u8 color, u8 bold)
|
||||||
|
{
|
||||||
printf("\x1b[%u;%dm", color + 40, bold);
|
printf("\x1b[%u;%dm", color + 40, bold);
|
||||||
}
|
}
|
||||||
void Console_SetColors(u8 bgColor, u8 bgBold, u8 fgColor, u8 fgBold) {
|
void Console_SetColors(u8 bgColor, u8 bgBold, u8 fgColor, u8 fgBold)
|
||||||
|
{
|
||||||
Console_SetBgColor(bgColor, bgBold);
|
Console_SetBgColor(bgColor, bgBold);
|
||||||
Console_SetFgColor(fgColor, fgBold);
|
Console_SetFgColor(fgColor, fgBold);
|
||||||
}
|
}
|
||||||
void Console_SetPosition(u8 row, u8 column) {
|
void Console_SetPosition(u8 row, u8 column)
|
||||||
|
{
|
||||||
// The console understands VT terminal escape codes
|
// The console understands VT terminal escape codes
|
||||||
// This positions the cursor on row 2, column 0
|
// This positions the cursor on row 2, column 0
|
||||||
// we can use variables for this with format codes too
|
// we can use variables for this with format codes too
|
||||||
// e.g. printf ("\x1b[%d;%dH", row, column );
|
// e.g. printf ("\x1b[%d;%dH", row, column );
|
||||||
printf("\x1b[%u;%uH", row, column);
|
printf("\x1b[%u;%uH", row, column);
|
||||||
}
|
}
|
||||||
void PrintBanner() {
|
void PrintBanner()
|
||||||
|
{
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
Console_SetColors(GREEN, 0, WHITE, 2);
|
Console_SetColors(GREEN, 0, WHITE, 2);
|
||||||
char text[ConsoleCols];
|
char text[ConsoleCols];
|
||||||
@ -191,23 +195,28 @@ void miscInit(void)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
ret = ISFS_Initialize();
|
ret = ISFS_Initialize();
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
|
{
|
||||||
gprintf("\nError! ISFS_Initialize (ret = %d)\n", ret);
|
gprintf("\nError! ISFS_Initialize (ret = %d)\n", ret);
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
gprintf("OK!\n");
|
gprintf("OK!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// IdentSysMenu();
|
// IdentSysMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentSysMenu(void){
|
void IdentSysMenu(void)
|
||||||
|
{
|
||||||
int ret;
|
int ret;
|
||||||
Identify_SysMenu();
|
Identify_SysMenu();
|
||||||
|
|
||||||
ret = ES_SetUID(TITLE_ID(1, 2));
|
ret = ES_SetUID(TITLE_ID(1, 2));
|
||||||
if (ret < 0){
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("SetUID fail %d", ret);
|
printf("SetUID fail %d", ret);
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -218,11 +227,14 @@ void IdentSysMenu(void){
|
|||||||
|
|
||||||
ISFS_Deinitialize();
|
ISFS_Deinitialize();
|
||||||
ret = ISFS_Initialize();
|
ret = ISFS_Initialize();
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("\nError! ISFS_Initialize (ret = %d)\n", ret);
|
printf("\nError! ISFS_Initialize (ret = %d)\n", ret);
|
||||||
wait_anyKey();
|
wait_anyKey();
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf("OK!\n");
|
printf("OK!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,12 +251,15 @@ u32 getButtons(void)
|
|||||||
return WPAD_ButtonsDown(0);
|
return WPAD_ButtonsDown(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 wait_anyKey(void) {
|
u32 wait_anyKey(void)
|
||||||
|
{
|
||||||
u32 pressed;
|
u32 pressed;
|
||||||
while(!(pressed = getButtons())) {
|
while (!(pressed = getButtons()))
|
||||||
|
{
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
}
|
}
|
||||||
if (pressed & WPAD_BUTTON_HOME) {
|
if (pressed & WPAD_BUTTON_HOME)
|
||||||
|
{
|
||||||
Console_SetPosition(26, 0);
|
Console_SetPosition(26, 0);
|
||||||
ClearLine();
|
ClearLine();
|
||||||
Console_SetPosition(26, 30);
|
Console_SetPosition(26, 30);
|
||||||
@ -255,12 +270,15 @@ u32 wait_anyKey(void) {
|
|||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 wait_key(u32 button) {
|
u32 wait_key(u32 button)
|
||||||
|
{
|
||||||
u32 pressed;
|
u32 pressed;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
pressed = getButtons();
|
pressed = getButtons();
|
||||||
if (pressed & WPAD_BUTTON_HOME) {
|
if (pressed & WPAD_BUTTON_HOME)
|
||||||
|
{
|
||||||
Console_SetPosition(26, 0);
|
Console_SetPosition(26, 0);
|
||||||
ClearLine();
|
ClearLine();
|
||||||
Console_SetPosition(26, 30);
|
Console_SetPosition(26, 30);
|
||||||
@ -273,22 +291,26 @@ u32 wait_key(u32 button) {
|
|||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
char charASCII(u8 c) {
|
char charASCII(u8 c)
|
||||||
|
{
|
||||||
if (c < 0x20 || c > 0x7E)
|
if (c < 0x20 || c > 0x7E)
|
||||||
return '.';
|
return '.';
|
||||||
else
|
else
|
||||||
return (char)c;
|
return (char)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hex_print_array16(const u8 *array, u32 size){
|
void hex_print_array16(const u8 *array, u32 size)
|
||||||
|
{
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
u32 page_size = 0x100;
|
u32 page_size = 0x100;
|
||||||
char line[17];
|
char line[17];
|
||||||
line[16] = 0;
|
line[16] = 0;
|
||||||
if (size > page_size)
|
if (size > page_size)
|
||||||
printf("Page 1 of %lu", (size / page_size) + 1);
|
printf("Page 1 of %lu", (size / page_size) + 1);
|
||||||
while (offset < size){
|
while (offset < size)
|
||||||
if (!(offset % 16)) printf("\n0x%08lX: ", offset);
|
{
|
||||||
|
if (!(offset % 16))
|
||||||
|
printf("\n0x%08lX: ", offset);
|
||||||
|
|
||||||
printf("%02X", array[offset]);
|
printf("%02X", array[offset]);
|
||||||
|
|
||||||
@ -300,7 +322,8 @@ void hex_print_array16(const u8 *array, u32 size){
|
|||||||
if (!(offset % 16))
|
if (!(offset % 16))
|
||||||
printf(line);
|
printf(line);
|
||||||
|
|
||||||
if (!(offset % page_size) && offset < size){
|
if (!(offset % page_size) && offset < size)
|
||||||
|
{
|
||||||
u32 pressed;
|
u32 pressed;
|
||||||
printf("\n\tPress a key for next page or B for finish\n");
|
printf("\n\tPress a key for next page or B for finish\n");
|
||||||
pressed = wait_anyKey();
|
pressed = wait_anyKey();
|
||||||
@ -312,24 +335,26 @@ void hex_print_array16(const u8 *array, u32 size){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool yes_or_no(void){
|
bool yes_or_no(void)
|
||||||
|
{
|
||||||
bool yes = 0;
|
bool yes = 0;
|
||||||
u32 buttons = 0;
|
u32 buttons = 0;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
yes = buttons & WPAD_BUTTON_LEFT;
|
yes = buttons & WPAD_BUTTON_LEFT;
|
||||||
if (yes)
|
if (yes)
|
||||||
printf("\r\x1b[K <\x1b[30m\x1b[47;1m Yes \x1b[37;1m\x1b[40m> No ");
|
printf("\r\x1b[K <\x1b[30m\x1b[47;1m Yes \x1b[37;1m\x1b[40m> No ");
|
||||||
else
|
else
|
||||||
printf("\r\x1b[K Yes <\x1b[30m\x1b[47;1m No \x1b[37;1m\x1b[40m> ");
|
printf("\r\x1b[K Yes <\x1b[30m\x1b[47;1m No \x1b[37;1m\x1b[40m> ");
|
||||||
} while ((buttons = wait_key(WPAD_BUTTON_A | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT))
|
} while ((buttons = wait_key(WPAD_BUTTON_A | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT)) && (!(buttons & WPAD_BUTTON_A)));
|
||||||
&& (!(buttons & WPAD_BUTTON_A)));
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return yes;
|
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) {
|
s32 ISFS_ReadFileToArray(const char *filepath, u8 *filearray, u32 max_size, u32 *file_size)
|
||||||
|
{
|
||||||
s32 ret, fd;
|
s32 ret, fd;
|
||||||
static fstats filestats ATTRIBUTE_ALIGN(32);
|
static fstats filestats ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
@ -381,7 +406,8 @@ s32 ISFS_ReadFileToArray (const char *filepath, u8 *filearray, u32 max_size, u32
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 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){
|
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 ret, fd = 0, out;
|
s32 ret, fd = 0, out;
|
||||||
u64 currentTid;
|
u64 currentTid;
|
||||||
u32 realownid;
|
u32 realownid;
|
||||||
@ -392,7 +418,8 @@ s32 ISFS_WriteFileFromArray (const char *filepath, const u8 *filearray, u32 arra
|
|||||||
out = 0;
|
out = 0;
|
||||||
|
|
||||||
ret = ISFS_Open(filepath, ISFS_OPEN_WRITE);
|
ret = ISFS_Open(filepath, ISFS_OPEN_WRITE);
|
||||||
if (ret == -102){
|
if (ret == -102)
|
||||||
|
{
|
||||||
|
|
||||||
printf("\tMaking file writable...\n");
|
printf("\tMaking file writable...\n");
|
||||||
ret = ISFS_SetAttr(filepath, ownerID, groupID, attr, 3, 3, 3);
|
ret = ISFS_SetAttr(filepath, ownerID, groupID, attr, 3, 3, 3);
|
||||||
@ -404,20 +431,23 @@ s32 ISFS_WriteFileFromArray (const char *filepath, const u8 *filearray, u32 arra
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ISFS_WriteFileFromArray(filepath, filearray, array_size, ownerID, groupID, attr, own_perm, group_perm, other_perm);
|
return ISFS_WriteFileFromArray(filepath, filearray, array_size, ownerID, groupID, attr, own_perm, group_perm, other_perm);
|
||||||
|
}
|
||||||
} else if (ret == -106){
|
else if (ret == -106)
|
||||||
|
{
|
||||||
|
|
||||||
printf("\tCreating file...\n");
|
printf("\tCreating file...\n");
|
||||||
ret = ISFS_CreateFile(filepath, attr, 3, 3, 3);
|
ret = ISFS_CreateFile(filepath, attr, 3, 3, 3);
|
||||||
if (ret < 0){
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("Error! ISFS_CreateFile (ret = %ld)\n", ret);
|
printf("Error! ISFS_CreateFile (ret = %ld)\n", ret);
|
||||||
out = -1;
|
out = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ISFS_WriteFileFromArray(filepath, filearray, array_size, ownerID, groupID, attr, own_perm, group_perm, other_perm);
|
return ISFS_WriteFileFromArray(filepath, filearray, array_size, ownerID, groupID, attr, own_perm, group_perm, other_perm);
|
||||||
|
}
|
||||||
} else if (ret <= 0) {
|
else if (ret <= 0)
|
||||||
|
{
|
||||||
printf("Error! ISFS_Open WRITE (ret = %ld)\n", ret);
|
printf("Error! ISFS_Open WRITE (ret = %ld)\n", ret);
|
||||||
out = -1;
|
out = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -426,7 +456,8 @@ s32 ISFS_WriteFileFromArray (const char *filepath, const u8 *filearray, u32 arra
|
|||||||
fd = ret;
|
fd = ret;
|
||||||
|
|
||||||
ret = ISFS_Seek(fd, 0, 0);
|
ret = ISFS_Seek(fd, 0, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
|
{
|
||||||
printf("Error! ISFS_Seek (ret = %ld)\n", ret);
|
printf("Error! ISFS_Seek (ret = %ld)\n", ret);
|
||||||
out = -1;
|
out = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -486,15 +517,18 @@ s32 ISFS_WriteFileFromArray (const char *filepath, const u8 *filearray, u32 arra
|
|||||||
out = -1;
|
out = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realownid != ownerID){
|
if (realownid != ownerID)
|
||||||
|
{
|
||||||
ret = ES_GetTitleID(¤tTid);
|
ret = ES_GetTitleID(¤tTid);
|
||||||
if (ret){
|
if (ret)
|
||||||
|
{
|
||||||
printf("Fail GetTitleID %ld", ret);
|
printf("Fail GetTitleID %ld", ret);
|
||||||
if (wait_key(WPAD_BUTTON_A | WPAD_BUTTON_B) & WPAD_BUTTON_B)
|
if (wait_key(WPAD_BUTTON_A | WPAD_BUTTON_B) & WPAD_BUTTON_B)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ret = ES_SetUID(getUIDTitleID(ownerID));
|
ret = ES_SetUID(getUIDTitleID(ownerID));
|
||||||
if (ret){
|
if (ret)
|
||||||
|
{
|
||||||
printf("Couldn't set OwnerID, using current owner ID\n");
|
printf("Couldn't set OwnerID, using current owner ID\n");
|
||||||
if (wait_key(WPAD_BUTTON_A | WPAD_BUTTON_B) & WPAD_BUTTON_B)
|
if (wait_key(WPAD_BUTTON_A | WPAD_BUTTON_B) & WPAD_BUTTON_B)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -510,9 +544,11 @@ s32 ISFS_WriteFileFromArray (const char *filepath, const u8 *filearray, u32 arra
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realownid != ownerID){
|
if (realownid != ownerID)
|
||||||
|
{
|
||||||
ret = ES_SetUID(currentTid);
|
ret = ES_SetUID(currentTid);
|
||||||
if (ret){
|
if (ret)
|
||||||
|
{
|
||||||
printf("Fail SetUID %ld", ret);
|
printf("Fail SetUID %ld", ret);
|
||||||
if (wait_key(WPAD_BUTTON_A | WPAD_BUTTON_B) & WPAD_BUTTON_B)
|
if (wait_key(WPAD_BUTTON_A | WPAD_BUTTON_B) & WPAD_BUTTON_B)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -520,7 +556,8 @@ s32 ISFS_WriteFileFromArray (const char *filepath, const u8 *filearray, u32 arra
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (fd) {
|
if (fd)
|
||||||
|
{
|
||||||
ret = ISFS_Close(fd);
|
ret = ISFS_Close(fd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -529,5 +566,4 @@ s32 ISFS_WriteFileFromArray (const char *filepath, const u8 *filearray, u32 arra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ distribution.
|
|||||||
#ifndef _WII_BASICS_H_
|
#ifndef _WII_BASICS_H_
|
||||||
#define _WII_BASICS_H_
|
#define _WII_BASICS_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))
|
||||||
// Get upper or lower half of a title ID
|
// Get upper or lower half of a title ID
|
||||||
|
Loading…
Reference in New Issue
Block a user