mirror of
https://github.com/wiiu-env/CustomRPXLoader.git
synced 2024-11-13 22:15:06 +01:00
Update .clang-format to update the comment, macro and assignment formatting
This commit is contained in:
parent
e5ead1af44
commit
9e96647469
@ -2,7 +2,8 @@
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
@ -56,7 +57,7 @@ SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 0
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
|
@ -28,7 +28,7 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
return true;
|
||||
}
|
||||
auto target = destination + offset;
|
||||
auto value = symbol_addr + addend;
|
||||
auto value = symbol_addr + addend;
|
||||
|
||||
|
||||
auto relValue = value - static_cast<uint32_t>(target);
|
||||
@ -122,10 +122,10 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
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));
|
||||
|
||||
@ -136,8 +136,8 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
freeSlot->status = RELOC_TRAMP_IMPORT_DONE;
|
||||
}
|
||||
auto symbolValue = (uint32_t) & (freeSlot->trampolin[0]);
|
||||
value = symbolValue + addend;
|
||||
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||
value = symbolValue + addend;
|
||||
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,15 +24,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#define DYN_LINK_FUNCTION_NAME_LENGTH 351
|
||||
#define DYN_LINK_IMPORT_NAME_LENGTH 50
|
||||
#define DYN_LINK_FUNCTION_NAME_LENGTH 351
|
||||
#define DYN_LINK_IMPORT_NAME_LENGTH 50
|
||||
|
||||
#define DYN_LINK_FUNCTION_LIST_LENGTH 500
|
||||
#define DYN_LINK_IMPORT_LIST_LENGTH 50
|
||||
#define DYN_LINK_FUNCTION_LIST_LENGTH 500
|
||||
#define DYN_LINK_IMPORT_LIST_LENGTH 50
|
||||
|
||||
#define DYN_LINK_TRAMPOLIN_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH
|
||||
// clang-format on
|
||||
#define DYN_LINK_TRAMPOLIN_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH
|
||||
|
||||
typedef struct _dyn_linking_function_t {
|
||||
char functionName[DYN_LINK_FUNCTION_NAME_LENGTH + 1];
|
||||
@ -46,8 +44,8 @@ typedef struct _dyn_linking_import_t {
|
||||
|
||||
typedef struct _dyn_linking_relocation_entry_t {
|
||||
dyn_linking_function_t *functionEntry = nullptr;
|
||||
dyn_linking_import_t *importEntry = nullptr;
|
||||
void *destination = NULL;
|
||||
dyn_linking_import_t *importEntry = nullptr;
|
||||
void *destination = nullptr;
|
||||
char type{};
|
||||
size_t offset{};
|
||||
int32_t addend{};
|
||||
|
@ -19,19 +19,17 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// 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,
|
||||
RELOC_TRAMP_FREE = 0,
|
||||
RELOC_TRAMP_FIXED = 1,
|
||||
RELOC_TRAMP_IMPORT_IN_PROGRESS = 2,
|
||||
RELOC_TRAMP_IMPORT_DONE = 3,
|
||||
} RelocationTrampolinStatus;
|
||||
|
||||
typedef enum RelocationType {
|
||||
RELOC_TYPE_FIXED = 0,
|
||||
RELOC_TYPE_IMPORT = 1
|
||||
RELOC_TYPE_FIXED = 0,
|
||||
RELOC_TYPE_IMPORT = 1
|
||||
} RelocationType;
|
||||
// clang-format on
|
||||
|
||||
typedef struct relocation_trampolin_entry_t {
|
||||
uint32_t trampolin[4];
|
||||
|
@ -27,7 +27,7 @@ EXPORT_VAR(uint32_t *, MEMFreeToDefaultHeap);
|
||||
|
||||
void InitFunctionPointers(void) {
|
||||
OSDynLoad_Module handle;
|
||||
addr_OSDynLoad_Acquire = (void *) 0x0102A3B4;
|
||||
addr_OSDynLoad_Acquire = (void *) 0x0102A3B4;
|
||||
addr_OSDynLoad_FindExport = (void *) 0x0102B828;
|
||||
|
||||
OSDynLoad_Acquire("coreinit.rpl", &handle);
|
||||
|
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" {
|
||||
|
22
src/main.cpp
22
src/main.cpp
@ -77,8 +77,8 @@ extern "C" int _start(int argc, char **argv) {
|
||||
|
||||
// Save last entry on mem2 heap to detect leaked memory
|
||||
MEMHeapHandle mem2_heap_handle = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2);
|
||||
auto heap = (MEMExpHeap *) mem2_heap_handle;
|
||||
MEMExpHeapBlock *memory_start = heap->usedList.tail;
|
||||
auto heap = (MEMExpHeap *) mem2_heap_handle;
|
||||
MEMExpHeapBlock *memory_start = heap->usedList.tail;
|
||||
|
||||
initLogging();
|
||||
DEBUG_FUNCTION_LINE("Hello from CustomRPXloader");
|
||||
@ -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++;
|
||||
}
|
||||
@ -119,7 +119,7 @@ uint32_t do_start(int argc, char **argv) {
|
||||
bool doProcUI = (argc >= 1 && std::string(argv[0]) != "safe.rpx");
|
||||
|
||||
auto *cfwLaunchedWithPtr = (uint64_t *) 0x00FFFFF8;
|
||||
*cfwLaunchedWithPtr = OSGetTitleID();
|
||||
*cfwLaunchedWithPtr = OSGetTitleID();
|
||||
|
||||
uint32_t ApplicationMemoryEnd;
|
||||
|
||||
@ -131,7 +131,7 @@ uint32_t do_start(int argc, char **argv) {
|
||||
auto *gModuleData = (module_information_t *) ApplicationMemoryEnd;
|
||||
|
||||
uint32_t moduleDataStartAddress = ((uint32_t) gModuleData + sizeof(module_information_t));
|
||||
moduleDataStartAddress = (moduleDataStartAddress + 0x10000) & 0xFFFF0000;
|
||||
moduleDataStartAddress = (moduleDataStartAddress + 0x10000) & 0xFFFF0000;
|
||||
|
||||
std::string filepath("fs:/vol/external01/wiiu/payload.rpx");
|
||||
int result = 0;
|
||||
@ -164,7 +164,7 @@ uint32_t do_start(int argc, char **argv) {
|
||||
|
||||
if (doProcUI) {
|
||||
nn::act::Initialize();
|
||||
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
||||
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
||||
nn::act::SlotNo defaultSlot = nn::act::GetDefaultAccount();
|
||||
nn::act::Finalize();
|
||||
|
||||
@ -189,10 +189,10 @@ 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) {
|
||||
const RelocationData &cur = curReloc;
|
||||
std::string functionName = cur.getName();
|
||||
std::string rplName = cur.getImportRPLInformation().getName();
|
||||
int32_t isData = cur.getImportRPLInformation().isData();
|
||||
const RelocationData &cur = curReloc;
|
||||
std::string functionName = cur.getName();
|
||||
std::string rplName = cur.getImportRPLInformation().getName();
|
||||
int32_t isData = cur.getImportRPLInformation().isData();
|
||||
OSDynLoad_Module rplHandle = nullptr;
|
||||
OSDynLoad_Acquire(rplName.c_str(), &rplHandle);
|
||||
|
||||
@ -217,7 +217,7 @@ void SplashScreen(const char *message, int32_t durationInMs) {
|
||||
OSScreenInit();
|
||||
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||
auto *screenBuffer = (uint8_t *) memalign(0x100, screen_buf0_size + screen_buf1_size);
|
||||
auto *screenBuffer = (uint8_t *) memalign(0x100, screen_buf0_size + screen_buf1_size);
|
||||
OSScreenSetBufferEx(SCREEN_TV, (void *) screenBuffer);
|
||||
OSScreenSetBufferEx(SCREEN_DRC, (void *) (screenBuffer + screen_buf0_size));
|
||||
|
||||
|
@ -25,7 +25,7 @@ class ImportRPLInformation {
|
||||
|
||||
public:
|
||||
explicit ImportRPLInformation(std::string name, bool isData = false) {
|
||||
this->name = name;
|
||||
this->name = name;
|
||||
this->_isData = isData;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
rplName = rawSectionName.substr(fimport.size());
|
||||
} else if (std::equal(dimport.begin(), dimport.end(), rawSectionName.begin())) {
|
||||
rplName = rawSectionName.substr(dimport.size());
|
||||
data = true;
|
||||
data = true;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("invalid section name\n");
|
||||
return {};
|
||||
|
@ -74,9 +74,9 @@ public:
|
||||
private:
|
||||
std::vector<RelocationData> relocation_data_list;
|
||||
|
||||
uint32_t bssAddr = 0;
|
||||
uint32_t bssSize = 0;
|
||||
uint32_t sbssAddr = 0;
|
||||
uint32_t sbssSize = 0;
|
||||
uint32_t bssAddr = 0;
|
||||
uint32_t bssSize = 0;
|
||||
uint32_t sbssAddr = 0;
|
||||
uint32_t sbssSize = 0;
|
||||
uint32_t entrypoint = 0;
|
||||
};
|
@ -74,7 +74,7 @@ ModuleDataFactory::load(const std::string &path, uint32_t destination_address, u
|
||||
|
||||
if ((psec->get_type() == SHT_PROGBITS || psec->get_type() == SHT_NOBITS) && (psec->get_flags() & SHF_ALLOC)) {
|
||||
uint32_t sectionSize = psec->get_size();
|
||||
auto address = (uint32_t) psec->get_address();
|
||||
auto address = (uint32_t) psec->get_address();
|
||||
|
||||
destinations[psec->get_index()] = (uint8_t *) baseOffset;
|
||||
|
||||
|
@ -24,11 +24,11 @@ class RelocationData {
|
||||
|
||||
public:
|
||||
RelocationData(char type, size_t offset, int32_t addend, void *destination, const std::string &name, const ImportRPLInformation &rplInfo) : rplInfo(rplInfo) {
|
||||
this->type = type;
|
||||
this->offset = offset;
|
||||
this->addend = addend;
|
||||
this->type = type;
|
||||
this->offset = offset;
|
||||
this->addend = addend;
|
||||
this->destination = destination;
|
||||
this->name = name;
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
~RelocationData() = default;
|
||||
|
@ -86,7 +86,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
|
||||
static char tmp[512];
|
||||
static wchar_t strWChar[512];
|
||||
strWChar[0] = 0;
|
||||
tmp[0] = 0;
|
||||
tmp[0] = 0;
|
||||
|
||||
if (!format) {
|
||||
return (const wchar_t *) strWChar;
|
||||
@ -101,7 +101,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
|
||||
if ((vsprintf(tmp, format, va) >= 0)) {
|
||||
int bt;
|
||||
int32_t strlength = strlen(tmp);
|
||||
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512);
|
||||
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512);
|
||||
|
||||
if (bt > 0) {
|
||||
strWChar[bt] = 0;
|
||||
@ -115,13 +115,13 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
|
||||
|
||||
int32_t StringTools::strprintf(std::string &str, const char *format, ...) {
|
||||
static char tmp[512];
|
||||
tmp[0] = 0;
|
||||
tmp[0] = 0;
|
||||
int32_t result = 0;
|
||||
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if ((vsprintf(tmp, format, va) >= 0)) {
|
||||
str = tmp;
|
||||
str = tmp;
|
||||
result = str.size();
|
||||
}
|
||||
va_end(va);
|
||||
@ -223,7 +223,7 @@ const char *StringTools::FullpathToFilename(const char *path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
const char *ptr = path;
|
||||
const char *ptr = path;
|
||||
const char *Filename = ptr;
|
||||
|
||||
while (*ptr != '\0') {
|
||||
@ -253,13 +253,13 @@ void StringTools::RemoveDoubleSlashs(std::string &str) {
|
||||
|
||||
// You must free the result if result is non-NULL.
|
||||
char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
||||
char *result; // the return string
|
||||
char *ins; // the next insert point
|
||||
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 count; // number of replacements
|
||||
char *result; // the return string
|
||||
char *ins; // the next insert point
|
||||
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 count; // number of replacements
|
||||
|
||||
// sanity checks and initialization
|
||||
if (!orig || !rep) {
|
||||
@ -268,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 *) "";
|
||||
}
|
||||
@ -292,11 +292,11 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
||||
// ins points to the next occurrence of rep in orig
|
||||
// orig points to the remainder of orig after "end of rep"
|
||||
while (count--) {
|
||||
ins = strstr(orig, rep);
|
||||
ins = strstr(orig, rep);
|
||||
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"
|
||||
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"
|
||||
}
|
||||
strcpy(tmp, orig);
|
||||
return result;
|
||||
|
@ -5,17 +5,17 @@
|
||||
#include <whb/log_udp.h>
|
||||
|
||||
uint32_t moduleLogInit = false;
|
||||
uint32_t cafeLogInit = false;
|
||||
uint32_t udpLogInit = false;
|
||||
#endif// DEBUG
|
||||
uint32_t cafeLogInit = false;
|
||||
uint32_t udpLogInit = false;
|
||||
#endif // DEBUG
|
||||
|
||||
void initLogging() {
|
||||
#ifdef DEBUG
|
||||
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||
cafeLogInit = WHBLogCafeInit();
|
||||
udpLogInit = WHBLogUdpInit();
|
||||
udpLogInit = WHBLogUdpInit();
|
||||
}
|
||||
#endif// DEBUG
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
void deinitLogging() {
|
||||
@ -32,5 +32,5 @@ void deinitLogging() {
|
||||
WHBLogUdpDeinit();
|
||||
udpLogInit = false;
|
||||
}
|
||||
#endif// DEBUG
|
||||
#endif // DEBUG
|
||||
}
|
@ -9,8 +9,8 @@ extern "C" {
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
|
||||
@ -28,9 +28,9 @@ extern "C" {
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user