Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/boot2/modules.h

Source at commit 429 created 13 years 8 months ago.
By meklort, Updated module system. Hooks can now be used within modules when cetaion functions are called in chameleon. Note that onle two hooks currently exist, more need to be added. I also updated the HelloWorld module to use a hook instead of print out right away.
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
43#define SYMBOLS_MODULE "Symbols"
44
45#define SYMBOL_DYLD_STUB_BINDER"dyld_stub_binder"
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 * 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 */
70inline void register_hook(const char* name);
71int execute_hook(const char* name, void*, void*, void*, void*);
72void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
73
74inline void rebase_location(UInt32* location, char* base);
75
76int load_module(const char* module);
77int is_module_laoded(const char* name);
78void module_loaded(char* name, UInt32 version, UInt32 compat);
79
80void add_symbol(char* symbol, void* addr);
81void* parse_mach(void* binary);
82
83unsigned int handle_symtable(UInt32 base, struct symtab_command* symtabCommand, char* symbolStub, UInt32 nonlazy);
84
85unsigned int lookup_all_symbols(const char* name);
86
87extern unsigned int (*lookup_symbol)(const char*);
88
89#endif /* __BOOT_MODULES_H */

Archive Download this file

Revision: 429