45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
#pragma once
|
|
|
|
#include "memmap.h"
|
|
#include "symbols.h"
|
|
#include "types.h"
|
|
#include "vector.h"
|
|
|
|
struct HiloadContext;
|
|
|
|
typedef enum {
|
|
HI_MODULE_STATE_ENABLED = (1 << 0),
|
|
HI_MODULE_STATE_DIRTY = (1 << 1),
|
|
HI_MODULE_STATE_PATCHABLE = (1 << 6), // non system module we will modify
|
|
HI_MODULE_STATE_EXEC = (1 << 7), // denote the current executable
|
|
} ModuleFlags;
|
|
|
|
typedef u32 ModuleInfo;
|
|
typedef struct {
|
|
/// Owning. Filename for the module.
|
|
const char *name;
|
|
/// Handle given by dlopen
|
|
void *dlhandle;
|
|
/// Start address for the module
|
|
uptr address;
|
|
/// Additional information, see @a ModuleFlags
|
|
ModuleInfo info;
|
|
} ModuleData;
|
|
|
|
vector_def(ModuleData, ModuleData);
|
|
|
|
static inline ModuleInfo modinfo_add(ModuleInfo flags, ModuleFlags flag) {
|
|
return flags | flag;
|
|
}
|
|
static inline ModuleInfo modinfo_clear(ModuleInfo flags, ModuleFlags flag) {
|
|
return flags & ~flag;
|
|
}
|
|
static inline bool modinfo_has(ModuleInfo flags, ModuleFlags flag) {
|
|
return (flags & flag) != 0;
|
|
}
|
|
|
|
#define HI_MODINFO_SET(info, flag) ((info) |= flag)
|
|
#define HI_MODINFO_CLEAR(info, flag) ((info) &= ~flag)
|
|
|
|
HiResult moduler_reload(VectorModuleData *modules, ModuleData *module);
|