Root/
Source at commit 307 created 12 years 10 months ago. By ifabio, merge changes from trunk (929). Also merge the module changes from Azimutz branche (fix compile error) Also edited the info.plist into AHCIPortInjector.kext: http://forum.voodooprojects.org/index.php/topic,1170.0.html | |
---|---|
1 | /*␊ |
2 | * Module Loading functionality␊ |
3 | * Copyright 2009 Evan Lojewski. All rights reserved.␊ |
4 | *␊ |
5 | */␊ |
6 | ␊ |
7 | #include <saio_types.h>␊ |
8 | #include <mach-o/loader.h>␊ |
9 | #include <mach-o/nlist.h>␊ |
10 | ␊ |
11 | ␊ |
12 | #ifndef __BOOT_MODULES_H␊ |
13 | #define __BOOT_MODULES_H␊ |
14 | ␊ |
15 | #define MODULE_PATH␉␉"/Extra/modules/"␊ |
16 | #define SYMBOLS_MODULE "Symbols.dylib"␊ |
17 | #define VOID_SYMBOL␉␉"dyld_void_start"␊ |
18 | extern UInt64 textAddress;␊ |
19 | extern UInt64 textSection;␊ |
20 | ␊ |
21 | ␊ |
22 | ␊ |
23 | typedef struct symbolList_t␊ |
24 | {␊ |
25 | ␉char* symbol;␊ |
26 | ␉UInt64 addr;␊ |
27 | ␉struct symbolList_t* next;␊ |
28 | } symbolList_t;␊ |
29 | ␊ |
30 | ␊ |
31 | typedef struct callbackList_t␊ |
32 | {␊ |
33 | ␉void(*callback)(void*, void*, void*, void*);␊ |
34 | ␉struct callbackList_t* next;␊ |
35 | } callbackList_t;␊ |
36 | ␊ |
37 | typedef struct moduleHook_t␊ |
38 | {␊ |
39 | ␉const char* name;␊ |
40 | ␉callbackList_t* callbacks;␊ |
41 | ␉struct moduleHook_t* next;␊ |
42 | } moduleHook_t;␊ |
43 | ␊ |
44 | typedef struct moduleList_t //Azi: modules or module? see modules/include/modules␊ |
45 | {␊ |
46 | ␉char*␉␉␉␉␉name;␊ |
47 | //␉UInt32␉␉␉␉␉version;␊ |
48 | //␉UInt32␉␉␉␉␉compat;␊ |
49 | ␉struct moduleList_t*␉next;␊ |
50 | } moduleList_t;␊ |
51 | ␊ |
52 | ␊ |
53 | ␊ |
54 | int init_module_system();␊ |
55 | void load_all_modules();␊ |
56 | ␊ |
57 | void start_built_in_module(char* name, void(*start_function)(void));␊ |
58 | ␊ |
59 | ␊ |
60 | int load_module(char* module);␊ |
61 | int is_module_loaded(const char* name);␊ |
62 | void module_loaded(const char* name/*, UInt32 version, UInt32 compat*/);␊ |
63 | ␊ |
64 | ␊ |
65 | ␊ |
66 | ␊ |
67 | /********************************************************************************/␊ |
68 | /*␉Symbol Functions␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
69 | /********************************************************************************/␊ |
70 | long long␉␉add_symbol(char* symbol, long long addr, char is64);␊ |
71 | unsigned int␉lookup_all_symbols(const char* name);␊ |
72 | ␊ |
73 | ␊ |
74 | ␊ |
75 | /********************************************************************************/␊ |
76 | /*␉Macho Parser␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
77 | /********************************************************************************/␊ |
78 | void*␉␉␉parse_mach(void* binary, ␊ |
79 | ␉␉␉␉␉␉␉int(*dylib_loader)(char*),␊ |
80 | ␉␉␉␉␉␉␉long long(*symbol_handler)(char*, long long, char),␊ |
81 | void (*section_handler)(char* section, char* segment, long long offset, long long address)␊ |
82 | );␊ |
83 | unsigned int␉handle_symtable(UInt32 base,␊ |
84 | ␉␉␉␉␉␉␉ struct symtab_command* symtabCommand,␊ |
85 | ␉␉␉␉␉␉␉ long long(*symbol_handler)(char*, long long, char),␊ |
86 | ␉␉␉␉␉␉␉ char is64);␊ |
87 | void␉␉␉rebase_macho(void* base, char* rebase_stream, UInt32 size);␊ |
88 | inline void␉␉rebase_location(UInt32* location, char* base, int type);␊ |
89 | void␉␉␉bind_macho(void* base, UInt8* bind_stream, UInt32 size);␊ |
90 | inline void␉␉bind_location(UInt32* location, char* value, UInt32 addend, int type);␊ |
91 | ␊ |
92 | ␊ |
93 | ␊ |
94 | ␊ |
95 | /********************************************************************************/␊ |
96 | /*␉Module Interface␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
97 | /********************************************************************************/␊ |
98 | int␉␉␉␉replace_function(const char* symbol, void* newAddress);␊ |
99 | int␉␉␉␉execute_hook(const char* name, void*, void*, void*, void*);␊ |
100 | void␉␉␉register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));␊ |
101 | moduleHook_t*␉hook_exists(const char* name);␊ |
102 | ␊ |
103 | #if DEBUG_MODULES␊ |
104 | void␉␉␉print_hook_list();␊ |
105 | #endif␊ |
106 | ␊ |
107 | /********************************************************************************/␊ |
108 | /*␉dyld Interface␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
109 | /********************************************************************************/␊ |
110 | void dyld_stub_binder();␊ |
111 | ␊ |
112 | #endif /* __BOOT_MODULES_H */␊ |
113 |