diff --git a/relocator/src/DynamicLinkingHelper.cpp b/relocator/src/DynamicLinkingHelper.cpp index 1b5dc9c..0812586 100644 --- a/relocator/src/DynamicLinkingHelper.cpp +++ b/relocator/src/DynamicLinkingHelper.cpp @@ -3,7 +3,6 @@ #include #include #include "utils/logger.h" -#include "../../source/common/module_defines.h" dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_linking_relocation_data_t *data, const char *functionName) { if (data == NULL) { diff --git a/relocator/src/DynamicLinkingHelper.h b/relocator/src/DynamicLinkingHelper.h index ce08c4f..1938bc6 100644 --- a/relocator/src/DynamicLinkingHelper.h +++ b/relocator/src/DynamicLinkingHelper.h @@ -1,6 +1,6 @@ #pragma once -#include "../../source/common/dynamic_linking_defines.h" +#include #include "utils/logger.h" #include #include diff --git a/relocator/src/ElfUtils.h b/relocator/src/ElfUtils.h index 044701e..7a51ca0 100644 --- a/relocator/src/ElfUtils.h +++ b/relocator/src/ElfUtils.h @@ -1,7 +1,7 @@ #pragma once #include -#include "../../source/common/relocation_defines.h" +#include #ifdef __cplusplus extern "C" { diff --git a/relocator/src/ModuleDataPersistence.cpp b/relocator/src/ModuleDataPersistence.cpp index ec372f8..689cf58 100644 --- a/relocator/src/ModuleDataPersistence.cpp +++ b/relocator/src/ModuleDataPersistence.cpp @@ -1,6 +1,5 @@ #include "ModuleDataPersistence.h" #include "DynamicLinkingHelper.h" -#include "../../source/common/module_defines.h" #include "../../source/module/ModuleData.h" #include "../../source/module/RelocationData.h" #include diff --git a/relocator/src/ModuleDataPersistence.h b/relocator/src/ModuleDataPersistence.h index 142d4bb..b73a3cd 100644 --- a/relocator/src/ModuleDataPersistence.h +++ b/relocator/src/ModuleDataPersistence.h @@ -1,6 +1,6 @@ #pragma once -#include "../../source/common/module_defines.h" +#include #include "../../source/module/ModuleData.h" class ModuleDataPersistence { diff --git a/relocator/src/entry.cpp b/relocator/src/entry.cpp index b95039d..21f1673 100644 --- a/relocator/src/entry.cpp +++ b/relocator/src/entry.cpp @@ -8,13 +8,10 @@ #include #include #include -#include "../../source/common/dynamic_linking_defines.h" -#include "../../source/common/module_defines.h" #include "../../source/module/RelocationData.h" #include "../../source/module/ModuleData.h" #include "ModuleDataPersistence.h" #include "ElfUtils.h" -#include "../../source/common/relocation_defines.h" #include "kernel/kernel_utils.h" #include "hooks_patcher_static.h" diff --git a/relocator/src/hooks.cpp b/relocator/src/hooks.cpp index c02503b..1e1ad6f 100644 --- a/relocator/src/hooks.cpp +++ b/relocator/src/hooks.cpp @@ -1,4 +1,3 @@ -#include "../../source/common/module_defines.h" #include #include "hooks.h" #include "utils/logger.h" diff --git a/relocator/src/hooks_patcher_static.cpp b/relocator/src/hooks_patcher_static.cpp index ebf6ea9..812f27a 100644 --- a/relocator/src/hooks_patcher_static.cpp +++ b/relocator/src/hooks_patcher_static.cpp @@ -1,6 +1,6 @@ #include "utils/logger.h" #include "utils/function_patcher.h" -#include "../../source/common/module_defines.h" +#include #include "globals.h" #include #include diff --git a/source/ElfUtils.h b/source/ElfUtils.h index e8d6fce..ecf1959 100644 --- a/source/ElfUtils.h +++ b/source/ElfUtils.h @@ -2,7 +2,7 @@ #include #include -#include "common/relocation_defines.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/common/dynamic_linking_defines.h b/source/common/dynamic_linking_defines.h deleted file mode 100644 index 716936a..0000000 --- a/source/common/dynamic_linking_defines.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2018 Maschell - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - ****************************************************************************/ - -#pragma once - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define DYN_LINK_FUNCTION_NAME_LENGTH 351 -#define DYN_LINK_IMPORT_NAME_LENGTH 50 - -#define DYN_LINK_FUNCTION_LIST_LENGTH 500 -#define DYN_LINK_IMPORT_LIST_LENGTH 50 - -#define DYN_LINK_TRAMPOLIN_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH - -typedef struct _dyn_linking_function_t { - char functionName[DYN_LINK_FUNCTION_NAME_LENGTH + 1]; - void *address; -} dyn_linking_function_t; - -typedef struct _dyn_linking_import_t { - char importName[DYN_LINK_IMPORT_NAME_LENGTH + 1]; - bool isData = false; -} dyn_linking_import_t; - -typedef struct _dyn_linking_relocation_entry_t { - dyn_linking_function_t *functionEntry = NULL; - dyn_linking_import_t *importEntry = NULL; - void *destination = NULL; - char type; - size_t offset; - int32_t addend; -} dyn_linking_relocation_entry_t; - -typedef struct _dyn_linking_relocation_data_t { - dyn_linking_function_t functions[DYN_LINK_FUNCTION_LIST_LENGTH]; - dyn_linking_import_t imports[DYN_LINK_IMPORT_LIST_LENGTH]; -} dyn_linking_relocation_data_t; - -#ifdef __cplusplus -} -#endif diff --git a/source/common/export_defines.h b/source/common/export_defines.h deleted file mode 100644 index 6b007c7..0000000 --- a/source/common/export_defines.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include - -#define EXPORT_MAXIMUM_NAME_LENGTH 50 -typedef struct export_data_t { - uint32_t type; - char name[EXPORT_MAXIMUM_NAME_LENGTH]; - uint32_t address = 0; -} export_data_t; \ No newline at end of file diff --git a/source/common/module_defines.h b/source/common/module_defines.h deleted file mode 100644 index 219742d..0000000 --- a/source/common/module_defines.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2018-2019 Maschell - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - ****************************************************************************/ - -#pragma once - -#include -#include -#include "dynamic_linking_defines.h" -#include "relocation_defines.h" -#include "export_defines.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAXIMUM_MODULE_PATH_NAME_LENGTH 256 -#define MAXIMUM_EXPORT_MODULE_NAME_LENGTH 51 - -#define DYN_LINK_RELOCATION_LIST_LENGTH 500 -#define EXPORT_ENTRY_LIST_LENGTH 100 -#define HOOK_ENTRY_LIST_LENGTH 10 - -typedef struct hook_data_t { - uint32_t type; - uint32_t target = 0; -} hook_data_t; - -struct module_information_single_t { - char path[MAXIMUM_MODULE_PATH_NAME_LENGTH] = ""; // Path where the module is stored - dyn_linking_relocation_entry_t linking_entries[DYN_LINK_RELOCATION_LIST_LENGTH]; - char module_export_name[MAXIMUM_EXPORT_MODULE_NAME_LENGTH]; - export_data_t export_entries[EXPORT_ENTRY_LIST_LENGTH]; - hook_data_t hook_entries[HOOK_ENTRY_LIST_LENGTH]; - int32_t priority; // Priority of this module - uint32_t bssAddr; - uint32_t bssSize; - uint32_t sbssAddr; - uint32_t sbssSize; - uint32_t entrypoint; - uint32_t startAddress; - uint32_t endAddress; -}; - -#define MAXIMUM_MODULES 8 - -struct module_information_t { - int32_t number_used_modules = 0; // Number of used function. Maximum is MAXIMUM_MODULES - dyn_linking_relocation_data_t linking_data; - relocation_trampolin_entry_t trampolines[DYN_LINK_TRAMPOLIN_LIST_LENGTH]; - module_information_single_t module_data[MAXIMUM_MODULES]; -}; - -#ifdef __cplusplus -} -#endif diff --git a/source/common/relocation_defines.h b/source/common/relocation_defines.h deleted file mode 100644 index 5efdf79..0000000 --- a/source/common/relocation_defines.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include - -typedef enum RelocationTrampolinStatus{ - RELOC_TRAMP_FREE = 0, - RELOC_TRAMP_FIXED = 1, - RELOC_TRAMP_IMPORT_IN_PROGRESS = 2, - RELOC_TRAMP_IMPORT_DONE = 3, -} RelocationTrampolinStatus; - -typedef enum RelocationType{ - RELOC_TYPE_FIXED = 0, - RELOC_TYPE_IMPORT = 1 -} RelocationType; - -typedef struct relocation_trampolin_entry_t { - uint32_t id; - uint32_t trampolin[4]; - RelocationTrampolinStatus status = RELOC_TRAMP_FREE; -} relocation_trampolin_entry_t; diff --git a/source/main.cpp b/source/main.cpp index 3440c68..b8ec097 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -22,8 +22,6 @@ #include "ElfUtils.h" #include "kernel.h" -#include "common/module_defines.h" - bool CheckRunning() { switch (ProcUIProcessMessages(true)) { diff --git a/source/module/DynamicLinkingHelper.cpp b/source/module/DynamicLinkingHelper.cpp index 501cca2..1cdb4a2 100644 --- a/source/module/DynamicLinkingHelper.cpp +++ b/source/module/DynamicLinkingHelper.cpp @@ -4,7 +4,6 @@ #include #include #include "utils/logger.h" -#include "common/module_defines.h" dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_linking_relocation_data_t *data, const char *functionName) { if (data == NULL) { diff --git a/source/module/DynamicLinkingHelper.h b/source/module/DynamicLinkingHelper.h index 4dfa5eb..016682e 100644 --- a/source/module/DynamicLinkingHelper.h +++ b/source/module/DynamicLinkingHelper.h @@ -1,6 +1,6 @@ #pragma once -#include "common/dynamic_linking_defines.h" +#include #include "utils/logger.h" #include #include diff --git a/source/module/ModuleDataFactory.h b/source/module/ModuleDataFactory.h index 685cfef..e930710 100644 --- a/source/module/ModuleDataFactory.h +++ b/source/module/ModuleDataFactory.h @@ -20,7 +20,7 @@ #include #include #include -#include "common/relocation_defines.h" +#include #include "ModuleData.h" #include "elfio/elfio.hpp" diff --git a/source/module/ModuleDataPersistence.cpp b/source/module/ModuleDataPersistence.cpp index 3328d63..e821d69 100644 --- a/source/module/ModuleDataPersistence.cpp +++ b/source/module/ModuleDataPersistence.cpp @@ -2,7 +2,6 @@ #include "ModuleDataPersistence.h" #include "DynamicLinkingHelper.h" -#include "common/module_defines.h" #include "ModuleData.h" #include "RelocationData.h" diff --git a/source/module/ModuleDataPersistence.h b/source/module/ModuleDataPersistence.h index 9506c2f..85959c7 100644 --- a/source/module/ModuleDataPersistence.h +++ b/source/module/ModuleDataPersistence.h @@ -1,6 +1,6 @@ #pragma once -#include "common/module_defines.h" +#include #include "ModuleData.h" class ModuleDataPersistence {