Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Chazi/i386/boot2/modules.h

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
14typedef struct symbolList_t
15{
16char* symbol;
17unsigned int addr;
18struct symbolList_t* next;
19} symbolList_t;
20
21typedef struct moduleList_t
22{
23char* module;
24unsigned int version;
25unsigned int compat;
26struct moduleList_t* next;
27} moduleList_t;
28
29typedef struct callbackList_t
30{
31void(*callback)(void*, void*, void*, void*);
32struct callbackList_t* next;
33} callbackList_t;
34
35typedef struct moduleHook_t
36{
37const char* name;
38callbackList_t* callbacks;
39struct moduleHook_t* next;
40} moduleHook_t;
41
42#define SYMBOLS_MODULE "Symbols.dylib"
43
44#define SYMBOL_DYLD_STUB_BINDER"dyld_stub_binder"
45#define SYMBOL_LOOKUP_SYMBOL"_lookup_symbol"
46#define STUB_ENTRY_SIZE6
47
48#define SECT_NON_LAZY_SYMBOL_PTR"__nl_symbol_ptr"
49#define SECT_SYMBOL_STUBS"__symbol_stub"
50
51
52
53int init_module_system();
54void load_all_modules();
55
56/*
57 * Modules Interface
58 * execute_hook
59 *Exexutes a registered hook. All callbaks are
60 *called in the same order that they were added
61 *
62 * register_hook_callback
63 *registers a void function to be executed when a
64 *hook is executed.
65 */
66int execute_hook(const char* name, void*, void*, void*, void*);
67void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
68
69inline void rebase_location(UInt32* location, char* base);
70
71int load_module(const char* module);
72int is_module_laoded(const char* name);
73void module_loaded(char* name, UInt32 version, UInt32 compat);
74
75long long add_symbol(char* symbol, long long addr, char is64);
76
77void* parse_mach(void* binary);
78
79unsigned int handle_symtable(UInt32 base,
80 struct symtab_command* symtabCommand,
81 long long(*symbol_handler)(char*, long long, char),
82 char is64);
83
84unsigned int lookup_all_symbols(const char* name);
85
86extern unsigned int (*lookup_symbol)(const char*);
87
88#endif /* __BOOT_MODULES_H */

Archive Download this file

Revision: 483