Chameleon

Chameleon Svn Source Tree

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

Source at commit 502 created 13 years 7 months ago.
By meklort, Typo fix, current status of kernel patcher. NOTE: 64bit doesn't work fully yet. This is just a placeholder untill I sync with trunk.
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
13extern unsigned long long textAddress;
14extern unsigned long long textSection;
15
16
17typedef struct symbolList_t
18{
19char* symbol;
20unsigned int addr;
21struct symbolList_t* next;
22} symbolList_t;
23
24typedef struct moduleList_t
25{
26char* module;
27unsigned int version;
28unsigned int compat;
29struct moduleList_t* next;
30} moduleList_t;
31
32typedef struct callbackList_t
33{
34void(*callback)(void*, void*, void*, void*);
35struct callbackList_t* next;
36} callbackList_t;
37
38typedef struct moduleHook_t
39{
40const char* name;
41callbackList_t* callbacks;
42struct moduleHook_t* next;
43} moduleHook_t;
44
45#define SYMBOLS_MODULE "Symbols.dylib"
46
47#define SYMBOL_DYLD_STUB_BINDER"dyld_stub_binder"
48#define SYMBOL_LOOKUP_SYMBOL"_lookup_symbol"
49#define STUB_ENTRY_SIZE6
50
51#define SECT_NON_LAZY_SYMBOL_PTR"__nl_symbol_ptr"
52#define SECT_SYMBOL_STUBS"__symbol_stub"
53
54
55
56int init_module_system();
57void load_all_modules();
58
59/*
60 * Modules Interface
61 * execute_hook
62 *Exexutes a registered hook. All callbaks are
63 *called in the same order that they were added
64 *
65 * register_hook_callback
66 *registers a void function to be executed when a
67 *hook is executed.
68 */
69int execute_hook(const char* name, void*, void*, void*, void*);
70void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
71
72inline void rebase_location(UInt32* location, char* base);
73void rebase_macho(void* base, char* rebase_stream, UInt32 size);
74void bind_macho(void* base, char* bind_stream, UInt32 size);
75
76int load_module(char* module);
77int is_module_loaded(const char* name);
78void module_loaded(const char* name/*, UInt32 version, UInt32 compat*/);
79
80long long add_symbol(char* symbol, long long addr, char is64);
81
82void* parse_mach(void* binary,
83 int(*dylib_loader)(char*),
84 long long(*symbol_handler)(char*, long long, char)
85 );
86
87unsigned int handle_symtable(UInt32 base,
88 struct symtab_command* symtabCommand,
89 long long(*symbol_handler)(char*, long long, char),
90 char is64);
91
92unsigned int lookup_all_symbols(const char* name);
93
94extern unsigned int (*lookup_symbol)(const char*);
95
96#endif /* __BOOT_MODULES_H */

Archive Download this file

Revision: 502