mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +01:00
Store the plugin configs at the correct location when running inside an environment
This commit is contained in:
parent
b0d1391e5a
commit
86a946a9fb
@ -2,15 +2,13 @@
|
||||
#include "globals.h"
|
||||
#include "hooks.h"
|
||||
#include "patcher/hooks_patcher_static.h"
|
||||
#include "plugin/PluginContainer.h"
|
||||
#include "plugin/PluginContainerPersistence.h"
|
||||
#include "plugin/PluginDataFactory.h"
|
||||
#include "plugin/PluginDataPersistence.h"
|
||||
#include "utils/utils.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <coreinit/memdefaultheap.h>
|
||||
#include <memory>
|
||||
#include <wums.h>
|
||||
|
||||
@ -54,22 +52,6 @@ WUMS_APPLICATION_ENDS() {
|
||||
|
||||
void *allocOnCustomHeap(int alignment, int size);
|
||||
|
||||
std::string getPluginPath() {
|
||||
char environmentPath[0x100];
|
||||
memset(environmentPath, 0, sizeof(environmentPath));
|
||||
|
||||
auto handle = IOS_Open("/dev/mcp", IOS_OPEN_READ);
|
||||
if (handle >= 0) {
|
||||
int in = 0xF9; // IPC_CUSTOM_COPY_ENVIRONMENT_PATH
|
||||
if (IOS_Ioctl(handle, 100, &in, sizeof(in), environmentPath, sizeof(environmentPath)) != IOS_ERROR_OK) {
|
||||
return "fs:/vol/external01/wiiu/plugins";
|
||||
}
|
||||
|
||||
IOS_Close(handle);
|
||||
}
|
||||
return std::string(environmentPath) + "/plugins";
|
||||
}
|
||||
|
||||
WUMS_APPLICATION_STARTS() {
|
||||
uint32_t upid = OSGetUPID();
|
||||
if (upid != 2 && upid != 15) {
|
||||
|
@ -54,7 +54,7 @@ int StorageUtils::OpenStorage(const char *plugin_id, wups_storage_item_t *items)
|
||||
return WUPS_STORAGE_ERROR_INVALID_BACKEND_PARAMS;
|
||||
}
|
||||
|
||||
std::string filePath = std::string("fs:/vol/external01/wiiu/plugins/config/") + plugin_id + ".json";
|
||||
std::string filePath = getPluginPath() + "/config/" + plugin_id + ".json";
|
||||
|
||||
nlohmann::json j;
|
||||
CFile file(filePath, CFile::ReadOnly);
|
||||
@ -113,7 +113,7 @@ int StorageUtils::CloseStorage(const char *plugin_id, wups_storage_item_t *items
|
||||
return WUPS_STORAGE_ERROR_INVALID_BACKEND_PARAMS;
|
||||
}
|
||||
|
||||
std::string folderPath = "fs:/vol/external01/wiiu/plugins/config/";
|
||||
std::string folderPath = getPluginPath() + "/config/";
|
||||
std::string filePath = folderPath + plugin_id + ".json";
|
||||
|
||||
FSUtils::CreateSubfolder(folderPath.c_str());
|
||||
@ -133,5 +133,6 @@ int StorageUtils::CloseStorage(const char *plugin_id, wups_storage_item_t *items
|
||||
memcpy(data, jsonString.c_str(), writeSize);
|
||||
file.write(data, writeSize);
|
||||
file.close();
|
||||
|
||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -1,11 +1,24 @@
|
||||
#include "utils/logger.h"
|
||||
#include <coreinit/ios.h>
|
||||
#include <cstring>
|
||||
#include <malloc.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
#include <string>
|
||||
|
||||
std::string getPluginPath() {
|
||||
char environmentPath[0x100];
|
||||
memset(environmentPath, 0, sizeof(environmentPath));
|
||||
|
||||
auto handle = IOS_Open("/dev/mcp", IOS_OPEN_READ);
|
||||
if (handle >= 0) {
|
||||
int in = 0xF9; // IPC_CUSTOM_COPY_ENVIRONMENT_PATH
|
||||
if (IOS_Ioctl(handle, 100, &in, sizeof(in), environmentPath, sizeof(environmentPath)) != IOS_ERROR_OK) {
|
||||
return "fs:/vol/external01/wiiu/plugins";
|
||||
}
|
||||
|
||||
IOS_Close(handle);
|
||||
}
|
||||
return std::string(environmentPath) + "/plugins";
|
||||
}
|
||||
|
||||
// https://gist.github.com/ccbrown/9722406
|
||||
void dumpHex(const void *data, size_t size) {
|
||||
@ -25,7 +38,7 @@ void dumpHex(const void *data, size_t size) {
|
||||
if ((i + 1) % 16 == 0) {
|
||||
WHBLogPrintf("| %s ", ascii);
|
||||
if (i + 1 < size) {
|
||||
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", data + i + 1, i + 1);
|
||||
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", ((uint32_t) data) + i + 1, i + 1);
|
||||
}
|
||||
} else if (i + 1 == size) {
|
||||
ascii[(i + 1) % 16] = '\0';
|
@ -1,7 +1,7 @@
|
||||
#ifndef __UTILS_H_
|
||||
#define __UTILS_H_
|
||||
#pragma once
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -41,4 +41,4 @@ void dumpHex(const void *data, size_t size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __UTILS_H_
|
||||
std::string getPluginPath();
|
Loading…
Reference in New Issue
Block a user