mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +01:00
Use DEBUG_FUNCTION_LINE_ERR on error.
This commit is contained in:
parent
6f607cfec3
commit
48eb915a70
@ -48,13 +48,13 @@ bool PluginManagement::doRelocation(const std::vector<std::shared_ptr<Relocation
|
||||
}
|
||||
|
||||
if (functionAddress == 0) {
|
||||
DEBUG_FUNCTION_LINE("Failed to find export for %s", functionName.c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to find export for %s", functionName.c_str());
|
||||
return false;
|
||||
} else {
|
||||
//DEBUG_FUNCTION_LINE("Found export for %s %s", rplName.c_str(), functionName.c_str());
|
||||
}
|
||||
if (!ElfUtils::elfLinkOne(cur->getType(), cur->getOffset(), cur->getAddend(), (uint32_t) cur->getDestination(), functionAddress, tramp_data, tramp_length, RELOC_TYPE_IMPORT, trampolineID)) {
|
||||
DEBUG_FUNCTION_LINE("Relocation failed");
|
||||
DEBUG_FUNCTION_LINE_ERR("Relocation failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ void PluginManagement::doRelocations(const std::vector<std::shared_ptr<PluginCon
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Doing relocations for plugin: %s", pluginContainer->getMetaInformation()->getName().c_str());
|
||||
|
||||
if (!PluginManagement::doRelocation(pluginContainer->getPluginInformation()->getRelocationDataList(), trampData, tramp_size, pluginContainer->getPluginInformation()->getTrampolineId())) {
|
||||
DEBUG_FUNCTION_LINE("Relocation failed");
|
||||
DEBUG_FUNCTION_LINE_ERR("Relocation failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,14 +113,14 @@ void PluginManagement::unloadPlugins(plugin_information_t *pluginInformation, ME
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Free plugin data buffer for %s [%08X on heap %08X]", plugin->meta.name, plugin->data.buffer, plugin->data.heapHandle);
|
||||
MEMFreeToExpHeap((MEMHeapHandle) plugin->data.heapHandle, plugin->data.buffer);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("########################");
|
||||
DEBUG_FUNCTION_LINE("Failed to free memory from plugin");
|
||||
DEBUG_FUNCTION_LINE("########################");
|
||||
DEBUG_FUNCTION_LINE_ERR("########################");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to free memory from plugin");
|
||||
DEBUG_FUNCTION_LINE_ERR("########################");
|
||||
}
|
||||
plugin->data.buffer = nullptr;
|
||||
plugin->data.bufferLength = 0;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Plugin has no copy of elf saved in memory, can't free it");
|
||||
DEBUG_FUNCTION_LINE_ERR("Plugin has no copy of elf saved in memory, can't free it");
|
||||
}
|
||||
}
|
||||
if (plugin->info.allocatedTextMemoryAddress != nullptr) {
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
return StringTools::strfmt("[ERROR %d]", res);
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED");
|
||||
return "NOT_IMPLEMENTED";
|
||||
}
|
||||
|
||||
@ -89,6 +90,7 @@ public:
|
||||
return StringTools::strfmt("[ERROR %d]", res);
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED");
|
||||
return "NOT_IMPLEMENTED";
|
||||
}
|
||||
|
||||
@ -100,7 +102,9 @@ public:
|
||||
void onSelected(bool isSelected) const {
|
||||
if (this->callbacks.onSelected != nullptr) {
|
||||
this->callbacks.onSelected(context, isSelected);
|
||||
return;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +114,9 @@ public:
|
||||
void onButtonPressed(WUPSConfigButtons buttons) const {
|
||||
if (this->callbacks.onButtonPressed != nullptr) {
|
||||
this->callbacks.onButtonPressed(context, buttons);
|
||||
return;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,6 +129,7 @@ public:
|
||||
if (this->callbacks.isMovementAllowed != nullptr) {
|
||||
return this->callbacks.isMovementAllowed(context);
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -132,7 +139,9 @@ public:
|
||||
void restoreDefault() {
|
||||
if (this->callbacks.restoreDefault != nullptr) {
|
||||
this->callbacks.restoreDefault(context);
|
||||
return;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +173,9 @@ public:
|
||||
virtual ~WUPSConfigItem() {
|
||||
if (this->callbacks.onDelete != nullptr) {
|
||||
this->callbacks.onDelete(context);
|
||||
return;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED");
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -100,12 +100,12 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
|
||||
((void(*)(wups_loader_init_storage_args_t))((uint32_t *) func_ptr))(args);
|
||||
// clang-format on
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("######################################");
|
||||
DEBUG_FUNCTION_LINE("Hook is not implemented %s [%d]", hook_names[hook_type], hook_type);
|
||||
DEBUG_FUNCTION_LINE("######################################");
|
||||
DEBUG_FUNCTION_LINE_ERR("######################################");
|
||||
DEBUG_FUNCTION_LINE_ERR("Hook is not implemented %s [%d]", hook_names[hook_type], hook_type);
|
||||
DEBUG_FUNCTION_LINE_ERR("######################################");
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Failed to call hook. It was not defined");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to call hook. It was not defined");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ WUMS_APPLICATION_STARTS() {
|
||||
}
|
||||
#endif
|
||||
if (!PluginContainerPersistence::savePlugin(gPluginInformation, pluginContainer, gPluginDataHeap)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to save plugin");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to save plugin");
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,14 +164,14 @@ WUMS_APPLICATION_STARTS() {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Free plugin data buffer for %s [%08X on heap %08X]", plugin->meta.name, plugin->data.buffer, plugin->data.heapHandle);
|
||||
MEMFreeToExpHeap((MEMHeapHandle) plugin->data.heapHandle, plugin->data.buffer);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("########################");
|
||||
DEBUG_FUNCTION_LINE("Failed to free memory from plugin");
|
||||
DEBUG_FUNCTION_LINE("########################");
|
||||
DEBUG_FUNCTION_LINE_ERR("########################");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to free memory from plugin");
|
||||
DEBUG_FUNCTION_LINE_ERR("########################");
|
||||
}
|
||||
plugin->data.buffer = nullptr;
|
||||
plugin->data.bufferLength = 0;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Plugin %s has no copy of elf saved in memory, can't free it", plugin->meta.name);
|
||||
DEBUG_FUNCTION_LINE_ERR("Plugin %s has no copy of elf saved in memory, can't free it", plugin->meta.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,7 +183,7 @@ WUMS_APPLICATION_STARTS() {
|
||||
for (auto &pluginContainer : plugins) {
|
||||
DEBUG_FUNCTION_LINE("Stored information for plugin %s ; %s", pluginContainer->getMetaInformation()->getName().c_str(), pluginContainer->getMetaInformation()->getAuthor().c_str());
|
||||
if (!PluginContainerPersistence::savePlugin(gPluginInformation, pluginContainer, gPluginDataHeap)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to save plugin");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to save plugin");
|
||||
}
|
||||
}
|
||||
gLinkOnReload.loadOnReload = false;
|
||||
|
@ -4,16 +4,18 @@
|
||||
|
||||
dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_linking_relocation_data_t *data, const char *functionName) {
|
||||
if (data == nullptr) {
|
||||
DEBUG_FUNCTION_LINE_ERR("data was NULL");
|
||||
return nullptr;
|
||||
}
|
||||
if (functionName == nullptr) {
|
||||
DEBUG_FUNCTION_LINE_ERR("functionName was NULL");
|
||||
return nullptr;
|
||||
}
|
||||
dyn_linking_function_t *result = nullptr;
|
||||
for (auto &curEntry : data->functions) {
|
||||
if (strlen(curEntry.functionName) == 0) {
|
||||
if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to add function name, it's too long.");
|
||||
return nullptr;
|
||||
}
|
||||
strncpy(curEntry.functionName, functionName, DYN_LINK_FUNCTION_NAME_LENGTH);
|
||||
@ -44,7 +46,7 @@ dyn_linking_import_t *DynamicLinkingHelper::getOrAddImport(dyn_linking_relocatio
|
||||
for (auto &curEntry : data->imports) {
|
||||
if (strlen(curEntry.importName) == 0) {
|
||||
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to add Import, it's too long.");
|
||||
return nullptr;
|
||||
}
|
||||
strncpy(curEntry.importName, importName, DYN_LINK_IMPORT_NAME_LENGTH);
|
||||
@ -71,13 +73,13 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *link
|
||||
const std::string &name, const std::shared_ptr<ImportRPLInformation> &rplInfo) {
|
||||
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo->getName().c_str(), rplInfo->isData());
|
||||
if (importInfoGbl == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.", DYN_LINK_IMPORT_LIST_LENGTH);
|
||||
DEBUG_FUNCTION_LINE_ERR("Getting import info failed. Probably maximum of %d rpl files to import reached.", DYN_LINK_IMPORT_LIST_LENGTH);
|
||||
return false;
|
||||
}
|
||||
|
||||
dyn_linking_function_t *functionInfo = DynamicLinkingHelper::getOrAddFunctionEntryByName(linking_data, name.c_str());
|
||||
if (functionInfo == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d function to be relocated reached.", DYN_LINK_FUNCTION_LIST_LENGTH);
|
||||
DEBUG_FUNCTION_LINE_ERR("Getting import info failed. Probably maximum of %d function to be relocated reached.", DYN_LINK_FUNCTION_LIST_LENGTH);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -100,6 +102,6 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_entry_t *lin
|
||||
curEntry->importEntry = importInfo;
|
||||
return true;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Failed to find empty slot for saving relocations entry. We ned more than %d slots.", linking_entry_length);
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to find empty slot for saving relocations entry. We need more than %d slots.", linking_entry_length);
|
||||
return false;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
auto pluginName = plugin->getMetaInformation()->getName();
|
||||
|
||||
if (plugin_count >= MAXIMUM_PLUGINS - 1) {
|
||||
DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!", MAXIMUM_PLUGINS, pluginName.c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Maximum of %d plugins reached. %s won't be loaded!", MAXIMUM_PLUGINS, pluginName.c_str());
|
||||
return false;
|
||||
}
|
||||
// Copy data to global struct.
|
||||
@ -28,37 +28,37 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
auto plugin_meta_data = &plugin_data->meta;
|
||||
|
||||
if (pluginMetaInfo->getName().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Warning: name will be truncated.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: name will be truncated.");
|
||||
}
|
||||
strncpy(plugin_meta_data->name, pluginMetaInfo->getName().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
|
||||
if (pluginMetaInfo->getAuthor().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Warning: author will be truncated.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: author will be truncated.");
|
||||
}
|
||||
strncpy(plugin_meta_data->author, pluginMetaInfo->getAuthor().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
|
||||
|
||||
if (pluginMetaInfo->getVersion().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Warning: version will be truncated.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: version will be truncated.");
|
||||
}
|
||||
strncpy(plugin_meta_data->version, pluginMetaInfo->getVersion().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
|
||||
|
||||
if (pluginMetaInfo->getLicense().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Warning: license will be truncated.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: license will be truncated.");
|
||||
}
|
||||
strncpy(plugin_meta_data->license, pluginMetaInfo->getLicense().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
|
||||
|
||||
if (pluginMetaInfo->getBuildTimestamp().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Warning: build timestamp will be truncated.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: build timestamp will be truncated.");
|
||||
}
|
||||
strncpy(plugin_meta_data->buildTimestamp, pluginMetaInfo->getBuildTimestamp().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
|
||||
|
||||
if (pluginMetaInfo->getDescription().size() >= MAXIMUM_PLUGIN_DESCRIPTION_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Warning: description will be truncated.");
|
||||
DEBUG_FUNCTION_LINE("%s", pluginMetaInfo->getDescription().c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: description will be truncated.");
|
||||
DEBUG_FUNCTION_LINE_ERR("%s", pluginMetaInfo->getDescription().c_str());
|
||||
}
|
||||
strncpy(plugin_meta_data->descripion, pluginMetaInfo->getDescription().c_str(), MAXIMUM_PLUGIN_DESCRIPTION_LENGTH - 1);
|
||||
|
||||
if (pluginMetaInfo->getStorageId().length() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Warning: plugin storage id will be truncated.");
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: plugin storage id will be truncated.");
|
||||
}
|
||||
strncpy(plugin_meta_data->storageId, pluginMetaInfo->getStorageId().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
|
||||
|
||||
@ -70,7 +70,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
auto relocationData = pluginInfo->getRelocationDataList();
|
||||
for (auto &reloc : relocationData) {
|
||||
if (!DynamicLinkingHelper::addReloationEntry(&(pluginInformation->linking_data), plugin_data->info.linking_entries, PLUGIN_DYN_LINK_RELOCATION_LIST_LENGTH, reloc)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add a relocation entry");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to add a relocation entry");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -79,16 +79,16 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
auto 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);
|
||||
DEBUG_FUNCTION_LINE_ERR("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;
|
||||
}
|
||||
if (hook_data_list.size() > MAXIMUM_HOOKS_PER_PLUGIN) {
|
||||
DEBUG_FUNCTION_LINE("Plugin %s would set too many hooks (%d, maximum is %d). It won't be loaded.", pluginName.c_str(), hook_data_list.size(), MAXIMUM_HOOKS_PER_PLUGIN);
|
||||
DEBUG_FUNCTION_LINE_ERR("Plugin %s would set too many hooks (%d, maximum is %d). It won't be loaded.", pluginName.c_str(), hook_data_list.size(), MAXIMUM_HOOKS_PER_PLUGIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pluginName.length() > MAXIMUM_PLUGIN_NAME_LENGTH - 1) {
|
||||
DEBUG_FUNCTION_LINE("Name for plugin %s was too long to be stored.", pluginName.c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Name for plugin %s was too long to be stored.", pluginName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
for (auto &curFunction : pluginInfo->getFunctionDataList()) {
|
||||
function_replacement_data_t *function_data = &plugin_data->info.functions[i];
|
||||
if (strlen(curFunction->getName().c_str()) > MAXIMUM_FUNCTION_NAME_LENGTH - 1) {
|
||||
DEBUG_FUNCTION_LINE("Could not add function \"%s\" for plugin \"%s\" function name is too long.", curFunction->getName().c_str(), pluginName.c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Could not add function \"%s\" for plugin \"%s\" function name is too long.", curFunction->getName().c_str(), pluginName.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
if (foundFreeSlot) {
|
||||
auto *sectionInfo = &(plugin_data->info.sectionInfos[slot]);
|
||||
if (curSection.first.length() > MAXIMUM_PLUGIN_SECTION_NAME_LENGTH - 1) {
|
||||
DEBUG_FUNCTION_LINE("Could not add section info \"%s\" for plugin \"%s\" section name is too long.", curSection.first.c_str(), pluginName.c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Could not add section info \"%s\" for plugin \"%s\" section name is too long.", curSection.first.c_str(), pluginName.c_str());
|
||||
break;
|
||||
}
|
||||
strncpy(sectionInfo->name, curSection.first.c_str(), MAXIMUM_PLUGIN_SECTION_NAME_LENGTH - 1);
|
||||
@ -153,7 +153,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
sectionInfo->size = curSection.second->getSize();
|
||||
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Failed to store SectionInfos");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to store SectionInfos");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -171,7 +171,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
|
||||
char *stringTable = (char *) MEMAllocFromExpHeapEx(heapHandle, funcSymStringLen, 0x4);
|
||||
if (stringTable == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Failed alloc memory to store string table for function symbol data");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed alloc memory to store string table for function symbol data");
|
||||
return false;
|
||||
}
|
||||
memset(stringTable, 0, funcSymStringLen);
|
||||
@ -180,7 +180,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
if (entryTable == nullptr) {
|
||||
MEMFreeToExpHeap((MEMHeapHandle) heapHandle, stringTable);
|
||||
free(stringTable);
|
||||
DEBUG_FUNCTION_LINE("Failed alloc memory to store function symbol data");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed alloc memory to store function symbol data");
|
||||
return false;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Allocated %d for the function symbol data", entryCount * sizeof(plugin_function_symbol_data_t));
|
||||
@ -220,7 +220,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPlugins(plugin_information_t *pluginInformation) {
|
||||
std::vector<std::shared_ptr<PluginContainer>> result;
|
||||
if (pluginInformation == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("pluginInformation == nullptr");
|
||||
DEBUG_FUNCTION_LINE_ERR("pluginInformation == nullptr");
|
||||
return result;
|
||||
}
|
||||
DCFlushRange((void *) pluginInformation, sizeof(plugin_information_t));
|
||||
@ -228,7 +228,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
|
||||
int32_t plugin_count = pluginInformation->number_used_plugins;
|
||||
if (plugin_count > MAXIMUM_PLUGINS) {
|
||||
DEBUG_FUNCTION_LINE("pluginInformation->plugin_count was bigger then allowed. %d > %d. Limiting to %d", plugin_count, MAXIMUM_PLUGINS, MAXIMUM_PLUGINS);
|
||||
DEBUG_FUNCTION_LINE_ERR("pluginInformation->plugin_count was bigger then allowed. %d > %d. Limiting to %d", plugin_count, MAXIMUM_PLUGINS, MAXIMUM_PLUGINS);
|
||||
plugin_count = MAXIMUM_PLUGINS;
|
||||
}
|
||||
for (int32_t i = 0; i < plugin_count; i++) {
|
||||
@ -271,7 +271,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
uint32_t hookCount = plugin_data->info.number_used_hooks;
|
||||
|
||||
if (hookCount > MAXIMUM_HOOKS_PER_PLUGIN) {
|
||||
DEBUG_FUNCTION_LINE("number_used_hooks was bigger then allowed. %d > %d. Limiting to %d", hookCount, MAXIMUM_HOOKS_PER_PLUGIN, MAXIMUM_HOOKS_PER_PLUGIN);
|
||||
DEBUG_FUNCTION_LINE_ERR("number_used_hooks was bigger then allowed. %d > %d. Limiting to %d", hookCount, MAXIMUM_HOOKS_PER_PLUGIN, MAXIMUM_HOOKS_PER_PLUGIN);
|
||||
hookCount = MAXIMUM_HOOKS_PER_PLUGIN;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
}
|
||||
}
|
||||
if (!storageHasId) {
|
||||
DEBUG_FUNCTION_LINE("Plugin is using the storage API but has not set an ID");
|
||||
DEBUG_FUNCTION_LINE_ERR("Plugin is using the storage API but has not set an ID");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
uint32_t functionReplaceCount = plugin_data->info.number_used_functions;
|
||||
|
||||
if (functionReplaceCount > MAXIMUM_FUNCTION_PER_PLUGIN) {
|
||||
DEBUG_FUNCTION_LINE("number_used_functions was bigger then allowed. %d > %d. Limiting to %d", functionReplaceCount, MAXIMUM_FUNCTION_PER_PLUGIN, MAXIMUM_FUNCTION_PER_PLUGIN);
|
||||
DEBUG_FUNCTION_LINE_ERR("number_used_functions was bigger then allowed. %d > %d. Limiting to %d", functionReplaceCount, MAXIMUM_FUNCTION_PER_PLUGIN, MAXIMUM_FUNCTION_PER_PLUGIN);
|
||||
functionReplaceCount = MAXIMUM_FUNCTION_PER_PLUGIN;
|
||||
}
|
||||
|
||||
@ -315,13 +315,13 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
}
|
||||
dyn_linking_import_t *importEntry = linking_entry.importEntry;
|
||||
if (importEntry == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("importEntry was nullptr, skipping relocation entry");
|
||||
DEBUG_FUNCTION_LINE_ERR("importEntry was nullptr, skipping relocation entry");
|
||||
continue;
|
||||
}
|
||||
dyn_linking_function_t *functionEntry = linking_entry.functionEntry;
|
||||
|
||||
if (functionEntry == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("functionEntry was nullptr, skipping relocation entry");
|
||||
DEBUG_FUNCTION_LINE_ERR("functionEntry was nullptr, skipping relocation entry");
|
||||
continue;
|
||||
}
|
||||
auto rplInfo = std::make_shared<ImportRPLInformation>(importEntry->importName, importEntry->isData);
|
||||
|
@ -19,12 +19,12 @@ void PluginData::freeMemory() {
|
||||
switch (memoryType) {
|
||||
default:
|
||||
case eMemTypeExpHeap:
|
||||
DEBUG_FUNCTION_LINE("Free PluginData buffer %08X on heap %08X", buffer, this->heapHandle);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Free PluginData buffer %08X on heap %08X", buffer, this->heapHandle);
|
||||
MEMFreeToExpHeap(this->heapHandle, buffer);
|
||||
this->buffer = nullptr;
|
||||
break;
|
||||
case eMemTypeMEM2:
|
||||
DEBUG_FUNCTION_LINE("Free PluginData buffer %08X on default heap", buffer);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Free PluginData buffer %08X on default heap", buffer);
|
||||
free(this->buffer);
|
||||
this->buffer = nullptr;
|
||||
break;
|
||||
@ -44,7 +44,7 @@ PluginData::PluginData(const std::vector<uint8_t> &input, MEMHeapHandle heapHand
|
||||
data_copy = MEMAllocFromExpHeapEx(heapHandle, length, 4);
|
||||
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");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate space on exp heap");
|
||||
} else {
|
||||
memcpy(data_copy, &input[0], length);
|
||||
}
|
||||
@ -54,7 +54,7 @@ PluginData::PluginData(const std::vector<uint8_t> &input, MEMHeapHandle heapHand
|
||||
data_copy = memalign(4, length);
|
||||
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");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate space on default heap");
|
||||
} else {
|
||||
memcpy(data_copy, &input[0], length);
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ std::vector<std::shared_ptr<PluginData>> PluginDataFactory::loadDir(const std::s
|
||||
DIR *dfd;
|
||||
|
||||
if (path.empty()) {
|
||||
DEBUG_FUNCTION_LINE("Path was empty");
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Path was empty");
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((dfd = opendir(path.c_str())) == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Couldn't open dir %s", path.c_str());
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Couldn't open dir %s", path.c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ std::vector<std::shared_ptr<PluginData>> PluginDataFactory::loadDir(const std::s
|
||||
std::string full_file_path = StringTools::strfmt("%s/%s", path.c_str(), dp->d_name);
|
||||
StringTools::RemoveDoubleSlashs(full_file_path);
|
||||
if (stat(full_file_path.c_str(), &stbuf) == -1) {
|
||||
DEBUG_FUNCTION_LINE("Unable to stat file: %s", full_file_path.c_str());
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Unable to stat file: %s", full_file_path.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ std::optional<std::shared_ptr<PluginData>> PluginDataFactory::load(const std::st
|
||||
uint8_t *buffer = nullptr;
|
||||
uint32_t fsize = 0;
|
||||
if (FSUtils::LoadFileToMem(filename.c_str(), &buffer, &fsize) < 0) {
|
||||
DEBUG_FUNCTION_LINE("Failed to load file");
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Failed to load file");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -31,12 +31,12 @@ std::optional<std::shared_ptr<PluginInformation>>
|
||||
PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, MEMHeapHandle heapHandle, relocation_trampoline_entry_t *trampoline_data, uint32_t trampoline_data_length,
|
||||
uint8_t trampolineId) {
|
||||
if (pluginData->buffer == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Buffer was nullptr");
|
||||
DEBUG_FUNCTION_LINE_ERR("Buffer was nullptr");
|
||||
return std::nullopt;
|
||||
}
|
||||
elfio reader;
|
||||
if (!reader.load((char *) pluginData->buffer, pluginData->length)) {
|
||||
DEBUG_FUNCTION_LINE("Can't process PluginData in elfio");
|
||||
DEBUG_FUNCTION_LINE_ERR("Can't process PluginData in elfio");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@ -71,14 +71,14 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
}
|
||||
void *text_data = MEMAllocFromExpHeapEx(heapHandle, text_size, 0x1000);
|
||||
if (text_data == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Failed to alloc memory for the .text section (%d bytes)", text_size);
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .text section (%d bytes)", text_size);
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
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);
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .data section (%d bytes)", data_size);
|
||||
|
||||
MEMFreeToExpHeap(heapHandle, text_data);
|
||||
return std::nullopt;
|
||||
@ -110,7 +110,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
//destinations[psec->get_index()] = (uint8_t *) data_data;
|
||||
//destinations[psec->get_index()] -= 0xC0000000;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Unhandled case");
|
||||
DEBUG_FUNCTION_LINE_ERR("Unhandled case");
|
||||
free(destinations);
|
||||
MEMFreeToExpHeap(heapHandle, text_data);
|
||||
MEMFreeToExpHeap(heapHandle, data_data);
|
||||
@ -145,7 +145,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
|
||||
if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data, (uint32_t) data_data, trampoline_data, trampoline_data_length,
|
||||
trampolineId)) {
|
||||
DEBUG_FUNCTION_LINE("elfLink failed");
|
||||
DEBUG_FUNCTION_LINE_ERR("elfLink failed");
|
||||
free(destinations);
|
||||
MEMFreeToExpHeap(heapHandle, text_data);
|
||||
MEMFreeToExpHeap(heapHandle, data_data);
|
||||
@ -273,7 +273,7 @@ std::vector<std::shared_ptr<RelocationData>> PluginInformationFactory::getImport
|
||||
Elf_Half sym_section_index;
|
||||
|
||||
if (!rel.get_entry(j, offset, sym_value, sym_name, type, addend, sym_section_index)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to get relocation");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to get relocation");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ std::vector<std::shared_ptr<RelocationData>> PluginInformationFactory::getImport
|
||||
std::string rawSectionName = infoMap[sym_section_index];
|
||||
|
||||
if (rawSectionName.size() < fimport.size()) {
|
||||
DEBUG_FUNCTION_LINE("Section name was shorter than expected, skipping this relocation");
|
||||
DEBUG_FUNCTION_LINE_ERR("Section name was shorter than expected, skipping this relocation");
|
||||
continue;
|
||||
} else if (std::equal(fimport.begin(), fimport.end(), rawSectionName.begin())) {
|
||||
rplName = rawSectionName.substr(fimport.size());
|
||||
@ -299,7 +299,7 @@ std::vector<std::shared_ptr<RelocationData>> PluginInformationFactory::getImport
|
||||
rplName = rawSectionName.substr(dimport.size());
|
||||
isData = true;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("invalid section name");
|
||||
DEBUG_FUNCTION_LINE_ERR("invalid section name");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section
|
||||
Elf_Half sym_section_index;
|
||||
|
||||
if (!rel.get_entry(j, offset, sym_value, sym_name, type, addend, sym_section_index)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to get relocation");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to get relocation");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section
|
||||
} else if (adjusted_sym_value == 0x0) {
|
||||
//
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Unhandled case %08X", adjusted_sym_value);
|
||||
DEBUG_FUNCTION_LINE_ERR("Unhandled case %08X", adjusted_sym_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -366,13 +366,13 @@ bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section
|
||||
if (sym_section_index == SHN_ABS) {
|
||||
//
|
||||
} else if (sym_section_index > SHN_LORESERVE) {
|
||||
DEBUG_FUNCTION_LINE("NOT IMPLEMENTED: %04X", sym_section_index);
|
||||
DEBUG_FUNCTION_LINE_ERR("NOT IMPLEMENTED: %04X", sym_section_index);
|
||||
return false;
|
||||
}
|
||||
// DEBUG_FUNCTION_LINE_VERBOSE("sym_value %08X adjusted_sym_value %08X offset %08X adjusted_offset %08X", (uint32_t) sym_value, adjusted_sym_value, (uint32_t) offset, adjusted_offset);
|
||||
|
||||
if (!ElfUtils::elfLinkOne(type, adjusted_offset, addend, destination, adjusted_sym_value, trampoline_data, trampoline_data_length, RELOC_TYPE_FIXED, trampolineId)) {
|
||||
DEBUG_FUNCTION_LINE("Link failed");
|
||||
DEBUG_FUNCTION_LINE_ERR("Link failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -380,6 +380,6 @@ bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section
|
||||
return true;
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Failed to find relocation section");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to find relocation section");
|
||||
return true;
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ using namespace ELFIO;
|
||||
|
||||
std::optional<std::shared_ptr<PluginMetaInformation>> PluginMetaInformationFactory::loadPlugin(const std::shared_ptr<PluginData> &pluginData) {
|
||||
if (pluginData->buffer == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Buffer was nullptr");
|
||||
DEBUG_FUNCTION_LINE_ERR("Buffer was nullptr");
|
||||
return std::nullopt;
|
||||
}
|
||||
elfio reader;
|
||||
if (!reader.load((char *) pluginData->buffer, pluginData->length)) {
|
||||
DEBUG_FUNCTION_LINE("Can't process PluginData in elfio");
|
||||
DEBUG_FUNCTION_LINE_ERR("Can't process PluginData in elfio");
|
||||
return {};
|
||||
}
|
||||
return loadPlugin(reader);
|
||||
@ -44,12 +44,12 @@ std::optional<std::shared_ptr<PluginMetaInformation>> PluginMetaInformationFacto
|
||||
uint8_t *buffer = nullptr;
|
||||
uint32_t length = 0;
|
||||
if (FSUtils::LoadFileToMem(filePath.c_str(), &buffer, &length) < 0) {
|
||||
DEBUG_FUNCTION_LINE("Failed to load file to memory");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to load file to memory");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!reader.load((char *) buffer, length)) {
|
||||
DEBUG_FUNCTION_LINE("Can't process PluginData in elfio");
|
||||
DEBUG_FUNCTION_LINE_ERR("Can't process PluginData in elfio");
|
||||
return {};
|
||||
}
|
||||
auto res = loadPlugin(reader);
|
||||
@ -60,7 +60,7 @@ std::optional<std::shared_ptr<PluginMetaInformation>> PluginMetaInformationFacto
|
||||
std::optional<std::shared_ptr<PluginMetaInformation>> PluginMetaInformationFactory::loadPlugin(char *buffer, size_t size) {
|
||||
elfio reader;
|
||||
if (!reader.load(buffer, size)) {
|
||||
DEBUG_FUNCTION_LINE("Can't find or process ELF file");
|
||||
DEBUG_FUNCTION_LINE_ERR("Can't find or process ELF file");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ std::optional<std::shared_ptr<PluginMetaInformation>> PluginMetaInformationFacto
|
||||
pluginInfo->setStorageId(value);
|
||||
} else if (key == "wups") {
|
||||
if (value != "0.7.0") {
|
||||
DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ void ConfigUtils::displayMenu() {
|
||||
} else if (buttonsTriggered & VPAD_BUTTON_A) {
|
||||
currentCategory = cats[selectedBtn];
|
||||
if (currentCategory == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("BYEBYE");
|
||||
DEBUG_FUNCTION_LINE_ERR("currentCategory was NULL");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -597,18 +597,18 @@ void ConfigUtils::openConfigMenu() {
|
||||
if (storedTVBuffer.buffer_size >= screen_buf0_size) {
|
||||
screenbuffer0 = storedTVBuffer.buffer;
|
||||
skipScreen0Free = true;
|
||||
DEBUG_FUNCTION_LINE("Use storedTVBuffer");
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Use storedTVBuffer");
|
||||
}
|
||||
}
|
||||
if (screenbuffer1 == nullptr) {
|
||||
if (storedDRCBuffer.buffer_size >= screen_buf1_size) {
|
||||
screenbuffer1 = storedDRCBuffer.buffer;
|
||||
skipScreen1Free = true;
|
||||
DEBUG_FUNCTION_LINE("Use storedDRCBuffer");
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Use storedDRCBuffer");
|
||||
}
|
||||
}
|
||||
if (!screenbuffer0 || !screenbuffer1) {
|
||||
DEBUG_FUNCTION_LINE("Failed to alloc buffers");
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc buffers");
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
*((uint16_t *) (target)) = static_cast<uint16_t>((value + 0x8000) >> 16);
|
||||
break;
|
||||
case R_PPC_DTPMOD32:
|
||||
DEBUG_FUNCTION_LINE("################IMPLEMENT ME");
|
||||
DEBUG_FUNCTION_LINE_ERR("################IMPLEMENT ME");
|
||||
//*((int32_t *)(target)) = tlsModuleIndex;
|
||||
break;
|
||||
case R_PPC_DTPREL32:
|
||||
@ -50,18 +50,18 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
case R_PPC_REL14: {
|
||||
auto distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||
if (distance > 0x7FFC || distance < -0x7FFC) {
|
||||
DEBUG_FUNCTION_LINE("***14-bit relative branch cannot hit target.");
|
||||
DEBUG_FUNCTION_LINE_ERR("***14-bit relative branch cannot hit target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (distance & 3) {
|
||||
DEBUG_FUNCTION_LINE("***RELOC ERROR %d: lower 2 bits must be zero before shifting.", -470040);
|
||||
DEBUG_FUNCTION_LINE_ERR("***RELOC ERROR %d: lower 2 bits must be zero before shifting.", -470040);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((distance >= 0 && (distance & 0xFFFF8000)) ||
|
||||
(distance < 0 && ((distance & 0xFFFF8000) != 0xFFFF8000))) {
|
||||
DEBUG_FUNCTION_LINE("***RELOC ERROR %d: upper 17 bits before shift must all be the same.", -470040);
|
||||
DEBUG_FUNCTION_LINE_ERR("***RELOC ERROR %d: upper 17 bits before shift must all be the same.", -470040);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -76,8 +76,8 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
auto distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||
if (distance > 0x1FFFFFC || distance < -0x1FFFFFC) {
|
||||
if (trampoline_data == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampoline isn't provided");
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, distance);
|
||||
DEBUG_FUNCTION_LINE_ERR("***24-bit relative branch cannot hit target. Trampoline isn't provided");
|
||||
DEBUG_FUNCTION_LINE_ERR("***value %08X - target %08X = distance %08X", value, target, distance);
|
||||
return false;
|
||||
} else {
|
||||
relocation_trampoline_entry_t *freeSlot = nullptr;
|
||||
@ -95,13 +95,13 @@ 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. Trampoline data list is full");
|
||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, target - (uint32_t) & (freeSlot->trampoline[0]));
|
||||
DEBUG_FUNCTION_LINE_ERR("***24-bit relative branch cannot hit target. Trampoline data list is full");
|
||||
DEBUG_FUNCTION_LINE_ERR("***value %08X - target %08X = distance %08X", value, target, target - (uint32_t) & (freeSlot->trampoline[0]));
|
||||
return false;
|
||||
}
|
||||
if (target - (uint32_t) & (freeSlot->trampoline[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->trampoline[0])));
|
||||
DEBUG_FUNCTION_LINE_ERR("**Cannot link 24-bit jump (too far to tramp buffer).");
|
||||
DEBUG_FUNCTION_LINE_ERR("***value %08X - target %08X = distance %08X", value, target, (target - (uint32_t) & (freeSlot->trampoline[0])));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -129,17 +129,17 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
}
|
||||
|
||||
if (distance & 3) {
|
||||
DEBUG_FUNCTION_LINE("***RELOC ERROR %d: lower 2 bits must be zero before shifting.", -470022);
|
||||
DEBUG_FUNCTION_LINE_ERR("***RELOC ERROR %d: lower 2 bits must be zero before shifting.", -470022);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (distance < 0 && (distance & 0xFE000000) != 0xFE000000) {
|
||||
DEBUG_FUNCTION_LINE("***RELOC ERROR %d: upper 7 bits before shift must all be the same (1).", -470040);
|
||||
DEBUG_FUNCTION_LINE_ERR("***RELOC ERROR %d: upper 7 bits before shift must all be the same (1).", -470040);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (distance >= 0 && (distance & 0xFE000000)) {
|
||||
DEBUG_FUNCTION_LINE("***RELOC ERROR %d: upper 7 bits before shift must all be the same (0).", -470040);
|
||||
DEBUG_FUNCTION_LINE_ERR("***RELOC ERROR %d: upper 7 bits before shift must all be the same (0).", -470040);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DEBUG_FUNCTION_LINE("***ERROR: Unsupported Relocation_Add Type (%08X):", type);
|
||||
DEBUG_FUNCTION_LINE_ERR("***ERROR: Unsupported Relocation_Add Type (%08X):", type);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -43,7 +43,7 @@ static void processJson(wups_storage_item_t *items, nlohmann::json json) {
|
||||
processJson(item, it.value());
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Unknown type %s for value %s", it.value().type_name(), it.key().c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Unknown type %s for value %s", it.value().type_name(), it.key().c_str());
|
||||
}
|
||||
index++;
|
||||
}
|
||||
@ -102,7 +102,7 @@ static nlohmann::json processItems(wups_storage_item_t *items) {
|
||||
} else if (item->type == WUPS_STORAGE_TYPE_ITEM) {
|
||||
json[item->key] = processItems(item);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Saving type %d not implemented", item->type);
|
||||
DEBUG_FUNCTION_LINE_ERR("Saving type %d not implemented", item->type);
|
||||
}
|
||||
}
|
||||
return json;
|
||||
@ -120,7 +120,7 @@ int StorageUtils::CloseStorage(const char *plugin_id, wups_storage_item_t *items
|
||||
|
||||
CFile file(filePath, CFile::WriteOnly);
|
||||
if (!file.isOpen()) {
|
||||
DEBUG_FUNCTION_LINE("Cannot create file %s", filePath.c_str());
|
||||
DEBUG_FUNCTION_LINE_ERR("Cannot create file %s", filePath.c_str());
|
||||
return WUPS_STORAGE_ERROR_IO;
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,7 @@ extern "C" PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const plugin_da
|
||||
}
|
||||
DCFlushRange(&gLinkOnReload, sizeof(gLinkOnReload));
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
return PLUGIN_BACKEND_API_ERROR_NONE;
|
||||
@ -77,12 +77,12 @@ extern "C" PluginBackendApiErrorType WUPSLoadPluginAsData(GetPluginInformationIn
|
||||
}
|
||||
|
||||
if (!pluginData) {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC");
|
||||
return PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC;
|
||||
}
|
||||
|
||||
if (out == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
} else {
|
||||
auto *pluginDataHandle = new PluginData(*pluginData.value());
|
||||
@ -108,17 +108,17 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformation(GetPluginInfor
|
||||
} else if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_BUFFER && buffer != nullptr && size > 0) {
|
||||
pluginInfo = PluginMetaInformationFactory::loadPlugin(buffer, size);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!pluginInfo) {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND");
|
||||
return PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (output == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
} else {
|
||||
fillPluginInformation(output, pluginInfo.value());
|
||||
@ -144,7 +144,7 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const
|
||||
plugin_data_list[i] = (uint32_t) pluginData;
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
res = PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
return res;
|
||||
@ -168,7 +168,7 @@ extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_contain
|
||||
plugin_information_list[i].size = container->metaInformation->getSize();
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
res = PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
return res;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <coreinit/debug.h>
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
@ -31,6 +32,11 @@ extern "C" {
|
||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) \
|
||||
do { \
|
||||
WHBLogPrintf("[%23s]%30s@L%04d: ##ERROR## " FMT "\n", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
@ -39,6 +45,11 @@ extern "C" {
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) \
|
||||
do { \
|
||||
OSReport("[%23s]%30s@L%04d: ##ERROR## " FMT "\n", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
void initLogging();
|
||||
|
Loading…
Reference in New Issue
Block a user