mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-12-18 09:01:54 +01:00
Even more formatting
This commit is contained in:
parent
4bf4a0eeea
commit
0c0680be77
@ -8,6 +8,7 @@ class PluginManagement {
|
||||
public:
|
||||
|
||||
static void doRelocations(const std::vector<PluginContainer> &plugins, relocation_trampolin_entry_t *trampData, uint32_t tramp_size);
|
||||
|
||||
static void memsetBSS(const std::vector<PluginContainer> &plugins);
|
||||
|
||||
static void callInitHooks(plugin_information_t *pluginInformation);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <wups.h>
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <wups.h>
|
||||
#include "common/plugin_defines.h"
|
||||
|
||||
void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type);
|
||||
|
||||
void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed);
|
||||
|
||||
bool HasHookCallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type);
|
||||
|
@ -14,13 +14,17 @@ void kern_write(void * addr, uint32_t value);
|
||||
uint32_t kern_read(const void *addr);
|
||||
|
||||
void SC0x0A_KernelWriteSRs(sr_table_t *table);
|
||||
|
||||
void SC0x36_KernelReadSRs(sr_table_t *table);
|
||||
|
||||
void KernelReadPTE(uint32_t addr, int32_t length);
|
||||
|
||||
void KernelWritePTE(uint32_t addr, int32_t length);
|
||||
|
||||
void KernelWrite(uint32_t addr, const void *data, uint32_t length);
|
||||
|
||||
void KernelWriteU32(uint32_t addr, uint32_t value);
|
||||
|
||||
void kernelInitialize();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -81,6 +81,7 @@ DECL(int32_t, VPADRead, int32_t chan, VPADStatus *buffer, uint32_t buffer_size,
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
void setupContextState() {
|
||||
g_vid_ownContextState = (GX2ContextState*)memalign(
|
||||
|
@ -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, const 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, const void *destination, const std::string& name, const 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, const void *destination,
|
||||
const std::string &name, const ImportRPLInformation &rplInfo) {
|
||||
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo.getName().c_str(), rplInfo.isData());
|
||||
if (importInfoGbl == NULL) {
|
||||
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.\n", 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);
|
||||
}
|
||||
|
||||
bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_entry_t * linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, const 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, const void *destination, dyn_linking_function_t *functionName,
|
||||
dyn_linking_import_t *importInfo) {
|
||||
for (uint32_t i = 0; i < linking_entry_length; i++) {
|
||||
dyn_linking_relocation_entry_t *curEntry = &(linking_entries[i]);
|
||||
if (curEntry->functionEntry != NULL) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/dynamic_linking_defines.h"
|
||||
#include "utils/logger.h"
|
||||
#include <string>
|
||||
@ -48,9 +49,13 @@ public:
|
||||
|
||||
static bool addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, const 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, const void *destination, const std::string& name, const 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, const void *destination, const std::string &name,
|
||||
const 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, const 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, const void *destination, dyn_linking_function_t * functionName, dyn_linking_import_t * importInfo);
|
||||
private:
|
||||
DynamicLinkingHelper() {
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
const void *getPhysicalAddress() const {
|
||||
return paddress;
|
||||
}
|
||||
|
||||
const void *getVirtualAddress() const {
|
||||
return vaddress;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
wups_loader_hook_type_t getType() const {
|
||||
return this->type;
|
||||
}
|
||||
|
||||
private:
|
||||
void *function_pointer;
|
||||
wups_loader_hook_type_t type;
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
PluginContainer() {
|
||||
|
||||
}
|
||||
|
||||
const PluginMetaInformation &getMetaInformation() const {
|
||||
return this->metaInformation;
|
||||
}
|
||||
|
@ -6,5 +6,6 @@
|
||||
class PluginContainerPersistence {
|
||||
public:
|
||||
static bool savePlugin(plugin_information_t *pluginInformation, PluginContainer &plugin);
|
||||
|
||||
static std::vector<PluginContainer> loadPlugins(plugin_information_t *pluginInformation);
|
||||
};
|
||||
|
@ -16,6 +16,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <malloc.h>
|
||||
@ -35,6 +36,7 @@ public:
|
||||
const std::optional<elfio *> &getReader() const {
|
||||
return reader;
|
||||
}
|
||||
|
||||
~PluginData() {
|
||||
if (nReader != NULL) {
|
||||
delete nReader;
|
||||
@ -44,11 +46,13 @@ public:
|
||||
|
||||
|
||||
void freeMemory();
|
||||
|
||||
private:
|
||||
PluginData() {
|
||||
}
|
||||
|
||||
PluginData(std::vector<uint8_t> buffer);
|
||||
|
||||
PluginData(std::vector<uint8_t> input, MEMHeapHandle heapHandle, eMemoryTypes memoryType);
|
||||
|
||||
|
||||
@ -62,7 +66,10 @@ private:
|
||||
MEMHeapHandle heapHandle;
|
||||
eMemoryTypes memoryType;
|
||||
size_t length;
|
||||
|
||||
friend class PluginDataFactory;
|
||||
|
||||
friend class PluginContainer;
|
||||
|
||||
friend class PluginContainerPersistence;
|
||||
};
|
||||
|
@ -26,6 +26,8 @@
|
||||
class PluginDataFactory {
|
||||
public:
|
||||
static std::vector<PluginData> loadDir(const std::string &path, MEMHeapHandle heapHandle);
|
||||
|
||||
static std::optional<PluginData> load(const std::string &path, MEMHeapHandle heapHandle);
|
||||
|
||||
static std::optional<PluginData> load(std::vector<uint8_t> &buffer, MEMHeapHandle heapHandle);
|
||||
};
|
||||
|
@ -95,5 +95,6 @@ private:
|
||||
void *allocatedDataMemoryAddress = 0;
|
||||
|
||||
friend class PluginInformationFactory;
|
||||
|
||||
friend class PluginContainerPersistence;
|
||||
};
|
||||
|
@ -190,8 +190,10 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
|
||||
if (entries != NULL) {
|
||||
for (size_t j = 0; j < entries_count; j++) {
|
||||
wups_loader_entry_t *cur_function = &entries[j];
|
||||
DEBUG_FUNCTION_LINE("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.physical_address,cur_function->_function.virtual_address, cur_function->_function.library,cur_function->_function.target, (void *) cur_function->_function.call_addr);
|
||||
FunctionData function_data((void *) cur_function->_function.physical_address,(void *) cur_function->_function.virtual_address, cur_function->_function.name, cur_function->_function.library, (void *) cur_function->_function.target, (void *) cur_function->_function.call_addr);
|
||||
DEBUG_FUNCTION_LINE("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.physical_address, cur_function->_function.virtual_address, cur_function->_function.library, cur_function->_function.target, (void *) cur_function->_function.call_addr);
|
||||
FunctionData function_data((void *) cur_function->_function.physical_address, (void *) cur_function->_function.virtual_address, cur_function->_function.name, cur_function->_function.library,
|
||||
(void *) cur_function->_function.target, (void *) cur_function->_function.call_addr);
|
||||
pluginInfo.addFunctionData(function_data);
|
||||
}
|
||||
}
|
||||
@ -277,7 +279,9 @@ std::vector<RelocationData> PluginInformationFactory::getImportRelocationData(co
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool PluginInformationFactory::linkSection(const PluginData& pluginData, 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, uint8_t trampolinId) {
|
||||
|
||||
bool PluginInformationFactory::linkSection(const PluginData &pluginData, 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,
|
||||
uint8_t trampolinId) {
|
||||
auto readerOpt = pluginData.getReader();
|
||||
if (!readerOpt) {
|
||||
return false;
|
||||
|
@ -30,6 +30,9 @@
|
||||
class PluginInformationFactory {
|
||||
public:
|
||||
static std::optional<PluginInformation> load(const PluginData &pluginData, MEMHeapHandle heaphandle, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length, uint8_t trampolinId);
|
||||
static bool linkSection(const PluginData & pluginData, 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, uint8_t trampolinId);
|
||||
|
||||
static bool
|
||||
linkSection(const PluginData &pluginData, 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, uint8_t trampolinId);
|
||||
|
||||
static std::vector<RelocationData> getImportRelocationData(const PluginData &pluginData, uint8_t **destinations);
|
||||
};
|
||||
|
@ -91,6 +91,8 @@ private:
|
||||
size_t size;
|
||||
|
||||
friend class PluginMetaInformationFactory;
|
||||
|
||||
friend class PluginContainerPersistence;
|
||||
|
||||
friend class PluginContainer;
|
||||
};
|
||||
|
@ -33,14 +33,23 @@
|
||||
class StringTools {
|
||||
public:
|
||||
static BOOL EndsWith(const std::string &a, const std::string &b);
|
||||
|
||||
static const char *byte_to_binary(int32_t x);
|
||||
|
||||
static std::string removeCharFromString(std::string &input, char toBeRemoved);
|
||||
|
||||
static const char *fmt(const char *format, ...);
|
||||
|
||||
static const wchar_t *wfmt(const char *format, ...);
|
||||
|
||||
static int32_t strprintf(std::string &str, const char *format, ...);
|
||||
|
||||
static std::string strfmt(const char *format, ...);
|
||||
|
||||
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 strextcmp(const char *string, const char *extension, char seperator);
|
||||
|
||||
static const char *FullpathToFilename(const char *path) {
|
||||
|
@ -8,9 +8,12 @@ extern "C" {
|
||||
#include <string.h>
|
||||
|
||||
void log_init_();
|
||||
|
||||
//void log_deinit_(void);
|
||||
void log_print_(const char *str);
|
||||
|
||||
void log_printf_(const char *format, ...);
|
||||
|
||||
void OSFatal_printf(const char *format, ...);
|
||||
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
@ -21,7 +24,6 @@ void OSFatal_printf(const char *format, ...);
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
#define log_init() log_init_()
|
||||
//#define log_deinit() log_deinit_()
|
||||
#define log_print(str) log_print_(str)
|
||||
|
Loading…
Reference in New Issue
Block a user