Remove \n in log messages

This commit is contained in:
Maschell 2020-12-28 14:40:53 +01:00
parent 4ef9a90378
commit f7b4b568d2
9 changed files with 29 additions and 29 deletions

View File

@ -52,7 +52,7 @@ bool PluginManagement::doRelocation(const std::vector<RelocationData> &relocData
//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, trampolinID)) {
DEBUG_FUNCTION_LINE("Relocation failed\n");
DEBUG_FUNCTION_LINE("Relocation failed");
return false;
}
}

View File

@ -283,7 +283,7 @@ class section_impl : public section
ret = inflate(&s, Z_FINISH);
if (ret != Z_OK && ret != Z_STREAM_END){
DEBUG_FUNCTION_LINE("NOOOO\n");
DEBUG_FUNCTION_LINE("NOOOO");
}
inflateEnd(&s);
@ -301,7 +301,7 @@ class section_impl : public section
}
}else{
set_size(0);
DEBUG_FUNCTION_LINE("Failed to allocate memory.\n");
DEBUG_FUNCTION_LINE("Failed to allocate memory.");
}
}
}

View File

@ -56,8 +56,8 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
continue;
}
//DEBUG_FUNCTION_LINE("Checking hook functions for %s.\n",plugin_data->plugin_name);
//DEBUG_FUNCTION_LINE("Found hooks: %d\n",plugin_data->number_used_hooks);
//DEBUG_FUNCTION_LINE("Checking hook functions for %s.",plugin_data->plugin_name);
//DEBUG_FUNCTION_LINE("Found hooks: %d",plugin_data->number_used_hooks);
for (uint32_t j = 0; j < plugin_data->info.number_used_hooks; j++) {
replacement_data_hook_t *hook_data = &plugin_data->info.hooks[j];
if (hook_data->type == hook_type) {
@ -66,7 +66,7 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
}
void *func_ptr = hook_data->func_pointer;
if (func_ptr != nullptr) {
//DEBUG_FUNCTION_LINE("function pointer is %08x\n",func_ptr);
//DEBUG_FUNCTION_LINE("function pointer is %08x",func_ptr);
if (hook_type == WUPS_LOADER_HOOK_INIT_PLUGIN) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) {
@ -106,7 +106,7 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
DEBUG_FUNCTION_LINE("######################################");
}
} else {
DEBUG_FUNCTION_LINE("Failed to call hook. It was not defined\n");
DEBUG_FUNCTION_LINE("Failed to call hook. It was not defined");
}
}
}

View File

@ -14,7 +14,7 @@ dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_li
dyn_linking_function_t *curEntry = &(data->functions[i]);
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.\n");
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long.");
return nullptr;
}
strncpy(curEntry->functionName, functionName, DYN_LINK_FUNCTION_NAME_LENGTH);
@ -46,7 +46,7 @@ dyn_linking_import_t *DynamicLinkingHelper::getOrAddImport(dyn_linking_relocatio
dyn_linking_import_t *curEntry = &(data->imports[i]);
if (strlen(curEntry->importName) == 0) {
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.\n");
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.");
return nullptr;
}
strncpy(curEntry->importName, importName, DYN_LINK_IMPORT_NAME_LENGTH);
@ -70,13 +70,13 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *link
const std::string &name, const 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.\n", 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);
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.\n", DYN_LINK_FUNCTION_LIST_LENGTH);
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d function to be relocated reached.", DYN_LINK_FUNCTION_LIST_LENGTH);
return false;
}

View File

@ -17,7 +17,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
//auto pluginPath = plugin.getMetaInformation().getPath();
if (plugin_count >= MAXIMUM_PLUGINS - 1) {
DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!\n", MAXIMUM_PLUGINS, pluginName.c_str());
DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!", MAXIMUM_PLUGINS, pluginName.c_str());
return false;
}
// Copy data to global struct.

View File

@ -28,12 +28,12 @@ std::vector<PluginData> PluginDataFactory::loadDir(const std::string &path, MEMH
DIR *dfd = nullptr;
if (path.empty()) {
DEBUG_FUNCTION_LINE("Path was empty\n");
DEBUG_FUNCTION_LINE("Path was empty");
return result;
}
if ((dfd = opendir(path.c_str())) == nullptr) {
DEBUG_FUNCTION_LINE("Couldn't open dir %s\n", path.c_str());
DEBUG_FUNCTION_LINE("Couldn't open dir %s", path.c_str());
return result;
}
@ -42,14 +42,14 @@ std::vector<PluginData> PluginDataFactory::loadDir(const std::string &path, MEMH
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\n", full_file_path.c_str());
DEBUG_FUNCTION_LINE("Unable to stat file: %s", full_file_path.c_str());
continue;
}
if ((stbuf.st_mode & S_IFMT) == S_IFDIR) { // Skip directories
continue;
} else {
DEBUG_FUNCTION_LINE("Found file: %s\n", full_file_path.c_str());
DEBUG_FUNCTION_LINE("Found file: %s", full_file_path.c_str());
auto pluginData = load(full_file_path, heapHandle);
if (pluginData) {
result.push_back(pluginData.value());

View File

@ -75,14 +75,14 @@ std::optional<PluginInformation> PluginInformationFactory::load(const PluginData
}
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)\n", text_size);
DEBUG_FUNCTION_LINE("Failed to alloc memory for the .text section (%d bytes)", text_size);
return std::nullopt;
}
DEBUG_FUNCTION_LINE("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)\n", data_size);
DEBUG_FUNCTION_LINE("Failed to alloc memory for the .data section (%d bytes)", data_size);
MEMFreeToExpHeap(heapHandle, text_data);
return std::nullopt;
@ -266,7 +266,7 @@ std::vector<RelocationData> PluginInformationFactory::getImportRelocationData(co
rplName = rawSectionName.substr(dimport.size());
isData = true;
} else {
DEBUG_FUNCTION_LINE("invalid section name\n");
DEBUG_FUNCTION_LINE("invalid section name");
continue;
}

View File

@ -43,7 +43,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::string &filePath) {
elfio reader;
if (!reader.load(filePath)) {
DEBUG_FUNCTION_LINE("Can't find or process ELF file\n");
DEBUG_FUNCTION_LINE("Can't find or process ELF file");
return std::nullopt;
}
return loadPlugin(reader);
@ -52,7 +52,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(st
std::optional<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\n");
DEBUG_FUNCTION_LINE("Can't find or process ELF file");
return std::nullopt;
}
@ -115,7 +115,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
pluginInfo.setDescription(value);
} else if (key.compare("wups") == 0) {
if (value.compare("0.2") != 0) {
DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.\n", value.c_str());
DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
return std::nullopt;
}
}

View File

@ -34,7 +34,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\n");
DEBUG_FUNCTION_LINE("################IMPLEMENT ME");
//*((int32_t *)(target)) = tlsModuleIndex;
break;
case R_PPC_DTPREL32:
@ -78,8 +78,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 (trampolin_data == NULL) {
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin isn't provided\n");
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, distance);
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin isn't provided");
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, distance);
return false;
} else {
relocation_trampolin_entry_t *freeSlot = NULL;
@ -97,13 +97,13 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
}
}
if (freeSlot != NULL) {
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full\n");
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, distance);
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full");
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, distance);
return false;
}
if (target - (uint32_t) &(freeSlot->trampolin[0]) > 0x1FFFFFC) {
DEBUG_FUNCTION_LINE("**Cannot link 24-bit jump (too far to tramp buffer).");
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, distance);
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, distance);
return false;
}
@ -129,7 +129,7 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
uint32_t symbolValue = (uint32_t) &(freeSlot->trampolin[0]);
value = symbolValue + addend;
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
DEBUG_FUNCTION_LINE("Created tramp\n");
DEBUG_FUNCTION_LINE("Created tramp");
}
}