mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-12-22 09:51:55 +01:00
* Fixed Ocarina download from Geckocodes issue2253 (Thanks Gave92)
* Added a check for downloaded Ocarina content (Thanks Airline38) * Removed Error #002 setting (Always set to Anti)
This commit is contained in:
parent
e1b58a73ce
commit
9a78c7a1a9
@ -2,8 +2,8 @@
|
||||
<app version="1">
|
||||
<name> USB Loader GX</name>
|
||||
<coder>USB Loader GX Team</coder>
|
||||
<version>3.0 r1224</version>
|
||||
<release_date>20140504153530</release_date>
|
||||
<version>3.0 r1225</version>
|
||||
<release_date>20140505182616</release_date>
|
||||
<!-- // remove this line to enable arguments
|
||||
<arguments>
|
||||
<arg>--ios=250</arg>
|
||||
|
@ -25,6 +25,7 @@ static s32 send_message(s32 server, char *msg)
|
||||
if ((bytes_transferred = net_write(server, msg, remaining > NET_BUFFER_SIZE ? NET_BUFFER_SIZE : remaining)) > 0)
|
||||
{
|
||||
remaining -= bytes_transferred;
|
||||
msg += bytes_transferred;
|
||||
usleep(20 * 1000);
|
||||
}
|
||||
else if (bytes_transferred < 0)
|
||||
@ -46,7 +47,7 @@ static s32 send_message(s32 server, char *msg)
|
||||
* @param u32 the port to connect to on the server
|
||||
* @return s32 The connection to the server (negative number if connection could not be established)
|
||||
*/
|
||||
static s32 server_connect(u32 ipaddress, u32 socket_port)
|
||||
static s32 server_connect(u32 ipaddress, u16 socket_port)
|
||||
{
|
||||
//Initialize socket
|
||||
s32 connection = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||
@ -55,7 +56,7 @@ static s32 server_connect(u32 ipaddress, u32 socket_port)
|
||||
struct sockaddr_in connect_addr;
|
||||
memset(&connect_addr, 0, sizeof(connect_addr));
|
||||
connect_addr.sin_family = AF_INET;
|
||||
connect_addr.sin_port = socket_port;
|
||||
connect_addr.sin_port = htons(socket_port);
|
||||
connect_addr.sin_addr.s_addr = ipaddress;
|
||||
|
||||
sprintf(incommingIP, "%s", inet_ntoa(connect_addr.sin_addr));
|
||||
@ -199,11 +200,18 @@ struct block downloadfile(const char *url)
|
||||
return emptyblock;
|
||||
}
|
||||
|
||||
|
||||
// Remove Referer from the request header for incompatible websites (ex. Cloudflare proxy)
|
||||
char referer[domainlength + 12];
|
||||
snprintf(referer, sizeof(referer), "Referer: %s\r\n", domain);
|
||||
if(strstr(url, "geckocodes"))
|
||||
{
|
||||
strcpy(referer, "");
|
||||
}
|
||||
|
||||
//Form a nice request header to send to the webserver
|
||||
char* headerformat = "GET %s HTTP/1.0\r\nHost: %s\r\nReferer: %s\r\n%sUser-Agent: USBLoaderGX r%s\r\n\r\n";
|
||||
char header[strlen(headerformat) + strlen(path) + strlen(domain)*2 + 100];
|
||||
sprintf(header, headerformat, path, domain, domain, GetRev());
|
||||
char* headerformat = "GET %s HTTP/1.0\r\nHost: %s\r\n%sUser-Agent: USBLoaderGX r%s\r\n\r\n";
|
||||
char header[strlen(headerformat) + strlen(path) + strlen(domain) + strlen(referer) + 100];
|
||||
sprintf(header, headerformat, path, domain, referer, GetRev());
|
||||
//gprintf("\nHTTP Request:\n");
|
||||
//gprintf("%s\n",header);
|
||||
|
||||
@ -245,10 +253,10 @@ struct block downloadfile(const char *url)
|
||||
//gprintf("HTTP response code: %d\n", code);
|
||||
if (code == 302) // 302 FOUND (redirected link)
|
||||
{
|
||||
char *ptr = strstr((char*)response.data, "ocation: "); // location or Location
|
||||
char *ptr = strcasestr((char*)response.data, "Location: ");
|
||||
if(ptr)
|
||||
{
|
||||
ptr += strlen("ocation: ");
|
||||
ptr += strlen("Location: ");
|
||||
strncpy(newURL, ptr, sizeof(newURL));
|
||||
*(strchr(newURL, '\r'))=0;
|
||||
|
||||
|
@ -50,7 +50,7 @@ void ClearDOLList()
|
||||
}
|
||||
|
||||
void gamepatches(u8 videoSelected, u8 videoPatchDol, u8 aspectForce, u8 languageChoice, u8 patchcountrystring,
|
||||
u8 vipatch, u8 sneekVideoPatch, u8 hooktype, u8 fix002, u64 returnTo)
|
||||
u8 vipatch, u8 sneekVideoPatch, u8 hooktype, u64 returnTo)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -82,8 +82,7 @@ void gamepatches(u8 videoSelected, u8 videoPatchDol, u8 aspectForce, u8 language
|
||||
|
||||
do_wip_code(dst, len);
|
||||
|
||||
if (fix002 == 2)
|
||||
Anti_002_fix(dst, len);
|
||||
Anti_002_fix(dst, len);
|
||||
|
||||
if(returnTo)
|
||||
PatchReturnTo(dst, len, (u32) returnTo);
|
||||
@ -96,8 +95,7 @@ void gamepatches(u8 videoSelected, u8 videoPatchDol, u8 aspectForce, u8 language
|
||||
}
|
||||
|
||||
/* ERROR 002 fix (thanks to WiiPower for sharing this)*/
|
||||
if (fix002 != 0)
|
||||
*(u32 *)0x80003140 = *(u32 *)0x80003188;
|
||||
*(u32 *)0x80003140 = *(u32 *)0x80003188;
|
||||
|
||||
DCFlushRange((void*) 0x80000000, 0x3f00);
|
||||
|
||||
|
@ -10,7 +10,7 @@ extern "C" {
|
||||
void RegisterDOL(u8 *dst, int len);
|
||||
void ClearDOLList();
|
||||
void gamepatches(u8 videoSelected, u8 videoPatchDol, u8 aspectForce, u8 languageChoice, u8 patchcountrystring,
|
||||
u8 vipatch, u8 sneekVideoPatch, u8 hooktype, u8 fix002, u64 returnTo);
|
||||
u8 vipatch, u8 sneekVideoPatch, u8 hooktype, u64 returnTo);
|
||||
bool Anti_002_fix(u8 * Address, int Size);
|
||||
bool NSMBPatch();
|
||||
bool PoPPatch();
|
||||
|
@ -1371,13 +1371,6 @@ bool NetworkInitPrompt()
|
||||
|
||||
return success;
|
||||
}
|
||||
/*
|
||||
static size_t writedata(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
int written = fwrite(ptr, size, nmemb, (FILE *)stream);
|
||||
return written;
|
||||
}
|
||||
*/
|
||||
int CodeDownload(const char *id)
|
||||
{
|
||||
if (!CreateSubfolder(Settings.TxtCheatcodespath))
|
||||
@ -1472,62 +1465,7 @@ int CodeDownload(const char *id)
|
||||
char codeurl[250];
|
||||
snprintf(codeurl, sizeof(codeurl), "http://geckocodes.org/txt.php?txt=%s", id);
|
||||
//snprintf(codeurl, sizeof(codeurl), "http://geckocodes.org/codes/G/%s.txt", id);
|
||||
|
||||
/* //// preparation for lib cURL - Thanks airline38
|
||||
|
||||
CURL *curl_handle;
|
||||
|
||||
// Forge cURL header - needed for cloudflare proxy
|
||||
char useragent[20];
|
||||
snprintf(useragent, sizeof(useragent), "USBLoaderGX r%s", GetRev());
|
||||
curl_handle = curl_easy_init();
|
||||
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, useragent);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, codeurl);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1); // needed?
|
||||
|
||||
FILE * pfile = fopen(txtpath, "wb");
|
||||
if(pfile)
|
||||
{
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writedata);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)pfile);
|
||||
curl_easy_perform(curl_handle);
|
||||
fclose(pfile);
|
||||
|
||||
// verify downloaded content
|
||||
pfile = fopen(txtpath, "rb");
|
||||
char target[4];
|
||||
fseek(pfile,0,SEEK_SET);
|
||||
fread(target, sizeof(char), 4, pfile);
|
||||
fclose(pfile);
|
||||
//printf("target=%s game id=%s\n",target,id);
|
||||
if (strncmp(target,id,4)== 0 )
|
||||
{
|
||||
snprintf(txtpath, sizeof(txtpath), "%s%s", txtpath, tr(" has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information." ));
|
||||
WindowPrompt(0, txtpath, tr( "OK" ));
|
||||
curl_easy_cleanup(curl_handle);
|
||||
curl_global_cleanup();
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveFile(txtpath);
|
||||
snprintf(codeurl, sizeof(codeurl), "%s%s", codeurl, tr( " is not on the server." ));
|
||||
WindowPrompt(tr( "Error" ), codeurl, tr( "OK" ));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(codeurl, sizeof(codeurl), "%s%s", codeurl, tr(" could not be downloaded."));
|
||||
WindowPrompt(tr( "Error" ), codeurl, tr( "OK" ));
|
||||
}
|
||||
|
||||
curl_easy_cleanup(curl_handle);
|
||||
curl_global_cleanup();
|
||||
|
||||
/////
|
||||
*/
|
||||
|
||||
struct block file = downloadfile(codeurl);
|
||||
|
||||
if (file.data != NULL)
|
||||
@ -1557,9 +1495,29 @@ int CodeDownload(const char *id)
|
||||
{
|
||||
fwrite(file.data, 1, file.size, pfile);
|
||||
fclose(pfile);
|
||||
snprintf(txtpath, sizeof(txtpath), "%s%s", txtpath, tr(" has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information." ));
|
||||
WindowPrompt(0, txtpath, tr( "OK" ));
|
||||
ret = 0;
|
||||
|
||||
// verify downloaded content - thanks airline38
|
||||
pfile = fopen(txtpath, "rb");
|
||||
if(pfile)
|
||||
{
|
||||
char target[4];
|
||||
fseek(pfile,0,SEEK_SET);
|
||||
fread(target, sizeof(char), 4, pfile);
|
||||
fclose(pfile);
|
||||
//printf("target=%s game id=%s\n",target,id);
|
||||
if (strncmp(target,id,4)== 0 )
|
||||
{
|
||||
snprintf(txtpath, sizeof(txtpath), "%s%s", txtpath, tr(" has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information." ));
|
||||
WindowPrompt(0, txtpath, tr( "OK" ));
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveFile(txtpath);
|
||||
snprintf(codeurl, sizeof(codeurl), "%s%s", codeurl, tr( " is not on the server." ));
|
||||
WindowPrompt(tr( "Error" ), codeurl, tr( "OK" ));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
WindowPrompt(tr("Error"), tr("Could not write file."), tr( "OK" ));
|
||||
|
@ -194,7 +194,6 @@ bool CGameSettings::Save()
|
||||
fprintf(f, "vipatch:%d; ", GameList[i].vipatch);
|
||||
fprintf(f, "ios:%d; ", GameList[i].ios);
|
||||
fprintf(f, "parentalcontrol:%d; ", GameList[i].parentalcontrol);
|
||||
fprintf(f, "errorfix002:%d; ", GameList[i].errorfix002);
|
||||
fprintf(f, "iosreloadblock:%d; ", GameList[i].iosreloadblock);
|
||||
fprintf(f, "patchcountrystrings:%d; ", GameList[i].patchcountrystrings);
|
||||
fprintf(f, "loadalternatedol:%d; ", GameList[i].loadalternatedol);
|
||||
@ -275,11 +274,6 @@ bool CGameSettings::SetSetting(GameCFG & game, const char *name, const char *val
|
||||
game.parentalcontrol = atoi(value);
|
||||
return true;
|
||||
}
|
||||
else if(strcmp(name, "errorfix002") == 0)
|
||||
{
|
||||
game.errorfix002 = atoi(value);
|
||||
return true;
|
||||
}
|
||||
else if(strcmp(name, "iosreloadblock") == 0)
|
||||
{
|
||||
game.iosreloadblock = atoi(value);
|
||||
@ -544,7 +538,6 @@ void CGameSettings::SetDefault(GameCFG &game)
|
||||
game.vipatch = INHERIT;
|
||||
game.ios = INHERIT;
|
||||
game.parentalcontrol = PARENTAL_LVL_EVERYONE;
|
||||
game.errorfix002 = INHERIT;
|
||||
game.patchcountrystrings = INHERIT;
|
||||
game.loadalternatedol = ALT_DOL_DEFAULT;
|
||||
game.alternatedolstart = 0;
|
||||
|
@ -18,7 +18,6 @@ typedef struct _GameCFG
|
||||
short vipatch;
|
||||
short ios;
|
||||
short parentalcontrol;
|
||||
short errorfix002;
|
||||
short iosreloadblock;
|
||||
short loadalternatedol;
|
||||
u32 alternatedolstart;
|
||||
@ -62,7 +61,6 @@ typedef struct _GameCFG
|
||||
this->vipatch = game.vipatch;
|
||||
this->ios = game.ios;
|
||||
this->parentalcontrol = game.parentalcontrol;
|
||||
this->errorfix002 = game.errorfix002;
|
||||
this->iosreloadblock = game.iosreloadblock;
|
||||
this->loadalternatedol = game.loadalternatedol;
|
||||
this->alternatedolstart = game.alternatedolstart;
|
||||
|
@ -109,7 +109,6 @@ void CSettings::SetDefault()
|
||||
LoaderIOS = BUILD_IOS;
|
||||
cios = BUILD_IOS;
|
||||
gridRows = 3;
|
||||
error002 = 2;
|
||||
partition = 0;
|
||||
discart = DISCARTS_ORIGINALS_CUSTOMS;
|
||||
coversfull = COVERSFULL_HQ;
|
||||
@ -331,7 +330,6 @@ bool CSettings::Save()
|
||||
fprintf(file, "patchcountrystrings = %d\n", patchcountrystrings);
|
||||
fprintf(file, "screensaver = %d\n", screensaver);
|
||||
fprintf(file, "musicloopmode = %d\n", musicloopmode);
|
||||
fprintf(file, "error002 = %d\n", error002);
|
||||
fprintf(file, "autonetwork = %d\n", autonetwork);
|
||||
fprintf(file, "discart = %d\n", discart);
|
||||
fprintf(file, "coversfull = %d\n", coversfull);
|
||||
@ -669,11 +667,6 @@ bool CSettings::SetSetting(char *name, char *value)
|
||||
coversfull = atoi(value);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "error002") == 0)
|
||||
{
|
||||
error002 = atoi(value);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "autonetwork") == 0)
|
||||
{
|
||||
autonetwork = atoi(value);
|
||||
|
@ -117,7 +117,6 @@ class CSettings
|
||||
short partition;
|
||||
short musicloopmode;
|
||||
short godmode;
|
||||
short error002;
|
||||
short titlesOverride; // db_titles
|
||||
short gridRows;
|
||||
short autonetwork;
|
||||
|
@ -84,13 +84,6 @@ static const char * LanguageText[] =
|
||||
trNOOP( "Console Default" ),
|
||||
};
|
||||
|
||||
static const char * Error002Text[] =
|
||||
{
|
||||
trNOOP( "No" ),
|
||||
trNOOP( "Yes" ),
|
||||
trNOOP( "Anti" )
|
||||
};
|
||||
|
||||
static const char * ParentalText[] =
|
||||
{
|
||||
trNOOP( "0 (Everyone)" ),
|
||||
@ -293,12 +286,6 @@ void GameLoadSM::SetOptionValues()
|
||||
else
|
||||
Options->SetValue(Idx++, "%i", GameConfig.ios);
|
||||
|
||||
//! Settings: Error 002 fix
|
||||
if(GameConfig.errorfix002 == INHERIT)
|
||||
Options->SetValue(Idx++, tr("Use global"));
|
||||
else
|
||||
Options->SetValue(Idx++, "%s", tr(Error002Text[GameConfig.errorfix002]));
|
||||
|
||||
//! Settings: Return To
|
||||
if(GameConfig.returnTo)
|
||||
{
|
||||
@ -488,12 +475,6 @@ int GameLoadSM::GetMenuInternal()
|
||||
}
|
||||
}
|
||||
|
||||
//! Settings: Error 002 fix
|
||||
else if (ret == ++Idx)
|
||||
{
|
||||
if (++GameConfig.errorfix002 >= 3) GameConfig.errorfix002 = INHERIT;
|
||||
}
|
||||
|
||||
//! Settings: Return To
|
||||
else if (ret == ++Idx)
|
||||
{
|
||||
|
@ -87,13 +87,6 @@ static const char * LanguageText[] =
|
||||
trNOOP( "Console Default" )
|
||||
};
|
||||
|
||||
static const char * Error002Text[] =
|
||||
{
|
||||
trNOOP( "No" ),
|
||||
trNOOP( "Yes" ),
|
||||
trNOOP( "Anti" )
|
||||
};
|
||||
|
||||
static const char * NandEmuText[] =
|
||||
{
|
||||
trNOOP( "OFF" ),
|
||||
@ -298,9 +291,6 @@ void LoaderSettings::SetOptionValues()
|
||||
//! Settings: Quick Boot
|
||||
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.quickboot] ));
|
||||
|
||||
//! Settings: Error 002 fix
|
||||
Options->SetValue(Idx++, "%s", tr( Error002Text[Settings.error002] ));
|
||||
|
||||
//! Settings: Block IOS Reload
|
||||
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.BlockIOSReload] ));
|
||||
|
||||
@ -523,12 +513,6 @@ int LoaderSettings::GetMenuInternal()
|
||||
if (++Settings.quickboot >= MAX_ON_OFF) Settings.quickboot = 0;
|
||||
}
|
||||
|
||||
//! Settings: Error 002 fix
|
||||
else if (ret == ++Idx )
|
||||
{
|
||||
if (++Settings.error002 >= 3) Settings.error002 = 0;
|
||||
}
|
||||
|
||||
//! Settings: Block IOS Reload
|
||||
else if (ret == ++Idx )
|
||||
{
|
||||
|
@ -270,7 +270,6 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
|
||||
u8 viChoice = game_cfg->vipatch == INHERIT ? Settings.videopatch : game_cfg->vipatch;
|
||||
u8 sneekChoice = game_cfg->sneekVideoPatch == INHERIT ? Settings.sneekVideoPatch : game_cfg->sneekVideoPatch;
|
||||
u8 iosChoice = game_cfg->ios == INHERIT ? Settings.cios : game_cfg->ios;
|
||||
u8 fix002 = game_cfg->errorfix002 == INHERIT ? Settings.error002 : game_cfg->errorfix002;
|
||||
u8 countrystrings = game_cfg->patchcountrystrings == INHERIT ? Settings.patchcountrystrings : game_cfg->patchcountrystrings;
|
||||
u8 alternatedol = game_cfg->loadalternatedol;
|
||||
u32 alternatedoloffset = game_cfg->alternatedolstart;
|
||||
@ -405,7 +404,7 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
|
||||
|
||||
//! Do all the game patches
|
||||
gprintf("Applying game patches...\n");
|
||||
gamepatches(videoChoice, videoPatchDolChoice, aspectChoice, languageChoice, countrystrings, viChoice, sneekChoice, Hooktype, fix002, returnToChoice);
|
||||
gamepatches(videoChoice, videoPatchDolChoice, aspectChoice, languageChoice, countrystrings, viChoice, sneekChoice, Hooktype, returnToChoice);
|
||||
|
||||
//! Load Code handler if needed
|
||||
load_handler(Hooktype, WiirdDebugger, Settings.WiirdDebuggerPause);
|
||||
|
Loading…
Reference in New Issue
Block a user