2020-04-29 18:02:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-09-25 14:26:18 +02:00
|
|
|
#include <cstddef>
|
2022-02-04 16:25:44 +01:00
|
|
|
#include <cstdint>
|
2020-06-06 16:40:25 +02:00
|
|
|
#include <wums/defines/dynamic_linking_defines.h>
|
|
|
|
#include <wums/defines/export_defines.h>
|
|
|
|
#include <wums/defines/relocation_defines.h>
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2020-06-13 16:57:53 +02:00
|
|
|
#include <function_patcher/function_patching.h>
|
2022-02-11 22:18:15 +01:00
|
|
|
#include <wups/hooks.h>
|
2020-06-13 16:57:53 +02:00
|
|
|
|
2020-04-29 18:02:36 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-02-04 16:25:44 +01:00
|
|
|
#define MAXIMUM_PLUGIN_SECTION_LENGTH 10
|
|
|
|
#define MAXIMUM_PLUGIN_SECTION_NAME_LENGTH 20
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2022-02-04 16:25:44 +01:00
|
|
|
#define MAXIMUM_PLUGIN_PATH_NAME_LENGTH 256
|
|
|
|
#define MAXIMUM_PLUGIN_NAME_LENGTH 51
|
|
|
|
#define MAXIMUM_PLUGIN_DESCRIPTION_LENGTH 100
|
|
|
|
#define MAXIMUM_PLUGIN_META_FIELD_LENGTH 51
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2022-02-04 16:25:44 +01:00
|
|
|
#define PLUGIN_DYN_LINK_RELOCATION_LIST_LENGTH 1000
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2022-02-04 16:25:44 +01:00
|
|
|
#define MAXIMUM_HOOKS_PER_PLUGIN 25
|
|
|
|
#define MAXIMUM_FUNCTION_PER_PLUGIN 100
|
2020-04-29 18:02:36 +02:00
|
|
|
|
|
|
|
struct plugin_section_info_t {
|
2021-04-01 00:37:22 +02:00
|
|
|
char name[MAXIMUM_PLUGIN_SECTION_NAME_LENGTH] = "";
|
2021-09-25 14:26:18 +02:00
|
|
|
uint32_t addr{};
|
|
|
|
uint32_t size{};
|
2020-04-29 18:02:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct plugin_meta_info_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
char name[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
|
|
|
|
char author[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
|
|
|
|
char version[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
|
|
|
|
char license[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
|
|
|
|
char buildTimestamp[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
|
|
|
|
char descripion[MAXIMUM_PLUGIN_DESCRIPTION_LENGTH] = "";
|
|
|
|
char storageId[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
|
|
|
|
uint32_t size{};
|
2020-04-29 18:02:36 +02:00
|
|
|
};
|
|
|
|
|
2020-06-13 16:57:53 +02:00
|
|
|
struct replacement_data_hook_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
void *func_pointer = nullptr; /* [will be filled] */
|
|
|
|
wups_loader_hook_type_t type{}; /* [will be filled] */
|
2020-06-13 16:57:53 +02:00
|
|
|
};
|
|
|
|
|
2021-12-15 17:04:30 +01:00
|
|
|
struct plugin_function_symbol_data_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
char *name;
|
|
|
|
void *address;
|
2021-12-15 17:04:30 +01:00
|
|
|
uint32_t size;
|
|
|
|
};
|
|
|
|
|
2020-04-29 18:02:36 +02:00
|
|
|
struct plugin_info_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
dyn_linking_relocation_entry_t linking_entries[PLUGIN_DYN_LINK_RELOCATION_LIST_LENGTH]{};
|
|
|
|
plugin_section_info_t sectionInfos[MAXIMUM_PLUGIN_SECTION_LENGTH];
|
|
|
|
uint32_t number_used_functions{}; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
|
|
|
|
function_replacement_data_t functions[MAXIMUM_FUNCTION_PER_PLUGIN]{}; // Replacement information for each function.
|
|
|
|
uint32_t number_used_hooks{}; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_PLUGIN
|
|
|
|
replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function.
|
|
|
|
uint8_t trampolineId{};
|
|
|
|
plugin_function_symbol_data_t *function_symbol_data = nullptr;
|
|
|
|
uint32_t number_function_symbol_data = 0;
|
|
|
|
void *allocatedTextMemoryAddress = nullptr;
|
|
|
|
void *allocatedDataMemoryAddress = nullptr;
|
|
|
|
void *allocatedFuncSymStringTableAddress = nullptr;
|
2020-04-29 18:02:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct plugin_data_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
char *buffer = nullptr;
|
|
|
|
size_t bufferLength = 0;
|
|
|
|
int memoryType = 0;
|
|
|
|
int heapHandle = 0;
|
2020-04-29 18:02:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct plugin_information_single_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
plugin_meta_info_t meta;
|
|
|
|
plugin_info_t info;
|
|
|
|
plugin_data_t data;
|
|
|
|
int32_t priority{}; // Priority of this plugin
|
2020-04-29 18:02:36 +02:00
|
|
|
};
|
|
|
|
|
2022-02-04 16:25:44 +01:00
|
|
|
#define MAXIMUM_PLUGINS 32
|
2020-04-29 18:02:36 +02:00
|
|
|
|
|
|
|
struct plugin_information_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
int32_t number_used_plugins = 0; // Number of used plugins. Maximum is MAXIMUM_PLUGINS
|
|
|
|
plugin_information_single_t plugin_data[MAXIMUM_PLUGINS];
|
|
|
|
dyn_linking_relocation_data_t linking_data{}; // RPL and function name list
|
2020-04-29 18:02:36 +02:00
|
|
|
};
|
|
|
|
|
2020-05-17 20:49:31 +02:00
|
|
|
struct plugin_information_on_reload_t {
|
2022-02-04 16:25:44 +01:00
|
|
|
int32_t number_used_plugins = 0; // Number of used plugins. Maximum is MAXIMUM_PLUGINS
|
|
|
|
plugin_data_t plugin_data[MAXIMUM_PLUGINS];
|
|
|
|
bool loadOnReload = false;
|
2020-05-17 20:49:31 +02:00
|
|
|
};
|
|
|
|
|
2020-04-29 18:02:36 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|