mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-09-08 11:59:16 -05:00
Reduce logging
This commit is contained in:
@@ -14,7 +14,6 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
int32_t plugin_count = pluginInformation->number_used_plugins;
|
||||
|
||||
auto pluginName = plugin.getMetaInformation().getName();
|
||||
//auto pluginPath = plugin.getMetaInformation().getPath();
|
||||
|
||||
if (plugin_count >= MAXIMUM_PLUGINS - 1) {
|
||||
DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!", MAXIMUM_PLUGINS, pluginName.c_str());
|
||||
@@ -63,7 +62,6 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
|
||||
auto pluginInfo = plugin.getPluginInformation();
|
||||
|
||||
|
||||
// Relocation
|
||||
std::vector<RelocationData> relocationData = pluginInfo.getRelocationDataList();
|
||||
for (auto &reloc : relocationData) {
|
||||
@@ -73,11 +71,9 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<FunctionData> function_data_list = pluginInfo.getFunctionDataList();
|
||||
std::vector<HookData> hook_data_list = pluginInfo.getHookDataList();
|
||||
|
||||
|
||||
if (function_data_list.size() > MAXIMUM_FUNCTION_PER_PLUGIN) {
|
||||
DEBUG_FUNCTION_LINE("Plugin %s would replace to many function (%d, maximum is %d). It won't be loaded.", pluginName.c_str(), function_data_list.size(), MAXIMUM_FUNCTION_PER_PLUGIN);
|
||||
return false;
|
||||
@@ -101,7 +97,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Adding function \"%s\" for plugin \"%s\"", curFunction.getName().c_str(), pluginName.c_str());
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Adding function \"%s\" for plugin \"%s\"", curFunction.getName().c_str(), pluginName.c_str());
|
||||
|
||||
strncpy(function_data->function_name, curFunction.getName().c_str(), MAXIMUM_FUNCTION_NAME_LENGTH - 1);
|
||||
|
||||
@@ -121,7 +117,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
for (auto &curHook : pluginInfo.getHookDataList()) {
|
||||
replacement_data_hook_t *hook_data = &plugin_data->info.hooks[i];
|
||||
|
||||
DEBUG_FUNCTION_LINE("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());
|
||||
|
||||
hook_data->func_pointer = (void *) curHook.getFunctionPointer();
|
||||
hook_data->type = curHook.getType();
|
||||
@@ -220,7 +216,7 @@ std::vector<PluginContainer> PluginContainerPersistence::loadPlugins(plugin_info
|
||||
if (sectionInfo->addr == 0 && sectionInfo->size == 0) {
|
||||
continue;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Add SectionInfo %s", sectionInfo->name);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Add SectionInfo %s", sectionInfo->name);
|
||||
std::string name(sectionInfo->name);
|
||||
curPluginInformation.addSectionInfo(SectionInfo(name, sectionInfo->addr, sectionInfo->size));
|
||||
}
|
||||
|
||||
@@ -43,18 +43,17 @@ PluginData::PluginData(const std::vector<uint8_t>& input, MEMHeapHandle heapHand
|
||||
default:
|
||||
case eMemTypeExpHeap:
|
||||
data_copy = MEMAllocFromExpHeapEx(heapHandle, length, 4);
|
||||
DEBUG_FUNCTION_LINE("Allocated %d kb on ExpHeap", length / 1024);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Allocated %d kb on ExpHeap", length / 1024);
|
||||
if (data_copy == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Failed to allocate space on exp heap");
|
||||
} else {
|
||||
memcpy(data_copy, &input[0], length);
|
||||
}
|
||||
this->buffer = data_copy;
|
||||
DEBUG_FUNCTION_LINE("copied data to exp heap");
|
||||
break;
|
||||
case eMemTypeMEM2:
|
||||
data_copy = memalign(4, length);
|
||||
DEBUG_FUNCTION_LINE("Allocated %d kb on default heap", length / 1024);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Allocated %d kb on default heap", length / 1024);
|
||||
if (data_copy == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Failed to allocate space on default heap");
|
||||
} else {
|
||||
|
||||
@@ -50,7 +50,7 @@ std::vector<PluginData> PluginDataFactory::loadDir(const std::string &path, MEMH
|
||||
if ((stbuf.st_mode & S_IFMT) == S_IFDIR) { // Skip directories
|
||||
continue;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Found file: %s", full_file_path.c_str());
|
||||
DEBUG_FUNCTION_LINE("Loading plugin: %s", full_file_path.c_str());
|
||||
auto pluginData = load(full_file_path, heapHandle);
|
||||
if (pluginData) {
|
||||
result.push_back(pluginData.value());
|
||||
@@ -88,7 +88,7 @@ std::optional<PluginData> PluginDataFactory::load(const std::string &filename, M
|
||||
free(data);
|
||||
is.close();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Loaded file!");
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Loaded file!");
|
||||
|
||||
return load(result, heapHandle);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Allocated %d kb from ExpHeap", text_size / 1024);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Allocated %d kb from ExpHeap", text_size / 1024);
|
||||
void *data_data = MEMAllocFromExpHeapEx(heapHandle, data_size, 0x1000);
|
||||
if (data_data == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Failed to alloc memory for the .data section (%d bytes)", data_size);
|
||||
@@ -87,7 +87,7 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
|
||||
MEMFreeToExpHeap(heapHandle, text_data);
|
||||
return std::nullopt;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Allocated %d kb from ExpHeap", data_size / 1024);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Allocated %d kb from ExpHeap", data_size / 1024);
|
||||
|
||||
uint32_t entrypoint = (uint32_t) text_data + (uint32_t) reader.get_entry() - 0x02000000;
|
||||
|
||||
@@ -126,16 +126,16 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
|
||||
const char *p = psec->get_data();
|
||||
|
||||
if (psec->get_type() == SHT_NOBITS) {
|
||||
DEBUG_FUNCTION_LINE("memset section %s %08X to 0 (%d bytes)", psec->get_name().c_str(), destination, sectionSize);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("memset section %s %08X to 0 (%d bytes)", psec->get_name().c_str(), destination, sectionSize);
|
||||
memset((void *) destination, 0, sectionSize);
|
||||
} else if (psec->get_type() == SHT_PROGBITS) {
|
||||
DEBUG_FUNCTION_LINE("Copy section %s %08X -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Copy section %s %08X -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize);
|
||||
memcpy((void *) destination, p, sectionSize);
|
||||
}
|
||||
|
||||
std::string sectionName(psec->get_name());
|
||||
pluginInfo.addSectionInfo(SectionInfo(sectionName, destination, sectionSize));
|
||||
DEBUG_FUNCTION_LINE("Saved %s section info. Location: %08X size: %08X", psec->get_name().c_str(), destination, sectionSize);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Saved %s section info. Location: %08X size: %08X", psec->get_name().c_str(), destination, sectionSize);
|
||||
|
||||
totalSize += sectionSize;
|
||||
|
||||
@@ -147,7 +147,7 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
|
||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||
section *psec = reader.sections[i];
|
||||
if ((psec->get_type() == SHT_PROGBITS || psec->get_type() == SHT_NOBITS) && (psec->get_flags() & SHF_ALLOC)) {
|
||||
DEBUG_FUNCTION_LINE("Linking (%d)... %s at %08X", i, psec->get_name().c_str(), destinations[psec->get_index()]);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Linking (%d)... %s at %08X", i, psec->get_name().c_str(), destinations[psec->get_index()]);
|
||||
|
||||
if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data, (uint32_t) data_data, trampolin_data, trampolin_data_length, trampolinId)) {
|
||||
DEBUG_FUNCTION_LINE("elfLink failed");
|
||||
@@ -173,7 +173,7 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
|
||||
|
||||
pluginInfo.setTrampolinId(trampolinId);
|
||||
|
||||
DEBUG_FUNCTION_LINE("Saved entrypoint as %08X", entrypoint);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Saved entrypoint as %08X", entrypoint);
|
||||
|
||||
std::optional<SectionInfo> secInfo = pluginInfo.getSectionInfo(".wups.hooks");
|
||||
if (secInfo && secInfo->getSize() > 0) {
|
||||
@@ -182,7 +182,7 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
|
||||
if (entries != nullptr) {
|
||||
for (size_t j = 0; j < entries_count; j++) {
|
||||
wups_loader_hook_t *hook = &entries[j];
|
||||
DEBUG_FUNCTION_LINE("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);
|
||||
HookData hook_data((void *) hook->target, hook->type);
|
||||
pluginInfo.addHookData(hook_data);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ 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()*/,
|
||||
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.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, (function_replacement_library_type_t) cur_function->_function.library,
|
||||
(void *) cur_function->_function.target, (void *) cur_function->_function.call_addr, (FunctionPatcherTargetProcess) cur_function->_function.targetProcess);
|
||||
@@ -229,7 +229,7 @@ std::vector<RelocationData> PluginInformationFactory::getImportRelocationData(co
|
||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||
section *psec = reader.sections[i];
|
||||
if (psec->get_type() == SHT_RELA || psec->get_type() == SHT_REL) {
|
||||
DEBUG_FUNCTION_LINE("Found relocation section %s", psec->get_name().c_str());
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Found relocation section %s", psec->get_name().c_str());
|
||||
relocation_section_accessor rel(reader, psec);
|
||||
for (uint32_t j = 0; j < (uint32_t) rel.get_entries_num(); ++j) {
|
||||
Elf64_Addr offset;
|
||||
@@ -288,7 +288,7 @@ bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section
|
||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||
section *psec = reader.sections[i];
|
||||
if (psec->get_info() == section_index) {
|
||||
DEBUG_FUNCTION_LINE("Found relocation section %s", psec->get_name().c_str());
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Found relocation section %s", psec->get_name().c_str());
|
||||
relocation_section_accessor rel(reader, psec);
|
||||
for (uint32_t j = 0; j < (uint32_t) rel.get_entries_num(); ++j) {
|
||||
Elf64_Addr offset;
|
||||
@@ -344,10 +344,10 @@ bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("done");
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("done");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Failed to find relocation section");
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Failed to find relocation section");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user