Update module_information_t struct

This commit is contained in:
Maschell 2022-05-07 20:42:31 +02:00
parent 4abbcbf848
commit 4ab8bccd5e
4 changed files with 110 additions and 103 deletions

View File

@ -1,19 +1,19 @@
/**************************************************************************** /****************************************************************************
* Copyright (C) 2018 Maschell * Copyright (C) 2022 Maschell
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
@ -25,37 +25,21 @@
extern "C" { extern "C" {
#endif #endif
#define DYN_LINK_FUNCTION_NAME_LENGTH 351 // clang-format off
#define DYN_LINK_IMPORT_NAME_LENGTH 50
#define DYN_LINK_FUNCTION_LIST_LENGTH 500
#define DYN_LINK_IMPORT_LIST_LENGTH 50
#define DYN_LINK_TRAMPOLINE_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 { typedef struct _dyn_linking_import_t {
char importName[DYN_LINK_IMPORT_NAME_LENGTH + 1]; const char * importName;
bool isData; bool isData;
} dyn_linking_import_t; } dyn_linking_import_t;
typedef struct _dyn_linking_relocation_entry_t { typedef struct _dyn_linking_relocation_entry_t {
dyn_linking_function_t *functionEntry; const char * functionName;
dyn_linking_import_t *importEntry; dyn_linking_import_t * importEntry;
void *destination; void * destination;
char type; char type;
size_t offset; size_t offset;
int32_t addend; int32_t addend;
} dyn_linking_relocation_entry_t; } dyn_linking_relocation_entry_t;
// clang-format on
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 #ifdef __cplusplus
} }

View File

@ -1,10 +1,28 @@
/****************************************************************************
* Copyright (C) 2022 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 #pragma once
#include <stdint.h> #include <stdint.h>
#define EXPORT_MAXIMUM_NAME_LENGTH 50 // clang-format off
typedef struct export_data_t { typedef struct export_data_t {
uint32_t type; uint32_t type;
char name[EXPORT_MAXIMUM_NAME_LENGTH]; const char * name;
uint32_t address; uint32_t address;
} export_data_t; } export_data_t;
// clang-format on

View File

@ -1,19 +1,19 @@
/**************************************************************************** /****************************************************************************
* Copyright (C) 2018-2019 Maschell * Copyright (C) 2022 Maschell
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
@ -27,59 +27,45 @@
extern "C" { extern "C" {
#endif #endif
#define MAXIMUM_MODULE_PATH_NAME_LENGTH 256 // clang-format off
#define MAXIMUM_EXPORT_MODULE_NAME_LENGTH 51
#define FUNCTION_SYMBOL_LIST_LENGTH 50000
#define DYN_LINK_RELOCATION_LIST_LENGTH 500
#define EXPORT_ENTRY_LIST_LENGTH 100
#define HOOK_ENTRY_LIST_LENGTH 20
typedef struct hook_data_t { typedef struct hook_data_t {
uint32_t type; uint32_t type;
uint32_t target; uint32_t target;
} hook_data_t; } hook_data_t;
typedef struct module_function_symbol_data_t { typedef struct module_function_symbol_data_t {
char *name; const char * name;
void *address; void * address;
uint32_t size; uint32_t size;
} module_function_symbol_data_t; } module_function_symbol_data_t;
// clang-format off
typedef struct module_information_single_t { typedef 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_linking_relocation_entry_t linking_entries[DYN_LINK_RELOCATION_LIST_LENGTH]; uint32_t number_linking_entries;
char module_export_name[MAXIMUM_EXPORT_MODULE_NAME_LENGTH]; const char * module_export_name;
export_data_t export_entries[EXPORT_ENTRY_LIST_LENGTH]; export_data_t * export_entries;
hook_data_t hook_entries[HOOK_ENTRY_LIST_LENGTH]; uint32_t number_export_entries;
int32_t priority; // Priority of this module hook_data_t * hook_entries;
uint32_t bssAddr; uint32_t number_hook_entries;
uint32_t bssSize; uint32_t bssAddr;
uint32_t sbssAddr; uint32_t bssSize;
uint32_t sbssSize; uint32_t sbssAddr;
uint32_t entrypoint; uint32_t sbssSize;
uint32_t startAddress; uint32_t startAddress;
uint32_t endAddress; uint32_t endAddress;
uint8_t skipInitFini; uint32_t entrypoint;
uint8_t initBeforeRelocationDoneHook; uint8_t skipInitFini;
module_function_symbol_data_t * function_symbol_entries; uint8_t initBeforeRelocationDoneHook;
uint32_t number_used_function_symbols; module_function_symbol_data_t * function_symbol_entries;
uint32_t number_function_symbols;
} module_information_single_t; } module_information_single_t;
// clang-format on
#define MAXIMUM_MODULES 32 #define MODULE_INFORMATION_VERSION 0x0000000D
#define MODULE_INFORMATION_VERSION 0x00000007
// clang-format off
typedef struct module_information_t { typedef struct module_information_t {
uint32_t version; uint32_t version;
int32_t number_used_modules; // Number of used function. Maximum is MAXIMUM_MODULES uint32_t number_modules;
dyn_linking_relocation_data_t linking_data; module_information_single_t * modules;
relocation_trampoline_entry_t trampolines[DYN_LINK_TRAMPOLINE_LIST_LENGTH];
module_function_symbol_data_t function_symbols[FUNCTION_SYMBOL_LIST_LENGTH];
uint32_t number_used_function_symbols;
module_information_single_t module_data[MAXIMUM_MODULES];
} module_information_t; } module_information_t;
// clang-format on // clang-format on

View File

@ -1,7 +1,25 @@
/****************************************************************************
* Copyright (C) 2022 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 #pragma once
#include <stdint.h> #include <stdint.h>
// clang-format off
typedef enum RelocationTrampolineStatus { typedef enum RelocationTrampolineStatus {
RELOC_TRAMP_FREE = 0, RELOC_TRAMP_FREE = 0,
RELOC_TRAMP_FIXED = 1, RELOC_TRAMP_FIXED = 1,
@ -15,7 +33,8 @@ typedef enum RelocationType {
} RelocationType; } RelocationType;
typedef struct relocation_trampoline_entry_t { typedef struct relocation_trampoline_entry_t {
uint32_t id; uint32_t id;
uint32_t trampoline[4]; uint32_t trampoline[4];
RelocationTrampolineStatus status; RelocationTrampolineStatus status;
} relocation_trampoline_entry_t; } relocation_trampoline_entry_t;
// clang-format on