#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 { /// Filename for the module. Owning if not same as original_name; const char *name; /// Owning. Original filename for the module. Used to track origins for /// patches. const char *original_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, size_t modindx);