mirror of
https://github.com/wiiu-env/CustomRPXLoader.git
synced 2025-02-16 16:39:14 +01:00
Formatting
This commit is contained in:
parent
b838b59421
commit
a1267cc821
@ -4,6 +4,7 @@
|
|||||||
#define IMPORT(name) void* addr_##name
|
#define IMPORT(name) void* addr_##name
|
||||||
#define IMPORT_BEGIN(lib)
|
#define IMPORT_BEGIN(lib)
|
||||||
#define IMPORT_END()
|
#define IMPORT_END()
|
||||||
|
|
||||||
#include "imports.h"
|
#include "imports.h"
|
||||||
|
|
||||||
#undef IMPORT
|
#undef IMPORT
|
||||||
|
@ -8,4 +8,5 @@
|
|||||||
|
|
||||||
|
|
||||||
void doKernelSetup();
|
void doKernelSetup();
|
||||||
|
|
||||||
void doKernelSetup2();
|
void doKernelSetup2();
|
||||||
|
@ -66,10 +66,12 @@ dyn_linking_import_t * DynamicLinkingHelper::getOrAddImport(dyn_linking_relocati
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, RelocationData *relocationData) {
|
bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, RelocationData *relocationData) {
|
||||||
return addReloationEntry(linking_data, linking_entries, linking_entry_length, relocationData->getType(), relocationData->getOffset(), relocationData->getAddend(), relocationData->getDestination(), relocationData->getName(), relocationData->getImportRPLInformation());
|
return addReloationEntry(linking_data, linking_entries, linking_entry_length, relocationData->getType(), relocationData->getOffset(), relocationData->getAddend(), relocationData->getDestination(), relocationData->getName(),
|
||||||
|
relocationData->getImportRPLInformation());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t * linking_data, dyn_linking_relocation_entry_t * linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, std::string name, ImportRPLInformation * rplInfo) {
|
bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination,
|
||||||
|
std::string name, ImportRPLInformation *rplInfo) {
|
||||||
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo->getName().c_str(), rplInfo->isData());
|
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo->getName().c_str(), rplInfo->isData());
|
||||||
if (importInfoGbl == NULL) {
|
if (importInfoGbl == NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.", DYN_LINK_IMPORT_LIST_LENGTH);
|
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.", DYN_LINK_IMPORT_LIST_LENGTH);
|
||||||
@ -85,7 +87,8 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t * lin
|
|||||||
return addReloationEntry(linking_entries, linking_entry_length, type, offset, addend, destination, functionInfo, importInfoGbl);
|
return addReloationEntry(linking_entries, linking_entry_length, type, offset, addend, destination, functionInfo, importInfoGbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_entry_t * linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t * functionName, dyn_linking_import_t * importInfo) {
|
bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t *functionName,
|
||||||
|
dyn_linking_import_t *importInfo) {
|
||||||
for (uint32_t i = 0; i < linking_entry_length; i++) {
|
for (uint32_t i = 0; i < linking_entry_length; i++) {
|
||||||
dyn_linking_relocation_entry_t *curEntry = &(linking_entries[i]);
|
dyn_linking_relocation_entry_t *curEntry = &(linking_entries[i]);
|
||||||
if (curEntry->functionEntry != NULL) {
|
if (curEntry->functionEntry != NULL) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/dynamic_linking_defines.h"
|
#include "common/dynamic_linking_defines.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -48,9 +49,12 @@ public:
|
|||||||
|
|
||||||
static bool addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, RelocationData *relocationData);
|
static bool addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, RelocationData *relocationData);
|
||||||
|
|
||||||
static bool addReloationEntry(dyn_linking_relocation_data_t * linking_data, dyn_linking_relocation_entry_t * linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, std::string name, ImportRPLInformation * rplInfo);
|
static bool addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, std::string name,
|
||||||
|
ImportRPLInformation *rplInfo);
|
||||||
|
|
||||||
|
static bool
|
||||||
|
addReloationEntry(dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t *functionName, dyn_linking_import_t *importInfo);
|
||||||
|
|
||||||
static bool addReloationEntry(dyn_linking_relocation_entry_t * linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t * functionName, dyn_linking_import_t * importInfo);
|
|
||||||
private:
|
private:
|
||||||
DynamicLinkingHelper() {
|
DynamicLinkingHelper() {
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string toString();
|
std::string toString();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<RelocationData *> relocation_data_list;
|
std::vector<RelocationData *> relocation_data_list;
|
||||||
|
|
||||||
|
@ -209,6 +209,7 @@ std::vector<RelocationData*> ModuleDataFactory::getImportRelocationData(elfio& r
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleDataFactory::linkSection(elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
bool ModuleDataFactory::linkSection(elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
||||||
uint32_t sec_num = reader.sections.size();
|
uint32_t sec_num = reader.sections.size();
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
class ModuleDataFactory {
|
class ModuleDataFactory {
|
||||||
public:
|
public:
|
||||||
static ModuleData *load(std::string path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
static ModuleData *load(std::string path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||||
|
|
||||||
static bool linkSection(ELFIO::elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
static bool linkSection(ELFIO::elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||||
|
|
||||||
static std::vector<RelocationData *> getImportRelocationData(ELFIO::elfio &reader, uint8_t **destinations);
|
static std::vector<RelocationData *> getImportRelocationData(ELFIO::elfio &reader, uint8_t **destinations);
|
||||||
};
|
};
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string toString();
|
std::string toString();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char type;
|
char type;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
@ -37,8 +37,9 @@
|
|||||||
|
|
||||||
|
|
||||||
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
|
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
|
||||||
if (b.size() > a.size())
|
if (b.size() > a.size()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
|
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +60,9 @@ std::string StringTools::removeCharFromString(std::string& input,char toBeRemove
|
|||||||
size_t position;
|
size_t position;
|
||||||
while (1) {
|
while (1) {
|
||||||
position = output.find(toBeRemoved);
|
position = output.find(toBeRemoved);
|
||||||
if(position == std::string::npos)
|
if (position == std::string::npos) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
output.erase(position, 1);
|
output.erase(position, 1);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
@ -87,11 +89,13 @@ const wchar_t * StringTools::wfmt(const char * format, ...) {
|
|||||||
strWChar[0] = 0;
|
strWChar[0] = 0;
|
||||||
tmp[0] = 0;
|
tmp[0] = 0;
|
||||||
|
|
||||||
if(!format)
|
if (!format) {
|
||||||
return (const wchar_t *) strWChar;
|
return (const wchar_t *) strWChar;
|
||||||
|
}
|
||||||
|
|
||||||
if(strcmp(format, "") == 0)
|
if (strcmp(format, "") == 0) {
|
||||||
return (const wchar_t *) strWChar;
|
return (const wchar_t *) strWChar;
|
||||||
|
}
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
@ -142,8 +146,9 @@ std::string StringTools::strfmt(const char * format, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOL StringTools::char2wchar_t(const char *strChar, wchar_t *dest) {
|
BOOL StringTools::char2wchar_t(const char *strChar, wchar_t *dest) {
|
||||||
if(!strChar || !dest)
|
if (!strChar || !dest) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int bt;
|
int bt;
|
||||||
bt = mbstowcs(dest, strChar, strlen(strChar));
|
bt = mbstowcs(dest, strChar, strlen(strChar));
|
||||||
@ -156,8 +161,9 @@ BOOL StringTools::char2wchar_t(const char * strChar, wchar_t * dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t StringTools::strtokcmp(const char *string, const char *compare, const char *separator) {
|
int32_t StringTools::strtokcmp(const char *string, const char *compare, const char *separator) {
|
||||||
if(!string || !compare)
|
if (!string || !compare) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
char TokCopy[512];
|
char TokCopy[512];
|
||||||
strncpy(TokCopy, compare, sizeof(TokCopy));
|
strncpy(TokCopy, compare, sizeof(TokCopy));
|
||||||
@ -176,12 +182,14 @@ int32_t StringTools::strtokcmp(const char * string, const char * compare, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t StringTools::strextcmp(const char *string, const char *extension, char seperator) {
|
int32_t StringTools::strextcmp(const char *string, const char *extension, char seperator) {
|
||||||
if(!string || !extension)
|
if (!string || !extension) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
char *ptr = strrchr(string, seperator);
|
char *ptr = strrchr(string, seperator);
|
||||||
if(!ptr)
|
if (!ptr) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return strcasecmp(ptr + 1, extension);
|
return strcasecmp(ptr + 1, extension);
|
||||||
}
|
}
|
||||||
@ -212,15 +220,17 @@ std::vector<std::string> StringTools::stringSplit(const std::string & inValue, c
|
|||||||
|
|
||||||
|
|
||||||
const char *StringTools::FullpathToFilename(const char *path) {
|
const char *StringTools::FullpathToFilename(const char *path) {
|
||||||
if(!path)
|
if (!path) {
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
const char *ptr = path;
|
const char *ptr = path;
|
||||||
const char *Filename = ptr;
|
const char *Filename = ptr;
|
||||||
|
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
if(ptr[0] == '/' && ptr[1] != '\0')
|
if (ptr[0] == '/' && ptr[1] != '\0') {
|
||||||
Filename = ptr + 1;
|
Filename = ptr + 1;
|
||||||
|
}
|
||||||
|
|
||||||
++ptr;
|
++ptr;
|
||||||
}
|
}
|
||||||
@ -253,11 +263,13 @@ char * StringTools::str_replace(char *orig, char *rep, char *with) {
|
|||||||
int count; // number of replacements
|
int count; // number of replacements
|
||||||
|
|
||||||
// sanity checks and initialization
|
// sanity checks and initialization
|
||||||
if (!orig || !rep)
|
if (!orig || !rep) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
len_rep = strlen(rep);
|
len_rep = strlen(rep);
|
||||||
if (len_rep == 0)
|
if (len_rep == 0) {
|
||||||
return NULL; // empty rep causes infinite loop during count
|
return NULL;
|
||||||
|
} // empty rep causes infinite loop during count
|
||||||
if (!with)
|
if (!with)
|
||||||
with = "";
|
with = "";
|
||||||
len_with = strlen(with);
|
len_with = strlen(with);
|
||||||
|
@ -33,18 +33,31 @@
|
|||||||
class StringTools {
|
class StringTools {
|
||||||
public:
|
public:
|
||||||
static BOOL EndsWith(const std::string &a, const std::string &b);
|
static BOOL EndsWith(const std::string &a, const std::string &b);
|
||||||
|
|
||||||
static const char *byte_to_binary(int32_t x);
|
static const char *byte_to_binary(int32_t x);
|
||||||
|
|
||||||
static std::string removeCharFromString(std::string &input, char toBeRemoved);
|
static std::string removeCharFromString(std::string &input, char toBeRemoved);
|
||||||
|
|
||||||
static const char *fmt(const char *format, ...);
|
static const char *fmt(const char *format, ...);
|
||||||
|
|
||||||
static const wchar_t *wfmt(const char *format, ...);
|
static const wchar_t *wfmt(const char *format, ...);
|
||||||
|
|
||||||
static int32_t strprintf(std::string &str, const char *format, ...);
|
static int32_t strprintf(std::string &str, const char *format, ...);
|
||||||
|
|
||||||
static std::string strfmt(const char *format, ...);
|
static std::string strfmt(const char *format, ...);
|
||||||
|
|
||||||
static BOOL char2wchar_t(const char *src, wchar_t *dest);
|
static BOOL char2wchar_t(const char *src, wchar_t *dest);
|
||||||
|
|
||||||
static int32_t strtokcmp(const char *string, const char *compare, const char *separator);
|
static int32_t strtokcmp(const char *string, const char *compare, const char *separator);
|
||||||
|
|
||||||
static int32_t strextcmp(const char *string, const char *extension, char seperator);
|
static int32_t strextcmp(const char *string, const char *extension, char seperator);
|
||||||
|
|
||||||
static char *str_replace(char *orig, char *rep, char *with);
|
static char *str_replace(char *orig, char *rep, char *with);
|
||||||
|
|
||||||
static const char *FullpathToFilename(const char *path);
|
static const char *FullpathToFilename(const char *path);
|
||||||
|
|
||||||
static void RemoveDoubleSlashs(std::string &str);
|
static void RemoveDoubleSlashs(std::string &str);
|
||||||
|
|
||||||
static std::vector<std::string> stringSplit(const std::string &value, const std::string &splitter);
|
static std::vector<std::string> stringSplit(const std::string &value, const std::string &splitter);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@ static volatile int log_lock __attribute__((section(".data"))) = 0;
|
|||||||
void log_init_() {
|
void log_init_() {
|
||||||
int broadcastEnable = 1;
|
int broadcastEnable = 1;
|
||||||
log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if (log_socket < 0)
|
if (log_socket < 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setsockopt(log_socket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
|
setsockopt(log_socket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
|
||||||
|
|
||||||
@ -43,8 +44,9 @@ void log_print_(const char *str) {
|
|||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
|
int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
|
||||||
ret = sendto(log_socket, str, block, 0, (struct sockaddr *) &connect_addr, sizeof(struct sockaddr_in));
|
ret = sendto(log_socket, str, block, 0, (struct sockaddr *) &connect_addr, sizeof(struct sockaddr_in));
|
||||||
if(ret < 0)
|
if (ret < 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
len -= ret;
|
len -= ret;
|
||||||
str += ret;
|
str += ret;
|
||||||
|
@ -8,9 +8,12 @@ extern "C" {
|
|||||||
#include <whb/log.h>
|
#include <whb/log.h>
|
||||||
|
|
||||||
void log_init_();
|
void log_init_();
|
||||||
|
|
||||||
//void log_deinit_(void);
|
//void log_deinit_(void);
|
||||||
void log_print_(const char *str);
|
void log_print_(const char *str);
|
||||||
|
|
||||||
void log_printf_(const char *format, ...);
|
void log_printf_(const char *format, ...);
|
||||||
|
|
||||||
void OSFatal_printf(const char *format, ...);
|
void OSFatal_printf(const char *format, ...);
|
||||||
|
|
||||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||||
@ -21,7 +24,6 @@ void OSFatal_printf(const char *format, ...);
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define log_init() log_init_()
|
#define log_init() log_init_()
|
||||||
//#define log_deinit() log_deinit_()
|
//#define log_deinit() log_deinit_()
|
||||||
#define log_print(str) log_print_(str)
|
#define log_print(str) log_print_(str)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user