mirror of
https://github.com/wiiu-env/CustomRPXLoader.git
synced 2024-11-22 01:49:16 +01:00
Format the code via clang-format (#1)
This commit is contained in:
parent
4e29e33931
commit
e5ead1af44
66
.clang-format
Normal file
66
.clang-format
Normal file
@ -0,0 +1,66 @@
|
||||
# Generated from CLion C/C++ Code Style settings
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
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: 0
|
||||
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 ./src
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
|
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 ./src
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
|
@ -1,3 +1,4 @@
|
||||
[![CI-Release](https://github.com/wiiu-env/CustomRPXLoader/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/CustomRPXLoader/actions/workflows/ci.yml)
|
||||
# CustomRPXLoader
|
||||
This custom loader for `.rpx` files which can be used with any `payload.elf` loader. (For example [PayloadFromRPX](https://github.com/wiiu-env/PayloadFromRPX) or [JsTypeHax](https://github.com/wiiu-env/JsTypeHax))
|
||||
|
||||
@ -23,6 +24,10 @@ docker run -it --rm -v ${PWD}:/project customrpxloader-builder make
|
||||
docker run -it --rm -v ${PWD}:/project customrpxloader-builder make clean
|
||||
```
|
||||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`
|
||||
|
||||
## Credits
|
||||
- Maschell
|
||||
- orboditilt
|
||||
|
@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include <cstring>
|
||||
#include <coreinit/cache.h>
|
||||
#include <whb/log.h>
|
||||
#include "utils/logger.h"
|
||||
#include "ElfUtils.h"
|
||||
#include "utils/logger.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <cstring>
|
||||
#include <whb/log.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_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||
@ -113,19 +113,19 @@ 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. Trampolin data list is full");
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, target - (uint32_t) &(freeSlot->trampolin[0]));
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, target - (uint32_t) & (freeSlot->trampolin[0]));
|
||||
return false;
|
||||
}
|
||||
if (target - (uint32_t) &(freeSlot->trampolin[0]) > 0x1FFFFFC) {
|
||||
if (target - (uint32_t) & (freeSlot->trampolin[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->trampolin[0])));
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, (target - (uint32_t) & (freeSlot->trampolin[0])));
|
||||
return false;
|
||||
}
|
||||
|
||||
freeSlot->trampolin[0] = 0x3D600000 | ((((uint32_t) value) >> 16) & 0x0000FFFF); // lis r11, real_addr@h
|
||||
freeSlot->trampolin[1] = 0x616B0000 | (((uint32_t) value) & 0x0000ffff); // ori r11, r11, real_addr@l
|
||||
freeSlot->trampolin[2] = 0x7D6903A6; // mtctr r11
|
||||
freeSlot->trampolin[3] = 0x4E800420; // bctr
|
||||
freeSlot->trampolin[0] = 0x3D600000 | ((((uint32_t) value) >> 16) & 0x0000FFFF);// lis r11, real_addr@h
|
||||
freeSlot->trampolin[1] = 0x616B0000 | (((uint32_t) value) & 0x0000ffff); // ori r11, r11, real_addr@l
|
||||
freeSlot->trampolin[2] = 0x7D6903A6; // mtctr r11
|
||||
freeSlot->trampolin[3] = 0x4E800420; // bctr
|
||||
DCFlushRange((void *) freeSlot->trampolin, sizeof(freeSlot->trampolin));
|
||||
ICInvalidateRange((unsigned char *) freeSlot->trampolin, sizeof(freeSlot->trampolin));
|
||||
|
||||
@ -135,7 +135,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->trampolin[0]);
|
||||
auto symbolValue = (uint32_t) & (freeSlot->trampolin[0]);
|
||||
value = symbolValue + addend;
|
||||
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||
}
|
||||
|
@ -17,13 +17,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "common/relocation_defines.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#define R_PPC_NONE 0
|
||||
#define R_PPC_ADDR32 1
|
||||
#define R_PPC_ADDR16_LO 4
|
||||
@ -51,6 +53,7 @@ extern "C" {
|
||||
#define PPC_LOW24 0x03FFFFFC
|
||||
#define PPC_LOW14 0x0020FFFC
|
||||
#define PPC_HALF16 0xFFFF
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -17,13 +17,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#define DYN_LINK_FUNCTION_NAME_LENGTH 351
|
||||
#define DYN_LINK_IMPORT_NAME_LENGTH 50
|
||||
|
||||
@ -31,6 +32,7 @@ extern "C" {
|
||||
#define DYN_LINK_IMPORT_LIST_LENGTH 50
|
||||
|
||||
#define DYN_LINK_TRAMPOLIN_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH
|
||||
// clang-format on
|
||||
|
||||
typedef struct _dyn_linking_function_t {
|
||||
char functionName[DYN_LINK_FUNCTION_NAME_LENGTH + 1];
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "dynamic_linking_defines.h"
|
||||
#include "relocation_defines.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -19,17 +19,19 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
typedef enum RelocationTrampolinStatus{
|
||||
// clang-format off
|
||||
typedef enum RelocationTrampolinStatus {
|
||||
RELOC_TRAMP_FREE = 0,
|
||||
RELOC_TRAMP_FIXED = 1,
|
||||
RELOC_TRAMP_IMPORT_IN_PROGRESS = 2,
|
||||
RELOC_TRAMP_IMPORT_DONE = 3,
|
||||
} RelocationTrampolinStatus;
|
||||
|
||||
typedef enum RelocationType{
|
||||
typedef enum RelocationType {
|
||||
RELOC_TYPE_FIXED = 0,
|
||||
RELOC_TYPE_IMPORT = 1
|
||||
} RelocationType;
|
||||
// clang-format on
|
||||
|
||||
typedef struct relocation_trampolin_entry_t {
|
||||
uint32_t trampolin[4];
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/dynload.h>
|
||||
|
||||
#define IMPORT(name) void* addr_##name
|
||||
#define IMPORT(name) void *addr_##name
|
||||
#define IMPORT_BEGIN(lib)
|
||||
#define IMPORT_END()
|
||||
|
||||
@ -11,12 +11,15 @@
|
||||
#undef IMPORT_BEGIN
|
||||
#undef IMPORT_END
|
||||
|
||||
#define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0)
|
||||
#define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle)
|
||||
#define IMPORT(name) \
|
||||
do { \
|
||||
if (OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0) OSFatal("Function " #name " is NULL"); \
|
||||
} while (0)
|
||||
#define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle)
|
||||
/* #define IMPORT_END() OSDynLoad_Release(handle) */
|
||||
#define IMPORT_END()
|
||||
|
||||
#define EXPORT_VAR(type, var) type var __attribute__((section(".data")));
|
||||
#define EXPORT_VAR(type, var) type var __attribute__((section(".data")));
|
||||
|
||||
EXPORT_VAR(uint32_t *, MEMAllocFromDefaultHeap);
|
||||
EXPORT_VAR(uint32_t *, MEMAllocFromDefaultHeapEx);
|
||||
|
@ -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
|
||||
|
||||
|
@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/memorymap.h>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/memorymap.h>
|
||||
|
||||
#include "kernel.h"
|
||||
|
||||
@ -29,7 +29,7 @@ extern "C" void KernelPatches(void);
|
||||
extern "C" void KernelPatchesFinal(void);
|
||||
extern "C" void SaveAndResetDataBATs_And_SRs_hook(void);
|
||||
|
||||
void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value);
|
||||
void __attribute__((noinline)) kern_write(void *addr, uint32_t value);
|
||||
|
||||
extern "C" void SC_0x25_KernelCopyData(unsigned int addr, unsigned int src, unsigned int len);
|
||||
|
||||
@ -80,27 +80,25 @@ void doKernelSetup2() {
|
||||
kern_write((void *) (KERN_SYSCALL_TBL_3 + (0x25 * 4)), (unsigned int) SCKernelCopyData);
|
||||
kern_write((void *) (KERN_SYSCALL_TBL_4 + (0x25 * 4)), (unsigned int) SCKernelCopyData);
|
||||
kern_write((void *) (KERN_SYSCALL_TBL_5 + (0x25 * 4)), (unsigned int) SCKernelCopyData);
|
||||
|
||||
}
|
||||
|
||||
/* Write a 32-bit word with kernel permissions */
|
||||
void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value) {
|
||||
asm volatile (
|
||||
"li 3,1\n"
|
||||
"li 4,0\n"
|
||||
"mr 5,%1\n"
|
||||
"li 6,0\n"
|
||||
"li 7,0\n"
|
||||
"lis 8,1\n"
|
||||
"mr 9,%0\n"
|
||||
"mr %1,1\n"
|
||||
"li 0,0x3500\n"
|
||||
"sc\n"
|
||||
"nop\n"
|
||||
"mr 1,%1\n"
|
||||
:
|
||||
: "r"(addr), "r"(value)
|
||||
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
||||
"11", "12"
|
||||
);
|
||||
void __attribute__((noinline)) kern_write(void *addr, uint32_t value) {
|
||||
asm volatile(
|
||||
"li 3,1\n"
|
||||
"li 4,0\n"
|
||||
"mr 5,%1\n"
|
||||
"li 6,0\n"
|
||||
"li 7,0\n"
|
||||
"lis 8,1\n"
|
||||
"mr 9,%0\n"
|
||||
"mr %1,1\n"
|
||||
"li 0,0x3500\n"
|
||||
"sc\n"
|
||||
"nop\n"
|
||||
"mr 1,%1\n"
|
||||
:
|
||||
: "r"(addr), "r"(value)
|
||||
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
||||
"11", "12");
|
||||
}
|
||||
|
10
src/kernel.h
10
src/kernel.h
@ -17,11 +17,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define KERN_SYSCALL_TBL_1 0xFFE84C70 // unknown
|
||||
#define KERN_SYSCALL_TBL_2 0xFFE85070 // works with games
|
||||
#define KERN_SYSCALL_TBL_3 0xFFE85470 // works with loader
|
||||
#define KERN_SYSCALL_TBL_4 0xFFEAAA60 // works with home menu
|
||||
#define KERN_SYSCALL_TBL_5 0xFFEAAE60 // works with browser (previously KERN_SYSCALL_TBL)
|
||||
#define KERN_SYSCALL_TBL_1 0xFFE84C70// unknown
|
||||
#define KERN_SYSCALL_TBL_2 0xFFE85070// works with games
|
||||
#define KERN_SYSCALL_TBL_3 0xFFE85470// works with loader
|
||||
#define KERN_SYSCALL_TBL_4 0xFFEAAA60// works with home menu
|
||||
#define KERN_SYSCALL_TBL_5 0xFFEAAE60// works with browser (previously KERN_SYSCALL_TBL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
29
src/main.cpp
29
src/main.cpp
@ -15,29 +15,29 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include <cstdint>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/title.h>
|
||||
#include <sysapp/launch.h>
|
||||
#include <proc_ui/procui.h>
|
||||
#include <coreinit/foreground.h>
|
||||
#include <coreinit/screen.h>
|
||||
#include <coreinit/title.h>
|
||||
#include <cstdint>
|
||||
#include <nn/act/client_cpp.h>
|
||||
#include <proc_ui/procui.h>
|
||||
#include <sysapp/launch.h>
|
||||
|
||||
#include "ElfUtils.h"
|
||||
#include "common/module_defines.h"
|
||||
#include "module/ModuleData.h"
|
||||
#include "module/ModuleDataFactory.h"
|
||||
#include "common/module_defines.h"
|
||||
|
||||
#include <utils/StringTools.h>
|
||||
|
||||
#include "kernel.h"
|
||||
#include "dynamic.h"
|
||||
#include "kernel.h"
|
||||
#include "utils/logger.h"
|
||||
#include <malloc.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include <malloc.h>
|
||||
|
||||
bool doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length);
|
||||
|
||||
@ -67,7 +67,7 @@ bool CheckRunning() {
|
||||
extern "C" void __init_wut();
|
||||
extern "C" void __fini_wut();
|
||||
|
||||
extern "C" int _start(int argc, char **argv) __attribute__ ((section (".start_code")));
|
||||
extern "C" int _start(int argc, char **argv) __attribute__((section(".start_code")));
|
||||
extern "C" int _start(int argc, char **argv) {
|
||||
doKernelSetup();
|
||||
InitFunctionPointers();
|
||||
@ -95,7 +95,7 @@ extern "C" int _start(int argc, char **argv) {
|
||||
if (memory_end == memory_start) {
|
||||
break;
|
||||
}
|
||||
auto mem_ptr = &memory_end[1]; // &memory_end + sizeof(MEMExpHeapBlock);
|
||||
auto mem_ptr = &memory_end[1];// &memory_end + sizeof(MEMExpHeapBlock);
|
||||
free(mem_ptr);
|
||||
leak_count++;
|
||||
}
|
||||
@ -105,7 +105,9 @@ extern "C" int _start(int argc, char **argv) {
|
||||
__fini_wut();
|
||||
|
||||
if (entrypoint > 0) {
|
||||
return ((int (*)(int, char **)) entrypoint)(argc, argv);
|
||||
// clang-format off
|
||||
return ((int(*)(int, char **)) entrypoint)(argc, argv);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -121,7 +123,8 @@ uint32_t do_start(int argc, char **argv) {
|
||||
|
||||
uint32_t ApplicationMemoryEnd;
|
||||
|
||||
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
|
||||
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l"
|
||||
: "=r"(ApplicationMemoryEnd));
|
||||
|
||||
ApplicationMemoryEnd = (ApplicationMemoryEnd + 0x100) & 0xFFFFFF00;
|
||||
|
||||
@ -185,7 +188,7 @@ uint32_t do_start(int argc, char **argv) {
|
||||
}
|
||||
|
||||
bool doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length) {
|
||||
for (auto const &curReloc: relocData) {
|
||||
for (auto const &curReloc : relocData) {
|
||||
const RelocationData &cur = curReloc;
|
||||
std::string functionName = cur.getName();
|
||||
std::string rplName = cur.getImportRPLInformation().getName();
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "utils/logger.h"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
class ImportRPLInformation {
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
std::string ModuleData::toString() const {
|
||||
std::string res = StringTools::strfmt("Entrypoint %08X, bss: %08X (%d), bss: %08X (%d)\n", getEntrypoint(), getBSSAddr(), getBSSSize(), getSBSSAddr(), getSBSSSize());
|
||||
for (auto const &reloc: relocation_data_list) {
|
||||
for (auto const &reloc : relocation_data_list) {
|
||||
res += reloc.toString();
|
||||
}
|
||||
return res;
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RelocationData.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "RelocationData.h"
|
||||
|
||||
class ModuleData {
|
||||
public:
|
||||
|
@ -15,13 +15,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ModuleDataFactory.h"
|
||||
#include "../ElfUtils.h"
|
||||
#include "elfio/elfio.hpp"
|
||||
#include <coreinit/cache.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <coreinit/cache.h>
|
||||
#include "ModuleDataFactory.h"
|
||||
#include "elfio/elfio.hpp"
|
||||
#include "../ElfUtils.h"
|
||||
|
||||
using namespace ELFIO;
|
||||
|
||||
@ -136,7 +136,7 @@ ModuleDataFactory::load(const std::string &path, uint32_t destination_address, u
|
||||
}
|
||||
std::vector<RelocationData> relocationData = getImportRelocationData(reader, destinations);
|
||||
|
||||
for (auto const &reloc: relocationData) {
|
||||
for (auto const &reloc : relocationData) {
|
||||
moduleData.addRelocationData(reloc);
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ModuleData.h"
|
||||
#include "common/relocation_defines.h"
|
||||
#include "elfio/elfio.hpp"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "common/relocation_defines.h"
|
||||
#include "ModuleData.h"
|
||||
#include "elfio/elfio.hpp"
|
||||
|
||||
class ModuleDataFactory {
|
||||
public:
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "ImportRPLInformation.h"
|
||||
#include <string>
|
||||
|
||||
class RelocationData {
|
||||
|
||||
|
@ -23,17 +23,16 @@
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <strings.h>
|
||||
#include <wut_types.h>
|
||||
#include <stdio.h>
|
||||
#include <utils/StringTools.h>
|
||||
#include <vector>
|
||||
#include <wchar.h>
|
||||
#include <wut_types.h>
|
||||
|
||||
|
||||
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
|
||||
@ -259,7 +258,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
||||
char *tmp; // varies
|
||||
int len_rep; // length of rep (the string to remove)
|
||||
int len_with; // length of with (the string to replace rep with)
|
||||
int len_front; // distance between rep and end of last rep
|
||||
int len_front;// distance between rep and end of last rep
|
||||
int count; // number of replacements
|
||||
|
||||
// sanity checks and initialization
|
||||
@ -269,7 +268,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
||||
len_rep = strlen(rep);
|
||||
if (len_rep == 0) {
|
||||
return NULL;
|
||||
} // empty rep causes infinite loop during count
|
||||
}// empty rep causes infinite loop during count
|
||||
if (!with) {
|
||||
with = (char *) "";
|
||||
}
|
||||
@ -297,7 +296,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
||||
len_front = ins - orig;
|
||||
tmp = strncpy(tmp, orig, len_front) + len_front;
|
||||
tmp = strcpy(tmp, with) + len_with;
|
||||
orig += len_front + len_rep; // move to next "end of rep"
|
||||
orig += len_front + len_rep;// move to next "end of rep"
|
||||
}
|
||||
strcpy(tmp, orig);
|
||||
return result;
|
||||
|
@ -25,8 +25,8 @@
|
||||
***************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wut_types.h>
|
||||
|
||||
class StringTools {
|
||||
|
@ -1,13 +1,13 @@
|
||||
#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;
|
||||
uint32_t udpLogInit = false;
|
||||
#endif // DEBUG
|
||||
#endif// DEBUG
|
||||
|
||||
void initLogging() {
|
||||
#ifdef DEBUG
|
||||
@ -15,7 +15,7 @@ void initLogging() {
|
||||
cafeLogInit = WHBLogCafeInit();
|
||||
udpLogInit = WHBLogUdpInit();
|
||||
}
|
||||
#endif // DEBUG
|
||||
#endif// DEBUG
|
||||
}
|
||||
|
||||
void deinitLogging() {
|
||||
@ -32,5 +32,5 @@ void deinitLogging() {
|
||||
WHBLogUdpDeinit();
|
||||
udpLogInit = false;
|
||||
}
|
||||
#endif // DEBUG
|
||||
#endif// DEBUG
|
||||
}
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user