Format the code via clang-format

This commit is contained in:
Maschell 2022-02-04 16:25:44 +01:00
parent c21f9d8567
commit 2547c7edca
75 changed files with 637 additions and 554 deletions

67
.clang-format Normal file
View 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

View File

@ -6,8 +6,16 @@ on:
- master - master
jobs: 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: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: build binary - name: build binary

View File

@ -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

View File

@ -3,8 +3,16 @@ name: CI-PR
on: [pull_request] on: [pull_request]
jobs: 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: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: build binary - name: build binary

View File

@ -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. This is the Backend for the [WiiUPluginSystem](https://github.com/Maschell/WiiUPluginSystem). Check out the readme for more information about the Plugin System.
## Usage ## 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 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 # Credits
- Maschell - Maschell
- orboditilt - orboditilt

View File

@ -1,22 +1,22 @@
#include <memory.h>
#include <coreinit/cache.h> #include <coreinit/cache.h>
#include <coreinit/dynload.h> #include <coreinit/dynload.h>
#include <coreinit/memdefaultheap.h> #include <coreinit/memdefaultheap.h>
#include <memory.h>
#include <memory> #include <memory>
#include "patcher/hooks_patcher_static.h" #include "patcher/hooks_patcher_static.h"
#include "plugin/PluginContainer.h" #include "plugin/PluginContainer.h"
#include "plugin/PluginMetaInformationFactory.h"
#include "plugin/PluginInformationFactory.h" #include "plugin/PluginInformationFactory.h"
#include "plugin/PluginMetaInformationFactory.h"
#include "utils/ElfUtils.h"
#include "PluginManagement.h" #include "PluginManagement.h"
#include "hooks.h"
#include "globals.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) { 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; std::map<std::string, OSDynLoad_Module> moduleHandleCache;
for (auto const &cur: relocData) { for (auto const &cur : relocData) {
uint32_t functionAddress = 0; uint32_t functionAddress = 0;
const std::string &functionName = cur->getName(); 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) { 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()); 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())) { 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) { 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"); auto sbssSection = pluginContainer->getPluginInformation()->getSectionInfo(".sbss");
if (sbssSection) { if (sbssSection) {
DEBUG_FUNCTION_LINE_VERBOSE("memset .sbss %08X (%d)", sbssSection.value()->getAddress(), sbssSection.value()->getSize()); 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) { 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; std::vector<std::shared_ptr<PluginContainer>> plugins;
for (auto &pluginData: pluginList) { for (auto &pluginData : pluginList) {
DEBUG_FUNCTION_LINE_VERBOSE("Load meta information"); DEBUG_FUNCTION_LINE_VERBOSE("Load meta information");
auto metaInfo = PluginMetaInformationFactory::loadPlugin(pluginData); auto metaInfo = PluginMetaInformationFactory::loadPlugin(pluginData);
if (metaInfo) { if (metaInfo) {
@ -205,7 +205,7 @@ PluginManagement::loadPlugins(const std::vector<std::shared_ptr<PluginData>> &pl
} }
} }
uint32_t trampolineID = 0; 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++); auto info = PluginInformationFactory::load(pluginContainer->getPluginData(), heapHandle, trampoline_data, trampoline_data_length, trampolineID++);
if (!info) { if (!info) {
DEBUG_FUNCTION_LINE("Failed to load Plugin %s", pluginContainer->getMetaInformation()->getName().c_str()); 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; return plugins;
} }

View File

@ -1,11 +1,12 @@
#pragma once #pragma once
#include "plugin/PluginContainer.h"
#include <common/plugin_defines.h> #include <common/plugin_defines.h>
#include <memory>
#include <vector> #include <vector>
class PluginManagement { class PluginManagement {
public: public:
static void doRelocations(const std::vector<std::shared_ptr<PluginContainer>> &plugins, relocation_trampoline_entry_t *trampData, uint32_t tramp_size); 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); static void memsetBSS(const std::vector<std::shared_ptr<PluginContainer>> &plugins);

View File

@ -17,8 +17,8 @@
#pragma once #pragma once
#include <cstdint>
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <wums/defines/dynamic_linking_defines.h> #include <wums/defines/dynamic_linking_defines.h>
#include <wums/defines/export_defines.h> #include <wums/defines/export_defines.h>
#include <wums/defines/relocation_defines.h> #include <wums/defines/relocation_defines.h>
@ -61,13 +61,13 @@ struct plugin_meta_info_t {
}; };
struct replacement_data_hook_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] */ wups_loader_hook_type_t type{}; /* [will be filled] */
}; };
struct plugin_function_symbol_data_t { struct plugin_function_symbol_data_t {
char* name; char *name;
void* address; void *address;
uint32_t size; 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 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. replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function.
uint8_t trampolineId{}; 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; uint32_t number_function_symbol_data = 0;
void * allocatedTextMemoryAddress = nullptr; void *allocatedTextMemoryAddress = nullptr;
void * allocatedDataMemoryAddress = nullptr; void *allocatedDataMemoryAddress = nullptr;
void * allocatedFuncSymStringTableAddress = nullptr; void *allocatedFuncSymStringTableAddress = nullptr;
}; };
struct plugin_data_t { struct plugin_data_t {
char * buffer = nullptr; char *buffer = nullptr;
size_t bufferLength = 0; size_t bufferLength = 0;
int memoryType = 0; int memoryType = 0;
int heapHandle = 0; int heapHandle = 0;

View File

@ -17,12 +17,12 @@
#pragma once #pragma once
#include <string>
#include <vector>
#include <optional>
#include <wups/config.h>
#include "WUPSConfigCategory.h" #include "WUPSConfigCategory.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <optional>
#include <string>
#include <vector>
#include <wups/config.h>
class WUPSConfig { class WUPSConfig {
public: public:
@ -31,7 +31,7 @@ public:
} }
~WUPSConfig() { ~WUPSConfig() {
for (auto &element: categories) { for (auto &element : categories) {
delete element; delete element;
} }
} }

View File

@ -17,10 +17,10 @@
#pragma once #pragma once
#include "WUPSConfigItem.h"
#include <string> #include <string>
#include <vector> #include <vector>
#include <wups/config.h> #include <wups/config.h>
#include "WUPSConfigItem.h"
class WUPSConfigCategory { class WUPSConfigCategory {
public: public:
@ -29,7 +29,7 @@ public:
} }
~WUPSConfigCategory() { ~WUPSConfigCategory() {
for (auto &element: items) { for (auto &element : items) {
delete element; delete element;
} }
} }

View File

@ -1,7 +1,7 @@
#include "../utils/logger.h"
#include "WUPSConfigCategory.h"
#include <wums.h> #include <wums.h>
#include <wups/config.h> #include <wups/config.h>
#include "WUPSConfigCategory.h"
#include "../utils/logger.h"
int32_t WUPSConfigCategory_Create(WUPSConfigCategoryHandle *out, const char *name) { int32_t WUPSConfigCategory_Create(WUPSConfigCategoryHandle *out, const char *name) {
if (name == nullptr || out == nullptr) { if (name == nullptr || out == nullptr) {

View File

@ -1,7 +1,7 @@
#include "../utils/logger.h"
#include "WUPSConfig.h"
#include <wums.h> #include <wums.h>
#include <wups/config.h> #include <wups/config.h>
#include "WUPSConfig.h"
#include "../utils/logger.h"
int32_t WUPSConfig_Create(WUPSConfigHandle *out, const char *name) { int32_t WUPSConfig_Create(WUPSConfigHandle *out, const char *name) {
if (name == nullptr || out == nullptr) { if (name == nullptr || out == nullptr) {

View File

@ -20,9 +20,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <wups/config.h>
#include "utils/StringTools.h" #include "utils/StringTools.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <wups/config.h>
class WUPSConfigItem { class WUPSConfigItem {
public: public:

View File

@ -1,6 +1,6 @@
#include "WUPSConfigItem.h"
#include <wums.h> #include <wums.h>
#include <wups/config.h> #include <wups/config.h>
#include "WUPSConfigItem.h"
typedef uint32_t WUPSConfigItemHandle; typedef uint32_t WUPSConfigItemHandle;

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
Copyright (C) 2001-2015 by Serge Lamikhov-Center Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,8 +1,8 @@
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <strings.h>
#include <fs/CFile.hpp> #include <fs/CFile.hpp>
#include <strings.h>
CFile::CFile() { CFile::CFile() {
iFd = -1; iFd = -1;
@ -170,5 +170,3 @@ int32_t CFile::fwrite(const char *format, ...) {
return result; return result;
} }

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <cstdio> #include <cstdio>
#include <string>
#include <cstring> #include <cstring>
#include <fcntl.h> #include <fcntl.h>
#include <string>
#include <unistd.h> #include <unistd.h>
#include <wut_types.h> #include <wut_types.h>

View File

@ -24,14 +24,14 @@
* DirList Class * DirList Class
* for WiiXplorer 2010 * for WiiXplorer 2010
***************************************************************************/ ***************************************************************************/
#include <algorithm>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <string> #include <string>
#include <strings.h> #include <strings.h>
#include <algorithm>
#include <sys/stat.h>
#include <sys/dirent.h> #include <sys/dirent.h>
#include <sys/stat.h>
#include <fs/DirList.h> #include <fs/DirList.h>
#include <utils/StringTools.h> #include <utils/StringTools.h>

View File

@ -27,8 +27,8 @@
#ifndef ___DIRLIST_H_ #ifndef ___DIRLIST_H_
#define ___DIRLIST_H_ #define ___DIRLIST_H_
#include <vector>
#include <string> #include <string>
#include <vector>
#include <wut_types.h> #include <wut_types.h>
typedef struct { typedef struct {
@ -97,6 +97,7 @@ public:
Dirs = 0x02, Dirs = 0x02,
CheckSubfolders = 0x08, CheckSubfolders = 0x08,
}; };
protected: protected:
// Internal parser // Internal parser
BOOL InternalLoadPath(std::string &path); BOOL InternalLoadPath(std::string &path);

View File

@ -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/FSUtils.h"
#include "fs/CFile.hpp" #include "fs/CFile.hpp"
#include "utils/logger.h" #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) { int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
//! always initialze input //! always initialze input
@ -139,4 +139,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size)
file.close(); file.close();
return written; return written;
} }

View File

@ -2,8 +2,8 @@
#include <wums.h> #include <wums.h>
#include "plugin/PluginContainer.h"
#include "common/plugin_defines.h" #include "common/plugin_defines.h"
#include "plugin/PluginContainer.h"
#include "utils/ConfigUtils.h" #include "utils/ConfigUtils.h"
extern plugin_information_t *gPluginInformation; extern plugin_information_t *gPluginInformation;

View File

@ -1,6 +1,6 @@
#include "hooks.h" #include "hooks.h"
#include "utils/logger.h"
#include "utils/StorageUtils.h" #include "utils/StorageUtils.h"
#include "utils/logger.h"
void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type) { void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type) {
CallHookEx(pluginInformation, hook_type, -1); CallHookEx(pluginInformation, hook_type, -1);
@ -20,7 +20,7 @@ bool HasHookCallHook(plugin_information_t *pluginInformation, wups_loader_hook_t
return false; 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_INIT_WUT_MALLOC",
"WUPS_LOADER_HOOK_FINI_WUT_MALLOC", "WUPS_LOADER_HOOK_FINI_WUT_MALLOC",
"WUPS_LOADER_HOOK_INIT_WUT_NEWLIB", "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_GET_CONFIG ||
hook_type == WUPS_LOADER_HOOK_CONFIG_CLOSED || hook_type == WUPS_LOADER_HOOK_CONFIG_CLOSED ||
hook_type == WUPS_LOADER_HOOK_RELEASE_FOREGROUND || hook_type == WUPS_LOADER_HOOK_RELEASE_FOREGROUND ||
hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND) {
) { ((void (*)())((uint32_t *) func_ptr))();
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_STORAGE) { } else if (hook_type == WUPS_LOADER_HOOK_INIT_STORAGE) {
wups_loader_init_storage_args_t args; wups_loader_init_storage_args_t args;
args.open_storage_ptr = &StorageUtils::OpenStorage; args.open_storage_ptr = &StorageUtils::OpenStorage;
args.close_storage_ptr = &StorageUtils::CloseStorage; args.close_storage_ptr = &StorageUtils::CloseStorage;
args.plugin_id = plugin_data->meta.storageId; 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 { } else {
DEBUG_FUNCTION_LINE("######################################"); DEBUG_FUNCTION_LINE("######################################");
DEBUG_FUNCTION_LINE("Hook is not implemented %s [%d]", hook_names[hook_type], hook_type); DEBUG_FUNCTION_LINE("Hook is not implemented %s [%d]", hook_names[hook_type], hook_type);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <wups.h>
#include "common/plugin_defines.h" #include "common/plugin_defines.h"
#include <wups.h>
void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type); void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type);

View File

@ -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 "PluginManagement.h"
#include "globals.h"
#include "hooks.h" #include "hooks.h"
#include "patcher/hooks_patcher_static.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"); WUMS_MODULE_EXPORT_NAME("homebrew_wupsbackend");
@ -141,9 +141,9 @@ WUMS_APPLICATION_STARTS() {
DEBUG_FUNCTION_LINE("Loaded data for %d plugins.", pluginList.size()); DEBUG_FUNCTION_LINE("Loaded data for %d plugins.", pluginList.size());
auto plugins = PluginManagement::loadPlugins(pluginList, gPluginDataHeap, gTrampolineData, gTrampolineDataSize); auto plugins = PluginManagement::loadPlugins(pluginList, gPluginDataHeap, gTrampolineData, gTrampolineDataSize);
for (auto &pluginContainer: plugins) { for (auto &pluginContainer : plugins) {
#ifdef DEBUG #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()); DEBUG_FUNCTION_LINE_VERBOSE("%s = %s %08X %d", kv.first.c_str(), kv.second->getName().c_str(), kv.second->getAddress(), kv.second->getSize());
} }
#endif #endif
@ -166,7 +166,7 @@ WUMS_APPLICATION_STARTS() {
for (int32_t plugin_index = 0; plugin_index < gPluginInformation->number_used_plugins; plugin_index++) { for (int32_t plugin_index = 0; plugin_index < gPluginInformation->number_used_plugins; plugin_index++) {
plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]); plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]);
BOOL doDelete = true; BOOL doDelete = true;
for (auto &pluginData: pluginDataList) { for (auto &pluginData : pluginDataList) {
if (pluginData->buffer == plugin->data.buffer) { if (pluginData->buffer == plugin->data.buffer) {
doDelete = false; doDelete = false;
break; break;
@ -198,7 +198,7 @@ WUMS_APPLICATION_STARTS() {
auto plugins = PluginManagement::loadPlugins(pluginDataList, gPluginDataHeap, gTrampolineData, gTrampolineDataSize); 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()); 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)) { if (!PluginContainerPersistence::savePlugin(gPluginInformation, pluginContainer, gPluginDataHeap)) {
DEBUG_FUNCTION_LINE("Failed to save plugin"); DEBUG_FUNCTION_LINE("Failed to save plugin");
@ -242,7 +242,7 @@ void *allocOnCustomHeap(int alignment, int size) {
} }
uint32_t *custom_memalign; uint32_t *custom_memalign;
dyn_res = OSDynLoad_FindExport(module, true, "MEMAllocFromMappedMemoryEx", reinterpret_cast<void **>(&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) { if (dyn_res != OS_DYNLOAD_OK) {
return nullptr; return nullptr;

View File

@ -1,13 +1,13 @@
#include "hooks_patcher_static.h" #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/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 "../globals.h"
#include "../hooks.h" #include "../hooks.h"
#include "../utils/ConfigUtils.h"
uint8_t vpadPressCooldown = 0xFF; uint8_t vpadPressCooldown = 0xFF;
bool configMenuOpened = false; 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 push_options
#pragma GCC optimize ("O0") #pragma GCC optimize("O0")
DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol, DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
uint32_t addr, uint32_t addr,
@ -120,7 +120,7 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]); plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]);
plugin_section_info_t *section = nullptr; plugin_section_info_t *section = nullptr;
for (auto &sectionInfo: plugin->info.sectionInfos) { for (auto &sectionInfo : plugin->info.sectionInfos) {
if (sectionInfo.addr == 0 && sectionInfo.size == 0) { if (sectionInfo.addr == 0 && sectionInfo.size == 0) {
break; 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_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]);
plugin_section_info_t *section = nullptr; plugin_section_info_t *section = nullptr;
for (auto &sectionInfo: plugin->info.sectionInfos) { for (auto &sectionInfo : plugin->info.sectionInfos) {
if (sectionInfo.addr == 0 && sectionInfo.size == 0) { if (sectionInfo.addr == 0 && sectionInfo.size == 0) {
break; break;
} }

View File

@ -10,7 +10,7 @@ dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_li
return nullptr; return nullptr;
} }
dyn_linking_function_t *result = nullptr; dyn_linking_function_t *result = nullptr;
for (auto &curEntry: data->functions) { for (auto &curEntry : data->functions) {
if (strlen(curEntry.functionName) == 0) { if (strlen(curEntry.functionName) == 0) {
if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) { if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) {
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long."); 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; return nullptr;
} }
dyn_linking_import_t *result = nullptr; dyn_linking_import_t *result = nullptr;
for (auto &curEntry: data->imports) { for (auto &curEntry : data->imports) {
if (strlen(curEntry.importName) == 0) { if (strlen(curEntry.importName) == 0) {
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) { if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long."); DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.");

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include <wums/defines/dynamic_linking_defines.h> #include "RelocationData.h"
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include <memory> #include <wums/defines/dynamic_linking_defines.h>
#include "RelocationData.h"
class DynamicLinkingHelper { class DynamicLinkingHelper {
public: public:

View File

@ -16,9 +16,9 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <wups.h>
#include <string>
#include <function_patcher/fpatching_defines.h> #include <function_patcher/fpatching_defines.h>
#include <string>
#include <wups.h>
class FunctionData { class FunctionData {
@ -73,4 +73,3 @@ private:
void *replaceAddr = nullptr; void *replaceAddr = nullptr;
void *replaceCall = nullptr; void *replaceCall = nullptr;
}; };

View File

@ -24,8 +24,7 @@ class FunctionSymbolData {
public: public:
FunctionSymbolData(const FunctionSymbolData &o2) = default; FunctionSymbolData(const FunctionSymbolData &o2) = default;
FunctionSymbolData(std::string &name, void *address, uint32_t size) : FunctionSymbolData(std::string &name, void *address, uint32_t size) : name(name),
name(name),
address(address), address(address),
size(size) { size(size) {
} }

View File

@ -17,8 +17,8 @@
#pragma once #pragma once
#include <wups.h>
#include <string> #include <string>
#include <wups.h>
class HookData { class HookData {

View File

@ -17,9 +17,9 @@
#pragma once #pragma once
#include "../utils/logger.h"
#include <string> #include <string>
#include <utility> #include <utility>
#include "../utils/logger.h"
class ImportRPLInformation { class ImportRPLInformation {

View File

@ -17,10 +17,10 @@
#pragma once #pragma once
#include <memory>
#include "PluginData.h" #include "PluginData.h"
#include "PluginMetaInformation.h"
#include "PluginInformation.h" #include "PluginInformation.h"
#include "PluginMetaInformation.h"
#include <memory>
class PluginContainer { class PluginContainer {
public: public:

View File

@ -2,12 +2,12 @@
#include <memory> #include <memory>
#include "DynamicLinkingHelper.h"
#include "PluginContainer.h" #include "PluginContainer.h"
#include "PluginInformationFactory.h"
#include "PluginMetaInformationFactory.h"
#include "PluginContainerPersistence.h" #include "PluginContainerPersistence.h"
#include "PluginDataPersistence.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) { bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformation, const std::shared_ptr<PluginContainer> &plugin, MEMHeapHandle heapHandle) {
int32_t plugin_count = pluginInformation->number_used_plugins; int32_t plugin_count = pluginInformation->number_used_plugins;
@ -68,7 +68,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
// Relocation // Relocation
auto relocationData = pluginInfo->getRelocationDataList(); 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)) { 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"); DEBUG_FUNCTION_LINE("Failed to add a relocation entry");
return false; return false;
@ -94,7 +94,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
/* Store function replacement information */ /* Store function replacement information */
uint32_t i = 0; 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]; function_replacement_data_t *function_data = &plugin_data->info.functions[i];
if (strlen(curFunction->getName().c_str()) > MAXIMUM_FUNCTION_NAME_LENGTH - 1) { 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()); 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; i = 0;
for (auto &curHook: pluginInfo->getHookDataList()) { for (auto &curHook : pluginInfo->getHookDataList()) {
replacement_data_hook_t *hook_data = &plugin_data->info.hooks[i]; 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()); 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 */ /* Saving SectionInfos */
for (auto &curSection: pluginInfo->getSectionInfoList()) { for (auto &curSection : pluginInfo->getSectionInfoList()) {
bool foundFreeSlot = false; bool foundFreeSlot = false;
uint32_t slot = 0; uint32_t slot = 0;
for (uint32_t j = 0; j < MAXIMUM_PLUGIN_SECTION_LENGTH; j++) { 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) { if (entryCount > 0) {
// Saving SectionInfos // Saving SectionInfos
uint32_t funcSymStringLen = 1; uint32_t funcSymStringLen = 1;
for (auto &curFuncSym: pluginInfo->getFunctionSymbolDataList()) { for (auto &curFuncSym : pluginInfo->getFunctionSymbolDataList()) {
funcSymStringLen += curFuncSym->getName().length() + 1; funcSymStringLen += curFuncSym->getName().length() + 1;
} }
@ -187,7 +187,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
uint32_t curStringOffset = 0; uint32_t curStringOffset = 0;
uint32_t curEntryIndex = 0; uint32_t curEntryIndex = 0;
for (auto &curFuncSym: pluginInfo->getFunctionSymbolDataList()) { for (auto &curFuncSym : pluginInfo->getFunctionSymbolDataList()) {
entryTable[curEntryIndex].address = curFuncSym->getAddress(); entryTable[curEntryIndex].address = curFuncSym->getAddress();
entryTable[curEntryIndex].name = &stringTable[curStringOffset]; entryTable[curEntryIndex].name = &stringTable[curStringOffset];
entryTable[curEntryIndex].size = curFuncSym->getSize(); entryTable[curEntryIndex].size = curFuncSym->getSize();
@ -257,7 +257,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
curPluginInformation->allocatedTextMemoryAddress = plugin_data->info.allocatedTextMemoryAddress; curPluginInformation->allocatedTextMemoryAddress = plugin_data->info.allocatedTextMemoryAddress;
curPluginInformation->allocatedDataMemoryAddress = plugin_data->info.allocatedDataMemoryAddress; 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; plugin_section_info_t *sectionInfo = &curItem;
if (sectionInfo->addr == 0 && sectionInfo->size == 0) { if (sectionInfo->addr == 0 && sectionInfo->size == 0) {
continue; continue;
@ -281,7 +281,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
} }
bool storageHasId = true; bool storageHasId = true;
for (auto const &value: curPluginInformation->getHookDataList()) { for (auto const &value : curPluginInformation->getHookDataList()) {
if (value->getType() == WUPS_LOADER_HOOK_INIT_STORAGE && if (value->getType() == WUPS_LOADER_HOOK_INIT_STORAGE &&
metaInformation->getStorageId().empty()) { metaInformation->getStorageId().empty()) {
storageHasId = false; storageHasId = false;
@ -309,7 +309,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
} }
/* load relocation data */ /* 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) { if (linking_entry.destination == nullptr) {
break; break;
} }

View File

@ -1,8 +1,8 @@
#include "PluginData.h" #include "PluginData.h"
#include <utility>
#include <malloc.h>
#include "../utils/logger.h" #include "../utils/logger.h"
#include <malloc.h>
#include <utility>
PluginData::PluginData(const PluginData &obj) { PluginData::PluginData(const PluginData &obj) {
this->buffer = obj.buffer; 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> &buffer) : PluginData(buffer, nullptr, eMemTypeMEM2) {
} }
PluginData::PluginData(const std::vector<uint8_t> &input, MEMHeapHandle heapHandle, eMemoryTypes memoryType) : PluginData::PluginData(const std::vector<uint8_t> &input, MEMHeapHandle heapHandle, eMemoryTypes memoryType) : heapHandle(heapHandle),
heapHandle(heapHandle),
memoryType(memoryType), memoryType(memoryType),
length(input.size()) { length(input.size()) {
void *data_copy = nullptr; void *data_copy = nullptr;

View File

@ -17,10 +17,10 @@
#pragma once #pragma once
#include <coreinit/memexpheap.h>
#include <malloc.h>
#include <optional> #include <optional>
#include <vector> #include <vector>
#include <malloc.h>
#include <coreinit/memexpheap.h>
#include "../elfio/elfio.hpp" #include "../elfio/elfio.hpp"

View File

@ -14,13 +14,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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 "PluginDataFactory.h"
#include "../utils/logger.h"
#include "../utils/StringTools.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) { 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) { 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); std::string full_file_path = StringTools::strfmt("%s/%s", path.c_str(), dp->d_name);
StringTools::RemoveDoubleSlashs(full_file_path); StringTools::RemoveDoubleSlashs(full_file_path);
if (stat(full_file_path.c_str(), &stbuf) == -1) { if (stat(full_file_path.c_str(), &stbuf) == -1) {

View File

@ -17,11 +17,12 @@
#pragma once #pragma once
#include "PluginData.h"
#include <coreinit/memexpheap.h>
#include <memory>
#include <optional> #include <optional>
#include <string> #include <string>
#include <vector> #include <vector>
#include <coreinit/memexpheap.h>
#include "PluginData.h"
class PluginDataFactory { class PluginDataFactory {
public: public:

View File

@ -1,6 +1,6 @@
#include <memory>
#include "../common/plugin_defines.h"
#include "PluginDataPersistence.h" #include "PluginDataPersistence.h"
#include "../common/plugin_defines.h"
#include <memory>
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, const std::shared_ptr<PluginData> &plugin) { bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, const std::shared_ptr<PluginData> &plugin) {
if (pluginDataStruct == nullptr) { if (pluginDataStruct == nullptr) {

View File

@ -1,6 +1,8 @@
#pragma once #pragma once
#include "../common/plugin_defines.h"
#include "PluginData.h" #include "PluginData.h"
#include <memory>
class PluginDataPersistence { class PluginDataPersistence {

View File

@ -1,16 +1,16 @@
#include "PluginInformation.h" #include "PluginInformation.h"
PluginInformation::PluginInformation(const PluginInformation &other) { 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); 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); 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); 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); symbol_data_list.insert(i);
} }
section_info_list = other.section_info_list; section_info_list = other.section_info_list;

View File

@ -17,18 +17,18 @@
#pragma once #pragma once
#include <map> #include "FunctionData.h"
#include <set> #include "FunctionSymbolData.h"
#include <optional> #include "HookData.h"
#include <string>
#include <vector>
#include <memory>
#include "PluginMetaInformation.h" #include "PluginMetaInformation.h"
#include "RelocationData.h" #include "RelocationData.h"
#include "HookData.h"
#include "FunctionData.h"
#include "SectionInfo.h" #include "SectionInfo.h"
#include "FunctionSymbolData.h" #include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
struct FunctionSymbolDataComparator { struct FunctionSymbolDataComparator {
bool operator()(const std::shared_ptr<FunctionSymbolData> &lhs, bool operator()(const std::shared_ptr<FunctionSymbolData> &lhs,

View File

@ -15,17 +15,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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 <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include <map>
#include <coreinit/cache.h>
#include <coreinit/memexpheap.h>
#include <wups.h> #include <wups.h>
#include "PluginData.h"
#include "PluginInformationFactory.h"
#include "../utils/utils.h"
#include "../utils/ElfUtils.h"
using namespace ELFIO; using namespace ELFIO;
@ -157,7 +157,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
} }
auto relocationData = getImportRelocationData(reader, destinations); auto relocationData = getImportRelocationData(reader, destinations);
for (auto const &reloc: relocationData) { for (auto const &reloc : relocationData) {
pluginInfo->addRelocationData(reloc); pluginInfo->addRelocationData(reloc);
} }
@ -177,7 +177,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
if (entries != nullptr) { if (entries != nullptr) {
for (size_t j = 0; j < entries_count; j++) { for (size_t j = 0; j < entries_count; j++) {
wups_loader_hook_t *hook = &entries[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); auto hook_data = std::make_shared<HookData>((void *) hook->target, hook->type);
pluginInfo->addHookData(hook_data); 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++) { for (size_t j = 0; j < entries_count; j++) {
wups_loader_entry_t *cur_function = &entries[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", 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, cur_function->_function.physical_address, cur_function->_function.virtual_address, cur_function->_function.library, cur_function->_function.target,
(void *) cur_function->_function.call_addr); (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, auto function_data = std::make_shared<FunctionData>((void *) cur_function->_function.physical_address, (void *) cur_function->_function.virtual_address, cur_function->_function.name,

View File

@ -17,15 +17,15 @@
#pragma once #pragma once
#include "../elfio/elfio.hpp"
#include "PluginContainer.h"
#include "PluginInformation.h"
#include <coreinit/memheap.h>
#include <map>
#include <optional> #include <optional>
#include <string> #include <string>
#include <vector> #include <vector>
#include <map>
#include <coreinit/memheap.h>
#include <wums/defines/relocation_defines.h> #include <wums/defines/relocation_defines.h>
#include "PluginInformation.h"
#include "PluginContainer.h"
#include "../elfio/elfio.hpp"
class PluginInformationFactory { class PluginInformationFactory {
public: public:

View File

@ -15,12 +15,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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 "PluginMetaInformationFactory.h"
#include "../utils/StringTools.h"
#include <dirent.h>
#include <memory>
#include <sys/types.h>
#include <whb/file.h>
using namespace ELFIO; using namespace ELFIO;

View File

@ -17,12 +17,12 @@
#pragma once #pragma once
#include "PluginData.h"
#include "PluginMetaInformation.h"
#include <memory>
#include <optional> #include <optional>
#include <string> #include <string>
#include <memory>
#include <vector> #include <vector>
#include "PluginMetaInformation.h"
#include "PluginData.h"
class PluginMetaInformationFactory { class PluginMetaInformationFactory {
public: public:

View File

@ -17,15 +17,15 @@
#pragma once #pragma once
#include "ImportRPLInformation.h"
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
#include "ImportRPLInformation.h"
class RelocationData { class RelocationData {
public: public:
RelocationData(const char type, size_t offset, int32_t addend, void *destination, std::string &name, std::shared_ptr<ImportRPLInformation> rplInfo) : RelocationData(const char type, size_t offset, int32_t addend, void *destination, std::string &name, std::shared_ptr<ImportRPLInformation> rplInfo) : type(type),
type(type),
offset(offset), offset(offset),
addend(addend), addend(addend),
destination(destination), destination(destination),

View File

@ -22,8 +22,7 @@
class SectionInfo { class SectionInfo {
public: public:
SectionInfo(std::string &name, uint32_t address, uint32_t sectionSize) : SectionInfo(std::string &name, uint32_t address, uint32_t sectionSize) : name(name),
name(name),
address(address), address(address),
sectionSize(sectionSize) { sectionSize(sectionSize) {
} }

View File

@ -1,17 +1,17 @@
#include "ConfigUtils.h" #include "ConfigUtils.h"
#include "logger.h"
#include "../config/WUPSConfig.h" #include "../config/WUPSConfig.h"
#include "../globals.h" #include "../globals.h"
#include "DrawUtils.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 <string>
#include <vector> #include <vector>
#include <coreinit/screen.h>
#include <memory/mappedmemory.h>
#include <vpad/input.h> #include <vpad/input.h>
#include <padscore/kpad.h>
#include <gx2/display.h>
#define COLOR_BACKGROUND Color(238, 238, 238, 255) #define COLOR_BACKGROUND Color(238, 238, 238, 255)
#define COLOR_TEXT Color(51, 51, 51, 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++) { for (uint32_t j = 0; j < plugin_data->info.number_used_hooks; j++) {
replacement_data_hook_t *hook_data = &plugin_data->info.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) { if (hook_data->func_pointer == nullptr) {
break; 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) { if (cur_config == nullptr) {
break; break;
} }
@ -543,9 +543,9 @@ void ConfigUtils::displayMenu() {
} }
} }
for (const auto &element: configs) { for (const auto &element : configs) {
for (const auto &cat: element.config->getCategories()) { for (const auto &cat : element.config->getCategories()) {
for (const auto &item: cat->getItems()) { for (const auto &item : cat->getItems()) {
if (item->isDirty()) { if (item->isDirty()) {
item->callCallback(); item->callCallback();
} }
@ -565,13 +565,13 @@ void ConfigUtils::displayMenu() {
if (hook_data->func_pointer == nullptr) { if (hook_data->func_pointer == nullptr) {
break; break;
} }
((void (*)()) ((uint32_t *) hook_data->func_pointer))(); ((void (*)())((uint32_t *) hook_data->func_pointer))();
break; break;
} }
} }
} }
for (const auto &element: configs) { for (const auto &element : configs) {
DEBUG_FUNCTION_LINE("Delete %08X", element.config); DEBUG_FUNCTION_LINE("Delete %08X", element.config);
delete element.config; delete element.config;
} }
@ -637,7 +637,7 @@ void ConfigUtils::openConfigMenu() {
DrawUtils::deinitFont(); DrawUtils::deinitFont();
error_exit: error_exit:
if (storedTVBuffer.buffer != nullptr) { if (storedTVBuffer.buffer != nullptr) {
GX2SetTVBuffer(storedTVBuffer.buffer, storedTVBuffer.buffer_size, static_cast<GX2TVRenderMode>(storedTVBuffer.mode), GX2SetTVBuffer(storedTVBuffer.buffer, storedTVBuffer.buffer_size, static_cast<GX2TVRenderMode>(storedTVBuffer.mode),

View File

@ -2,8 +2,8 @@
#include <coreinit/memory.h> #include <coreinit/memory.h>
#include <coreinit/screen.h> #include <coreinit/screen.h>
#include <png.h>
#include <ft2build.h> #include <ft2build.h>
#include <png.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
// buffer width // buffer width
@ -243,7 +243,8 @@ void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRigh
buffer[num] = 0; buffer[num] = 0;
} else { } else {
wchar_t *tmp = buffer; wchar_t *tmp = buffer;
while ((*tmp++ = *string++)); while ((*tmp++ = *string++))
;
} }
print(x, y, buffer, alignRight); print(x, y, buffer, alignRight);
@ -283,7 +284,8 @@ uint32_t DrawUtils::getTextWidth(const char *string) {
buffer[num] = 0; buffer[num] = 0;
} else { } else {
wchar_t *tmp = buffer; wchar_t *tmp = buffer;
while ((*tmp++ = *string++)); while ((*tmp++ = *string++))
;
} }
uint32_t width = getTextWidth(buffer); uint32_t width = getTextWidth(buffer);

View File

@ -1,8 +1,8 @@
#include <cstring>
#include <coreinit/cache.h> #include <coreinit/cache.h>
#include <cstring>
#include "utils/logger.h"
#include "ElfUtils.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 // 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, 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) { if (freeSlot == nullptr) {
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampoline data list is full"); 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; 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("**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; 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 // Relocations for the imports may be overridden
freeSlot->status = RELOC_TRAMP_IMPORT_DONE; freeSlot->status = RELOC_TRAMP_IMPORT_DONE;
} }
auto symbolValue = (uint32_t) &(freeSlot->trampoline[0]); auto symbolValue = (uint32_t) & (freeSlot->trampoline[0]);
value = symbolValue + addend; value = symbolValue + addend;
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target); distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
} }

View File

@ -1,10 +1,10 @@
#include "StorageUtils.h" #include "StorageUtils.h"
#include <string> #include <string>
#include "utils/logger.h"
#include "utils/json.hpp"
#include "fs/CFile.hpp" #include "fs/CFile.hpp"
#include "fs/FSUtils.h" #include "fs/FSUtils.h"
#include "utils/json.hpp"
#include "utils/logger.h"
static void processJson(wups_storage_item_t *items, nlohmann::json json) { static void processJson(wups_storage_item_t *items, nlohmann::json json) {
if (items == nullptr) { if (items == nullptr) {

View File

@ -23,14 +23,14 @@
* *
* for WiiXplorer 2010 * for WiiXplorer 2010
***************************************************************************/ ***************************************************************************/
#include <vector>
#include <string>
#include <cstdarg> #include <cstdarg>
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <string.h> #include <string.h>
#include <wut_types.h> #include <string>
#include <cstdio>
#include <utils/StringTools.h> #include <utils/StringTools.h>
#include <vector>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) { BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {

View File

@ -26,8 +26,8 @@
#ifndef __STRING_TOOLS_H #ifndef __STRING_TOOLS_H
#define __STRING_TOOLS_H #define __STRING_TOOLS_H
#include <vector>
#include <string> #include <string>
#include <vector>
#include <wut_types.h> #include <wut_types.h>
class StringTools { class StringTools {
@ -86,4 +86,3 @@ public:
}; };
#endif /* __STRING_TOOLS_H */ #endif /* __STRING_TOOLS_H */

View File

@ -1,15 +1,15 @@
#include <coreinit/cache.h> #include "exports.h"
#include "../plugin/PluginMetaInformationFactory.h" #include "../PluginManagement.h"
#include "../globals.h"
#include "../plugin/PluginContainer.h" #include "../plugin/PluginContainer.h"
#include "../plugin/PluginContainerPersistence.h" #include "../plugin/PluginContainerPersistence.h"
#include "../plugin/PluginDataFactory.h" #include "../plugin/PluginDataFactory.h"
#include "../PluginManagement.h"
#include "../globals.h"
#include "../plugin/PluginDataPersistence.h" #include "../plugin/PluginDataPersistence.h"
#include "exports.h" #include "../plugin/PluginMetaInformationFactory.h"
#include <coreinit/cache.h>
#include <wums.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; out->plugin_information_version = PLUGIN_INFORMATION_VERSION;
strncpy(out->author, metaInformation->getAuthor().c_str(), sizeof(out->author) - 1); strncpy(out->author, metaInformation->getAuthor().c_str(), sizeof(out->author) - 1);
strncpy(out->buildTimestamp, metaInformation->getBuildTimestamp().c_str(), sizeof(out->buildTimestamp) - 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; *plugin_information_version = PLUGIN_INFORMATION_VERSION;
auto plugins = PluginContainerPersistence::loadPlugins(gPluginInformation); auto plugins = PluginContainerPersistence::loadPlugins(gPluginInformation);
uint32_t counter = 0; uint32_t counter = 0;
for (auto &plugin: plugins) { for (auto &plugin : plugins) {
if (counter < buffer_size) { if (counter < buffer_size) {
auto *container = new PluginContainer(*plugin); auto *container = new PluginContainer(*plugin);
io_handles[counter] = (uint32_t) container; io_handles[counter] = (uint32_t) container;

View File

@ -7,8 +7,6 @@
extern "C" { extern "C" {
#endif #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 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); PluginBackendApiErrorType WUPSDeletePluginContainer(const plugin_container_handle *handle_list, uint32_t handle_list_size);

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
__ _____ _____ _____ __ _____ _____ _____
__| | __| | | | JSON for Modern C++ __| | __| | | | JSON for Modern C++

View File

@ -1,8 +1,8 @@
#ifdef DEBUG #ifdef DEBUG
#include <stdint.h> #include <stdint.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h> #include <whb/log_cafe.h>
#include <whb/log_module.h> #include <whb/log_module.h>
#include <whb/log_udp.h>
uint32_t moduleLogInit = false; uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false; uint32_t cafeLogInit = false;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <whb/log.h>
#include <string.h> #include <string.h>
#include <whb/log.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -14,12 +14,14 @@ extern "C" {
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0) } while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0) } while (0)
#else #else
@ -39,4 +41,3 @@ void deinitLogging();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,11 +1,11 @@
#include <string.h> #include "utils/logger.h"
#include <stdlib.h> #include <malloc.h>
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <malloc.h> #include <stdlib.h>
#include <string.h>
#include <whb/log.h> #include <whb/log.h>
#include "utils/logger.h"
// https://gist.github.com/ccbrown/9722406 // https://gist.github.com/ccbrown/9722406
void dumpHex(const void *data, size_t size) { void dumpHex(const void *data, size_t size) {

View File

@ -9,26 +9,27 @@ extern "C" {
#define LIMIT(x, min, max) \ #define LIMIT(x, min, max) \
({ \ ({ \
typeof( x ) _x = x; \ typeof(x) _x = x; \
typeof( min ) _min = min; \ typeof(min) _min = min; \
typeof( max ) _max = max; \ typeof(max) _max = max; \
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \ (((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
}) : (_x)); \
})
#define DegToRad(a) ( (a) * 0.01745329252f ) #define DegToRad(a) ((a) *0.01745329252f)
#define RadToDeg(a) ( (a) * 57.29577951f ) #define RadToDeg(a) ((a) *57.29577951f)
#define ALIGN4(x) (((x) + 3) & ~3) #define ALIGN4(x) (((x) + 3) & ~3)
#define ALIGN32(x) (((x) + 31) & ~31) #define ALIGN32(x) (((x) + 31) & ~31)
// those work only in powers of 2 // those work only in powers of 2
#define ROUNDDOWN(val, align) ((val) & ~(align-1)) #define ROUNDDOWN(val, align) ((val) & ~(align - 1))
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align) #define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8))) #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 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 le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
//Needs to have log_init() called beforehand. //Needs to have log_init() called beforehand.
void dumpHex(const void *data, size_t size); void dumpHex(const void *data, size_t size);