Root/
Source at commit 1146 created 12 years 10 months ago. By azimutz, Sync with trunk (r1145). Add nVidia dev id's, 0DF4 for "GeForce GT 450M" (issue 99) and 1251 for "GeForce GTX 560M" (thanks to oSxFr33k for testing). | |
---|---|
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 | ␊ |
11 | #ifndef __BOOT_MODULES_H␊ |
12 | #define __BOOT_MODULES_H␊ |
13 | ␊ |
14 | #define MODULE_PATH␉␉"/Extra/modules/"␊ |
15 | #define SYMBOLS_MODULE "Symbols.dylib"␊ |
16 | #define VOID_SYMBOL␉␉"dyld_void_start"␊ |
17 | extern unsigned long long textAddress;␊ |
18 | extern unsigned long long textSection;␊ |
19 | ␊ |
20 | ␊ |
21 | ␊ |
22 | typedef struct symbolList_t␊ |
23 | {␊ |
24 | ␉char* symbol;␊ |
25 | ␉unsigned int addr;␊ |
26 | ␉struct symbolList_t* next;␊ |
27 | } symbolList_t;␊ |
28 | ␊ |
29 | ␊ |
30 | typedef struct callbackList_t␊ |
31 | {␊ |
32 | ␉void(*callback)(void*, void*, void*, void*);␊ |
33 | ␉struct callbackList_t* next;␊ |
34 | } callbackList_t;␊ |
35 | ␊ |
36 | typedef struct moduleHook_t␊ |
37 | {␊ |
38 | ␉const char* name;␊ |
39 | ␉callbackList_t* callbacks;␊ |
40 | ␉struct moduleHook_t* next;␊ |
41 | } moduleHook_t;␊ |
42 | ␊ |
43 | typedef struct modulesList_t␊ |
44 | {␊ |
45 | ␉char*␉␉␉␉␉name;␊ |
46 | //␉UInt32␉␉␉␉␉version;␊ |
47 | //␉UInt32␉␉␉␉␉compat;␊ |
48 | ␉struct modulesList_t* next;␊ |
49 | } moduleList_t;␊ |
50 | ␊ |
51 | ␊ |
52 | ␊ |
53 | int init_module_system();␊ |
54 | void load_all_modules();␊ |
55 | ␊ |
56 | ␊ |
57 | ␊ |
58 | int load_module(char* module);␊ |
59 | int is_module_loaded(const char* name);␊ |
60 | void module_loaded(const char* name/*, UInt32 version, UInt32 compat*/);␊ |
61 | ␊ |
62 | ␊ |
63 | ␊ |
64 | ␊ |
65 | /********************************************************************************/␊ |
66 | /*␉Symbol Functions␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
67 | /********************************************************************************/␊ |
68 | long long␉␉add_symbol(char* symbol, long long addr, char is64);␊ |
69 | unsigned int␉lookup_all_symbols(const char* name);␊ |
70 | ␊ |
71 | ␊ |
72 | ␊ |
73 | /********************************************************************************/␊ |
74 | /*␉Macho Parser␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
75 | /********************************************************************************/␊ |
76 | void*␉␉␉parse_mach(void* binary, ␊ |
77 | ␉␉␉␉␉␉␉int(*dylib_loader)(char*),␊ |
78 | ␉␉␉␉␉␉␉long long(*symbol_handler)(char*, long long, char));␊ |
79 | unsigned int␉handle_symtable(UInt32 base,␊ |
80 | ␉␉␉␉␉␉␉ struct symtab_command* symtabCommand,␊ |
81 | ␉␉␉␉␉␉␉ long long(*symbol_handler)(char*, long long, char),␊ |
82 | ␉␉␉␉␉␉␉ char is64);␊ |
83 | void␉␉␉rebase_macho(void* base, char* rebase_stream, UInt32 size);␊ |
84 | inline void␉␉rebase_location(UInt32* location, char* base, int type);␊ |
85 | void␉␉␉bind_macho(void* base, char* bind_stream, UInt32 size);␊ |
86 | inline void␉␉bind_location(UInt32* location, char* value, UInt32 addend, int type);␊ |
87 | ␊ |
88 | ␊ |
89 | ␊ |
90 | ␊ |
91 | /********************************************************************************/␊ |
92 | /*␉Module Interface␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
93 | /********************************************************************************/␊ |
94 | int␉␉␉␉replace_function(const char* symbol, void* newAddress);␊ |
95 | int␉␉␉␉execute_hook(const char* name, void*, void*, void*, void*);␊ |
96 | void␉␉␉register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));␊ |
97 | moduleHook_t*␉hook_exists(const char* name);␊ |
98 | ␊ |
99 | #if DEBUG_MODULES␊ |
100 | void␉␉␉print_hook_list();␊ |
101 | #endif␊ |
102 | ␊ |
103 | /********************************************************************************/␊ |
104 | /*␉dyld Interface␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉␉*/␊ |
105 | /********************************************************************************/␊ |
106 | void dyld_stub_binder();␊ |
107 | ␊ |
108 | #endif /* __BOOT_MODULES_H */ |