Root/
Source at commit 463 created 13 years 9 months ago. By azimutz, Doc edit/clean up. | |
---|---|
1 | /*␊ |
2 | * Module Loading functionality␊ |
3 | * Copyright 2009 Evan Lojewski. All rights reserved.␊ |
4 | *␊ |
5 | */␊ |
6 | ␊ |
7 | #include <mach-o/loader.h>␊ |
8 | #include <mach-o/nlist.h>␊ |
9 | ␊ |
10 | #ifndef __BOOT_MODULES_H␊ |
11 | #define __BOOT_MODULES_H␊ |
12 | ␊ |
13 | ␊ |
14 | typedef struct symbolList_t␊ |
15 | {␊ |
16 | ␉char* symbol;␊ |
17 | ␉unsigned int addr;␊ |
18 | ␉struct symbolList_t* next;␊ |
19 | } symbolList_t;␊ |
20 | ␊ |
21 | typedef struct moduleList_t␊ |
22 | {␊ |
23 | ␉char* module;␊ |
24 | ␉unsigned int version;␊ |
25 | ␉unsigned int compat;␊ |
26 | ␉struct moduleList_t* next;␊ |
27 | } moduleList_t;␊ |
28 | ␊ |
29 | typedef struct callbackList_t␊ |
30 | {␊ |
31 | ␉void(*callback)(void*, void*, void*, void*);␊ |
32 | ␉struct callbackList_t* next;␊ |
33 | } callbackList_t;␊ |
34 | ␊ |
35 | typedef struct moduleHook_t␊ |
36 | {␊ |
37 | ␉const char* name;␊ |
38 | ␉callbackList_t* callbacks;␊ |
39 | ␉struct moduleHook_t* next;␊ |
40 | } moduleHook_t;␊ |
41 | ␊ |
42 | ␊ |
43 | #define SYMBOLS_MODULE "Symbols"␊ |
44 | ␊ |
45 | #define SYMBOL_DYLD_STUB_BINDER␉"dyld_stub_binder"␊ |
46 | #define STUB_ENTRY_SIZE␉6␊ |
47 | ␊ |
48 | #define SECT_NON_LAZY_SYMBOL_PTR␉"__nl_symbol_ptr"␊ |
49 | #define SECT_SYMBOL_STUBS␉␉␉"__symbol_stub"␊ |
50 | ␊ |
51 | ␊ |
52 | ␊ |
53 | int init_module_system();␊ |
54 | void load_all_modules();␊ |
55 | ␊ |
56 | /*␊ |
57 | * Modules Interface␊ |
58 | * register_hook␊ |
59 | *␉␉Notifies the module system that it should log requests␊ |
60 | *␉␉for callbacks on the hool execution␊ |
61 | *␊ |
62 | * execute_hook␊ |
63 | *␉␉Exexutes a registered hook. All callbaks are␊ |
64 | *␉␉called in the same order that they were added␊ |
65 | *␊ |
66 | * register_hook_callback␊ |
67 | *␉␉registers a void function to be executed when a␊ |
68 | *␉␉hook is executed.␊ |
69 | */␊ |
70 | inline void register_hook(const char* name);␊ |
71 | int execute_hook(const char* name, void*, void*, void*, void*);␊ |
72 | void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));␊ |
73 | ␊ |
74 | inline void rebase_location(UInt32* location, char* base);␊ |
75 | ␊ |
76 | int load_module(const char* module);␊ |
77 | int is_module_laoded(const char* name);␊ |
78 | void module_loaded(char* name, UInt32 version, UInt32 compat);␊ |
79 | ␊ |
80 | void* add_symbol(char* symbol, void* addr);␊ |
81 | ␊ |
82 | void* parse_mach(void* binary);␊ |
83 | ␊ |
84 | unsigned int handle_symtable(UInt32 base,␊ |
85 | ␉␉␉␉␉␉␉ struct symtab_command* symtabCommand,␊ |
86 | ␉␉␉␉␉␉␉ void*(*symbol_handler)(char*, void*));␊ |
87 | ␉␉␉␉␉␉␉ ␊ |
88 | unsigned int lookup_all_symbols(const char* name);␊ |
89 | ␊ |
90 | extern unsigned int (*lookup_symbol)(const char*);␊ |
91 | ␊ |
92 | #endif /* __BOOT_MODULES_H */ |