1 | /*␊ |
2 | * Module Loading functionality␊ |
3 | * Copyright 2009 Evan Lojewski. All rights reserved.␊ |
4 | *␊ |
5 | */␊ |
6 | ␊ |
7 | /*␊ |
8 | * Copyright 2012 Cadet-petit Armel <armelcadetpetit@gmail.com>. All rights reserved.␊ |
9 | *␊ |
10 | * Cleaned, Added bundles support.␊ |
11 | *␊ |
12 | */␊ |
13 | ␊ |
14 | // There is a bug with the module system / rebasing / binding␊ |
15 | // that causes static variables to be incorrectly rebased or bound␊ |
16 | // Disable static variables for the moment␊ |
17 | // #define static␊ |
18 | ␊ |
19 | #ifndef _PEXPERT_MODULES_H␊ |
20 | #define _PEXPERT_MODULES_H␊ |
21 | ␊ |
22 | #include <efi.h>␊ |
23 | ␊ |
24 | #define DEFAULT_BUNDLE_SPEC_SIZE 4096␊ |
25 | #define macho_64 0␊ |
26 | ␊ |
27 | extern unsigned long long textAddress;␊ |
28 | extern unsigned long long textSection;␊ |
29 | ␊ |
30 | typedef struct symbolList_t␊ |
31 | {␊ |
32 | char* module;␊ |
33 | ␉char* symbol;␊ |
34 | ␉unsigned int addr;␊ |
35 | ␉struct symbolList_t* next;␊ |
36 | } symbolList_t;␊ |
37 | ␊ |
38 | typedef struct callbackList_t␊ |
39 | {␊ |
40 | ␉void(*callback)(void*, void*, void*, void*, void*, void*);␊ |
41 | ␉struct callbackList_t* next;␊ |
42 | } callbackList_t;␊ |
43 | ␊ |
44 | typedef struct moduleHook_t␊ |
45 | {␊ |
46 | ␉const char* name;␊ |
47 | ␉callbackList_t* callbacks;␊ |
48 | ␉struct moduleHook_t* next;␊ |
49 | } moduleHook_t;␊ |
50 | ␊ |
51 | #define SYMBOLS_BUNDLE "Symbols"␊ |
52 | ␊ |
53 | #define SYMBOL_DYLD_STUB_BINDER␉"dyld_stub_binder"␊ |
54 | #define SYMBOL_LOOKUP_SYMBOL␉"_lookup_symbol"␊ |
55 | #define STUB_ENTRY_SIZE␉6␊ |
56 | ␊ |
57 | #define SECT_NON_LAZY_SYMBOL_PTR␉"__nl_symbol_ptr"␊ |
58 | #define SECT_SYMBOL_STUBS␉␉␉"__symbol_stub"␊ |
59 | ␊ |
60 | #define SYS_CLASS "SYMS"␊ |
61 | #define SYSLIB_CLASS "SYS_LIB"␊ |
62 | ␊ |
63 | /*␊ |
64 | * Modules Interface␊ |
65 | * execute_hook␊ |
66 | *␉␉Exexutes a registered hook. All callbaks are␊ |
67 | *␉␉called in the same order that they were added␊ |
68 | *␊ |
69 | * register_hook_callback␊ |
70 | *␉␉registers a void function to be executed when a␊ |
71 | *␉␉hook is executed.␊ |
72 | */␊ |
73 | EFI_STATUS execute_hook(const char* name, void*, void*, void*, void*, void*, void*);␊ |
74 | VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*));␊ |
75 | VOID register_one_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*));␊ |
76 | ␊ |
77 | void rebase_location(unsigned long* location, char* base, int type);␊ |
78 | void bind_location(unsigned long* location, char* value, unsigned long addend, int type);␊ |
79 | void rebase_macho(void* base, char* rebase_stream, unsigned long size);␊ |
80 | EFI_STATUS bind_macho(char* module, void* base, char* bind_stream, unsigned long size);␊ |
81 | ␊ |
82 | #if macho_64␊ |
83 | long long add_symbol(char* module,char* symbol, long long addr, char is64);␊ |
84 | #else␊ |
85 | long long add_symbol(char* module,char* symbol, long long addr);␊ |
86 | #endif␊ |
87 | ␊ |
88 | unsigned int lookup_all_symbols(const char* module, const char* name);␊ |
89 | ␊ |
90 | EFI_STATUS replace_function(const char* module, const char* symbol, void* newAddress);␊ |
91 | EFI_STATUS replace_system_function(const char* symbol, void* newAddress);␊ |
92 | EFI_STATUS replace_function_any(const char* symbol, void* newAddress);␊ |
93 | ␊ |
94 | extern unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*));␊ |
95 | ␊ |
96 | ␊ |
97 | long InitBundleSupport(void);␊ |
98 | long FileLoadBundles(char *dirSpec, long plugin);␊ |
99 | long LoadBundlePList(char *dirSpec, char *name, long bundleType);␊ |
100 | long LoadMatchedBundles(void);␊ |
101 | long MatchBundlesLibraries(void);␊ |
102 | long LoadBundles( char * dirSpec );␊ |
103 | void * GetBundleDict( char * bundle_id );␊ |
104 | void * GetBundlePersonality( char * bundle_id );␊ |
105 | char * GetBundlePath( char * bundle_id );␊ |
106 | ␊ |
107 | #endif /* _PEXPERT_MODULES_H */ |