* Fixed compiling on Mac/Linux

* Fixed "return to NK2O" not working with neek.
This commit is contained in:
cyan06 2015-07-07 19:34:32 +00:00
parent f49b732a3b
commit be6092e1e9
4 changed files with 161 additions and 157 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name> USB Loader GX</name> <name> USB Loader GX</name>
<coder>USB Loader GX Team</coder> <coder>USB Loader GX Team</coder>
<version>3.0 r1250</version> <version>3.0 r1251</version>
<release_date>20150705141019</release_date> <release_date>20150707190220</release_date>
<!-- // remove this line to enable arguments <!-- // remove this line to enable arguments
<arguments> <arguments>
<arg>--ios=250</arg> <arg>--ios=250</arg>

View File

@ -1,118 +1,118 @@
/* /*
Copyright (c) 2014 - Cyan Copyright (c) 2014 - Cyan
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#include "homebrewboot\HomebrewXML.h" #include "homebrewboot\HomebrewXML.h"
#include "FileOperations\fileops.h" #include "FileOperations\fileops.h"
#include "settings\CSettings.h" #include "settings\CSettings.h"
#include "svnrev.h" #include "svnrev.h"
int updateMetaXML (void) int updateMetaXML (void)
{ {
HomebrewXML MetaXML; HomebrewXML MetaXML;
char filepath[255]; char filepath[255];
snprintf(filepath, sizeof(filepath), "%s/meta.xml", Settings.update_path); snprintf(filepath, sizeof(filepath), "%s/meta.xml", Settings.update_path);
if(!MetaXML.LoadHomebrewXMLData(filepath)) if(!MetaXML.LoadHomebrewXMLData(filepath))
return 0; return 0;
char line[50]; char line[50];
snprintf(line, sizeof(line), "--ios=%d", Settings.LoaderIOS); snprintf(line, sizeof(line), "--ios=%d", Settings.LoaderIOS);
MetaXML.SetArgument(line); MetaXML.SetArgument(line);
snprintf(line, sizeof(line), "--usbport=%d", Settings.USBPort); snprintf(line, sizeof(line), "--usbport=%d", Settings.USBPort);
MetaXML.SetArgument(line); MetaXML.SetArgument(line);
snprintf(line, sizeof(line), "--mountusb=%d", Settings.USBAutoMount); snprintf(line, sizeof(line), "--mountusb=%d", Settings.USBAutoMount);
MetaXML.SetArgument(line); MetaXML.SetArgument(line);
snprintf(line, sizeof(line), "3.0 r%s", GetRev()); snprintf(line, sizeof(line), "3.0 r%s", GetRev());
MetaXML.SetVersion(line); MetaXML.SetVersion(line);
int ret = MetaXML.SaveHomebrewXMLData(filepath); int ret = MetaXML.SaveHomebrewXMLData(filepath);
return ret; return ret;
} }
int editMetaArguments (void) int editMetaArguments (void)
{ {
char metapath[255] = ""; char metapath[255] = "";
char metatmppath[255] = ""; char metatmppath[255] = "";
snprintf(metapath, sizeof(metapath), "%s/meta.xml", Settings.update_path); snprintf(metapath, sizeof(metapath), "%s/meta.xml", Settings.update_path);
snprintf(metatmppath, sizeof(metatmppath), "%s/meta.tmp", Settings.update_path); snprintf(metatmppath, sizeof(metatmppath), "%s/meta.tmp", Settings.update_path);
FILE *source = fopen(metapath, "rb"); FILE *source = fopen(metapath, "rb");
if(!source) if(!source)
{ {
return 0; return 0;
} }
FILE *destination = fopen(metatmppath, "wb"); FILE *destination = fopen(metatmppath, "wb");
if(!destination) if(!destination)
{ {
fclose(source); fclose(source);
return 0; return 0;
} }
const int max_line_size = 255; const int max_line_size = 255;
char *line = new char[max_line_size]; char *line = new char[max_line_size];
while (fgets(line, max_line_size, source) != NULL) while (fgets(line, max_line_size, source) != NULL)
{ {
// delete commented lines // delete commented lines
if( strstr(line, "<!-- // remove this line to enable arguments") != NULL || if( strstr(line, "<!-- // remove this line to enable arguments") != NULL ||
strstr(line, "// remove this line to enable arguments -->") != NULL) strstr(line, "// remove this line to enable arguments -->") != NULL)
{ {
strcpy(line, " \n"); strcpy(line, " \n");
} }
// generate argurments // generate argurments
if(strstr(line, "<arguments>") != NULL) if(strstr(line, "<arguments>") != NULL)
{ {
fputs(line, destination); fputs(line, destination);
snprintf(line, max_line_size, " <arg>--ios=%d</arg>\n", Settings.LoaderIOS); snprintf(line, max_line_size, " <arg>--ios=%d</arg>\n", Settings.LoaderIOS);
fputs(line, destination); fputs(line, destination);
snprintf(line, max_line_size, " <arg>--usbport=%d</arg>\n", Settings.USBPort); snprintf(line, max_line_size, " <arg>--usbport=%d</arg>\n", Settings.USBPort);
fputs(line, destination); fputs(line, destination);
snprintf(line, max_line_size, " <arg>--mountusb=%d</arg>\n", Settings.USBAutoMount); snprintf(line, max_line_size, " <arg>--mountusb=%d</arg>\n", Settings.USBAutoMount);
fputs(line, destination); fputs(line, destination);
while(strstr(line, "</arguments>") == NULL) while(strstr(line, "</arguments>") == NULL)
{ {
fgets(line, max_line_size, source); // advance one line fgets(line, max_line_size, source); // advance one line
if(feof(source)) if(feof(source))
{ {
fclose(source); fclose(source);
fclose(destination); fclose(destination);
delete [] line; delete [] line;
return 0; return 0;
} }
} }
} }
fputs(line, destination); fputs(line, destination);
} }
fclose(source); fclose(source);
fclose(destination); fclose(destination);
delete [] line; delete [] line;
if(CopyFile(metatmppath, metapath) <0) if(CopyFile(metatmppath, metapath) <0)
return 0; return 0;
RemoveFile(metatmppath); RemoveFile(metatmppath);
return 1; return 1;
} }

View File

@ -1,30 +1,30 @@
/**************************************************************************** /****************************************************************************
* Copyright (C) 2014 * Copyright (C) 2014
* by cyan * by cyan
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any * warranty. In no event will the authors be held liable for any
* damages arising from the use of this software. * damages arising from the use of this software.
* *
* Permission is granted to anyone to use this software for any * Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and * purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions: * redistribute it freely, subject to the following restrictions:
* *
* 1. The origin of this software must not be misrepresented; you * 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use * must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product * this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required. * documentation would be appreciated but is not required.
* *
* 2. Altered source versions must be plainly marked as such, and * 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software. * must not be misrepresented as being the original software.
* *
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
***************************************************************************/ ***************************************************************************/
#ifndef _META_H_ #ifndef _META_H_
#define _META_H_ #define _META_H_
int updateMetaXML(void); int updateMetaXML(void);
int editMetaArguments(void); int editMetaArguments(void);
#endif #endif

View File

@ -1547,6 +1547,7 @@ int GameBooter::BootNeek(struct discHdr *gameHdr)
u64 returnToChoice = game_cfg->returnTo; u64 returnToChoice = game_cfg->returnTo;
const char *NandEmuPath = game_cfg->NandEmuPath.size() == 0 ? Settings.NandEmuChanPath : game_cfg->NandEmuPath.c_str(); const char *NandEmuPath = game_cfg->NandEmuPath.size() == 0 ? Settings.NandEmuChanPath : game_cfg->NandEmuPath.c_str();
bool autoboot = true; bool autoboot = true;
bool NK2O_isInstalled = false;
char tempPath[100] = ""; char tempPath[100] = "";
int ret = -1; int ret = -1;
@ -1655,6 +1656,12 @@ int GameBooter::BootNeek(struct discHdr *gameHdr)
if(CheckFile(tempPath)) if(CheckFile(tempPath))
RemoveFile(tempPath); RemoveFile(tempPath);
} }
else
{
snprintf(tempPath, sizeof(tempPath), "%s/title/00010001/4e4b324f/content/title.tmd", NandEmuPath);
if(CheckFile(tempPath))
NK2O_isInstalled = true;
}
// Every checks passed successfully. Continue execution. // Every checks passed successfully. Continue execution.
@ -1684,19 +1691,16 @@ int GameBooter::BootNeek(struct discHdr *gameHdr)
if(autoboot && returnToChoice) if(autoboot && returnToChoice)
{ {
// Todo : allow user to select the channel to return to. // Todo : allow user to select the channel to return to.
if(NK2O_isInstalled)
// check if NK2O is installed
snprintf(tempPath, sizeof(tempPath), "%s/title/00010001/4e4b324f/content/title.tmd", NandEmuPath);
if(CheckFile(tempPath))
{ {
neek_config->returnto = TITLE_ID(0x00010001, 'NK2O'); // Currently forced to NK2O user channel neek_config->returnto = TITLE_ID(0x00010001, 'NK2O'); // Currently forced to NK2O user channel
neek_config->config |= NCON_EXT_RETURN_TO; // enable "return to" patch neek_config->config |= NCON_EXT_RETURN_TO; // enable "return to" patch
} }
if(isWiiU()) if(isWiiU())
{ {
neek_config->returnto = TITLE_ID(0x00010002, 'HCVA');// Currently forced to "Return to WiiU" system channel neek_config->returnto = TITLE_ID(0x00010002, 'HCVA'); // Currently forced to "Return to WiiU" system channel
neek_config->config |= NCON_EXT_RETURN_TO; // enable "return to" patch neek_config->config |= NCON_EXT_RETURN_TO; // enable "return to" patch
} }
} }