|
Revision 1994, 2.4 KB
(checked in by mwhitworth, 3 years ago)
|
|
Place thisModule inside of module code, add ModuleGetIcDir function.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #ifndef MODULE_H |
|---|
| 20 | #define MODULE_H |
|---|
| 21 | |
|---|
| 22 | #define ModuleInit(func) \ |
|---|
| 23 | int _ModuleInit(void) __attribute__((alias(#func))); |
|---|
| 24 | |
|---|
| 25 | #define MODULE_START 0xD8000000 |
|---|
| 26 | #define MODULE_END 0xE0000000 |
|---|
| 27 | |
|---|
| 28 | #include <elf.h> |
|---|
| 29 | #include <llist.h> |
|---|
| 30 | #include <typedefs.h> |
|---|
| 31 | #include <keobject.h> |
|---|
| 32 | |
|---|
| 33 | struct KernelSymbol; |
|---|
| 34 | |
|---|
| 35 | struct Module |
|---|
| 36 | { |
|---|
| 37 | struct ListHead next; |
|---|
| 38 | |
|---|
| 39 | struct KernelSymbol* keSymTab; |
|---|
| 40 | int keSymTabSize; |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | DWORD loadAddr; |
|---|
| 44 | DWORD textAddr; |
|---|
| 45 | DWORD textLength; |
|---|
| 46 | |
|---|
| 47 | struct ElfSectionHeader* sectionHeaders; |
|---|
| 48 | |
|---|
| 49 | char* strTable; |
|---|
| 50 | int strTableSize; |
|---|
| 51 | |
|---|
| 52 | struct ElfSymbol* symTable; |
|---|
| 53 | int symTableSize; |
|---|
| 54 | |
|---|
| 55 | struct KeObject object; |
|---|
| 56 | }; |
|---|
| 57 | |
|---|
| 58 | static inline struct KeFsEntry* ModuleGetIcDir(struct Module* module) |
|---|
| 59 | { |
|---|
| 60 | return module->object.dir; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | #ifndef MODULE |
|---|
| 64 | |
|---|
| 65 | void ModuleSymbolPrint(DWORD address); |
|---|
| 66 | int ModuleAdd(char* name, void* file, void* image, unsigned long length, int flags); |
|---|
| 67 | |
|---|
| 68 | #endif |
|---|
| 69 | |
|---|
| 70 | struct KernelSymbol |
|---|
| 71 | { |
|---|
| 72 | unsigned long addr; |
|---|
| 73 | const char* name; |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | #define SYMBOL_EXPORT(sym) \ |
|---|
| 80 | static const char _KeStrTab_##sym[] \ |
|---|
| 81 | __attribute__((section(".symstrings"))) __attribute__((__used__)) \ |
|---|
| 82 | = #sym; \ |
|---|
| 83 | static const struct KernelSymbol _KeSymTab_##sym \ |
|---|
| 84 | __attribute__((section(".symtable"))) __attribute__((__used__)) \ |
|---|
| 85 | = { (unsigned long)&sym, _KeStrTab_##sym } |
|---|
| 86 | |
|---|
| 87 | #ifdef MODULE |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | static struct Module thisModule __attribute__((section(".gnu.linkonce.thisModule"))) __attribute__((used)); |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | #define THIS_MODULE &thisModule |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | #endif |
|---|