forked from PretendoNetwork/Inkay
feat!: Split Inkay into a module and a plugin
This is necessary for a future Aroma feature. This also makes more clear the immutability of the patches that Pretendo requires, since they cannot be reverted easily. All patching code is now managed inside the module, which the plugin triggers by calling an exported function from it. The WWP reset code remains within the plugin as it isn't strictly tied to the patches.
This commit is contained in:
parent
cc967126fe
commit
f4aeee8034
30 changed files with 1034 additions and 294 deletions
|
|
@ -22,7 +22,8 @@
|
|||
#include "utils/logger.h"
|
||||
#include "utils/replace_mem.h"
|
||||
|
||||
#include <wups.h>
|
||||
#include <function_patcher/function_patching.h>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/filesystem.h>
|
||||
|
|
@ -54,6 +55,7 @@ const char wave_new[] = "saccount.pretendo.cc";
|
|||
bool isAccountSettingsTitle();
|
||||
|
||||
static std::optional<FSFileHandle> rootca_pem_handle{};
|
||||
std::vector<PatchedFunctionHandle> account_patches;
|
||||
|
||||
DECL_FUNCTION(int, FSOpenFile_accSettings, FSClient *client, FSCmdBlock *block, char *path, const char *mode, uint32_t *handle,
|
||||
int error) {
|
||||
|
|
@ -131,10 +133,27 @@ bool patchAccountSettings() {
|
|||
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: We didn't find the whitelist /)>~<(\\");
|
||||
return false;
|
||||
}
|
||||
|
||||
account_patches.reserve(3);
|
||||
|
||||
auto add_patch = [](function_replacement_data_t repl, const char *name) {
|
||||
PatchedFunctionHandle handle = 0;
|
||||
if (FunctionPatcher_AddFunctionPatch(&repl, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE("Inkay/Account: Failed to patch %s!", name);
|
||||
}
|
||||
account_patches.push_back(handle);
|
||||
};
|
||||
|
||||
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSOpenFile_accSettings, LIBRARY_COREINIT, FSOpenFile, FP_TARGET_PROCESS_GAME), "FSOpenFile_accSettings");
|
||||
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSReadFile_accSettings, LIBRARY_COREINIT, FSReadFile, FP_TARGET_PROCESS_GAME), "FSReadFile_accSettings");
|
||||
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSCloseFile_accSettings, LIBRARY_COREINIT, FSReadFile, FP_TARGET_PROCESS_GAME), "FSCloseFile_accSettings");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile_accSettings, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_GAME);
|
||||
WUPS_MUST_REPLACE_FOR_PROCESS(FSReadFile_accSettings, WUPS_LOADER_LIBRARY_COREINIT, FSReadFile, WUPS_FP_TARGET_PROCESS_GAME);
|
||||
WUPS_MUST_REPLACE_FOR_PROCESS(FSCloseFile_accSettings, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFile, WUPS_FP_TARGET_PROCESS_GAME);
|
||||
void unpatchAccountSettings() {
|
||||
for (auto handle: account_patches) {
|
||||
FunctionPatcher_RemoveFunctionPatch(handle);
|
||||
}
|
||||
account_patches.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue