mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-21 20:29:17 +01:00
Format the code via clang-format
This commit is contained in:
parent
c21f9d8567
commit
2547c7edca
67
.clang-format
Normal file
67
.clang-format
Normal file
@ -0,0 +1,67 @@
|
||||
# Generated from CLion C/C++ Code Style settings
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 8
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -6,8 +6,16 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
|
16
.github/workflows/ci_non_master.yml
vendored
16
.github/workflows/ci_non_master.yml
vendored
@ -1,16 +0,0 @@
|
||||
name: Build binary
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -t builder
|
||||
docker run --rm -v ${PWD}:/project builder make
|
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
@ -3,8 +3,16 @@ name: CI-PR
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
|
@ -1,4 +1,6 @@
|
||||
# Wii U Plugin Loader Backend
|
||||
[![CI-Release](https://github.com/wiiu-env/WiiUPluginLoaderBackend/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/WiiUPluginLoaderBackend/actions/workflows/ci.yml)
|
||||
|
||||
# Wii U Plugin Loader Backend
|
||||
This is the Backend for the [WiiUPluginSystem](https://github.com/Maschell/WiiUPluginSystem). Check out the readme for more information about the Plugin System.
|
||||
|
||||
## Usage
|
||||
@ -46,6 +48,10 @@ docker run -it --rm -v ${PWD}:/project wiiupluginloaderbackend-builder make
|
||||
docker run -it --rm -v ${PWD}:/project wiiupluginloaderbackend-builder make clean
|
||||
```
|
||||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
|
||||
|
||||
# Credits
|
||||
- Maschell
|
||||
- orboditilt
|
||||
|
@ -1,22 +1,22 @@
|
||||
#include <memory.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/memdefaultheap.h>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
|
||||
#include "patcher/hooks_patcher_static.h"
|
||||
#include "plugin/PluginContainer.h"
|
||||
#include "plugin/PluginMetaInformationFactory.h"
|
||||
#include "plugin/PluginInformationFactory.h"
|
||||
#include "plugin/PluginMetaInformationFactory.h"
|
||||
|
||||
#include "utils/ElfUtils.h"
|
||||
#include "PluginManagement.h"
|
||||
#include "hooks.h"
|
||||
#include "globals.h"
|
||||
#include "hooks.h"
|
||||
#include "utils/ElfUtils.h"
|
||||
|
||||
bool PluginManagement::doRelocation(const std::vector<std::shared_ptr<RelocationData>> &relocData, relocation_trampoline_entry_t *tramp_data, uint32_t tramp_length, uint32_t trampolineID) {
|
||||
std::map<std::string, OSDynLoad_Module> moduleHandleCache;
|
||||
for (auto const &cur: relocData) {
|
||||
for (auto const &cur : relocData) {
|
||||
uint32_t functionAddress = 0;
|
||||
const std::string &functionName = cur->getName();
|
||||
|
||||
@ -66,7 +66,7 @@ bool PluginManagement::doRelocation(const std::vector<std::shared_ptr<Relocation
|
||||
|
||||
|
||||
void PluginManagement::doRelocations(const std::vector<std::shared_ptr<PluginContainer>> &plugins, relocation_trampoline_entry_t *trampData, uint32_t tramp_size) {
|
||||
for (auto &pluginContainer: plugins) {
|
||||
for (auto &pluginContainer : plugins) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Doing relocations for plugin: %s", pluginContainer->getMetaInformation()->getName().c_str());
|
||||
|
||||
if (!PluginManagement::doRelocation(pluginContainer->getPluginInformation()->getRelocationDataList(), trampData, tramp_size, pluginContainer->getPluginInformation()->getTrampolineId())) {
|
||||
@ -76,7 +76,7 @@ void PluginManagement::doRelocations(const std::vector<std::shared_ptr<PluginCon
|
||||
}
|
||||
|
||||
void PluginManagement::memsetBSS(const std::vector<std::shared_ptr<PluginContainer>> &plugins) {
|
||||
for (auto &pluginContainer: plugins) {
|
||||
for (auto &pluginContainer : plugins) {
|
||||
auto sbssSection = pluginContainer->getPluginInformation()->getSectionInfo(".sbss");
|
||||
if (sbssSection) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("memset .sbss %08X (%d)", sbssSection.value()->getAddress(), sbssSection.value()->getSize());
|
||||
@ -192,7 +192,7 @@ std::vector<std::shared_ptr<PluginContainer>>
|
||||
PluginManagement::loadPlugins(const std::vector<std::shared_ptr<PluginData>> &pluginList, MEMHeapHandle heapHandle, relocation_trampoline_entry_t *trampoline_data, uint32_t trampoline_data_length) {
|
||||
std::vector<std::shared_ptr<PluginContainer>> plugins;
|
||||
|
||||
for (auto &pluginData: pluginList) {
|
||||
for (auto &pluginData : pluginList) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Load meta information");
|
||||
auto metaInfo = PluginMetaInformationFactory::loadPlugin(pluginData);
|
||||
if (metaInfo) {
|
||||
@ -205,7 +205,7 @@ PluginManagement::loadPlugins(const std::vector<std::shared_ptr<PluginData>> &pl
|
||||
}
|
||||
}
|
||||
uint32_t trampolineID = 0;
|
||||
for (auto &pluginContainer: plugins) {
|
||||
for (auto &pluginContainer : plugins) {
|
||||
auto info = PluginInformationFactory::load(pluginContainer->getPluginData(), heapHandle, trampoline_data, trampoline_data_length, trampolineID++);
|
||||
if (!info) {
|
||||
DEBUG_FUNCTION_LINE("Failed to load Plugin %s", pluginContainer->getMetaInformation()->getName().c_str());
|
||||
@ -215,4 +215,3 @@ PluginManagement::loadPlugins(const std::vector<std::shared_ptr<PluginData>> &pl
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "plugin/PluginContainer.h"
|
||||
#include <common/plugin_defines.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class PluginManagement {
|
||||
public:
|
||||
|
||||
static void doRelocations(const std::vector<std::shared_ptr<PluginContainer>> &plugins, relocation_trampoline_entry_t *trampData, uint32_t tramp_size);
|
||||
|
||||
static void memsetBSS(const std::vector<std::shared_ptr<PluginContainer>> &plugins);
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <wums/defines/dynamic_linking_defines.h>
|
||||
#include <wums/defines/export_defines.h>
|
||||
#include <wums/defines/relocation_defines.h>
|
||||
@ -61,13 +61,13 @@ struct plugin_meta_info_t {
|
||||
};
|
||||
|
||||
struct replacement_data_hook_t {
|
||||
void * func_pointer = nullptr; /* [will be filled] */
|
||||
void *func_pointer = nullptr; /* [will be filled] */
|
||||
wups_loader_hook_type_t type{}; /* [will be filled] */
|
||||
};
|
||||
|
||||
struct plugin_function_symbol_data_t {
|
||||
char* name;
|
||||
void* address;
|
||||
char *name;
|
||||
void *address;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
@ -79,15 +79,15 @@ struct plugin_info_t {
|
||||
uint32_t number_used_hooks{}; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_PLUGIN
|
||||
replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function.
|
||||
uint8_t trampolineId{};
|
||||
plugin_function_symbol_data_t * function_symbol_data = nullptr;
|
||||
plugin_function_symbol_data_t *function_symbol_data = nullptr;
|
||||
uint32_t number_function_symbol_data = 0;
|
||||
void * allocatedTextMemoryAddress = nullptr;
|
||||
void * allocatedDataMemoryAddress = nullptr;
|
||||
void * allocatedFuncSymStringTableAddress = nullptr;
|
||||
void *allocatedTextMemoryAddress = nullptr;
|
||||
void *allocatedDataMemoryAddress = nullptr;
|
||||
void *allocatedFuncSymStringTableAddress = nullptr;
|
||||
};
|
||||
|
||||
struct plugin_data_t {
|
||||
char * buffer = nullptr;
|
||||
char *buffer = nullptr;
|
||||
size_t bufferLength = 0;
|
||||
int memoryType = 0;
|
||||
int heapHandle = 0;
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <wups/config.h>
|
||||
#include "WUPSConfigCategory.h"
|
||||
#include "utils/logger.h"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wups/config.h>
|
||||
|
||||
class WUPSConfig {
|
||||
public:
|
||||
@ -31,7 +31,7 @@ public:
|
||||
}
|
||||
|
||||
~WUPSConfig() {
|
||||
for (auto &element: categories) {
|
||||
for (auto &element : categories) {
|
||||
delete element;
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WUPSConfigItem.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wups/config.h>
|
||||
#include "WUPSConfigItem.h"
|
||||
|
||||
class WUPSConfigCategory {
|
||||
public:
|
||||
@ -29,7 +29,7 @@ public:
|
||||
}
|
||||
|
||||
~WUPSConfigCategory() {
|
||||
for (auto &element: items) {
|
||||
for (auto &element : items) {
|
||||
delete element;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "../utils/logger.h"
|
||||
#include "WUPSConfigCategory.h"
|
||||
#include <wums.h>
|
||||
#include <wups/config.h>
|
||||
#include "WUPSConfigCategory.h"
|
||||
#include "../utils/logger.h"
|
||||
|
||||
int32_t WUPSConfigCategory_Create(WUPSConfigCategoryHandle *out, const char *name) {
|
||||
if (name == nullptr || out == nullptr) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "../utils/logger.h"
|
||||
#include "WUPSConfig.h"
|
||||
#include <wums.h>
|
||||
#include <wups/config.h>
|
||||
#include "WUPSConfig.h"
|
||||
#include "../utils/logger.h"
|
||||
|
||||
int32_t WUPSConfig_Create(WUPSConfigHandle *out, const char *name) {
|
||||
if (name == nullptr || out == nullptr) {
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <wups/config.h>
|
||||
#include "utils/StringTools.h"
|
||||
#include "utils/logger.h"
|
||||
#include <wups/config.h>
|
||||
|
||||
class WUPSConfigItem {
|
||||
public:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "WUPSConfigItem.h"
|
||||
#include <wums.h>
|
||||
#include <wups/config.h>
|
||||
#include "WUPSConfigItem.h"
|
||||
|
||||
typedef uint32_t WUPSConfigItemHandle;
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
Copyright (C) 2001-2015 by Serge Lamikhov-Center
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <strings.h>
|
||||
#include <fs/CFile.hpp>
|
||||
#include <strings.h>
|
||||
|
||||
CFile::CFile() {
|
||||
iFd = -1;
|
||||
@ -170,5 +170,3 @@ int32_t CFile::fwrite(const char *format, ...) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <wut_types.h>
|
||||
|
||||
|
@ -24,14 +24,14 @@
|
||||
* DirList Class
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <strings.h>
|
||||
#include <algorithm>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <fs/DirList.h>
|
||||
#include <utils/StringTools.h>
|
||||
|
@ -27,8 +27,8 @@
|
||||
#ifndef ___DIRLIST_H_
|
||||
#define ___DIRLIST_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wut_types.h>
|
||||
|
||||
typedef struct {
|
||||
@ -97,6 +97,7 @@ public:
|
||||
Dirs = 0x02,
|
||||
CheckSubfolders = 0x08,
|
||||
};
|
||||
|
||||
protected:
|
||||
// Internal parser
|
||||
BOOL InternalLoadPath(std::string &path);
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "fs/FSUtils.h"
|
||||
#include "fs/CFile.hpp"
|
||||
#include "utils/logger.h"
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
|
||||
//! always initialze input
|
||||
@ -139,4 +139,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size)
|
||||
file.close();
|
||||
return written;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include <wums.h>
|
||||
|
||||
#include "plugin/PluginContainer.h"
|
||||
#include "common/plugin_defines.h"
|
||||
#include "plugin/PluginContainer.h"
|
||||
#include "utils/ConfigUtils.h"
|
||||
|
||||
extern plugin_information_t *gPluginInformation;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "hooks.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/StorageUtils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type) {
|
||||
CallHookEx(pluginInformation, hook_type, -1);
|
||||
@ -20,7 +20,7 @@ bool HasHookCallHook(plugin_information_t *pluginInformation, wups_loader_hook_t
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char **hook_names = (const char *[]) {
|
||||
static const char **hook_names = (const char *[]){
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_MALLOC",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_MALLOC",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_NEWLIB",
|
||||
@ -87,15 +87,14 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
|
||||
hook_type == WUPS_LOADER_HOOK_GET_CONFIG ||
|
||||
hook_type == WUPS_LOADER_HOOK_CONFIG_CLOSED ||
|
||||
hook_type == WUPS_LOADER_HOOK_RELEASE_FOREGROUND ||
|
||||
hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND
|
||||
) {
|
||||
((void (*)()) ((uint32_t *) func_ptr))();
|
||||
hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND) {
|
||||
((void (*)())((uint32_t *) func_ptr))();
|
||||
} else if (hook_type == WUPS_LOADER_HOOK_INIT_STORAGE) {
|
||||
wups_loader_init_storage_args_t args;
|
||||
args.open_storage_ptr = &StorageUtils::OpenStorage;
|
||||
args.close_storage_ptr = &StorageUtils::CloseStorage;
|
||||
args.plugin_id = plugin_data->meta.storageId;
|
||||
((void (*)(wups_loader_init_storage_args_t)) ((uint32_t *) func_ptr))(args);
|
||||
((void (*)(wups_loader_init_storage_args_t))((uint32_t *) func_ptr))(args);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("######################################");
|
||||
DEBUG_FUNCTION_LINE("Hook is not implemented %s [%d]", hook_names[hook_type], hook_type);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <wups.h>
|
||||
#include "common/plugin_defines.h"
|
||||
#include <wups.h>
|
||||
|
||||
void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type);
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
#include <wums.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/memdefaultheap.h>
|
||||
#include <memory>
|
||||
#include "plugin/PluginContainer.h"
|
||||
#include "globals.h"
|
||||
#include "plugin/PluginDataFactory.h"
|
||||
#include "plugin/PluginDataPersistence.h"
|
||||
#include "plugin/PluginContainerPersistence.h"
|
||||
#include "PluginManagement.h"
|
||||
#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 <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <coreinit/memdefaultheap.h>
|
||||
#include <memory>
|
||||
#include <wums.h>
|
||||
|
||||
WUMS_MODULE_EXPORT_NAME("homebrew_wupsbackend");
|
||||
|
||||
@ -141,9 +141,9 @@ WUMS_APPLICATION_STARTS() {
|
||||
DEBUG_FUNCTION_LINE("Loaded data for %d plugins.", pluginList.size());
|
||||
|
||||
auto plugins = PluginManagement::loadPlugins(pluginList, gPluginDataHeap, gTrampolineData, gTrampolineDataSize);
|
||||
for (auto &pluginContainer: plugins) {
|
||||
for (auto &pluginContainer : plugins) {
|
||||
#ifdef DEBUG
|
||||
for (const auto &kv: pluginContainer->getPluginInformation()->getSectionInfoList()) {
|
||||
for (const auto &kv : pluginContainer->getPluginInformation()->getSectionInfoList()) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s = %s %08X %d", kv.first.c_str(), kv.second->getName().c_str(), kv.second->getAddress(), kv.second->getSize());
|
||||
}
|
||||
#endif
|
||||
@ -166,7 +166,7 @@ WUMS_APPLICATION_STARTS() {
|
||||
for (int32_t plugin_index = 0; plugin_index < gPluginInformation->number_used_plugins; plugin_index++) {
|
||||
plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]);
|
||||
BOOL doDelete = true;
|
||||
for (auto &pluginData: pluginDataList) {
|
||||
for (auto &pluginData : pluginDataList) {
|
||||
if (pluginData->buffer == plugin->data.buffer) {
|
||||
doDelete = false;
|
||||
break;
|
||||
@ -198,7 +198,7 @@ WUMS_APPLICATION_STARTS() {
|
||||
|
||||
auto plugins = PluginManagement::loadPlugins(pluginDataList, gPluginDataHeap, gTrampolineData, gTrampolineDataSize);
|
||||
|
||||
for (auto &pluginContainer: plugins) {
|
||||
for (auto &pluginContainer : plugins) {
|
||||
DEBUG_FUNCTION_LINE("Stored information for plugin %s ; %s", pluginContainer->getMetaInformation()->getName().c_str(), pluginContainer->getMetaInformation()->getAuthor().c_str());
|
||||
if (!PluginContainerPersistence::savePlugin(gPluginInformation, pluginContainer, gPluginDataHeap)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to save plugin");
|
||||
@ -242,7 +242,7 @@ void *allocOnCustomHeap(int alignment, int size) {
|
||||
}
|
||||
uint32_t *custom_memalign;
|
||||
dyn_res = OSDynLoad_FindExport(module, true, "MEMAllocFromMappedMemoryEx", reinterpret_cast<void **>(&custom_memalign));
|
||||
auto *customMEMAllocFromDefaultHeapEx = (void *(*)(uint32_t, int)) *custom_memalign;
|
||||
auto *customMEMAllocFromDefaultHeapEx = (void *(*) (uint32_t, int) ) * custom_memalign;
|
||||
|
||||
if (dyn_res != OS_DYNLOAD_OK) {
|
||||
return nullptr;
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "hooks_patcher_static.h"
|
||||
#include <wups.h>
|
||||
#include <vpad/input.h>
|
||||
#include <padscore/wpad.h>
|
||||
#include <coreinit/messagequeue.h>
|
||||
#include <coreinit/core.h>
|
||||
#include <coreinit/messagequeue.h>
|
||||
#include <padscore/wpad.h>
|
||||
#include <vpad/input.h>
|
||||
#include <wups.h>
|
||||
|
||||
#include "../utils/ConfigUtils.h"
|
||||
#include "../globals.h"
|
||||
#include "../hooks.h"
|
||||
#include "../utils/ConfigUtils.h"
|
||||
|
||||
uint8_t vpadPressCooldown = 0xFF;
|
||||
bool configMenuOpened = false;
|
||||
@ -103,11 +103,11 @@ DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
|
||||
}
|
||||
|
||||
|
||||
#define KiReport ((void (*)( const char*, ... ))0xfff0ad0c)
|
||||
#define KiReport ((void (*)(const char *, ...)) 0xfff0ad0c)
|
||||
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("O0")
|
||||
#pragma GCC optimize("O0")
|
||||
|
||||
DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
|
||||
uint32_t addr,
|
||||
@ -120,7 +120,7 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
|
||||
plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]);
|
||||
plugin_section_info_t *section = nullptr;
|
||||
|
||||
for (auto §ionInfo: plugin->info.sectionInfos) {
|
||||
for (auto §ionInfo : plugin->info.sectionInfos) {
|
||||
if (sectionInfo.addr == 0 && sectionInfo.size == 0) {
|
||||
break;
|
||||
}
|
||||
@ -168,7 +168,7 @@ DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t
|
||||
plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]);
|
||||
plugin_section_info_t *section = nullptr;
|
||||
|
||||
for (auto §ionInfo: plugin->info.sectionInfos) {
|
||||
for (auto §ionInfo : plugin->info.sectionInfos) {
|
||||
if (sectionInfo.addr == 0 && sectionInfo.size == 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_li
|
||||
return nullptr;
|
||||
}
|
||||
dyn_linking_function_t *result = nullptr;
|
||||
for (auto &curEntry: data->functions) {
|
||||
for (auto &curEntry : data->functions) {
|
||||
if (strlen(curEntry.functionName) == 0) {
|
||||
if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long.");
|
||||
@ -41,7 +41,7 @@ dyn_linking_import_t *DynamicLinkingHelper::getOrAddImport(dyn_linking_relocatio
|
||||
return nullptr;
|
||||
}
|
||||
dyn_linking_import_t *result = nullptr;
|
||||
for (auto &curEntry: data->imports) {
|
||||
for (auto &curEntry : data->imports) {
|
||||
if (strlen(curEntry.importName) == 0) {
|
||||
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.");
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <wums/defines/dynamic_linking_defines.h>
|
||||
#include "RelocationData.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "RelocationData.h"
|
||||
#include <wums/defines/dynamic_linking_defines.h>
|
||||
|
||||
class DynamicLinkingHelper {
|
||||
public:
|
||||
|
@ -16,9 +16,9 @@
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <wups.h>
|
||||
#include <string>
|
||||
#include <function_patcher/fpatching_defines.h>
|
||||
#include <string>
|
||||
#include <wups.h>
|
||||
|
||||
class FunctionData {
|
||||
|
||||
@ -73,4 +73,3 @@ private:
|
||||
void *replaceAddr = nullptr;
|
||||
void *replaceCall = nullptr;
|
||||
};
|
||||
|
||||
|
@ -24,8 +24,7 @@ class FunctionSymbolData {
|
||||
public:
|
||||
FunctionSymbolData(const FunctionSymbolData &o2) = default;
|
||||
|
||||
FunctionSymbolData(std::string &name, void *address, uint32_t size) :
|
||||
name(name),
|
||||
FunctionSymbolData(std::string &name, void *address, uint32_t size) : name(name),
|
||||
address(address),
|
||||
size(size) {
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wups.h>
|
||||
#include <string>
|
||||
#include <wups.h>
|
||||
|
||||
class HookData {
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../utils/logger.h"
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "../utils/logger.h"
|
||||
|
||||
class ImportRPLInformation {
|
||||
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "PluginData.h"
|
||||
#include "PluginMetaInformation.h"
|
||||
#include "PluginInformation.h"
|
||||
#include "PluginMetaInformation.h"
|
||||
#include <memory>
|
||||
|
||||
class PluginContainer {
|
||||
public:
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "DynamicLinkingHelper.h"
|
||||
#include "PluginContainer.h"
|
||||
#include "PluginInformationFactory.h"
|
||||
#include "PluginMetaInformationFactory.h"
|
||||
#include "PluginContainerPersistence.h"
|
||||
#include "PluginDataPersistence.h"
|
||||
#include "DynamicLinkingHelper.h"
|
||||
#include "PluginInformationFactory.h"
|
||||
#include "PluginMetaInformationFactory.h"
|
||||
|
||||
bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformation, const std::shared_ptr<PluginContainer> &plugin, MEMHeapHandle heapHandle) {
|
||||
int32_t plugin_count = pluginInformation->number_used_plugins;
|
||||
@ -68,7 +68,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
|
||||
// Relocation
|
||||
auto relocationData = pluginInfo->getRelocationDataList();
|
||||
for (auto &reloc: relocationData) {
|
||||
for (auto &reloc : relocationData) {
|
||||
if (!DynamicLinkingHelper::addReloationEntry(&(pluginInformation->linking_data), plugin_data->info.linking_entries, PLUGIN_DYN_LINK_RELOCATION_LIST_LENGTH, reloc)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add a relocation entry");
|
||||
return false;
|
||||
@ -94,7 +94,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
|
||||
/* Store function replacement information */
|
||||
uint32_t i = 0;
|
||||
for (auto &curFunction: pluginInfo->getFunctionDataList()) {
|
||||
for (auto &curFunction : pluginInfo->getFunctionDataList()) {
|
||||
function_replacement_data_t *function_data = &plugin_data->info.functions[i];
|
||||
if (strlen(curFunction->getName().c_str()) > MAXIMUM_FUNCTION_NAME_LENGTH - 1) {
|
||||
DEBUG_FUNCTION_LINE("Could not add function \"%s\" for plugin \"%s\" function name is too long.", curFunction->getName().c_str(), pluginName.c_str());
|
||||
@ -118,7 +118,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (auto &curHook: pluginInfo->getHookDataList()) {
|
||||
for (auto &curHook : pluginInfo->getHookDataList()) {
|
||||
replacement_data_hook_t *hook_data = &plugin_data->info.hooks[i];
|
||||
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Set hook for plugin \"%s\" of type %08X to target %08X", plugin_data->meta.name, curHook->getType(), (void *) curHook->getFunctionPointer());
|
||||
@ -131,7 +131,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
}
|
||||
|
||||
/* Saving SectionInfos */
|
||||
for (auto &curSection: pluginInfo->getSectionInfoList()) {
|
||||
for (auto &curSection : pluginInfo->getSectionInfoList()) {
|
||||
bool foundFreeSlot = false;
|
||||
uint32_t slot = 0;
|
||||
for (uint32_t j = 0; j < MAXIMUM_PLUGIN_SECTION_LENGTH; j++) {
|
||||
@ -165,7 +165,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
if (entryCount > 0) {
|
||||
// Saving SectionInfos
|
||||
uint32_t funcSymStringLen = 1;
|
||||
for (auto &curFuncSym: pluginInfo->getFunctionSymbolDataList()) {
|
||||
for (auto &curFuncSym : pluginInfo->getFunctionSymbolDataList()) {
|
||||
funcSymStringLen += curFuncSym->getName().length() + 1;
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
|
||||
uint32_t curStringOffset = 0;
|
||||
uint32_t curEntryIndex = 0;
|
||||
for (auto &curFuncSym: pluginInfo->getFunctionSymbolDataList()) {
|
||||
for (auto &curFuncSym : pluginInfo->getFunctionSymbolDataList()) {
|
||||
entryTable[curEntryIndex].address = curFuncSym->getAddress();
|
||||
entryTable[curEntryIndex].name = &stringTable[curStringOffset];
|
||||
entryTable[curEntryIndex].size = curFuncSym->getSize();
|
||||
@ -257,7 +257,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
curPluginInformation->allocatedTextMemoryAddress = plugin_data->info.allocatedTextMemoryAddress;
|
||||
curPluginInformation->allocatedDataMemoryAddress = plugin_data->info.allocatedDataMemoryAddress;
|
||||
|
||||
for (auto &curItem: plugin_data->info.sectionInfos) {
|
||||
for (auto &curItem : plugin_data->info.sectionInfos) {
|
||||
plugin_section_info_t *sectionInfo = &curItem;
|
||||
if (sectionInfo->addr == 0 && sectionInfo->size == 0) {
|
||||
continue;
|
||||
@ -281,7 +281,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
}
|
||||
|
||||
bool storageHasId = true;
|
||||
for (auto const &value: curPluginInformation->getHookDataList()) {
|
||||
for (auto const &value : curPluginInformation->getHookDataList()) {
|
||||
if (value->getType() == WUPS_LOADER_HOOK_INIT_STORAGE &&
|
||||
metaInformation->getStorageId().empty()) {
|
||||
storageHasId = false;
|
||||
@ -309,7 +309,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
}
|
||||
|
||||
/* load relocation data */
|
||||
for (auto &linking_entry: plugin_data->info.linking_entries) {
|
||||
for (auto &linking_entry : plugin_data->info.linking_entries) {
|
||||
if (linking_entry.destination == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "PluginData.h"
|
||||
|
||||
#include <utility>
|
||||
#include <malloc.h>
|
||||
#include "../utils/logger.h"
|
||||
#include <malloc.h>
|
||||
#include <utility>
|
||||
|
||||
PluginData::PluginData(const PluginData &obj) {
|
||||
this->buffer = obj.buffer;
|
||||
@ -34,8 +34,7 @@ void PluginData::freeMemory() {
|
||||
PluginData::PluginData(const std::vector<uint8_t> &buffer) : PluginData(buffer, nullptr, eMemTypeMEM2) {
|
||||
}
|
||||
|
||||
PluginData::PluginData(const std::vector<uint8_t> &input, MEMHeapHandle heapHandle, eMemoryTypes memoryType) :
|
||||
heapHandle(heapHandle),
|
||||
PluginData::PluginData(const std::vector<uint8_t> &input, MEMHeapHandle heapHandle, eMemoryTypes memoryType) : heapHandle(heapHandle),
|
||||
memoryType(memoryType),
|
||||
length(input.size()) {
|
||||
void *data_copy = nullptr;
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include <malloc.h>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <malloc.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
|
||||
#include "../elfio/elfio.hpp"
|
||||
|
||||
|
@ -14,13 +14,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <memory>
|
||||
#include "PluginDataFactory.h"
|
||||
#include "../utils/logger.h"
|
||||
#include "../utils/StringTools.h"
|
||||
#include "../utils/logger.h"
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
std::vector<std::shared_ptr<PluginData>> PluginDataFactory::loadDir(const std::string &path, MEMHeapHandle heapHandle) {
|
||||
@ -39,7 +39,7 @@ std::vector<std::shared_ptr<PluginData>> PluginDataFactory::loadDir(const std::s
|
||||
}
|
||||
|
||||
while ((dp = readdir(dfd)) != nullptr) {
|
||||
struct stat stbuf{};
|
||||
struct stat stbuf {};
|
||||
std::string full_file_path = StringTools::strfmt("%s/%s", path.c_str(), dp->d_name);
|
||||
StringTools::RemoveDoubleSlashs(full_file_path);
|
||||
if (stat(full_file_path.c_str(), &stbuf) == -1) {
|
||||
|
@ -17,11 +17,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PluginData.h"
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include "PluginData.h"
|
||||
|
||||
class PluginDataFactory {
|
||||
public:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <memory>
|
||||
#include "../common/plugin_defines.h"
|
||||
#include "PluginDataPersistence.h"
|
||||
#include "../common/plugin_defines.h"
|
||||
#include <memory>
|
||||
|
||||
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, const std::shared_ptr<PluginData> &plugin) {
|
||||
if (pluginDataStruct == nullptr) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/plugin_defines.h"
|
||||
#include "PluginData.h"
|
||||
#include <memory>
|
||||
|
||||
class PluginDataPersistence {
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "PluginInformation.h"
|
||||
|
||||
PluginInformation::PluginInformation(const PluginInformation &other) {
|
||||
for (const auto &i: other.hook_data_list) {
|
||||
for (const auto &i : other.hook_data_list) {
|
||||
hook_data_list.push_back(i);
|
||||
}
|
||||
for (const auto &i: other.function_data_list) {
|
||||
for (const auto &i : other.function_data_list) {
|
||||
function_data_list.push_back(i);
|
||||
}
|
||||
for (const auto &i: other.relocation_data_list) {
|
||||
for (const auto &i : other.relocation_data_list) {
|
||||
relocation_data_list.push_back(i);
|
||||
}
|
||||
for (const auto &i: other.symbol_data_list) {
|
||||
for (const auto &i : other.symbol_data_list) {
|
||||
symbol_data_list.insert(i);
|
||||
}
|
||||
section_info_list = other.section_info_list;
|
||||
|
@ -17,18 +17,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "FunctionData.h"
|
||||
#include "FunctionSymbolData.h"
|
||||
#include "HookData.h"
|
||||
#include "PluginMetaInformation.h"
|
||||
#include "RelocationData.h"
|
||||
#include "HookData.h"
|
||||
#include "FunctionData.h"
|
||||
#include "SectionInfo.h"
|
||||
#include "FunctionSymbolData.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct FunctionSymbolDataComparator {
|
||||
bool operator()(const std::shared_ptr<FunctionSymbolData> &lhs,
|
||||
|
@ -15,17 +15,17 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include "PluginInformationFactory.h"
|
||||
#include "../utils/ElfUtils.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "PluginData.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include <wups.h>
|
||||
#include "PluginData.h"
|
||||
#include "PluginInformationFactory.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "../utils/ElfUtils.h"
|
||||
|
||||
using namespace ELFIO;
|
||||
|
||||
@ -157,7 +157,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
}
|
||||
auto relocationData = getImportRelocationData(reader, destinations);
|
||||
|
||||
for (auto const &reloc: relocationData) {
|
||||
for (auto const &reloc : relocationData) {
|
||||
pluginInfo->addRelocationData(reloc);
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
if (entries != nullptr) {
|
||||
for (size_t j = 0; j < entries_count; j++) {
|
||||
wups_loader_hook_t *hook = &entries[j];
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Saving hook of plugin Type: %08X, target: %08X"/*,pluginData->getPluginInformation()->getName().c_str()*/, hook->type, (void *) hook->target);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Saving hook of plugin Type: %08X, target: %08X" /*,pluginData->getPluginInformation()->getName().c_str()*/, hook->type, (void *) hook->target);
|
||||
auto hook_data = std::make_shared<HookData>((void *) hook->target, hook->type);
|
||||
pluginInfo->addHookData(hook_data);
|
||||
}
|
||||
@ -192,7 +192,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
for (size_t j = 0; j < entries_count; j++) {
|
||||
wups_loader_entry_t *cur_function = &entries[j];
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Saving function \"%s\" of plugin . PA:%08X VA:%08X Library: %08X, target: %08X, call_addr: %08X",
|
||||
cur_function->_function.name/*,pluginData->getPluginInformation()->getName().c_str()*/,
|
||||
cur_function->_function.name /*,pluginData->getPluginInformation()->getName().c_str()*/,
|
||||
cur_function->_function.physical_address, cur_function->_function.virtual_address, cur_function->_function.library, cur_function->_function.target,
|
||||
(void *) cur_function->_function.call_addr);
|
||||
auto function_data = std::make_shared<FunctionData>((void *) cur_function->_function.physical_address, (void *) cur_function->_function.virtual_address, cur_function->_function.name,
|
||||
|
@ -17,15 +17,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../elfio/elfio.hpp"
|
||||
#include "PluginContainer.h"
|
||||
#include "PluginInformation.h"
|
||||
#include <coreinit/memheap.h>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <coreinit/memheap.h>
|
||||
#include <wums/defines/relocation_defines.h>
|
||||
#include "PluginInformation.h"
|
||||
#include "PluginContainer.h"
|
||||
#include "../elfio/elfio.hpp"
|
||||
|
||||
class PluginInformationFactory {
|
||||
public:
|
||||
|
@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <whb/file.h>
|
||||
#include <memory>
|
||||
#include "../utils/StringTools.h"
|
||||
#include "PluginMetaInformationFactory.h"
|
||||
#include "../utils/StringTools.h"
|
||||
#include <dirent.h>
|
||||
#include <memory>
|
||||
#include <sys/types.h>
|
||||
#include <whb/file.h>
|
||||
|
||||
using namespace ELFIO;
|
||||
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PluginData.h"
|
||||
#include "PluginMetaInformation.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "PluginMetaInformation.h"
|
||||
#include "PluginData.h"
|
||||
|
||||
class PluginMetaInformationFactory {
|
||||
public:
|
||||
|
@ -17,15 +17,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ImportRPLInformation.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "ImportRPLInformation.h"
|
||||
|
||||
class RelocationData {
|
||||
|
||||
public:
|
||||
RelocationData(const char type, size_t offset, int32_t addend, void *destination, std::string &name, std::shared_ptr<ImportRPLInformation> rplInfo) :
|
||||
type(type),
|
||||
RelocationData(const char type, size_t offset, int32_t addend, void *destination, std::string &name, std::shared_ptr<ImportRPLInformation> rplInfo) : type(type),
|
||||
offset(offset),
|
||||
addend(addend),
|
||||
destination(destination),
|
||||
|
@ -22,8 +22,7 @@
|
||||
class SectionInfo {
|
||||
|
||||
public:
|
||||
SectionInfo(std::string &name, uint32_t address, uint32_t sectionSize) :
|
||||
name(name),
|
||||
SectionInfo(std::string &name, uint32_t address, uint32_t sectionSize) : name(name),
|
||||
address(address),
|
||||
sectionSize(sectionSize) {
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "ConfigUtils.h"
|
||||
|
||||
#include "logger.h"
|
||||
#include "../config/WUPSConfig.h"
|
||||
#include "../globals.h"
|
||||
#include "DrawUtils.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <coreinit/screen.h>
|
||||
#include <gx2/display.h>
|
||||
#include <memory/mappedmemory.h>
|
||||
#include <padscore/kpad.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <coreinit/screen.h>
|
||||
#include <memory/mappedmemory.h>
|
||||
#include <vpad/input.h>
|
||||
#include <padscore/kpad.h>
|
||||
#include <gx2/display.h>
|
||||
|
||||
#define COLOR_BACKGROUND Color(238, 238, 238, 255)
|
||||
#define COLOR_TEXT Color(51, 51, 51, 255)
|
||||
@ -131,11 +131,11 @@ void ConfigUtils::displayMenu() {
|
||||
|
||||
for (uint32_t j = 0; j < plugin_data->info.number_used_hooks; j++) {
|
||||
replacement_data_hook_t *hook_data = &plugin_data->info.hooks[j];
|
||||
if (hook_data->type == WUPS_LOADER_HOOK_GET_CONFIG/*WUPS_LOADER_HOOK_GET_CONFIG*/) {
|
||||
if (hook_data->type == WUPS_LOADER_HOOK_GET_CONFIG /*WUPS_LOADER_HOOK_GET_CONFIG*/) {
|
||||
if (hook_data->func_pointer == nullptr) {
|
||||
break;
|
||||
}
|
||||
auto *cur_config = reinterpret_cast<WUPSConfig *>(((WUPSConfigHandle (*)()) ((uint32_t *) hook_data->func_pointer))());
|
||||
auto *cur_config = reinterpret_cast<WUPSConfig *>(((WUPSConfigHandle(*)())((uint32_t *) hook_data->func_pointer))());
|
||||
if (cur_config == nullptr) {
|
||||
break;
|
||||
}
|
||||
@ -543,9 +543,9 @@ void ConfigUtils::displayMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &element: configs) {
|
||||
for (const auto &cat: element.config->getCategories()) {
|
||||
for (const auto &item: cat->getItems()) {
|
||||
for (const auto &element : configs) {
|
||||
for (const auto &cat : element.config->getCategories()) {
|
||||
for (const auto &item : cat->getItems()) {
|
||||
if (item->isDirty()) {
|
||||
item->callCallback();
|
||||
}
|
||||
@ -565,13 +565,13 @@ void ConfigUtils::displayMenu() {
|
||||
if (hook_data->func_pointer == nullptr) {
|
||||
break;
|
||||
}
|
||||
((void (*)()) ((uint32_t *) hook_data->func_pointer))();
|
||||
((void (*)())((uint32_t *) hook_data->func_pointer))();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &element: configs) {
|
||||
for (const auto &element : configs) {
|
||||
DEBUG_FUNCTION_LINE("Delete %08X", element.config);
|
||||
delete element.config;
|
||||
}
|
||||
@ -637,7 +637,7 @@ void ConfigUtils::openConfigMenu() {
|
||||
|
||||
DrawUtils::deinitFont();
|
||||
|
||||
error_exit:
|
||||
error_exit:
|
||||
|
||||
if (storedTVBuffer.buffer != nullptr) {
|
||||
GX2SetTVBuffer(storedTVBuffer.buffer, storedTVBuffer.buffer_size, static_cast<GX2TVRenderMode>(storedTVBuffer.mode),
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include <coreinit/memory.h>
|
||||
#include <coreinit/screen.h>
|
||||
#include <png.h>
|
||||
#include <ft2build.h>
|
||||
#include <png.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
// buffer width
|
||||
@ -243,7 +243,8 @@ void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRigh
|
||||
buffer[num] = 0;
|
||||
} else {
|
||||
wchar_t *tmp = buffer;
|
||||
while ((*tmp++ = *string++));
|
||||
while ((*tmp++ = *string++))
|
||||
;
|
||||
}
|
||||
|
||||
print(x, y, buffer, alignRight);
|
||||
@ -283,7 +284,8 @@ uint32_t DrawUtils::getTextWidth(const char *string) {
|
||||
buffer[num] = 0;
|
||||
} else {
|
||||
wchar_t *tmp = buffer;
|
||||
while ((*tmp++ = *string++));
|
||||
while ((*tmp++ = *string++))
|
||||
;
|
||||
}
|
||||
|
||||
uint32_t width = getTextWidth(buffer);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <cstring>
|
||||
#include <coreinit/cache.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "ElfUtils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
// See https://github.com/decaf-emu/decaf-emu/blob/43366a34e7b55ab9d19b2444aeb0ccd46ac77dea/src/libdecaf/src/cafe/loader/cafe_loader_reloc.cpp#L144
|
||||
bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampoline_entry_t *trampoline_data, uint32_t trampoline_data_length,
|
||||
@ -96,12 +96,12 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
}
|
||||
if (freeSlot == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampoline data list is full");
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, target - (uint32_t) &(freeSlot->trampoline[0]));
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, target - (uint32_t) & (freeSlot->trampoline[0]));
|
||||
return false;
|
||||
}
|
||||
if (target - (uint32_t) &(freeSlot->trampoline[0]) > 0x1FFFFFC) {
|
||||
if (target - (uint32_t) & (freeSlot->trampoline[0]) > 0x1FFFFFC) {
|
||||
DEBUG_FUNCTION_LINE("**Cannot link 24-bit jump (too far to tramp buffer).");
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, (target - (uint32_t) &(freeSlot->trampoline[0])));
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, (target - (uint32_t) & (freeSlot->trampoline[0])));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
// Relocations for the imports may be overridden
|
||||
freeSlot->status = RELOC_TRAMP_IMPORT_DONE;
|
||||
}
|
||||
auto symbolValue = (uint32_t) &(freeSlot->trampoline[0]);
|
||||
auto symbolValue = (uint32_t) & (freeSlot->trampoline[0]);
|
||||
value = symbolValue + addend;
|
||||
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "StorageUtils.h"
|
||||
#include <string>
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "utils/json.hpp"
|
||||
#include "fs/CFile.hpp"
|
||||
#include "fs/FSUtils.h"
|
||||
#include "utils/json.hpp"
|
||||
#include "utils/logger.h"
|
||||
|
||||
static void processJson(wups_storage_item_t *items, nlohmann::json json) {
|
||||
if (items == nullptr) {
|
||||
|
@ -23,14 +23,14 @@
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string.h>
|
||||
#include <wut_types.h>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <utils/StringTools.h>
|
||||
#include <vector>
|
||||
#include <wut_types.h>
|
||||
|
||||
|
||||
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
|
||||
|
@ -26,8 +26,8 @@
|
||||
#ifndef __STRING_TOOLS_H
|
||||
#define __STRING_TOOLS_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wut_types.h>
|
||||
|
||||
class StringTools {
|
||||
@ -86,4 +86,3 @@ public:
|
||||
};
|
||||
|
||||
#endif /* __STRING_TOOLS_H */
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include <coreinit/cache.h>
|
||||
#include "../plugin/PluginMetaInformationFactory.h"
|
||||
#include "exports.h"
|
||||
#include "../PluginManagement.h"
|
||||
#include "../globals.h"
|
||||
#include "../plugin/PluginContainer.h"
|
||||
#include "../plugin/PluginContainerPersistence.h"
|
||||
#include "../plugin/PluginDataFactory.h"
|
||||
#include "../PluginManagement.h"
|
||||
#include "../globals.h"
|
||||
#include "../plugin/PluginDataPersistence.h"
|
||||
#include "exports.h"
|
||||
#include "../plugin/PluginMetaInformationFactory.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <wums.h>
|
||||
|
||||
void fillPluginInformation(plugin_information *out, const std::shared_ptr<PluginMetaInformation> &metaInformation) {
|
||||
static void fillPluginInformation(plugin_information *out, const std::shared_ptr<PluginMetaInformation> &metaInformation) {
|
||||
out->plugin_information_version = PLUGIN_INFORMATION_VERSION;
|
||||
strncpy(out->author, metaInformation->getAuthor().c_str(), sizeof(out->author) - 1);
|
||||
strncpy(out->buildTimestamp, metaInformation->getBuildTimestamp().c_str(), sizeof(out->buildTimestamp) - 1);
|
||||
@ -182,7 +182,7 @@ extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(plugin_container_handl
|
||||
*plugin_information_version = PLUGIN_INFORMATION_VERSION;
|
||||
auto plugins = PluginContainerPersistence::loadPlugins(gPluginInformation);
|
||||
uint32_t counter = 0;
|
||||
for (auto &plugin: plugins) {
|
||||
for (auto &plugin : plugins) {
|
||||
if (counter < buffer_size) {
|
||||
auto *container = new PluginContainer(*plugin);
|
||||
io_handles[counter] = (uint32_t) container;
|
||||
|
@ -7,8 +7,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void fillPluginInformation(plugin_information *out, PluginMetaInformation *metaInformation);
|
||||
|
||||
PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
|
||||
|
||||
PluginBackendApiErrorType WUPSDeletePluginContainer(const plugin_container_handle *handle_list, uint32_t handle_list_size);
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
__ _____ _____ _____
|
||||
__| | __| | | | JSON for Modern C++
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifdef DEBUG
|
||||
#include <stdint.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <whb/log_cafe.h>
|
||||
#include <whb/log_module.h>
|
||||
#include <whb/log_udp.h>
|
||||
|
||||
uint32_t moduleLogInit = false;
|
||||
uint32_t cafeLogInit = false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <whb/log.h>
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -14,12 +14,14 @@ extern "C" {
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
|
||||
do { \
|
||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
|
||||
do { \
|
||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
@ -39,4 +41,3 @@ void deinitLogging();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "utils/logger.h"
|
||||
#include <malloc.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
#include "utils/logger.h"
|
||||
|
||||
// https://gist.github.com/ccbrown/9722406
|
||||
void dumpHex(const void *data, size_t size) {
|
||||
|
@ -9,26 +9,27 @@ extern "C" {
|
||||
|
||||
#define LIMIT(x, min, max) \
|
||||
({ \
|
||||
typeof( x ) _x = x; \
|
||||
typeof( min ) _min = min; \
|
||||
typeof( max ) _max = max; \
|
||||
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
|
||||
})
|
||||
typeof(x) _x = x; \
|
||||
typeof(min) _min = min; \
|
||||
typeof(max) _max = max; \
|
||||
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
|
||||
: (_x)); \
|
||||
})
|
||||
|
||||
#define DegToRad(a) ( (a) * 0.01745329252f )
|
||||
#define RadToDeg(a) ( (a) * 57.29577951f )
|
||||
#define DegToRad(a) ((a) *0.01745329252f)
|
||||
#define RadToDeg(a) ((a) *57.29577951f)
|
||||
|
||||
#define ALIGN4(x) (((x) + 3) & ~3)
|
||||
#define ALIGN32(x) (((x) + 31) & ~31)
|
||||
|
||||
// those work only in powers of 2
|
||||
#define ROUNDDOWN(val, align) ((val) & ~(align-1))
|
||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align)
|
||||
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
|
||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
||||
|
||||
|
||||
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8)))
|
||||
#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16)))
|
||||
#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
|
||||
#define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8)))
|
||||
#define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16)))
|
||||
#define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
|
||||
|
||||
//Needs to have log_init() called beforehand.
|
||||
void dumpHex(const void *data, size_t size);
|
||||
|
Loading…
Reference in New Issue
Block a user