mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-19 00:42:06 +00:00
loader; suppress gcc warning
This commit is contained in:
parent
a5854afd2f
commit
7ddaad615b
1 changed files with 40 additions and 39 deletions
|
@ -13,7 +13,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
|
@ -68,44 +68,44 @@ static std::map<u64, ContentManagement::ExternalContentSource> g_external_conten
|
||||||
Result ContentManagement::MountCode(u64 tid, FsStorageId sid) {
|
Result ContentManagement::MountCode(u64 tid, FsStorageId sid) {
|
||||||
char path[FS_MAX_PATH] = {0};
|
char path[FS_MAX_PATH] = {0};
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
/* We defer SD card mounting, so if relevant ensure it is mounted. */
|
/* We defer SD card mounting, so if relevant ensure it is mounted. */
|
||||||
if (!g_has_initialized_fs_dev) {
|
if (!g_has_initialized_fs_dev) {
|
||||||
TryMountSdCard();
|
TryMountSdCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_has_initialized_fs_dev) {
|
if (g_has_initialized_fs_dev) {
|
||||||
RefreshConfigurationData();
|
RefreshConfigurationData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShouldOverrideContentsWithSD(tid) && R_SUCCEEDED(MountCodeNspOnSd(tid))) {
|
if (ShouldOverrideContentsWithSD(tid) && R_SUCCEEDED(MountCodeNspOnSd(tid))) {
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED(rc = ResolveContentPath(path, tid, sid))) {
|
if (R_FAILED(rc = ResolveContentPath(path, tid, sid))) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix up path. */
|
/* Fix up path. */
|
||||||
for (unsigned int i = 0; i < FS_MAX_PATH && path[i] != '\x00'; i++) {
|
for (unsigned int i = 0; i < FS_MAX_PATH && path[i] != '\x00'; i++) {
|
||||||
if (path[i] == '\\') {
|
if (path[i] == '\\') {
|
||||||
path[i] = '/';
|
path[i] = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Always re-initialize fsp-ldr, in case it's closed */
|
/* Always re-initialize fsp-ldr, in case it's closed */
|
||||||
if (R_FAILED(rc = fsldrInitialize())) {
|
if (R_FAILED(rc = fsldrInitialize())) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED(rc = fsldrOpenCodeFileSystem(tid, path, &g_CodeFileSystem))) {
|
if (R_FAILED(rc = fsldrOpenCodeFileSystem(tid, path, &g_CodeFileSystem))) {
|
||||||
fsldrExit();
|
fsldrExit();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
fsdevMountDevice("code", g_CodeFileSystem);
|
fsdevMountDevice("code", g_CodeFileSystem);
|
||||||
TryMountHblNspOnSd();
|
TryMountHblNspOnSd();
|
||||||
|
|
||||||
fsldrExit();
|
fsldrExit();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -121,14 +121,15 @@ Result ContentManagement::UnmountCode() {
|
||||||
|
|
||||||
|
|
||||||
void ContentManagement::TryMountHblNspOnSd() {
|
void ContentManagement::TryMountHblNspOnSd() {
|
||||||
char path[FS_MAX_PATH + 1] = {0};
|
char path[FS_MAX_PATH + 1];
|
||||||
strncpy(path, g_hbl_sd_path, FS_MAX_PATH);
|
strncpy(path, g_hbl_sd_path, FS_MAX_PATH);
|
||||||
|
path[FS_MAX_PATH] = 0;
|
||||||
for (unsigned int i = 0; i < FS_MAX_PATH && path[i] != '\x00'; i++) {
|
for (unsigned int i = 0; i < FS_MAX_PATH && path[i] != '\x00'; i++) {
|
||||||
if (path[i] == '\\') {
|
if (path[i] == '\\') {
|
||||||
path[i] = '/';
|
path[i] = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g_has_initialized_fs_dev && !g_mounted_hbl_nsp && R_SUCCEEDED(fsOpenFileSystemWithId(&g_HblFileSystem, 0, FsFileSystemType_ApplicationPackage, path))) {
|
if (g_has_initialized_fs_dev && !g_mounted_hbl_nsp && R_SUCCEEDED(fsOpenFileSystemWithId(&g_HblFileSystem, 0, FsFileSystemType_ApplicationPackage, path))) {
|
||||||
fsdevMountDevice("hbl", g_HblFileSystem);
|
fsdevMountDevice("hbl", g_HblFileSystem);
|
||||||
g_mounted_hbl_nsp = true;
|
g_mounted_hbl_nsp = true;
|
||||||
}
|
}
|
||||||
|
@ -136,14 +137,14 @@ void ContentManagement::TryMountHblNspOnSd() {
|
||||||
|
|
||||||
Result ContentManagement::MountCodeNspOnSd(u64 tid) {
|
Result ContentManagement::MountCodeNspOnSd(u64 tid) {
|
||||||
char path[FS_MAX_PATH+1] = {0};
|
char path[FS_MAX_PATH+1] = {0};
|
||||||
snprintf(path, FS_MAX_PATH, "@Sdcard:/atmosphere/titles/%016lx/exefs.nsp", tid);
|
snprintf(path, FS_MAX_PATH, "@Sdcard:/atmosphere/titles/%016lx/exefs.nsp", tid);
|
||||||
Result rc = fsOpenFileSystemWithId(&g_CodeFileSystem, 0, FsFileSystemType_ApplicationPackage, path);
|
Result rc = fsOpenFileSystemWithId(&g_CodeFileSystem, 0, FsFileSystemType_ApplicationPackage, path);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
fsdevMountDevice("code", g_CodeFileSystem);
|
fsdevMountDevice("code", g_CodeFileSystem);
|
||||||
TryMountHblNspOnSd();
|
TryMountHblNspOnSd();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,34 +157,34 @@ Result ContentManagement::ResolveContentPath(char *out_path, u64 tid, FsStorageI
|
||||||
LrRegisteredLocationResolver reg;
|
LrRegisteredLocationResolver reg;
|
||||||
LrLocationResolver lr;
|
LrLocationResolver lr;
|
||||||
char path[FS_MAX_PATH] = {0};
|
char path[FS_MAX_PATH] = {0};
|
||||||
|
|
||||||
/* Try to get the path from the registered resolver. */
|
/* Try to get the path from the registered resolver. */
|
||||||
if (R_FAILED(rc = lrOpenRegisteredLocationResolver(®))) {
|
if (R_FAILED(rc = lrOpenRegisteredLocationResolver(®))) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc = lrRegLrResolveProgramPath(®, tid, path))) {
|
if (R_SUCCEEDED(rc = lrRegLrResolveProgramPath(®, tid, path))) {
|
||||||
strncpy(out_path, path, FS_MAX_PATH);
|
strncpy(out_path, path, FS_MAX_PATH);
|
||||||
} else if (rc != 0x408) {
|
} else if (rc != 0x408) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceClose(®.s);
|
serviceClose(®.s);
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If getting the path from the registered resolver fails, fall back to the normal resolver. */
|
/* If getting the path from the registered resolver fails, fall back to the normal resolver. */
|
||||||
if (R_FAILED(rc = lrOpenLocationResolver(sid, &lr))) {
|
if (R_FAILED(rc = lrOpenLocationResolver(sid, &lr))) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc = lrLrResolveProgramPath(&lr, tid, path))) {
|
if (R_SUCCEEDED(rc = lrLrResolveProgramPath(&lr, tid, path))) {
|
||||||
strncpy(out_path, path, FS_MAX_PATH);
|
strncpy(out_path, path, FS_MAX_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceClose(&lr.s);
|
serviceClose(&lr.s);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,15 +195,15 @@ Result ContentManagement::ResolveContentPathForTidSid(char *out_path, Registrati
|
||||||
Result ContentManagement::RedirectContentPath(const char *path, u64 tid, FsStorageId sid) {
|
Result ContentManagement::RedirectContentPath(const char *path, u64 tid, FsStorageId sid) {
|
||||||
Result rc;
|
Result rc;
|
||||||
LrLocationResolver lr;
|
LrLocationResolver lr;
|
||||||
|
|
||||||
if (R_FAILED(rc = lrOpenLocationResolver(sid, &lr))) {
|
if (R_FAILED(rc = lrOpenLocationResolver(sid, &lr))) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = lrLrRedirectProgramPath(&lr, tid, path);
|
rc = lrLrRedirectProgramPath(&lr, tid, path);
|
||||||
|
|
||||||
serviceClose(&lr.s);
|
serviceClose(&lr.s);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +223,7 @@ void ContentManagement::SetCreatedTitle(u64 tid) {
|
||||||
|
|
||||||
static OverrideKey ParseOverrideKey(const char *value) {
|
static OverrideKey ParseOverrideKey(const char *value) {
|
||||||
OverrideKey cfg;
|
OverrideKey cfg;
|
||||||
|
|
||||||
/* Parse on by default. */
|
/* Parse on by default. */
|
||||||
if (value[0] == '!') {
|
if (value[0] == '!') {
|
||||||
cfg.override_by_default = true;
|
cfg.override_by_default = true;
|
||||||
|
@ -230,7 +231,7 @@ static OverrideKey ParseOverrideKey(const char *value) {
|
||||||
} else {
|
} else {
|
||||||
cfg.override_by_default = false;
|
cfg.override_by_default = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse key combination. */
|
/* Parse key combination. */
|
||||||
if (strcasecmp(value, "A") == 0) {
|
if (strcasecmp(value, "A") == 0) {
|
||||||
cfg.key_combination = KEY_A;
|
cfg.key_combination = KEY_A;
|
||||||
|
@ -271,7 +272,7 @@ static OverrideKey ParseOverrideKey(const char *value) {
|
||||||
} else {
|
} else {
|
||||||
cfg.key_combination = 0;
|
cfg.key_combination = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +311,7 @@ static int LoaderIniHandler(void *user, const char *section, const char *name, c
|
||||||
static int LoaderTitleSpecificIniHandler(void *user, const char *section, const char *name, const char *value) {
|
static int LoaderTitleSpecificIniHandler(void *user, const char *section, const char *name, const char *value) {
|
||||||
/* We'll output an override key when relevant. */
|
/* We'll output an override key when relevant. */
|
||||||
OverrideKey *user_cfg = reinterpret_cast<OverrideKey *>(user);
|
OverrideKey *user_cfg = reinterpret_cast<OverrideKey *>(user);
|
||||||
|
|
||||||
if (strcasecmp(section, "override_config") == 0) {
|
if (strcasecmp(section, "override_config") == 0) {
|
||||||
if (strcasecmp(name, "override_key") == 0) {
|
if (strcasecmp(name, "override_key") == 0) {
|
||||||
*user_cfg = ParseOverrideKey(value);
|
*user_cfg = ParseOverrideKey(value);
|
||||||
|
@ -326,11 +327,11 @@ void ContentManagement::RefreshConfigurationData() {
|
||||||
if (config == NULL) {
|
if (config == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fill(g_config_ini_data, g_config_ini_data + 0x800, 0);
|
std::fill(g_config_ini_data, g_config_ini_data + 0x800, 0);
|
||||||
fread(g_config_ini_data, 1, 0x7FF, config);
|
fread(g_config_ini_data, 1, 0x7FF, config);
|
||||||
fclose(config);
|
fclose(config);
|
||||||
|
|
||||||
ini_parse_string(g_config_ini_data, LoaderIniHandler, NULL);
|
ini_parse_string(g_config_ini_data, LoaderIniHandler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,10 +344,10 @@ void ContentManagement::TryMountSdCard() {
|
||||||
if (R_FAILED(smGetServiceOriginal(&tmp_hnd, smEncodeName(required_active_services[i])))) {
|
if (R_FAILED(smGetServiceOriginal(&tmp_hnd, smEncodeName(required_active_services[i])))) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
svcCloseHandle(tmp_hnd);
|
svcCloseHandle(tmp_hnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(fsdevMountSdmc())) {
|
if (R_SUCCEEDED(fsdevMountSdmc())) {
|
||||||
g_has_initialized_fs_dev = true;
|
g_has_initialized_fs_dev = true;
|
||||||
}
|
}
|
||||||
|
@ -360,9 +361,9 @@ static bool IsHBLTitleId(u64 tid) {
|
||||||
OverrideKey ContentManagement::GetTitleOverrideKey(u64 tid) {
|
OverrideKey ContentManagement::GetTitleOverrideKey(u64 tid) {
|
||||||
OverrideKey cfg = g_default_override_key;
|
OverrideKey cfg = g_default_override_key;
|
||||||
char path[FS_MAX_PATH+1] = {0};
|
char path[FS_MAX_PATH+1] = {0};
|
||||||
snprintf(path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/config.ini", tid);
|
snprintf(path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/config.ini", tid);
|
||||||
|
|
||||||
|
|
||||||
FILE *config = fopen(path, "r");
|
FILE *config = fopen(path, "r");
|
||||||
if (config != NULL) {
|
if (config != NULL) {
|
||||||
ON_SCOPE_EXIT { fclose(config); };
|
ON_SCOPE_EXIT { fclose(config); };
|
||||||
|
@ -370,7 +371,7 @@ OverrideKey ContentManagement::GetTitleOverrideKey(u64 tid) {
|
||||||
/* Parse current title ini. */
|
/* Parse current title ini. */
|
||||||
ini_parse_file(config, LoaderTitleSpecificIniHandler, &cfg);
|
ini_parse_file(config, LoaderTitleSpecificIniHandler, &cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue