Chameleon

Chameleon Svn Source Tree

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

Source at commit 430 created 13 years 7 months ago.
By meklort, Removed unused code left over from before rebinding. Modified then handel_symtab function so that it can be used within the kernel patcher module. This is untested, other than to make sure it boots.
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);
81
82void* parse_mach(void* binary);
83
84unsigned int handle_symtable(UInt32 base,
85 struct symtab_command* symtabCommand,
86 void*(*symbol_handler)(char*, void*));
87
88unsigned int lookup_all_symbols(const char* name);
89
90extern unsigned int (*lookup_symbol)(const char*);
91
92#endif /* __BOOT_MODULES_H */

Archive Download this file

Revision: 430