mirror of
https://github.com/wiiu-env/RPXLoadingModule.git
synced 2024-11-25 11:26:53 +01:00
Formatting and logging
This commit is contained in:
parent
9d43e49e7b
commit
158db91f7a
@ -87,29 +87,32 @@ int32_t readIntoBuffer(int32_t handle, void *buffer, size_t size, size_t count)
|
|||||||
//DEBUG_FUNCTION_LINE("Reading. missing %08X bytes\n", sizeToRead);
|
//DEBUG_FUNCTION_LINE("Reading. missing %08X bytes\n", sizeToRead);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
////DEBUG_FUNCTION_LINE("Success: Read %08X bytes from handle %08X. result %08X \n", size * count, handle, totalSize);
|
//DEBUG_FUNCTION_LINE("Success: Read %08X bytes from handle %08X. result %08X \n", size * count, handle, totalSize);
|
||||||
return totalSize;
|
return totalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CheckFile(const char * filepath) {
|
int32_t CheckFile(const char * filepath) {
|
||||||
if(!filepath)
|
if (!filepath) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct stat filestat{};
|
struct stat filestat{};
|
||||||
|
|
||||||
char dirnoslash[strlen(filepath)+2];
|
char dirnoslash[strlen(filepath) + 2];
|
||||||
snprintf(dirnoslash, sizeof(dirnoslash), "%s", filepath);
|
snprintf(dirnoslash, sizeof(dirnoslash), "%s", filepath);
|
||||||
|
|
||||||
while(dirnoslash[strlen(dirnoslash)-1] == '/')
|
while (dirnoslash[strlen(dirnoslash) - 1] == '/') {
|
||||||
dirnoslash[strlen(dirnoslash)-1] = '\0';
|
dirnoslash[strlen(dirnoslash) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
char * notRoot = strrchr(dirnoslash, '/');
|
char *notRoot = strrchr(dirnoslash, '/');
|
||||||
if(!notRoot) {
|
if (!notRoot) {
|
||||||
strcat(dirnoslash, "/");
|
strcat(dirnoslash, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(dirnoslash, &filestat) == 0)
|
if (stat(dirnoslash, &filestat) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -140,8 +143,9 @@ int32_t CreateSubfolder(const char * fullpath) {
|
|||||||
//!Device root directory (must be with '/')
|
//!Device root directory (must be with '/')
|
||||||
strcat(parentpath, "/");
|
strcat(parentpath, "/");
|
||||||
struct stat filestat{};
|
struct stat filestat{};
|
||||||
if (stat(parentpath, &filestat) == 0)
|
if (stat(parentpath, &filestat) == 0){
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -178,7 +182,6 @@ int32_t getRPXInfoForPath(const std::string &path, romfs_fileInfo *info) {
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
int res = -3;
|
int res = -3;
|
||||||
while ((entry = readdir(dir)) != nullptr) {
|
while ((entry = readdir(dir)) != nullptr) {
|
||||||
DEBUG_FUNCTION_LINE("%s", entry->d_name);
|
|
||||||
if (StringTools::EndsWith(entry->d_name, ".rpx")) {
|
if (StringTools::EndsWith(entry->d_name, ".rpx")) {
|
||||||
if (romfsGetFileInfoPerPath("rcc", (std::string("code/") + entry->d_name).c_str(), info) >= 0) {
|
if (romfsGetFileInfoPerPath("rcc", (std::string("code/") + entry->d_name).c_str(), info) >= 0) {
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -24,9 +24,11 @@ char gIconCache[65580] __attribute__((section(".data")));
|
|||||||
DECL_FUNCTION(int32_t, HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *metaxml, uint32_t device) {
|
DECL_FUNCTION(int32_t, HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *metaxml, uint32_t device) {
|
||||||
if (gReplacedRPX) {
|
if (gReplacedRPX) {
|
||||||
memset(&metaxml->longname_ja, 0, 0x338C - 0x38C); // clear all names
|
memset(&metaxml->longname_ja, 0, 0x338C - 0x38C); // clear all names
|
||||||
strncpy(metaxml->longname_en, gBundleInfo.longname, 64);
|
strncpy(metaxml->longname_en, gBundleInfo.longname, sizeof(gBundleInfo.longname));
|
||||||
strncpy(metaxml->shortname_en, gBundleInfo.shortname, 64);
|
strncpy(metaxml->shortname_en, gBundleInfo.shortname, sizeof(gBundleInfo.longname));
|
||||||
strncpy(metaxml->publisher_en, gBundleInfo.author, 64);
|
strncpy(metaxml->publisher_en, gBundleInfo.author, sizeof(gBundleInfo.longname));
|
||||||
|
|
||||||
|
// Disbale the emanual
|
||||||
metaxml->e_manual = 0;
|
metaxml->e_manual = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -83,7 +85,6 @@ uint32_t rpx_utils_function_replacements_size = sizeof(rpx_utils_function_replac
|
|||||||
|
|
||||||
static int parseINIhandler(void *user, const char *section, const char *name,
|
static int parseINIhandler(void *user, const char *section, const char *name,
|
||||||
const char *value) {
|
const char *value) {
|
||||||
DEBUG_FUNCTION_LINE("%s %s %s", section, name, value);
|
|
||||||
auto *fInfo = (BundleInformation *) user;
|
auto *fInfo = (BundleInformation *) user;
|
||||||
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
|
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
|
||||||
if (MATCH("menu", "longname")) {
|
if (MATCH("menu", "longname")) {
|
||||||
@ -116,7 +117,6 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
|||||||
int res = getRPXInfoForPath(completePath, &info);
|
int res = getRPXInfoForPath(completePath, &info);
|
||||||
bool isBundle = false;
|
bool isBundle = false;
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
DEBUG_FUNCTION_LINE("Is bundle :)");
|
|
||||||
isBundle = true;
|
isBundle = true;
|
||||||
request.filesize = ((uint32_t *) &info.length)[1];
|
request.filesize = ((uint32_t *) &info.length)[1];
|
||||||
request.fileoffset = ((uint32_t *) &info.offset)[1];
|
request.fileoffset = ((uint32_t *) &info.offset)[1];
|
||||||
@ -153,8 +153,6 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
|||||||
}
|
}
|
||||||
romfsUnmount("rcc");
|
romfsUnmount("rcc");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DEBUG_FUNCTION_LINE("not a bundle %s %d", completePath.c_str(), res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metaLoaded) {
|
if (!metaLoaded) {
|
||||||
@ -165,7 +163,7 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
|||||||
|
|
||||||
strncpy(request.path, bundle_path, 255);
|
strncpy(request.path, bundle_path, 255);
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Loading file %s size: %08X offset: %08X", request.path, request.filesize, request.fileoffset);
|
DEBUG_FUNCTION_LINE("Launch %s on next restart [size: %08X offset: %08X]", request.path, request.filesize, request.fileoffset);
|
||||||
|
|
||||||
DCFlushRange(gIconCache, sizeof(gIconCache));
|
DCFlushRange(gIconCache, sizeof(gIconCache));
|
||||||
DCFlushRange(&request, sizeof(LOAD_REQUEST));
|
DCFlushRange(&request, sizeof(LOAD_REQUEST));
|
||||||
@ -179,10 +177,12 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isBundle) {
|
if (isBundle) {
|
||||||
|
DEBUG_FUNCTION_LINE("Loaded file is a .wuhb bundle");
|
||||||
gTryToReplaceOnNextLaunch = true;
|
gTryToReplaceOnNextLaunch = true;
|
||||||
memset(gLoadedBundlePath, 0, sizeof(gLoadedBundlePath));
|
memset(gLoadedBundlePath, 0, sizeof(gLoadedBundlePath));
|
||||||
strncpy(gLoadedBundlePath, completePath.c_str(), completePath.length());
|
strncpy(gLoadedBundlePath, completePath.c_str(), completePath.length());
|
||||||
} else {
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Loaded file is no bundle");
|
||||||
if (!gIsMounted) {
|
if (!gIsMounted) {
|
||||||
gTryToReplaceOnNextLaunch = false;
|
gTryToReplaceOnNextLaunch = false;
|
||||||
memset(gLoadedBundlePath, 0, sizeof(gLoadedBundlePath));
|
memset(gLoadedBundlePath, 0, sizeof(gLoadedBundlePath));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <function_patcher/function_patching.h>
|
#include <function_patcher/function_patching.h>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
WUMS_MODULE_EXPORT_NAME("homebrew_rpx_loader");
|
WUMS_MODULE_EXPORT_NAME("homebrew_rpx_loader");
|
||||||
|
|
||||||
WUMS_INITIALIZE(args) {
|
WUMS_INITIALIZE() {
|
||||||
WHBLogUdpInit();
|
WHBLogUdpInit();
|
||||||
DEBUG_FUNCTION_LINE("Patch functions");
|
DEBUG_FUNCTION_LINE("Patch functions");
|
||||||
// we only patch static functions, we don't need re-patch them and every launch
|
// we only patch static functions, we don't need re-patch them and every launch
|
||||||
@ -32,8 +32,8 @@ WUMS_INITIALIZE(args) {
|
|||||||
|
|
||||||
|
|
||||||
WUMS_APPLICATION_ENDS() {
|
WUMS_APPLICATION_ENDS() {
|
||||||
DEBUG_FUNCTION_LINE("bye bye from rpx loader");
|
|
||||||
if (gIsMounted) {
|
if (gIsMounted) {
|
||||||
|
DEBUG_FUNCTION_LINE("Unmount /vol/content");
|
||||||
romfsUnmount("rom");
|
romfsUnmount("rom");
|
||||||
gIsMounted = false;
|
gIsMounted = false;
|
||||||
DCFlushRange(&gIsMounted, sizeof(gIsMounted));
|
DCFlushRange(&gIsMounted, sizeof(gIsMounted));
|
||||||
@ -47,7 +47,7 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
}
|
}
|
||||||
WHBLogUdpInit();
|
WHBLogUdpInit();
|
||||||
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
||||||
DEBUG_FUNCTION_LINE("gTryToReplaceOnNextLaunch, gReplacedRPX and gIsMounted to FALSE");
|
DEBUG_FUNCTION_LINE("Set gTryToReplaceOnNextLaunch, gReplacedRPX and gIsMounted to FALSE");
|
||||||
gReplacedRPX = false;
|
gReplacedRPX = false;
|
||||||
gTryToReplaceOnNextLaunch = false;
|
gTryToReplaceOnNextLaunch = false;
|
||||||
gIsMounted = false;
|
gIsMounted = false;
|
||||||
@ -74,10 +74,10 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
CreateSubfolder(user.c_str());
|
CreateSubfolder(user.c_str());
|
||||||
DEBUG_FUNCTION_LINE("Created %s and %s", common.c_str(), user.c_str());
|
DEBUG_FUNCTION_LINE("Created %s and %s", common.c_str(), user.c_str());
|
||||||
if (romfsMount("rom", gLoadedBundlePath, RomfsSource_FileDescriptor_CafeOS) == 0) {
|
if (romfsMount("rom", gLoadedBundlePath, RomfsSource_FileDescriptor_CafeOS) == 0) {
|
||||||
DEBUG_FUNCTION_LINE("MOUNTED!");
|
DEBUG_FUNCTION_LINE("Mounted %s to /vol/content", gLoadedBundlePath);
|
||||||
gIsMounted = true;
|
gIsMounted = true;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("MOUNTED FAILED %s", gLoadedBundlePath);
|
DEBUG_FUNCTION_LINE("Failed to mount %s", gLoadedBundlePath);
|
||||||
gIsMounted = false;
|
gIsMounted = false;
|
||||||
}
|
}
|
||||||
gReplacedRPX = true;
|
gReplacedRPX = true;
|
||||||
|
@ -254,17 +254,17 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
|||||||
|
|
||||||
// sanity checks and initialization
|
// sanity checks and initialization
|
||||||
if (!orig || !rep)
|
if (!orig || !rep)
|
||||||
return NULL;
|
return nullptr;
|
||||||
len_rep = strlen(rep);
|
len_rep = strlen(rep);
|
||||||
if (len_rep == 0)
|
if (len_rep == 0)
|
||||||
return NULL; // empty rep causes infinite loop during count
|
return nullptr; // empty rep causes infinite loop during count
|
||||||
if (!with)
|
if (!with)
|
||||||
with = "";
|
with = "";
|
||||||
len_with = strlen(with);
|
len_with = strlen(with);
|
||||||
|
|
||||||
// count the number of replacements needed
|
// count the number of replacements needed
|
||||||
ins = orig;
|
ins = orig;
|
||||||
for (count = 0; tmp = strstr(ins, rep); ++count) {
|
for (count = 0; (tmp = strstr(ins, rep)); ++count) {
|
||||||
ins = tmp + len_rep;
|
ins = tmp + len_rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user