mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-25 14:16:53 +01:00
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
#include "utils/logger.h"
|
|
#include <coreinit/ios.h>
|
|
#include <cstring>
|
|
#include <malloc.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).append("/plugins");
|
|
}
|
|
|
|
// https://gist.github.com/ccbrown/9722406
|
|
void dumpHex(const void *data, size_t size) {
|
|
char ascii[17];
|
|
size_t i, j;
|
|
ascii[16] = '\0';
|
|
DEBUG_FUNCTION_LINE("0x%08X (0x0000): ", data);
|
|
for (i = 0; i < size; ++i) {
|
|
WHBLogWritef("%02X ", ((unsigned char *) data)[i]);
|
|
if (((unsigned char *) data)[i] >= ' ' && ((unsigned char *) data)[i] <= '~') {
|
|
ascii[i % 16] = ((unsigned char *) data)[i];
|
|
} else {
|
|
ascii[i % 16] = '.';
|
|
}
|
|
if ((i + 1) % 8 == 0 || i + 1 == size) {
|
|
WHBLogWritef(" ");
|
|
if ((i + 1) % 16 == 0) {
|
|
WHBLogPrintf("| %s ", ascii);
|
|
if (i + 1 < size) {
|
|
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", ((uint32_t) data) + i + 1, i + 1);
|
|
}
|
|
} else if (i + 1 == size) {
|
|
ascii[(i + 1) % 16] = '\0';
|
|
if ((i + 1) % 16 <= 8) {
|
|
WHBLogWritef(" ");
|
|
}
|
|
for (j = (i + 1) % 16; j < 16; ++j) {
|
|
WHBLogWritef(" ");
|
|
}
|
|
WHBLogPrintf("| %s ", ascii);
|
|
}
|
|
}
|
|
}
|
|
}
|